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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2280963002: Fix clip-path reference box/coordinate space setup for hit-testing (Closed)
Patch Set: Go through with test-cleanup... 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 if (!result.hitTestRequest().listBased()) 2050 if (!result.hitTestRequest().listBased())
2051 result = tempResult; 2051 result = tempResult;
2052 if (!depthSortDescendants) 2052 if (!depthSortDescendants)
2053 break; 2053 break;
2054 } 2054 }
2055 } 2055 }
2056 2056
2057 return resultLayer; 2057 return resultLayer;
2058 } 2058 }
2059 2059
2060 LayoutRect PaintLayer::computeReferenceBox() const
2061 {
2062 if (!layoutObject()->isBox()) {
2063 SECURITY_DCHECK(layoutObject()->isLayoutInline());
2064 return toLayoutInline(layoutObject())->linesBoundingBox();
2065 }
2066 return toLayoutBox(layoutObject())->borderBoxRect();
2067 }
2068
2060 bool PaintLayer::hitTestClippedOutByClipPath(PaintLayer* rootLayer, const HitTes tLocation& hitTestLocation) const 2069 bool PaintLayer::hitTestClippedOutByClipPath(PaintLayer* rootLayer, const HitTes tLocation& hitTestLocation) const
2061 { 2070 {
2062 if (!layoutObject()->hasClipPath()) 2071 if (!layoutObject()->hasClipPath())
2063 return false; 2072 return false;
2064 ASSERT(isSelfPaintingLayer()); 2073 DCHECK(isSelfPaintingLayer());
2065 2074
2066 LayoutPoint offsetToRootLayer; 2075 LayoutPoint offsetToRootLayer;
2067 if (rootLayer) 2076 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
2068 convertToLayerCoords(rootLayer, offsetToRootLayer); 2077 LayoutRect referenceBox(computeReferenceBox());
2069 LayoutRect rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndSta ckingChildren(offsetToRootLayer); 2078 referenceBox.moveBy(offsetToRootLayer);
2079
2080 FloatPoint point(hitTestLocation.point());
2070 2081
2071 ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath(); 2082 ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath();
2072 ASSERT(clipPathOperation); 2083 DCHECK(clipPathOperation);
2073 if (clipPathOperation->type() == ClipPathOperation::SHAPE) { 2084 if (clipPathOperation->type() == ClipPathOperation::SHAPE) {
2074 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOper ation); 2085 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOper ation);
2075 if (!clipPath->path(FloatRect(rootRelativeBounds)).contains(FloatPoint(h itTestLocation.point()))) 2086 return !clipPath->path(FloatRect(referenceBox)).contains(point);
2076 return true;
2077 } else {
2078 ASSERT(clipPathOperation->type() == ClipPathOperation::REFERENCE);
2079 ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClip PathOperation(clipPathOperation);
2080 Element* element = layoutObject()->document().getElementById(referenceCl ipPathOperation->fragment());
2081 if (isSVGClipPathElement(element) && element->layoutObject()) {
2082 LayoutSVGResourceClipper* clipper = toLayoutSVGResourceClipper(toLay outSVGResourceContainer(element->layoutObject()));
2083 if (!clipper->hitTestClipContent(FloatRect(rootRelativeBounds), Floa tPoint(hitTestLocation.point())))
2084 return true;
2085 }
2086 } 2087 }
2087 2088 DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE);
2088 return false; 2089 ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPath Operation(clipPathOperation);
2090 Element* element = layoutObject()->document().getElementById(referenceClipPa thOperation->fragment());
2091 if (!isSVGClipPathElement(element) || !element->layoutObject())
2092 return false;
2093 LayoutSVGResourceClipper* clipper =
2094 toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutO bject()));
2095 // If the clipPath is using "userspace on use" units, then the origin of
2096 // the coordinate system is the top-left of the reference box, so adjust
2097 // the point accordingly.
2098 if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse)
2099 point.moveBy(-offsetToRootLayer);
2100 return !clipper->hitTestClipContent(FloatRect(referenceBox), point);
2089 } 2101 }
2090 2102
2091 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, const Layou tRect& damageRect, const LayoutPoint& offsetFromRoot) const 2103 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, const Layou tRect& damageRect, const LayoutPoint& offsetFromRoot) const
2092 { 2104 {
2093 // Always examine the canvas and the root. 2105 // Always examine the canvas and the root.
2094 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView 2106 // FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the LayoutView
2095 // paints the root's background. 2107 // paints the root's background.
2096 if (isRootLayer() || layoutObject()->isDocumentElement()) 2108 if (isRootLayer() || layoutObject()->isDocumentElement())
2097 return true; 2109 return true;
2098 2110
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 2947
2936 void showLayerTree(const blink::LayoutObject* layoutObject) 2948 void showLayerTree(const blink::LayoutObject* layoutObject)
2937 { 2949 {
2938 if (!layoutObject) { 2950 if (!layoutObject) {
2939 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); 2951 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n");
2940 return; 2952 return;
2941 } 2953 }
2942 showLayerTree(layoutObject->enclosingLayer()); 2954 showLayerTree(layoutObject->enclosingLayer());
2943 } 2955 }
2944 #endif 2956 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698