Index: third_party/WebKit/Source/core/paint/ClipPathClipper.cpp |
diff --git a/third_party/WebKit/Source/core/paint/ClipPathClipper.cpp b/third_party/WebKit/Source/core/paint/ClipPathClipper.cpp |
index f86ede84123693820931c457b3a9e5d4464bb1d0..723110707b67b346556153faf2addf2e7fc21451 100644 |
--- a/third_party/WebKit/Source/core/paint/ClipPathClipper.cpp |
+++ b/third_party/WebKit/Source/core/paint/ClipPathClipper.cpp |
@@ -14,7 +14,6 @@ ClipPathClipper::ClipPathClipper( |
GraphicsContext& context, |
const LayoutObject& layoutObject, |
const FloatRect& referenceBox, |
- const FloatRect& visualOverflowRect, |
const FloatPoint& origin) |
: m_resourceClipper(nullptr) |
, m_clipperState(SVGClipPainter::ClipperNotApplied) |
@@ -25,27 +24,31 @@ ClipPathClipper::ClipPathClipper( |
ClipPathOperation* clipPathOperation = layoutObject.styleRef().clipPath(); |
if (clipPathOperation->type() == ClipPathOperation::SHAPE) { |
ShapeClipPathOperation* shape = toShapeClipPathOperation(clipPathOperation); |
- if (shape->isValid()) |
- m_clipPathRecorder.emplace(context, layoutObject, shape->path(referenceBox)); |
+ if (!shape->isValid()) |
+ return; |
+ m_clipPathRecorder.emplace(context, layoutObject, shape->path(referenceBox)); |
} else { |
DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); |
ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPathOperation(clipPathOperation); |
- Document& document = layoutObject.document(); |
// TODO(fs): 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->layoutObject()) { |
- m_resourceClipper = toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutObject())); |
- // When SVG applies the clip, and the coordinate system is "userspace on use", we must explicitly pass in |
- // the offset to have the clip paint in the correct location. When the coordinate system is |
- // "object bounding box" the offset should already be accounted for in the visualOverflowRect. |
- FloatPoint originTranslation = m_resourceClipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse ? |
- origin : FloatPoint(); |
- if (!SVGClipPainter(*m_resourceClipper).prepareEffect(layoutObject, referenceBox, |
- visualOverflowRect, originTranslation, context, m_clipperState)) { |
- // No need to "finish" the clipper if this failed. |
- m_resourceClipper = nullptr; |
- } |
+ Element* element = layoutObject.document().getElementById(referenceClipPathOperation->fragment()); |
+ if (!isSVGClipPathElement(element) || !element->layoutObject()) |
+ return; |
+ LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutObject())); |
+ // Compute the (conservative) bounds of the clip-path. |
+ FloatRect clipPathBounds = clipper->resourceBoundingBox(referenceBox); |
+ // When SVG applies the clip, and the coordinate system is "userspace on use", we must explicitly pass in |
+ // the offset to have the clip paint in the correct location. When the coordinate system is |
+ // "object bounding box" the offset should already be accounted for in the reference box. |
+ FloatPoint originTranslation; |
+ if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { |
+ clipPathBounds.moveBy(origin); |
+ originTranslation = origin; |
} |
+ if (!SVGClipPainter(*clipper).prepareEffect(layoutObject, referenceBox, |
+ clipPathBounds, originTranslation, context, m_clipperState)) |
+ return; |
+ m_resourceClipper = clipper; |
} |
} |