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

Unified Diff: third_party/WebKit/Source/core/paint/ClipPathClipper.cpp

Issue 2279823002: Use LayoutSVGResourceClipper::resourceBoundingBox() in ClipPathClipper (Closed)
Patch Set: Rebase Created 4 years, 3 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/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;
}
}
« no previous file with comments | « third_party/WebKit/Source/core/paint/ClipPathClipper.h ('k') | third_party/WebKit/Source/core/paint/FilterPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698