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 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 #include "core/SVGNames.h" | 26 #include "core/SVGNames.h" |
27 #include "core/dom/ElementTraversal.h" | 27 #include "core/dom/ElementTraversal.h" |
28 #include "core/layout/HitTestResult.h" | 28 #include "core/layout/HitTestResult.h" |
29 #include "core/layout/svg/SVGLayoutSupport.h" | 29 #include "core/layout/svg/SVGLayoutSupport.h" |
30 #include "core/layout/svg/SVGResources.h" | 30 #include "core/layout/svg/SVGResources.h" |
31 #include "core/layout/svg/SVGResourcesCache.h" | 31 #include "core/layout/svg/SVGResourcesCache.h" |
32 #include "core/paint/CompositingRecorder.h" | 32 #include "core/paint/CompositingRecorder.h" |
33 #include "core/paint/PaintInfo.h" | 33 #include "core/paint/PaintInfo.h" |
34 #include "core/paint/TransformRecorder.h" | 34 #include "core/paint/TransformRecorder.h" |
35 #include "core/svg/SVGGeometryElement.h" | |
35 #include "core/svg/SVGUseElement.h" | 36 #include "core/svg/SVGUseElement.h" |
36 #include "platform/RuntimeEnabledFeatures.h" | 37 #include "platform/RuntimeEnabledFeatures.h" |
37 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 38 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
38 #include "platform/graphics/paint/CompositingDisplayItem.h" | 39 #include "platform/graphics/paint/CompositingDisplayItem.h" |
39 #include "platform/graphics/paint/DisplayItemList.h" | 40 #include "platform/graphics/paint/DisplayItemList.h" |
40 #include "platform/graphics/paint/DrawingDisplayItem.h" | 41 #include "platform/graphics/paint/DrawingDisplayItem.h" |
41 #include "platform/graphics/paint/SkPictureBuilder.h" | 42 #include "platform/graphics/paint/SkPictureBuilder.h" |
42 #include "third_party/skia/include/core/SkPicture.h" | 43 #include "third_party/skia/include/core/SkPicture.h" |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 | 77 |
77 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { | 78 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { |
78 LayoutObject* childLayoutObject = childElement->layoutObject(); | 79 LayoutObject* childLayoutObject = childElement->layoutObject(); |
79 if (!childLayoutObject) | 80 if (!childLayoutObject) |
80 continue; | 81 continue; |
81 // Only shapes or paths are supported for direct clipping. We need to fa llback to masking for texts. | 82 // Only shapes or paths are supported for direct clipping. We need to fa llback to masking for texts. |
82 if (childLayoutObject->isSVGText()) | 83 if (childLayoutObject->isSVGText()) |
83 return false; | 84 return false; |
84 if (!childElement->isSVGGraphicsElement()) | 85 if (!childElement->isSVGGraphicsElement()) |
85 continue; | 86 continue; |
86 SVGGraphicsElement* styled = toSVGGraphicsElement(childElement); | 87 SVGGeometryElement* styled = toSVGGeometryElement(childElement); |
pdr.
2015/06/09 05:15:58
Because this element can be an SVGUseElement, we'l
hyunjunekim2
2015/06/10 14:00:42
Ok, I understand.
| |
87 const ComputedStyle* style = childLayoutObject->style(); | 88 const ComputedStyle* style = childLayoutObject->style(); |
88 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) | 89 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) |
89 continue; | 90 continue; |
90 const SVGComputedStyle& svgStyle = style->svgStyle(); | 91 const SVGComputedStyle& svgStyle = style->svgStyle(); |
91 // Current shape in clip-path gets clipped too. Fallback to masking. | 92 // Current shape in clip-path gets clipped too. Fallback to masking. |
92 if (!svgStyle.clipperResource().isEmpty()) | 93 if (!svgStyle.clipperResource().isEmpty()) |
93 return false; | 94 return false; |
94 | 95 |
96 bool isUseElement = isSVGUseElement(*childElement); | |
97 | |
95 if (clipPath.isEmpty()) { | 98 if (clipPath.isEmpty()) { |
96 // First clip shape. | 99 // First clip shape. |
97 styled->toClipPath(clipPath); | 100 if (!isUseElement) |
101 styled->toClipPath(clipPath); | |
102 else | |
103 toSVGUseElement(*childElement).layoutObjectClipChild(clipPath); | |
98 continue; | 104 continue; |
99 } | 105 } |
100 | 106 |
101 if (RuntimeEnabledFeatures::pathOpsSVGClippingEnabled()) { | 107 if (RuntimeEnabledFeatures::pathOpsSVGClippingEnabled()) { |
102 // Attempt to generate a combined clip path, fall back to masking if not possible. | 108 // Attempt to generate a combined clip path, fall back to masking if not possible. |
103 Path subPath; | 109 Path subPath; |
104 styled->toClipPath(subPath); | 110 if (!isUseElement) |
111 styled->toClipPath(clipPath); | |
112 else | |
113 toSVGUseElement(*childElement).layoutObjectClipChild(clipPath); | |
114 | |
105 if (!clipPath.unionPath(subPath)) | 115 if (!clipPath.unionPath(subPath)) |
106 return false; | 116 return false; |
107 } else { | 117 } else { |
108 return false; | 118 return false; |
109 } | 119 } |
110 } | 120 } |
111 | 121 |
112 // We are able to represent the clip as a path. Continue with direct clippin g, | 122 // We are able to represent the clip as a path. Continue with direct clippin g, |
113 // and transform the content to userspace if necessary. | 123 // and transform the content to userspace if necessary. |
114 if (clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { | 124 if (clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 LayoutObject* layoutObject = childElement->layoutObject(); | 167 LayoutObject* layoutObject = childElement->layoutObject(); |
158 if (!layoutObject) | 168 if (!layoutObject) |
159 continue; | 169 continue; |
160 | 170 |
161 const ComputedStyle* style = layoutObject->style(); | 171 const ComputedStyle* style = layoutObject->style(); |
162 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) | 172 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) |
163 continue; | 173 continue; |
164 | 174 |
165 bool isUseElement = isSVGUseElement(*childElement); | 175 bool isUseElement = isSVGUseElement(*childElement); |
166 if (isUseElement) { | 176 if (isUseElement) { |
167 layoutObject = toSVGUseElement(*childElement).layoutObjectClipChild( ); | 177 Path clipPath; |
178 SVGGeometryElement* element = toSVGUseElement(*childElement).layoutO bjectClipChild(clipPath); | |
179 layoutObject = element->layoutObject(); | |
168 if (!layoutObject) | 180 if (!layoutObject) |
169 continue; | 181 continue; |
170 } | 182 } |
171 | 183 |
172 // Only shapes, paths and texts are allowed for clipping. | 184 // Only shapes, paths and texts are allowed for clipping. |
173 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText()) | 185 if (!layoutObject->isSVGShape() && !layoutObject->isSVGText()) |
174 continue; | 186 continue; |
175 | 187 |
176 if (isUseElement) | 188 if (isUseElement) |
177 layoutObject = childElement->layoutObject(); | 189 layoutObject = childElement->layoutObject(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 AffineTransform transform; | 266 AffineTransform transform; |
255 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 267 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
256 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); | 268 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); |
257 return transform.mapRect(m_clipBoundaries); | 269 return transform.mapRect(m_clipBoundaries); |
258 } | 270 } |
259 | 271 |
260 return m_clipBoundaries; | 272 return m_clipBoundaries; |
261 } | 273 } |
262 | 274 |
263 } | 275 } |
OLD | NEW |