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

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

Issue 2478233002: Make 'transform' a presentation attribute on SVG elements (Closed)
Patch Set: Updated expectations Created 4 years, 1 month 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, 2006, 2007, 2008 Nikolas Zimmermann 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann
3 * <zimmermann@kde.org> 3 * <zimmermann@kde.org>
4 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> 4 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
5 * Copyright (C) 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 6 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
7 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 animatedProperty->animationEnded(); 305 animatedProperty->animationEnded();
306 }); 306 });
307 } 307 }
308 308
309 AffineTransform SVGElement::localCoordinateSpaceTransform(CTMScope) const { 309 AffineTransform SVGElement::localCoordinateSpaceTransform(CTMScope) const {
310 // To be overriden by SVGGraphicsElement (or as special case SVGTextElement 310 // To be overriden by SVGGraphicsElement (or as special case SVGTextElement
311 // and SVGPatternElement) 311 // and SVGPatternElement)
312 return AffineTransform(); 312 return AffineTransform();
313 } 313 }
314 314
315 bool SVGElement::hasTransform() const {
316 return layoutObject() && layoutObject()->styleRef().hasTransform();
317 }
318
319 AffineTransform SVGElement::calculateTransform() const {
320 const ComputedStyle* style =
321 layoutObject() ? layoutObject()->style() : nullptr;
322
323 // If CSS property was set, use that, otherwise fallback to attribute (if
324 // set).
325 if (!style || !style->hasTransform())
326 return AffineTransform();
327
328 TransformationMatrix transform;
329 float zoom = style->effectiveZoom();
330
331 // SVGTextElements need special handling for the text positioning code.
332 if (isSVGTextElement(this)) {
333 // Do not take into account SVG's zoom rules, transform-origin, or
334 // percentage values.
335 style->applyTransform(transform, LayoutSize(0, 0),
336 ComputedStyle::ExcludeTransformOrigin,
337 ComputedStyle::IncludeMotionPath,
338 ComputedStyle::IncludeIndependentTransformProperties);
339 } else {
340 // CSS transforms operate with pre-scaled lengths. To make this work with
341 // SVG (which applies the zoom factor globally, at the root level) we
342 //
343 // * pre-scale the bounding box (to bring it into the same space as the
344 // other CSS values)
345 // * invert the zoom factor (to effectively compute the CSS transform
346 // under a 1.0 zoom)
347 //
348 // Note: objectBoundingBox is an emptyRect for elements like pattern or
349 // clipPath. See the "Object bounding box units" section of
350 // http://dev.w3.org/csswg/css3-transforms/
351 if (zoom != 1) {
352 FloatRect scaledBBox = layoutObject()->objectBoundingBox();
353 scaledBBox.scale(zoom);
354 transform.scale(1 / zoom);
355 style->applyTransform(
356 transform, scaledBBox, ComputedStyle::IncludeTransformOrigin,
357 ComputedStyle::IncludeMotionPath,
358 ComputedStyle::IncludeIndependentTransformProperties);
359 transform.scale(zoom);
360 } else {
361 style->applyTransform(
362 transform, layoutObject()->objectBoundingBox(),
363 ComputedStyle::IncludeTransformOrigin,
364 ComputedStyle::IncludeMotionPath,
pdr. 2016/11/22 04:02:48 Does this include motion path but exclude animate
fs 2016/11/22 13:54:07 Yes, correct. (SVGGraphicsElement::calculateAnimat
365 ComputedStyle::IncludeIndependentTransformProperties);
366 }
367 }
368 // Flatten any 3D transform.
369 return transform.toAffineTransform();
370 }
371
315 Node::InsertionNotificationRequest SVGElement::insertedInto( 372 Node::InsertionNotificationRequest SVGElement::insertedInto(
316 ContainerNode* rootParent) { 373 ContainerNode* rootParent) {
317 Element::insertedInto(rootParent); 374 Element::insertedInto(rootParent);
318 updateRelativeLengthsInformation(); 375 updateRelativeLengthsInformation();
319 buildPendingResourcesIfNeeded(); 376 buildPendingResourcesIfNeeded();
320 return InsertionDone; 377 return InsertionDone;
321 } 378 }
322 379
323 void SVGElement::removedFrom(ContainerNode* rootParent) { 380 void SVGElement::removedFrom(ContainerNode* rootParent) {
324 bool wasInDocument = rootParent->isConnected(); 381 bool wasInDocument = rootParent->isConnected();
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 visitor->trace(m_className); 1301 visitor->trace(m_className);
1245 Element::trace(visitor); 1302 Element::trace(visitor);
1246 } 1303 }
1247 1304
1248 const AtomicString& SVGElement::eventParameterName() { 1305 const AtomicString& SVGElement::eventParameterName() {
1249 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); 1306 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt"));
1250 return evtString; 1307 return evtString;
1251 } 1308 }
1252 1309
1253 } // namespace blink 1310 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698