OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CompositorElementId_h | 5 #ifndef CompositorElementId_h |
6 #define CompositorElementId_h | 6 #define CompositorElementId_h |
7 | 7 |
8 #include "cc/trees/element_id.h" | 8 #include "cc/trees/element_id.h" |
9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
| 10 #include "wtf/HashFunctions.h" |
| 11 #include "wtf/HashSet.h" |
| 12 #include "wtf/HashTraits.h" |
10 | 13 |
11 namespace blink { | 14 namespace blink { |
12 | 15 |
13 enum class CompositorSubElementId { Primary, Scroll, Viewport, LinkHighlight }; | 16 enum class CompositorSubElementId { Primary, Scroll, Viewport, LinkHighlight }; |
14 | 17 |
15 using CompositorElementId = cc::ElementId; | 18 using CompositorElementId = cc::ElementId; |
16 | 19 |
17 CompositorElementId PLATFORM_EXPORT | 20 CompositorElementId PLATFORM_EXPORT |
18 createCompositorElementId(int domNodeId, CompositorSubElementId); | 21 createCompositorElementId(int domNodeId, CompositorSubElementId); |
19 | 22 |
| 23 // Note cc::ElementId has a hash function already implemented via |
| 24 // ElementIdHash::operator(). However for consistency's sake we choose to use |
| 25 // Blink's hash functions with Blink specific data structures. |
| 26 struct CompositorElementIdHash { |
| 27 static unsigned hash(const CompositorElementId& p) { |
| 28 return WTF::hashInts(p.primaryId, p.secondaryId); |
| 29 } |
| 30 static bool equal(const CompositorElementId& a, |
| 31 const CompositorElementId& b) { |
| 32 return a.primaryId == b.primaryId && a.secondaryId == b.secondaryId; |
| 33 } |
| 34 static const bool safeToCompareToEmptyOrDeleted = true; |
| 35 }; |
| 36 |
| 37 struct CompositorElementIdHashTraits |
| 38 : WTF::GenericHashTraits<CompositorElementId> { |
| 39 static CompositorElementId emptyValue() { return CompositorElementId(); } |
| 40 static void constructDeletedValue(CompositorElementId& slot, bool) { |
| 41 slot = CompositorElementId(-1, -1); |
| 42 } |
| 43 static bool isDeletedValue(CompositorElementId value) { |
| 44 return value == CompositorElementId(-1, -1); |
| 45 } |
| 46 }; |
| 47 |
| 48 using CompositorElementIdSet = HashSet<CompositorElementId, |
| 49 CompositorElementIdHash, |
| 50 CompositorElementIdHashTraits>; |
| 51 |
20 } // namespace blink | 52 } // namespace blink |
21 | 53 |
22 #endif // CompositorElementId_h | 54 #endif // CompositorElementId_h |
OLD | NEW |