Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| index f93d85f709d718c91fd9709c95732111197a0b20..caef5768302ef18604a47d490283402a2fef5e70 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| @@ -2057,35 +2057,47 @@ PaintLayer* PaintLayer::hitTestChildren(ChildrenIteration childrentoVisit, Paint |
| return resultLayer; |
| } |
| +LayoutRect PaintLayer::computeReferenceBox() const |
| +{ |
| + if (!layoutObject()->isBox()) { |
| + SECURITY_DCHECK(layoutObject()->isLayoutInline()); |
| + return toLayoutInline(layoutObject())->linesBoundingBox(); |
| + } |
| + return toLayoutBox(layoutObject())->borderBoxRect(); |
| +} |
| + |
| bool PaintLayer::hitTestClippedOutByClipPath(PaintLayer* rootLayer, const HitTestLocation& hitTestLocation) const |
| { |
| if (!layoutObject()->hasClipPath()) |
| return false; |
| - ASSERT(isSelfPaintingLayer()); |
| + DCHECK(isSelfPaintingLayer()); |
| LayoutPoint offsetToRootLayer; |
| - if (rootLayer) |
| - convertToLayerCoords(rootLayer, offsetToRootLayer); |
| - LayoutRect rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndStackingChildren(offsetToRootLayer); |
| + convertToLayerCoords(rootLayer, offsetToRootLayer); |
|
Stephen Chennney
2016/08/26 14:19:28
I infer that this method can handle a null rootLay
fs
2016/08/26 14:41:51
Yeah, my assumption is the latter (corroborated by
|
| + LayoutRect referenceBox(computeReferenceBox()); |
| + referenceBox.moveBy(offsetToRootLayer); |
| + |
| + FloatPoint point(hitTestLocation.point()); |
| ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath(); |
| - ASSERT(clipPathOperation); |
| + DCHECK(clipPathOperation); |
| if (clipPathOperation->type() == ClipPathOperation::SHAPE) { |
| ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOperation); |
| - if (!clipPath->path(FloatRect(rootRelativeBounds)).contains(FloatPoint(hitTestLocation.point()))) |
| - return true; |
| - } else { |
| - ASSERT(clipPathOperation->type() == ClipPathOperation::REFERENCE); |
| - ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPathOperation(clipPathOperation); |
| - Element* element = layoutObject()->document().getElementById(referenceClipPathOperation->fragment()); |
| - if (isSVGClipPathElement(element) && element->layoutObject()) { |
| - LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutObject())); |
| - if (!clipper->hitTestClipContent(FloatRect(rootRelativeBounds), FloatPoint(hitTestLocation.point()))) |
| - return true; |
| - } |
| + return !clipPath->path(FloatRect(referenceBox)).contains(point); |
| } |
| - |
| - return false; |
| + DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); |
| + ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPathOperation(clipPathOperation); |
| + Element* element = layoutObject()->document().getElementById(referenceClipPathOperation->fragment()); |
| + if (!isSVGClipPathElement(element) || !element->layoutObject()) |
| + return false; |
| + LayoutSVGResourceClipper* clipper = |
| + toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutObject())); |
| + // If the clipPath is using "userspace on use" units, then the origin of |
| + // the coordinate system is the top-left of the reference box, so adjust |
| + // the point accordingly. |
| + if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) |
| + point.moveBy(-offsetToRootLayer); |
| + return !clipper->hitTestClipContent(FloatRect(referenceBox), point); |
| } |
| bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const LayoutPoint& offsetFromRoot) const |