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

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

Issue 185333004: [SVG] Refactor getIntersectionList() and getEnclosureList() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Build fix. 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
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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (!targetCTM.isInvertible()) { 59 if (!targetCTM.isInvertible()) {
60 exceptionState.throwDOMException(InvalidStateError, "The target tran sformation is not invertable."); 60 exceptionState.throwDOMException(InvalidStateError, "The target tran sformation is not invertable.");
61 return nullptr; 61 return nullptr;
62 } 62 }
63 ctm = targetCTM.inverse() * ctm; 63 ctm = targetCTM.inverse() * ctm;
64 } 64 }
65 65
66 return SVGMatrixTearOff::create(ctm); 66 return SVGMatrixTearOff::create(ctm);
67 } 67 }
68 68
69 static AffineTransform computeCTM(SVGGraphicsElement* element, SVGElement::CTMSc ope mode, SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy) 69 static bool isViewportElement(const Element* element)
70 { 70 {
71 ASSERT(element); 71 return (element->hasTagName(SVGNames::svgTag)
72 if (styleUpdateStrategy == SVGGraphicsElement::AllowStyleUpdate) 72 || element->hasTagName(SVGNames::symbolTag)
73 element->document().updateLayoutIgnorePendingStylesheets(); 73 || element->hasTagName(SVGNames::foreignObjectTag)
74 || element->hasTagName(SVGNames::imageTag));
75 }
76
77 AffineTransform SVGGraphicsElement::computeCTM(SVGElement::CTMScope mode,
78 SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy, const SVGGraphi csElement* ancestor) const
79 {
80 if (styleUpdateStrategy == AllowStyleUpdate)
81 document().updateLayoutIgnorePendingStylesheets();
74 82
75 AffineTransform ctm; 83 AffineTransform ctm;
84 bool done = false;
76 85
77 SVGElement* stopAtElement = mode == SVGGraphicsElement::NearestViewportScope ? element->nearestViewportElement() : 0; 86 for (const Element* currentElement = this; currentElement && !done;
78 for (Element* currentElement = element; currentElement; currentElement = cur rentElement->parentOrShadowHostElement()) { 87 currentElement = currentElement->parentOrShadowHostElement()) {
79 if (!currentElement->isSVGElement()) 88 if (!currentElement->isSVGElement())
80 break; 89 break;
81 90
82 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode). multiply(ctm); 91 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode). multiply(ctm);
83 92
84 // For getCTM() computation, stop at the nearest viewport element 93 switch (mode) {
85 if (currentElement == stopAtElement) 94 case NearestViewportScope:
95 // Stop at the nearest viewport ancestor.
96 done = currentElement != this && isViewportElement(currentElement);
86 break; 97 break;
98 case AncestorScope:
99 // Stop at the designated ancestor.
100 done = currentElement == ancestor;
101 break;
102 default:
103 ASSERT(mode == ScreenScope);
104 break;
105 }
87 } 106 }
88 107
89 return ctm; 108 return ctm;
90 } 109 }
91 110
92 AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrate gy) 111 AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrate gy)
93 { 112 {
94 return computeCTM(this, NearestViewportScope, styleUpdateStrategy); 113 return computeCTM(NearestViewportScope, styleUpdateStrategy);
95 } 114 }
96 115
97 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate Strategy) 116 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate Strategy)
98 { 117 {
99 return computeCTM(this, ScreenScope, styleUpdateStrategy); 118 return computeCTM(ScreenScope, styleUpdateStrategy);
100 } 119 }
101 120
102 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getCTMFromJavascript() 121 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getCTMFromJavascript()
103 { 122 {
104 return SVGMatrixTearOff::create(getCTM()); 123 return SVGMatrixTearOff::create(getCTM());
105 } 124 }
106 125
107 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() 126 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript()
108 { 127 {
109 return SVGMatrixTearOff::create(getScreenCTM()); 128 return SVGMatrixTearOff::create(getScreenCTM());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 216
198 if (attrName == SVGNames::transformAttr) { 217 if (attrName == SVGNames::transformAttr) {
199 object->setNeedsTransformUpdate(); 218 object->setNeedsTransformUpdate();
200 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); 219 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
201 return; 220 return;
202 } 221 }
203 222
204 ASSERT_NOT_REACHED(); 223 ASSERT_NOT_REACHED();
205 } 224 }
206 225
207 static bool isViewportElement(Node* node)
208 {
209 return (node->hasTagName(SVGNames::svgTag)
210 || node->hasTagName(SVGNames::symbolTag)
211 || node->hasTagName(SVGNames::foreignObjectTag)
212 || node->hasTagName(SVGNames::imageTag));
213 }
214
215 SVGElement* SVGGraphicsElement::nearestViewportElement() const 226 SVGElement* SVGGraphicsElement::nearestViewportElement() const
216 { 227 {
217 for (Element* current = parentOrShadowHostElement(); current; current = curr ent->parentOrShadowHostElement()) { 228 for (Element* current = parentOrShadowHostElement(); current; current = curr ent->parentOrShadowHostElement()) {
218 if (isViewportElement(current)) 229 if (isViewportElement(current))
219 return toSVGElement(current); 230 return toSVGElement(current);
220 } 231 }
221 232
222 return 0; 233 return 0;
223 } 234 }
224 235
(...skipping 30 matching lines...) Expand all
255 } 266 }
256 267
257 void SVGGraphicsElement::toClipPath(Path& path) 268 void SVGGraphicsElement::toClipPath(Path& path)
258 { 269 {
259 updatePathFromGraphicsElement(this, path); 270 updatePathFromGraphicsElement(this, path);
260 // FIXME: How do we know the element has done a layout? 271 // FIXME: How do we know the element has done a layout?
261 path.transform(animatedLocalTransform()); 272 path.transform(animatedLocalTransform());
262 } 273 }
263 274
264 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698