OLD | NEW |
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 Loading... |
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::boxForClipPath() 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()); |
| 2074 DCHECK(rootLayer); |
2065 | 2075 |
2066 LayoutPoint offsetToRootLayer; | 2076 LayoutPoint offsetToRootLayer; |
2067 if (rootLayer) | 2077 convertToLayerCoords(rootLayer, offsetToRootLayer); |
2068 convertToLayerCoords(rootLayer, offsetToRootLayer); | 2078 LayoutRect referenceBox(boxForClipPath()); |
2069 LayoutRect rootRelativeBounds = physicalBoundingBoxIncludingReflectionAndSta
ckingChildren(offsetToRootLayer); | 2079 referenceBox.moveBy(offsetToRootLayer); |
| 2080 |
| 2081 FloatPoint point(hitTestLocation.point()); |
2070 | 2082 |
2071 ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath(); | 2083 ClipPathOperation* clipPathOperation = layoutObject()->style()->clipPath(); |
2072 ASSERT(clipPathOperation); | 2084 DCHECK(clipPathOperation); |
2073 if (clipPathOperation->type() == ClipPathOperation::SHAPE) { | 2085 if (clipPathOperation->type() == ClipPathOperation::SHAPE) { |
2074 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOper
ation); | 2086 ShapeClipPathOperation* clipPath = toShapeClipPathOperation(clipPathOper
ation); |
2075 if (!clipPath->path(FloatRect(rootRelativeBounds)).contains(FloatPoint(h
itTestLocation.point()))) | 2087 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 } | 2088 } |
2087 | 2089 DCHECK_EQ(clipPathOperation->type(), ClipPathOperation::REFERENCE); |
2088 return false; | 2090 ReferenceClipPathOperation* referenceClipPathOperation = toReferenceClipPath
Operation(clipPathOperation); |
| 2091 Element* element = layoutObject()->document().getElementById(referenceClipPa
thOperation->fragment()); |
| 2092 if (!isSVGClipPathElement(element) || !element->layoutObject()) |
| 2093 return false; |
| 2094 LayoutSVGResourceClipper* clipper = |
| 2095 toLayoutSVGResourceClipper(toLayoutSVGResourceContainer(element->layoutO
bject())); |
| 2096 // If the clipPath is using "userspace on use" units, then the origin of |
| 2097 // the coordinate system is the top-left of the reference box, so adjust |
| 2098 // the point accordingly. |
| 2099 if (clipper->clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) |
| 2100 point.moveBy(-offsetToRootLayer); |
| 2101 return !clipper->hitTestClipContent(FloatRect(referenceBox), point); |
2089 } | 2102 } |
2090 | 2103 |
2091 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, const Layou
tRect& damageRect, const LayoutPoint& offsetFromRoot) const | 2104 bool PaintLayer::intersectsDamageRect(const LayoutRect& layerBounds, const Layou
tRect& damageRect, const LayoutPoint& offsetFromRoot) const |
2092 { | 2105 { |
2093 // Always examine the canvas and the root. | 2106 // Always examine the canvas and the root. |
2094 // FIXME: Could eliminate the isDocumentElement() check if we fix background
painting so that the LayoutView | 2107 // FIXME: Could eliminate the isDocumentElement() check if we fix background
painting so that the LayoutView |
2095 // paints the root's background. | 2108 // paints the root's background. |
2096 if (isRootLayer() || layoutObject()->isDocumentElement()) | 2109 if (isRootLayer() || layoutObject()->isDocumentElement()) |
2097 return true; | 2110 return true; |
2098 | 2111 |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2935 | 2948 |
2936 void showLayerTree(const blink::LayoutObject* layoutObject) | 2949 void showLayerTree(const blink::LayoutObject* layoutObject) |
2937 { | 2950 { |
2938 if (!layoutObject) { | 2951 if (!layoutObject) { |
2939 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2952 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2940 return; | 2953 return; |
2941 } | 2954 } |
2942 showLayerTree(layoutObject->enclosingLayer()); | 2955 showLayerTree(layoutObject->enclosingLayer()); |
2943 } | 2956 } |
2944 #endif | 2957 #endif |
OLD | NEW |