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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/CompositorIdToElementMap.cpp
diff --git a/third_party/WebKit/Source/core/dom/CompositorIdToElementMap.cpp b/third_party/WebKit/Source/core/dom/CompositorIdToElementMap.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3d26c9e2905ccf02c8adb429cb8ffc3f8a83019e
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/CompositorIdToElementMap.cpp
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/dom/CompositorIdToElementMap.h"
+
+#include "core/dom/Element.h"
+#include "core/dom/WeakIdentifierMap.h"
+#include "platform/heap/Handle.h"
+#include "wtf/HashMap.h"
+
+namespace blink {
+
+class WeakIdToElementMap : public GarbageCollected<WeakIdToElementMap> {
+public:
+ static void put(CompositorElementId elementId, Element* element)
+ {
+ ASSERT(element);
+ instance().m_IdToElement->set(elementId, element);
+ }
+
+ static Element* lookup(CompositorElementId elementId)
+ {
+ return instance().m_IdToElement->get(elementId);
+ }
+
+ static void notifyObjectDestroyed(Element* object) { }
+
+ DEFINE_INLINE_TRACE()
+ {
+ visitor->trace(m_IdToElement);
+ }
+
+private:
+ static WeakIdToElementMap& instance()
+ {
+ DEFINE_STATIC_LOCAL(WeakIdToElementMap, mapInstance, (new WeakIdToElementMap()));
+ return mapInstance;
+ }
+
+ WeakIdToElementMap()
+ : m_IdToElement(new IdToElement())
+ {
+ }
+
+ 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.
+ Member<IdToElement> m_IdToElement;
+};
+
+
+// static
+void CompositorIdToElementMap::registerElement(Element& element)
+{
+ ASSERT(element.compositorElementId());
+ WeakIdToElementMap::put(element.compositorElementId(), &element);
+}
+
+// static
+Element* CompositorIdToElementMap::getById(CompositorElementId elementId)
+{
+ return WeakIdToElementMap::lookup(elementId);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698