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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceClipper.cpp

Issue 1839973003: If the <use> is hidden and the child of it is visible, should clip the non-resource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 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
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)
fs 2016/04/19 10:17:27 I went looking through the various specs (CSS Mask
hyunjunekim2 2016/04/27 12:18:40 So Just check child of <use> element whether visib
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() != VISIBLE )
181 continue; 181 continue;
182 182
183 bool isUseElement = isSVGUseElement(*childElement); 183 bool isUseElement = isSVGUseElement(*childElement);
fs 2016/04/19 10:17:27 You need to fix this code-path too. The easiest wa
hyunjunekim2 2016/04/27 12:18:40 Added a test and fixed it.
184 if (isUseElement) { 184 if (isUseElement) {
185 const SVGGraphicsElement* clippingElement = toSVGUseElement(*childEl ement).targetGraphicsElementForClipping(); 185 const SVGGraphicsElement* clippingElement = toSVGUseElement(*childEl ement).targetGraphicsElementForClipping();
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
(...skipping 20 matching lines...) Expand all
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)
fs 2016/04/19 10:17:27 Same comment here as in calculateClipContentPathIf
hyunjunekim2 2016/04/27 12:18:40 Done.
225 continue; 225 continue;
226
227 if (isSVGUseElement(*childElement) && !toSVGUseElement(*childElement).is VisibleGraphicsElementForClipping())
228 continue;
229
226 m_clipBoundaries.unite(layoutObject->localToSVGParentTransform().mapRect (layoutObject->paintInvalidationRectInLocalSVGCoordinates())); 230 m_clipBoundaries.unite(layoutObject->localToSVGParentTransform().mapRect (layoutObject->paintInvalidationRectInLocalSVGCoordinates()));
227 } 231 }
228 m_clipBoundaries = toSVGClipPathElement(element())->calculateAnimatedLocalTr ansform().mapRect(m_clipBoundaries); 232 m_clipBoundaries = toSVGClipPathElement(element())->calculateAnimatedLocalTr ansform().mapRect(m_clipBoundaries);
229 } 233 }
230 234
231 bool LayoutSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundin gBox, const FloatPoint& nodeAtPoint) 235 bool LayoutSVGResourceClipper::hitTestClipContent(const FloatRect& objectBoundin gBox, const FloatPoint& nodeAtPoint)
232 { 236 {
233 FloatPoint point = nodeAtPoint; 237 FloatPoint point = nodeAtPoint;
234 if (!SVGLayoutSupport::pointInClippingArea(this, point)) 238 if (!SVGLayoutSupport::pointInClippingArea(this, point))
235 return false; 239 return false;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 AffineTransform transform; 280 AffineTransform transform;
277 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); 281 transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
278 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); 282 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight());
279 return transform.mapRect(m_clipBoundaries); 283 return transform.mapRect(m_clipBoundaries);
280 } 284 }
281 285
282 return m_clipBoundaries; 286 return m_clipBoundaries;
283 } 287 }
284 288
285 } // namespace blink 289 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698