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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 const ComputedStyle* style = | 324 const ComputedStyle* style = |
325 layoutObject() ? layoutObject()->style() : nullptr; | 325 layoutObject() ? layoutObject()->style() : nullptr; |
326 | 326 |
327 // If CSS property was set, use that, otherwise fallback to attribute (if | 327 // If CSS property was set, use that, otherwise fallback to attribute (if |
328 // set). | 328 // set). |
329 AffineTransform matrix; | 329 AffineTransform matrix; |
330 if (style && style->hasTransform()) { | 330 if (style && style->hasTransform()) { |
331 TransformationMatrix transform; | 331 TransformationMatrix transform; |
332 float zoom = style->effectiveZoom(); | 332 float zoom = style->effectiveZoom(); |
333 | 333 |
| 334 FloatRect boundingBox = layoutObject()->objectBoundingBox(); |
| 335 ComputedStyle::ApplyTransformOrigin applyTransformOrigin = |
| 336 ComputedStyle::IncludeTransformOrigin; |
334 // SVGTextElements need special handling for the text positioning code. | 337 // SVGTextElements need special handling for the text positioning code. |
335 if (isSVGTextElement(this)) { | 338 if (isSVGTextElement(this)) { |
336 // Do not take into account SVG's zoom rules, transform-origin, or | 339 // Do not take into account transform-origin, or percentage values. |
337 // percentage values. | 340 boundingBox = FloatRect(); |
| 341 applyTransformOrigin = ComputedStyle::ExcludeTransformOrigin; |
| 342 } |
| 343 |
| 344 // CSS transforms operate with pre-scaled lengths. To make this work with |
| 345 // SVG (which applies the zoom factor globally, at the root level) we |
| 346 // |
| 347 // * pre-scale the bounding box (to bring it into the same space as the |
| 348 // other CSS values) |
| 349 // * invert the zoom factor (to effectively compute the CSS transform |
| 350 // under a 1.0 zoom) |
| 351 // |
| 352 // Note: objectBoundingBox is an emptyRect for elements like pattern or |
| 353 // clipPath. See the "Object bounding box units" section of |
| 354 // http://dev.w3.org/csswg/css3-transforms/ |
| 355 if (zoom != 1) { |
| 356 boundingBox.scale(zoom); |
| 357 transform.scale(1 / zoom); |
338 style->applyTransform( | 358 style->applyTransform( |
339 transform, LayoutSize(0, 0), ComputedStyle::ExcludeTransformOrigin, | 359 transform, boundingBox, applyTransformOrigin, |
340 ComputedStyle::IncludeMotionPath, | 360 ComputedStyle::IncludeMotionPath, |
341 ComputedStyle::IncludeIndependentTransformProperties); | 361 ComputedStyle::IncludeIndependentTransformProperties); |
| 362 transform.scale(zoom); |
342 } else { | 363 } else { |
343 // CSS transforms operate with pre-scaled lengths. To make this work with | 364 style->applyTransform( |
344 // SVG (which applies the zoom factor globally, at the root level) we | 365 transform, boundingBox, applyTransformOrigin, |
345 // | 366 ComputedStyle::IncludeMotionPath, |
346 // * pre-scale the bounding box (to bring it into the same space as the | 367 ComputedStyle::IncludeIndependentTransformProperties); |
347 // other CSS values) | |
348 // * invert the zoom factor (to effectively compute the CSS transform | |
349 // under a 1.0 zoom) | |
350 // | |
351 // Note: objectBoundingBox is an emptyRect for elements like pattern or | |
352 // clipPath. See the "Object bounding box units" section of | |
353 // http://dev.w3.org/csswg/css3-transforms/ | |
354 if (zoom != 1) { | |
355 FloatRect scaledBBox = layoutObject()->objectBoundingBox(); | |
356 scaledBBox.scale(zoom); | |
357 transform.scale(1 / zoom); | |
358 style->applyTransform( | |
359 transform, scaledBBox, ComputedStyle::IncludeTransformOrigin, | |
360 ComputedStyle::IncludeMotionPath, | |
361 ComputedStyle::IncludeIndependentTransformProperties); | |
362 transform.scale(zoom); | |
363 } else { | |
364 style->applyTransform( | |
365 transform, layoutObject()->objectBoundingBox(), | |
366 ComputedStyle::IncludeTransformOrigin, | |
367 ComputedStyle::IncludeMotionPath, | |
368 ComputedStyle::IncludeIndependentTransformProperties); | |
369 } | |
370 } | 368 } |
371 // Flatten any 3D transform. | 369 // Flatten any 3D transform. |
372 matrix = transform.toAffineTransform(); | 370 matrix = transform.toAffineTransform(); |
373 } | 371 } |
374 | 372 |
375 // Apply any "motion transform" contribution if requested (and existing.) | 373 // Apply any "motion transform" contribution if requested (and existing.) |
376 if (applyMotionTransform == IncludeMotionTransform && hasSVGRareData()) | 374 if (applyMotionTransform == IncludeMotionTransform && hasSVGRareData()) |
377 matrix.preMultiply(*svgRareData()->animateMotionTransform()); | 375 matrix.preMultiply(*svgRareData()->animateMotionTransform()); |
378 | 376 |
379 return matrix; | 377 return matrix; |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 visitor->trace(m_className); | 1303 visitor->trace(m_className); |
1306 Element::trace(visitor); | 1304 Element::trace(visitor); |
1307 } | 1305 } |
1308 | 1306 |
1309 const AtomicString& SVGElement::eventParameterName() { | 1307 const AtomicString& SVGElement::eventParameterName() { |
1310 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); | 1308 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); |
1311 return evtString; | 1309 return evtString; |
1312 } | 1310 } |
1313 | 1311 |
1314 } // namespace blink | 1312 } // namespace blink |
OLD | NEW |