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

Side by Side Diff: Source/core/svg/SVGGraphicsElement.cpp

Issue 190793011: Use isSVG*Element() helpers more in SVG code (Part 4) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGGlyphRefElement.cpp ('k') | Source/core/svg/SVGLinearGradientElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * Copyright (C) 2014 Google, Inc. 4 * Copyright (C) 2014 Google, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 if (!targetCTM.isInvertible()) { 53 if (!targetCTM.isInvertible()) {
54 exceptionState.throwDOMException(InvalidStateError, "The target tran sformation is not invertable."); 54 exceptionState.throwDOMException(InvalidStateError, "The target tran sformation is not invertable.");
55 return nullptr; 55 return nullptr;
56 } 56 }
57 ctm = targetCTM.inverse() * ctm; 57 ctm = targetCTM.inverse() * ctm;
58 } 58 }
59 59
60 return SVGMatrixTearOff::create(ctm); 60 return SVGMatrixTearOff::create(ctm);
61 } 61 }
62 62
63 static bool isViewportElement(const Element* element) 63 static bool isViewportElement(const Element& element)
64 { 64 {
65 return (element->hasTagName(SVGNames::svgTag) 65 return (isSVGSVGElement(element)
66 || element->hasTagName(SVGNames::symbolTag) 66 || isSVGSymbolElement(element)
67 || element->hasTagName(SVGNames::foreignObjectTag) 67 || isSVGForeignObjectElement(element)
68 || element->hasTagName(SVGNames::imageTag)); 68 || isSVGImageElement(element));
69 } 69 }
70 70
71 AffineTransform SVGGraphicsElement::computeCTM(SVGElement::CTMScope mode, 71 AffineTransform SVGGraphicsElement::computeCTM(SVGElement::CTMScope mode,
72 SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy, const SVGGraphi csElement* ancestor) const 72 SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy, const SVGGraphi csElement* ancestor) const
73 { 73 {
74 if (styleUpdateStrategy == AllowStyleUpdate) 74 if (styleUpdateStrategy == AllowStyleUpdate)
75 document().updateLayoutIgnorePendingStylesheets(); 75 document().updateLayoutIgnorePendingStylesheets();
76 76
77 AffineTransform ctm; 77 AffineTransform ctm;
78 bool done = false; 78 bool done = false;
79 79
80 for (const Element* currentElement = this; currentElement && !done; 80 for (const Element* currentElement = this; currentElement && !done;
81 currentElement = currentElement->parentOrShadowHostElement()) { 81 currentElement = currentElement->parentOrShadowHostElement()) {
82 if (!currentElement->isSVGElement()) 82 if (!currentElement->isSVGElement())
83 break; 83 break;
84 84
85 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode). multiply(ctm); 85 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode). multiply(ctm);
86 86
87 switch (mode) { 87 switch (mode) {
88 case NearestViewportScope: 88 case NearestViewportScope:
89 // Stop at the nearest viewport ancestor. 89 // Stop at the nearest viewport ancestor.
90 done = currentElement != this && isViewportElement(currentElement); 90 done = currentElement != this && isViewportElement(*currentElement);
91 break; 91 break;
92 case AncestorScope: 92 case AncestorScope:
93 // Stop at the designated ancestor. 93 // Stop at the designated ancestor.
94 done = currentElement == ancestor; 94 done = currentElement == ancestor;
95 break; 95 break;
96 default: 96 default:
97 ASSERT(mode == ScreenScope); 97 ASSERT(mode == ScreenScope);
98 break; 98 break;
99 } 99 }
100 } 100 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); 213 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
214 return; 214 return;
215 } 215 }
216 216
217 ASSERT_NOT_REACHED(); 217 ASSERT_NOT_REACHED();
218 } 218 }
219 219
220 SVGElement* SVGGraphicsElement::nearestViewportElement() const 220 SVGElement* SVGGraphicsElement::nearestViewportElement() const
221 { 221 {
222 for (Element* current = parentOrShadowHostElement(); current; current = curr ent->parentOrShadowHostElement()) { 222 for (Element* current = parentOrShadowHostElement(); current; current = curr ent->parentOrShadowHostElement()) {
223 if (isViewportElement(current)) 223 if (isViewportElement(*current))
224 return toSVGElement(current); 224 return toSVGElement(current);
225 } 225 }
226 226
227 return 0; 227 return 0;
228 } 228 }
229 229
230 SVGElement* SVGGraphicsElement::farthestViewportElement() const 230 SVGElement* SVGGraphicsElement::farthestViewportElement() const
231 { 231 {
232 SVGElement* farthest = 0; 232 SVGElement* farthest = 0;
233 for (Element* current = parentOrShadowHostElement(); current; current = curr ent->parentOrShadowHostElement()) { 233 for (Element* current = parentOrShadowHostElement(); current; current = curr ent->parentOrShadowHostElement()) {
234 if (isViewportElement(current)) 234 if (isViewportElement(*current))
235 farthest = toSVGElement(current); 235 farthest = toSVGElement(current);
236 } 236 }
237 return farthest; 237 return farthest;
238 } 238 }
239 239
240 FloatRect SVGGraphicsElement::getBBox() 240 FloatRect SVGGraphicsElement::getBBox()
241 { 241 {
242 document().updateLayoutIgnorePendingStylesheets(); 242 document().updateLayoutIgnorePendingStylesheets();
243 243
244 // FIXME: Eventually we should support getBBox for detached elements. 244 // FIXME: Eventually we should support getBBox for detached elements.
(...skipping 15 matching lines...) Expand all
260 } 260 }
261 261
262 void SVGGraphicsElement::toClipPath(Path& path) 262 void SVGGraphicsElement::toClipPath(Path& path)
263 { 263 {
264 updatePathFromGraphicsElement(this, path); 264 updatePathFromGraphicsElement(this, path);
265 // FIXME: How do we know the element has done a layout? 265 // FIXME: How do we know the element has done a layout?
266 path.transform(animatedLocalTransform()); 266 path.transform(animatedLocalTransform());
267 } 267 }
268 268
269 } 269 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGGlyphRefElement.cpp ('k') | Source/core/svg/SVGLinearGradientElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698