CrossOriginPropertyDescriptorMap.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/DeprecatedString.h>
  8. #include <AK/Forward.h>
  9. #include <AK/Optional.h>
  10. #include <AK/Traits.h>
  11. #include <LibJS/Forward.h>
  12. #include <LibJS/Runtime/PropertyKey.h>
  13. namespace Web::HTML {
  14. struct CrossOriginProperty {
  15. DeprecatedString property;
  16. Optional<bool> needs_get {};
  17. Optional<bool> needs_set {};
  18. };
  19. struct CrossOriginKey {
  20. FlatPtr current_settings_object;
  21. FlatPtr relevant_settings_object;
  22. JS::PropertyKey property_key;
  23. };
  24. using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
  25. }
  26. namespace AK {
  27. template<>
  28. struct Traits<Web::HTML::CrossOriginKey> : public GenericTraits<Web::HTML::CrossOriginKey> {
  29. static unsigned hash(Web::HTML::CrossOriginKey const& key)
  30. {
  31. return pair_int_hash(
  32. Traits<JS::PropertyKey>::hash(key.property_key),
  33. pair_int_hash(ptr_hash(key.current_settings_object), ptr_hash(key.relevant_settings_object)));
  34. }
  35. static bool equals(Web::HTML::CrossOriginKey const& a, Web::HTML::CrossOriginKey const& b)
  36. {
  37. return a.current_settings_object == b.current_settings_object
  38. && a.relevant_settings_object == b.relevant_settings_object
  39. && Traits<JS::PropertyKey>::equals(a.property_key, b.property_key);
  40. }
  41. };
  42. }