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

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

Issue 2390773004: reflow comments in core/svg/ (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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, 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { 109 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() {
110 return SVGMatrixTearOff::create(getScreenCTM()); 110 return SVGMatrixTearOff::create(getScreenCTM());
111 } 111 }
112 112
113 bool SVGGraphicsElement::hasAnimatedLocalTransform() const { 113 bool SVGGraphicsElement::hasAnimatedLocalTransform() const {
114 const ComputedStyle* style = 114 const ComputedStyle* style =
115 layoutObject() ? layoutObject()->style() : nullptr; 115 layoutObject() ? layoutObject()->style() : nullptr;
116 116
117 // Each of these is used in SVGGraphicsElement::calculateAnimatedLocalTransfor m to create an animated local transform. 117 // Each of these is used in
118 // SVGGraphicsElement::calculateAnimatedLocalTransform to create an animated
119 // local transform.
118 return (style && style->hasTransform()) || 120 return (style && style->hasTransform()) ||
119 !m_transform->currentValue()->isEmpty() || hasSVGRareData(); 121 !m_transform->currentValue()->isEmpty() || hasSVGRareData();
120 } 122 }
121 123
122 AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const { 124 AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const {
123 AffineTransform matrix; 125 AffineTransform matrix;
124 const ComputedStyle* style = 126 const ComputedStyle* style =
125 layoutObject() ? layoutObject()->style() : nullptr; 127 layoutObject() ? layoutObject()->style() : nullptr;
126 128
127 // If CSS property was set, use that, otherwise fallback to attribute (if set) . 129 // If CSS property was set, use that, otherwise fallback to attribute (if
130 // set).
128 if (style && style->hasTransform()) { 131 if (style && style->hasTransform()) {
129 TransformationMatrix transform; 132 TransformationMatrix transform;
130 float zoom = style->effectiveZoom(); 133 float zoom = style->effectiveZoom();
131 134
132 // SVGTextElements need special handling for the text positioning code. 135 // SVGTextElements need special handling for the text positioning code.
133 if (isSVGTextElement(this)) { 136 if (isSVGTextElement(this)) {
134 // Do not take into account SVG's zoom rules, transform-origin, or percent age values. 137 // Do not take into account SVG's zoom rules, transform-origin, or
138 // percentage values.
135 style->applyTransform( 139 style->applyTransform(
136 transform, LayoutSize(0, 0), ComputedStyle::ExcludeTransformOrigin, 140 transform, LayoutSize(0, 0), ComputedStyle::ExcludeTransformOrigin,
137 ComputedStyle::IncludeMotionPath, 141 ComputedStyle::IncludeMotionPath,
138 ComputedStyle::IncludeIndependentTransformProperties); 142 ComputedStyle::IncludeIndependentTransformProperties);
139 } else { 143 } else {
140 // CSS transforms operate with pre-scaled lengths. To make this work with SVG 144 // CSS transforms operate with pre-scaled lengths. To make this work with
141 // (which applies the zoom factor globally, at the root level) we 145 // SVG (which applies the zoom factor globally, at the root level) we
142 // 146 //
143 // * pre-scale the bounding box (to bring it into the same space as the other CSS values) 147 // * pre-scale the bounding box (to bring it into the same space as the
144 // * invert the zoom factor (to effectively compute the CSS transform un der a 1.0 zoom) 148 // other CSS values)
149 // * invert the zoom factor (to effectively compute the CSS transform
150 // under a 1.0 zoom)
145 // 151 //
146 // Note: objectBoundingBox is an emptyRect for elements like pattern or cl ipPath. 152 // Note: objectBoundingBox is an emptyRect for elements like pattern or
147 // See the "Object bounding box units" section of http://dev.w3.org/csswg/ css3-transforms/ 153 // clipPath. See the "Object bounding box units" section of
154 // http://dev.w3.org/csswg/css3-transforms/
148 if (zoom != 1) { 155 if (zoom != 1) {
149 FloatRect scaledBBox = layoutObject()->objectBoundingBox(); 156 FloatRect scaledBBox = layoutObject()->objectBoundingBox();
150 scaledBBox.scale(zoom); 157 scaledBBox.scale(zoom);
151 transform.scale(1 / zoom); 158 transform.scale(1 / zoom);
152 style->applyTransform( 159 style->applyTransform(
153 transform, scaledBBox, ComputedStyle::IncludeTransformOrigin, 160 transform, scaledBBox, ComputedStyle::IncludeTransformOrigin,
154 ComputedStyle::IncludeMotionPath, 161 ComputedStyle::IncludeMotionPath,
155 ComputedStyle::IncludeIndependentTransformProperties); 162 ComputedStyle::IncludeIndependentTransformProperties);
156 transform.scale(zoom); 163 transform.scale(zoom);
157 } else { 164 } else {
(...skipping 14 matching lines...) Expand all
172 if (hasSVGRareData()) 179 if (hasSVGRareData())
173 return *svgRareData()->animateMotionTransform() * matrix; 180 return *svgRareData()->animateMotionTransform() * matrix;
174 return matrix; 181 return matrix;
175 } 182 }
176 183
177 AffineTransform* SVGGraphicsElement::animateMotionTransform() { 184 AffineTransform* SVGGraphicsElement::animateMotionTransform() {
178 return ensureSVGRareData()->animateMotionTransform(); 185 return ensureSVGRareData()->animateMotionTransform();
179 } 186 }
180 187
181 void SVGGraphicsElement::svgAttributeChanged(const QualifiedName& attrName) { 188 void SVGGraphicsElement::svgAttributeChanged(const QualifiedName& attrName) {
182 // Reattach so the isValid() check will be run again during layoutObject creat ion. 189 // Reattach so the isValid() check will be run again during layoutObject
190 // creation.
183 if (SVGTests::isKnownAttribute(attrName)) { 191 if (SVGTests::isKnownAttribute(attrName)) {
184 SVGElement::InvalidationGuard invalidationGuard(this); 192 SVGElement::InvalidationGuard invalidationGuard(this);
185 lazyReattachIfAttached(); 193 lazyReattachIfAttached();
186 return; 194 return;
187 } 195 }
188 196
189 if (attrName == SVGNames::transformAttr) { 197 if (attrName == SVGNames::transformAttr) {
190 LayoutObject* object = layoutObject(); 198 LayoutObject* object = layoutObject();
191 if (!object) 199 if (!object)
192 return; 200 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 237
230 return layoutObject()->objectBoundingBox(); 238 return layoutObject()->objectBoundingBox();
231 } 239 }
232 240
233 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { 241 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() {
234 return SVGRectTearOff::create(SVGRect::create(getBBox()), 0, 242 return SVGRectTearOff::create(SVGRect::create(getBBox()), 0,
235 PropertyIsNotAnimVal); 243 PropertyIsNotAnimVal);
236 } 244 }
237 245
238 } // namespace blink 246 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGGeometryElement.cpp ('k') | third_party/WebKit/Source/core/svg/SVGImageElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698