Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: third_party/WebKit/Source/core/dom/CompositorIdToElementMap.cpp

Issue 1921503008: Blink CompositorWorker: Use CompositorElementId and CompositorIdToElementMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@elementid
Patch Set: Vend ids via local blink nextCompositorElementId. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #include "core/dom/CompositorIdToElementMap.h"
6
7 #include "core/dom/Element.h"
8 #include "core/dom/WeakIdentifierMap.h"
9 #include "platform/heap/Handle.h"
10 #include "wtf/HashMap.h"
11
12 namespace blink {
13
14 class WeakIdToElementMap : public GarbageCollected<WeakIdToElementMap> {
15 public:
16 static void put(CompositorElementId elementId, Element* element)
17 {
18 ASSERT(element);
19 instance().m_IdToElement->set(elementId, element);
20 }
21
22 static Element* lookup(CompositorElementId elementId)
23 {
24 return instance().m_IdToElement->get(elementId);
25 }
26
27 static void notifyObjectDestroyed(Element* object) { }
28
29 DEFINE_INLINE_TRACE()
30 {
31 visitor->trace(m_IdToElement);
32 }
33
34 private:
35 static WeakIdToElementMap& instance()
36 {
37 DEFINE_STATIC_LOCAL(WeakIdToElementMap, mapInstance, (new WeakIdToElemen tMap()));
38 return mapInstance;
39 }
40
41 WeakIdToElementMap()
42 : m_IdToElement(new IdToElement())
43 {
44 }
45
46 using IdToElement = HeapHashMap<CompositorElementId, WeakMember<Element>>;
esprehn 2016/05/10 22:46:57 I don't want to add more maps, use DOMNodeIds for
loyso (OOO) 2016/05/12 05:55:39 Acknowledged.
47 Member<IdToElement> m_IdToElement;
48 };
49
50
51 // static
52 void CompositorIdToElementMap::registerElement(Element& element)
53 {
54 ASSERT(element.compositorElementId());
55 WeakIdToElementMap::put(element.compositorElementId(), &element);
56 }
57
58 // static
59 Element* CompositorIdToElementMap::getById(CompositorElementId elementId)
60 {
61 return WeakIdToElementMap::lookup(elementId);
62 }
63
64 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698