| OLD | NEW |
| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // To be overriden by SVGGraphicsElement (or as special case SVGTextElement | 289 // To be overriden by SVGGraphicsElement (or as special case SVGTextElement |
| 290 // and SVGPatternElement) | 290 // and SVGPatternElement) |
| 291 return AffineTransform(); | 291 return AffineTransform(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 bool SVGElement::hasTransform(ApplyMotionTransform applyMotionTransform) const { | 294 bool SVGElement::hasTransform(ApplyMotionTransform applyMotionTransform) const { |
| 295 return (layoutObject() && layoutObject()->styleRef().hasTransform()) || | 295 return (layoutObject() && layoutObject()->styleRef().hasTransform()) || |
| 296 (applyMotionTransform == IncludeMotionTransform && hasSVGRareData()); | 296 (applyMotionTransform == IncludeMotionTransform && hasSVGRareData()); |
| 297 } | 297 } |
| 298 | 298 |
| 299 static inline bool transformUsesBoxSize( |
| 300 const ComputedStyle& style, |
| 301 ComputedStyle::ApplyTransformOrigin applyTransformOrigin) { |
| 302 if (applyTransformOrigin == ComputedStyle::IncludeTransformOrigin && |
| 303 (style.transformOriginX().type() == Percent || |
| 304 style.transformOriginY().type() == Percent) && |
| 305 style.requireTransformOrigin(ComputedStyle::IncludeTransformOrigin, |
| 306 ComputedStyle::ExcludeMotionPath)) |
| 307 return true; |
| 308 if (style.transform().dependsOnBoxSize()) |
| 309 return true; |
| 310 if (style.translate() && style.translate()->dependsOnBoxSize()) |
| 311 return true; |
| 312 if (style.hasOffset()) |
| 313 return true; |
| 314 return false; |
| 315 } |
| 316 |
| 299 AffineTransform SVGElement::calculateTransform( | 317 AffineTransform SVGElement::calculateTransform( |
| 300 ApplyMotionTransform applyMotionTransform) const { | 318 ApplyMotionTransform applyMotionTransform) const { |
| 301 const ComputedStyle* style = | 319 const ComputedStyle* style = |
| 302 layoutObject() ? layoutObject()->style() : nullptr; | 320 layoutObject() ? layoutObject()->style() : nullptr; |
| 303 | 321 |
| 304 // If CSS property was set, use that, otherwise fallback to attribute (if | 322 // If CSS property was set, use that, otherwise fallback to attribute (if |
| 305 // set). | 323 // set). |
| 306 AffineTransform matrix; | 324 AffineTransform matrix; |
| 307 if (style && style->hasTransform()) { | 325 if (style && style->hasTransform()) { |
| 308 TransformationMatrix transform; | 326 TransformationMatrix transform; |
| 309 float zoom = style->effectiveZoom(); | 327 float zoom = style->effectiveZoom(); |
| 310 | 328 |
| 311 FloatRect boundingBox = layoutObject()->objectBoundingBox(); | 329 FloatRect boundingBox = layoutObject()->objectBoundingBox(); |
| 312 ComputedStyle::ApplyTransformOrigin applyTransformOrigin = | 330 ComputedStyle::ApplyTransformOrigin applyTransformOrigin = |
| 313 ComputedStyle::IncludeTransformOrigin; | 331 ComputedStyle::IncludeTransformOrigin; |
| 314 // SVGTextElements need special handling for the text positioning code. | 332 // SVGTextElements need special handling for the text positioning code. |
| 315 if (isSVGTextElement(this)) { | 333 if (isSVGTextElement(this)) { |
| 316 // Do not take into account transform-origin, or percentage values. | 334 // Do not take into account transform-origin, or percentage values. |
| 317 boundingBox = FloatRect(); | 335 boundingBox = FloatRect(); |
| 318 applyTransformOrigin = ComputedStyle::ExcludeTransformOrigin; | 336 applyTransformOrigin = ComputedStyle::ExcludeTransformOrigin; |
| 319 } | 337 } |
| 320 | 338 |
| 339 if (transformUsesBoxSize(*style, applyTransformOrigin)) |
| 340 UseCounter::count(document(), UseCounter::TransformUsesBoxSizeOnSVG); |
| 341 |
| 321 // CSS transforms operate with pre-scaled lengths. To make this work with | 342 // CSS transforms operate with pre-scaled lengths. To make this work with |
| 322 // SVG (which applies the zoom factor globally, at the root level) we | 343 // SVG (which applies the zoom factor globally, at the root level) we |
| 323 // | 344 // |
| 324 // * pre-scale the bounding box (to bring it into the same space as the | 345 // * pre-scale the bounding box (to bring it into the same space as the |
| 325 // other CSS values) | 346 // other CSS values) |
| 326 // * invert the zoom factor (to effectively compute the CSS transform | 347 // * invert the zoom factor (to effectively compute the CSS transform |
| 327 // under a 1.0 zoom) | 348 // under a 1.0 zoom) |
| 328 // | 349 // |
| 329 // Note: objectBoundingBox is an emptyRect for elements like pattern or | 350 // Note: objectBoundingBox is an emptyRect for elements like pattern or |
| 330 // clipPath. See the "Object bounding box units" section of | 351 // clipPath. See the "Object bounding box units" section of |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 visitor->trace(m_className); | 1297 visitor->trace(m_className); |
| 1277 Element::trace(visitor); | 1298 Element::trace(visitor); |
| 1278 } | 1299 } |
| 1279 | 1300 |
| 1280 const AtomicString& SVGElement::eventParameterName() { | 1301 const AtomicString& SVGElement::eventParameterName() { |
| 1281 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); | 1302 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); |
| 1282 return evtString; | 1303 return evtString; |
| 1283 } | 1304 } |
| 1284 | 1305 |
| 1285 } // namespace blink | 1306 } // namespace blink |
| OLD | NEW |