OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 continue; | 79 continue; |
80 // Only shapes or paths are supported for direct clipping. We need to fa
llback to masking for texts. | 80 // Only shapes or paths are supported for direct clipping. We need to fa
llback to masking for texts. |
81 if (childLayoutObject->isSVGText()) { | 81 if (childLayoutObject->isSVGText()) { |
82 m_clipContentPath.clear(); | 82 m_clipContentPath.clear(); |
83 return false; | 83 return false; |
84 } | 84 } |
85 if (!childElement->isSVGGraphicsElement()) | 85 if (!childElement->isSVGGraphicsElement()) |
86 continue; | 86 continue; |
87 | 87 |
88 const ComputedStyle* style = childLayoutObject->style(); | 88 const ComputedStyle* style = childLayoutObject->style(); |
89 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 89 if (!style || style->display() == NONE || (style->visibility() != VISIBL
E && !isSVGUseElement(*childElement))) |
90 continue; | 90 continue; |
91 | 91 |
92 // Current shape in clip-path gets clipped too. Fallback to masking. | 92 // Current shape in clip-path gets clipped too. Fallback to masking. |
93 if (style->svgStyle().hasClipper()) { | 93 if (style->svgStyle().hasClipper()) { |
94 m_clipContentPath.clear(); | 94 m_clipContentPath.clear(); |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 // First clip shape. | 98 // First clip shape. |
99 if (m_clipContentPath.isEmpty()) { | 99 if (m_clipContentPath.isEmpty()) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 FloatRect bounds = strokeBoundingBox(); | 170 FloatRect bounds = strokeBoundingBox(); |
171 | 171 |
172 SkPictureBuilder pictureBuilder(bounds, nullptr, nullptr); | 172 SkPictureBuilder pictureBuilder(bounds, nullptr, nullptr); |
173 | 173 |
174 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 174 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
175 LayoutObject* layoutObject = childElement->layoutObject(); | 175 LayoutObject* layoutObject = childElement->layoutObject(); |
176 if (!layoutObject) | 176 if (!layoutObject) |
177 continue; | 177 continue; |
178 | 178 |
179 const ComputedStyle* style = layoutObject->style(); | 179 const ComputedStyle* style = layoutObject->style(); |
180 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 180 if (!style || style->display() == NONE || (style->visibility() != VISIBL
E && !isSVGUseElement(*childElement))) |
181 continue; | 181 continue; |
182 | 182 |
183 bool isUseElement = isSVGUseElement(*childElement); | 183 bool isUseElement = isSVGUseElement(*childElement); |
184 if (isUseElement) { | 184 if (isUseElement) { |
185 const SVGGraphicsElement* clippingElement = toSVGUseElement(*childEl
ement).targetGraphicsElementForClipping(); | 185 const SVGGraphicsElement* clippingElement = toSVGUseElement(*childEl
ement).visibleTargetGraphicsElementForClipping(); |
186 if (!clippingElement) | 186 if (!clippingElement) |
187 continue; | 187 continue; |
188 | 188 |
189 layoutObject = clippingElement->layoutObject(); | 189 layoutObject = clippingElement->layoutObject(); |
190 if (!layoutObject) | 190 if (!layoutObject) |
191 continue; | 191 continue; |
192 } | 192 } |
193 | 193 |
194 // Only shapes, paths and texts are allowed for clipping. | 194 // Only shapes, paths and texts are allowed for clipping. |
195 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText()) | 195 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText()) |
(...skipping 18 matching lines...) Expand all Loading... |
214 void LayoutSVGResourceClipper::calculateClipContentPaintInvalidationRect() | 214 void LayoutSVGResourceClipper::calculateClipContentPaintInvalidationRect() |
215 { | 215 { |
216 // This is a rough heuristic to appraise the clip size and doesn't consider
clip on clip. | 216 // This is a rough heuristic to appraise the clip size and doesn't consider
clip on clip. |
217 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 217 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
218 LayoutObject* layoutObject = childElement->layoutObject(); | 218 LayoutObject* layoutObject = childElement->layoutObject(); |
219 if (!layoutObject) | 219 if (!layoutObject) |
220 continue; | 220 continue; |
221 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText() && !isSVGU
seElement(*childElement)) | 221 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText() && !isSVGU
seElement(*childElement)) |
222 continue; | 222 continue; |
223 const ComputedStyle* style = layoutObject->style(); | 223 const ComputedStyle* style = layoutObject->style(); |
224 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 224 if (!style || style->display() == NONE || (style->visibility() != VISIBL
E && !isSVGUseElement(*childElement))) |
225 continue; | 225 continue; |
| 226 if (isSVGUseElement(*childElement) && !toSVGUseElement(*childElement).vi
sibleTargetGraphicsElementForClipping()) |
| 227 continue; |
| 228 |
226 m_clipBoundaries.unite(layoutObject->localToSVGParentTransform().mapRect
(layoutObject->paintInvalidationRectInLocalSVGCoordinates())); | 229 m_clipBoundaries.unite(layoutObject->localToSVGParentTransform().mapRect
(layoutObject->paintInvalidationRectInLocalSVGCoordinates())); |
227 } | 230 } |
228 m_clipBoundaries = toSVGClipPathElement(element())->calculateAnimatedLocalTr
ansform().mapRect(m_clipBoundaries); | 231 m_clipBoundaries = toSVGClipPathElement(element())->calculateAnimatedLocalTr
ansform().mapRect(m_clipBoundaries); |
229 } | 232 } |
230 | 233 |
231 bool LayoutSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundin
gBox, const FloatPoint& nodeAtPoint) | 234 bool LayoutSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundin
gBox, const FloatPoint& nodeAtPoint) |
232 { | 235 { |
233 FloatPoint point = nodeAtPoint; | 236 FloatPoint point = nodeAtPoint; |
234 if (!SVGLayoutSupport::pointInClippingArea(this, point)) | 237 if (!SVGLayoutSupport::pointInClippingArea(this, point)) |
235 return false; | 238 return false; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 AffineTransform transform; | 279 AffineTransform transform; |
277 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 280 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
278 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 281 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
279 return transform.mapRect(m_clipBoundaries); | 282 return transform.mapRect(m_clipBoundaries); |
280 } | 283 } |
281 | 284 |
282 return m_clipBoundaries; | 285 return m_clipBoundaries; |
283 } | 286 } |
284 | 287 |
285 } // namespace blink | 288 } // namespace blink |
OLD | NEW |