OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007 Apple Inc. All rights reserved. |
5 * Copyright (C) 2014 Google, Inc. | 5 * Copyright (C) 2014 Google, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 SVGTransformTearOff* SVGSVGElement::createSVGTransform() { | 449 SVGTransformTearOff* SVGSVGElement::createSVGTransform() { |
450 return SVGTransformTearOff::Create(SVGTransform::Create(kSvgTransformMatrix), | 450 return SVGTransformTearOff::Create(SVGTransform::Create(kSvgTransformMatrix), |
451 0, kPropertyIsNotAnimVal); | 451 0, kPropertyIsNotAnimVal); |
452 } | 452 } |
453 | 453 |
454 SVGTransformTearOff* SVGSVGElement::createSVGTransformFromMatrix( | 454 SVGTransformTearOff* SVGSVGElement::createSVGTransformFromMatrix( |
455 SVGMatrixTearOff* matrix) { | 455 SVGMatrixTearOff* matrix) { |
456 return SVGTransformTearOff::Create(matrix); | 456 return SVGTransformTearOff::Create(matrix); |
457 } | 457 } |
458 | 458 |
459 AffineTransform SVGSVGElement::LocalCoordinateSpaceTransform() const { | 459 AffineTransform SVGSVGElement::LocalCoordinateSpaceTransform( |
| 460 CTMScope mode) const { |
460 AffineTransform transform; | 461 AffineTransform transform; |
461 if (!IsOutermostSVGSVGElement()) { | 462 if (!IsOutermostSVGSVGElement()) { |
462 SVGLengthContext length_context(this); | 463 SVGLengthContext length_context(this); |
463 transform.Translate(x_->CurrentValue()->Value(length_context), | 464 transform.Translate(x_->CurrentValue()->Value(length_context), |
464 y_->CurrentValue()->Value(length_context)); | 465 y_->CurrentValue()->Value(length_context)); |
| 466 } else if (mode == kScreenScope) { |
| 467 if (LayoutObject* layout_object = this->GetLayoutObject()) { |
| 468 TransformationMatrix transform; |
| 469 // Adjust for the zoom level factored into CSS coordinates (WK bug |
| 470 // #96361). |
| 471 transform.Scale(1.0 / layout_object->StyleRef().EffectiveZoom()); |
| 472 |
| 473 // Origin in the document. (This, together with the inverse-scale above, |
| 474 // performs the same operation as |
| 475 // Document::adjustFloatRectForScrollAndAbsoluteZoom, but in |
| 476 // transformation matrix form.) |
| 477 if (FrameView* view = GetDocument().View()) { |
| 478 LayoutRect visible_content_rect(view->VisibleContentRect()); |
| 479 transform.Translate(-visible_content_rect.X(), |
| 480 -visible_content_rect.Y()); |
| 481 } |
| 482 |
| 483 // Apply transforms from our ancestor coordinate space, including any |
| 484 // non-SVG ancestor transforms. |
| 485 transform.Multiply(layout_object->LocalToAbsoluteTransform()); |
| 486 |
| 487 // At the SVG/HTML boundary (aka LayoutSVGRoot), we need to apply the |
| 488 // localToBorderBoxTransform to map an element from SVG viewport |
| 489 // coordinates to CSS box coordinates. |
| 490 transform.Multiply( |
| 491 ToLayoutSVGRoot(layout_object)->LocalToBorderBoxTransform()); |
| 492 // Drop any potential non-affine parts, because we're not able to convey |
| 493 // that information further anyway until getScreenCTM returns a DOMMatrix |
| 494 // (4x4 matrix.) |
| 495 return transform.ToAffineTransform(); |
| 496 } |
465 } | 497 } |
466 if (!HasEmptyViewBox()) { | 498 if (!HasEmptyViewBox()) { |
467 FloatSize size = CurrentViewportSize(); | 499 FloatSize size = CurrentViewportSize(); |
468 transform.Multiply(ViewBoxToViewTransform(size.Width(), size.Height())); | 500 transform.Multiply(ViewBoxToViewTransform(size.Width(), size.Height())); |
469 } | 501 } |
470 return transform; | 502 return transform; |
471 } | 503 } |
472 | 504 |
473 bool SVGSVGElement::LayoutObjectIsNeeded(const ComputedStyle& style) { | 505 bool SVGSVGElement::LayoutObjectIsNeeded(const ComputedStyle& style) { |
474 // FIXME: We should respect display: none on the documentElement svg element | 506 // FIXME: We should respect display: none on the documentElement svg element |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 visitor->Trace(width_); | 764 visitor->Trace(width_); |
733 visitor->Trace(height_); | 765 visitor->Trace(height_); |
734 visitor->Trace(translation_); | 766 visitor->Trace(translation_); |
735 visitor->Trace(time_container_); | 767 visitor->Trace(time_container_); |
736 visitor->Trace(view_spec_); | 768 visitor->Trace(view_spec_); |
737 SVGGraphicsElement::Trace(visitor); | 769 SVGGraphicsElement::Trace(visitor); |
738 SVGFitToViewBox::Trace(visitor); | 770 SVGFitToViewBox::Trace(visitor); |
739 } | 771 } |
740 | 772 |
741 } // namespace blink | 773 } // namespace blink |
OLD | NEW |