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

Unified Diff: Source/core/rendering/RenderLayerClipPathInfo.cpp

Issue 423823004: Add support for SVG Clip paths in HTML (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changed LayoutTests and Aligned with review comments Created 6 years, 4 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: Source/core/rendering/RenderLayerClipPathInfo.cpp
diff --git a/Source/core/rendering/RenderLayerClipPathInfo.cpp b/Source/core/rendering/RenderLayerClipPathInfo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ecb1ed87087bc57fd54de68266c41ebe70e244e3
--- /dev/null
+++ b/Source/core/rendering/RenderLayerClipPathInfo.cpp
@@ -0,0 +1,54 @@
+// Copyright 2014 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/rendering/RenderLayerClipPathInfo.h"
+
+#include "core/rendering/RenderLayer.h"
+#include "core/rendering/svg/RenderSVGResourceContainer.h"
+
+namespace blink {
+
+RenderLayerClipPathInfo::RenderLayerClipPathInfo(RenderLayer* layer)
+ : m_layer(layer)
+{
+}
+
+RenderLayerClipPathInfo::~RenderLayerClipPathInfo()
+{
+ removeReferenceClipPathClients();
+}
+
+void RenderLayerClipPathInfo::updateReferenceClipPathClients(ClipPathOperation* clipPathOperation)
+{
+ ASSERT(clipPathOperation->type() == ClipPathOperation::REFERENCE);
+
+ removeReferenceClipPathClients();
+ ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPathOperation(clipPathOperation);
+ Element* clipPath = m_layer->renderer()->node()->document().getElementById(referenceClipPathOperation->fragment());
esprehn 2014/08/06 17:25:10 This is not Shadow DOM aware.
+ if (!isSVGClipPathElement(clipPath))
+ return;
+ if (clipPath->renderer())
+ toRenderSVGResourceContainer(clipPath->renderer())->addClientRenderLayer(m_layer);
+ else
+ toSVGClipPathElement(clipPath)->addClient(m_layer->renderer()->node());
+
+ m_clipPathElement = PassRefPtr<SVGClipPathElement>(toSVGClipPathElement(clipPath));
+}
+
+void RenderLayerClipPathInfo::removeReferenceClipPathClients()
+{
+ if (!m_clipPathElement)
+ return;
+
+ if (m_clipPathElement->renderer())
+ toRenderSVGResourceContainer(m_clipPathElement->renderer())->removeClientRenderLayer(m_layer);
+ else
+ m_clipPathElement->removeClient(m_layer->renderer()->node());
+
+ m_clipPathElement.clear();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698