Index: third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp |
diff --git a/third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp b/third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..901a38315e5838fe02720d8f84bb9882e08fdae3 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/paint/ObjectPaintProperties.cpp |
@@ -0,0 +1,57 @@ |
+// Copyright 2015 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 "config.h" |
+#include "core/paint/ObjectPaintProperties.h" |
+ |
+#include "platform/RuntimeEnabledFeatures.h" |
+ |
+namespace blink { |
+ |
+ObjectPaintProperties::Owner::NodeMapping* ObjectPaintProperties::Owner::s_nodeMapping = nullptr; |
+ |
+ObjectPaintProperties::Owner::~Owner() |
+{ |
+ if (!s_nodeMapping) |
+ return; |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ |
+ clearObjectPaintProperties(); |
+} |
+ |
+ObjectPaintProperties* ObjectPaintProperties::Owner::objectPaintProperties() const |
+{ |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ |
+ if (!s_nodeMapping) |
+ return nullptr; |
+ |
+ return s_nodeMapping->get(this); |
+} |
+ |
+ObjectPaintProperties& ObjectPaintProperties::Owner::ensureObjectPaintProperties() |
+{ |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ |
+ if (ObjectPaintProperties* properties = objectPaintProperties()) |
+ return *properties; |
+ |
+ if (!s_nodeMapping) |
+ s_nodeMapping = new NodeMapping; |
+ |
+ ObjectPaintProperties* newProperties = new ObjectPaintProperties; |
+ s_nodeMapping->set(this, adoptPtr(newProperties)); |
+ return *newProperties; |
+} |
+ |
+void ObjectPaintProperties::Owner::clearObjectPaintProperties() |
+{ |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ |
+ if (!s_nodeMapping) |
+ return; |
+ s_nodeMapping->remove(this); |
+} |
+ |
+} // namespace blink |