1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_CUSTOM_ELEMENT_DESCRIPTOR_HASH_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_CUSTOM_ELEMENT_DESCRIPTOR_HASH_H_ 7 8 #include "third_party/blink/renderer/core/html/custom/custom_element_descriptor.h" 9 #include "third_party/blink/renderer/platform/wtf/hash_functions.h" 10 #include "third_party/blink/renderer/platform/wtf/hash_traits.h" 11 #include "third_party/blink/renderer/platform/wtf/text/atomic_string_hash.h" 12 13 namespace blink { 14 15 struct CustomElementDescriptorHash { 16 STATIC_ONLY(CustomElementDescriptorHash); GetHashCustomElementDescriptorHash17 static unsigned GetHash(const CustomElementDescriptor& descriptor) { 18 return WTF::HashInts(AtomicStringHash::GetHash(descriptor.GetName()), 19 AtomicStringHash::GetHash(descriptor.LocalName())); 20 } 21 EqualCustomElementDescriptorHash22 static bool Equal(const CustomElementDescriptor& a, 23 const CustomElementDescriptor& b) { 24 return a == b; 25 } 26 27 static const bool safe_to_compare_to_empty_or_deleted = true; 28 }; 29 30 } // namespace blink 31 32 namespace WTF { 33 34 template <> 35 struct HashTraits<blink::CustomElementDescriptor> 36 : SimpleClassHashTraits<blink::CustomElementDescriptor> { 37 STATIC_ONLY(HashTraits); 38 static const bool kEmptyValueIsZero = 39 HashTraits<AtomicString>::kEmptyValueIsZero; 40 41 static bool IsDeletedValue(const blink::CustomElementDescriptor& value) { 42 return HashTraits<AtomicString>::IsDeletedValue(value.name_); 43 } 44 45 static void ConstructDeletedValue(blink::CustomElementDescriptor& slot, 46 bool zero_value) { 47 HashTraits<AtomicString>::ConstructDeletedValue(slot.name_, zero_value); 48 } 49 }; 50 51 template <> 52 struct DefaultHash<blink::CustomElementDescriptor> { 53 using Hash = blink::CustomElementDescriptorHash; 54 }; 55 56 } // namespace WTF 57 58 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_CUSTOM_CUSTOM_ELEMENT_DESCRIPTOR_HASH_H_ 59