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

Unified Diff: Source/core/rendering/RenderLayer.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/RenderLayer.cpp
diff --git a/Source/core/rendering/RenderLayer.cpp b/Source/core/rendering/RenderLayer.cpp
index ea83bc9e465458e5b59d3e73b430a8b72a3eb3e3..38773d5b4e04a31ed25b6ee8582c508329683077 100644
--- a/Source/core/rendering/RenderLayer.cpp
+++ b/Source/core/rendering/RenderLayer.cpp
@@ -1841,26 +1841,21 @@ void RenderLayer::paintLayerContents(GraphicsContext* context, const LayerPainti
}
context->clipPath(clipPath->path(rootRelativeBounds), clipPath->windRule());
- } else if (style->clipPath()->type() == ClipPathOperation::REFERENCE) {
- ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPathOperation(style->clipPath());
- Document& document = renderer()->document();
+ } else if (m_clipPathInfo && m_clipPathInfo->getClipPathElement() && m_clipPathInfo->getClipPathElement()->renderer()) {
// FIXME: It doesn't work with forward or external SVG references (https://bugs.webkit.org/show_bug.cgi?id=90405)
- Element* element = document.getElementById(referenceClipPathOperation->fragment());
- if (isSVGClipPathElement(element) && element->renderer()) {
- // FIXME: Saving at this point is not required in the 'mask'-
- // case, or if the clip ends up empty.
- clipStateSaver.save();
- if (!rootRelativeBoundsComputed) {
- rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot);
- rootRelativeBoundsComputed = true;
- }
+ // FIXME: Saving at this point is not required in the 'mask'-
+ // case, or if the clip ends up empty.
+ clipStateSaver.save();
+ if (!rootRelativeBoundsComputed) {
+ rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStackingChildren(paintingInfo.rootLayer, offsetFromRoot);
+ rootRelativeBoundsComputed = true;
+ }
- resourceClipper = toRenderSVGResourceClipper(toRenderSVGResourceContainer(element->renderer()));
- if (!resourceClipper->applyClippingToContext(renderer(), rootRelativeBounds,
- paintingInfo.paintDirtyRect, context, clipperContext)) {
- // No need to post-apply the clipper if this failed.
- resourceClipper = 0;
- }
+ resourceClipper = toRenderSVGResourceClipper(toRenderSVGResourceContainer(m_clipPathInfo->getClipPathElement()->renderer()));
+ if (!resourceClipper->applyClippingToContext(renderer(), rootRelativeBounds,
+ paintingInfo.paintDirtyRect, context, clipperContext)) {
+ // No need to post-apply the clipper if this failed.
+ resourceClipper = 0;
}
}
}
@@ -3549,6 +3544,20 @@ void RenderLayer::updateFilters(const RenderStyle* oldStyle, const RenderStyle*
updateOrRemoveFilterEffectRenderer();
}
+void RenderLayer::updateClipPathInfo(const RenderStyle* oldStyle, const RenderStyle* newStyle)
+{
+ if (!newStyle->clipPath() && (!oldStyle || !oldStyle->clipPath()))
+ return;
+
+ if (renderer()->hasClipPath() && renderer()->style()->clipPath()->type() == ClipPathOperation::REFERENCE) {
+ if (!m_clipPathInfo)
+ m_clipPathInfo = adoptPtr(new RenderLayerClipPathInfo(this));
+ m_clipPathInfo->updateReferenceClipPathClients(renderer()->style()->clipPath());
+ } else if (m_clipPathInfo) {
+ m_clipPathInfo = nullptr;
+ }
+}
+
bool RenderLayer::attemptDirectCompositingUpdate(StyleDifference diff, const RenderStyle* oldStyle)
{
CompositingReasons oldPotentialCompositingReasonsFromStyle = m_potentialCompositingReasonsFromStyle;
@@ -3571,12 +3580,12 @@ bool RenderLayer::attemptDirectCompositingUpdate(StyleDifference diff, const Ren
// the reflection layers.
if (renderer()->hasReflection())
return false;
- // If we're unwinding a scheduleSVGFilterLayerUpdateHack(), then we can't
+ // If we're unwinding a scheduleSVGEffectsLayerUpdateHack(), then we can't
// perform a direct compositing update because the filters code is going
// to produce different output this time around. We can remove this code
// once we fix the chicken/egg bugs in the filters code and delete the
- // scheduleSVGFilterLayerUpdateHack().
- if (renderer()->node() && renderer()->node()->svgFilterNeedsLayerUpdate())
+ // scheduleSVGEffectsLayerUpdateHack().
+ if (renderer()->node() && renderer()->node()->svgEffectsNeedLayerUpdate())
return false;
if (!m_compositedLayerMapping)
return false;
@@ -3627,6 +3636,8 @@ void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle
updateReflectionInfo(oldStyle);
}
+ updateClipPathInfo(oldStyle, renderer()->style());
+
if (RuntimeEnabledFeatures::cssCompositingEnabled())
m_blendInfo.updateBlendMode();
@@ -3714,15 +3725,15 @@ void RenderLayer::updateOrRemoveFilterEffectRenderer()
filterInfo->setRenderer(nullptr);
}
-void RenderLayer::filterNeedsPaintInvalidation()
+void RenderLayer::svgEffectsNeedPaintInvalidation()
esprehn 2014/08/06 17:25:10 We should not be adding more callers of this or sc
{
{
DeprecatedScheduleStyleRecalcDuringLayout marker(renderer()->document().lifecycle());
- // It's possible for scheduleSVGFilterLayerUpdateHack to schedule a style recalc, which
+ // It's possible for scheduleSVGEffectsLayerUpdateHack to schedule a style recalc, which
// is a problem because this function can be called while performing layout.
// Presumably this represents an illegal data flow of layout or compositing
// information into the style system.
- toElement(renderer()->node())->scheduleSVGFilterLayerUpdateHack();
+ toElement(renderer()->node())->scheduleSVGEffectsLayerUpdateHack();
}
if (renderer()->view()) {

Powered by Google App Engine
This is Rietveld 408576698