| 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 SVGTransformTearOff* SVGSVGElement::createSVGTransform() { | 443 SVGTransformTearOff* SVGSVGElement::createSVGTransform() { |
| 444 return SVGTransformTearOff::create(SVGTransform::create(kSvgTransformMatrix), | 444 return SVGTransformTearOff::create(SVGTransform::create(kSvgTransformMatrix), |
| 445 0, PropertyIsNotAnimVal); | 445 0, PropertyIsNotAnimVal); |
| 446 } | 446 } |
| 447 | 447 |
| 448 SVGTransformTearOff* SVGSVGElement::createSVGTransformFromMatrix( | 448 SVGTransformTearOff* SVGSVGElement::createSVGTransformFromMatrix( |
| 449 SVGMatrixTearOff* matrix) { | 449 SVGMatrixTearOff* matrix) { |
| 450 return SVGTransformTearOff::create(matrix); | 450 return SVGTransformTearOff::create(matrix); |
| 451 } | 451 } |
| 452 | 452 |
| 453 AffineTransform SVGSVGElement::localCoordinateSpaceTransform( | 453 AffineTransform SVGSVGElement::localCoordinateSpaceTransform() const { |
| 454 SVGElement::CTMScope mode) const { | |
| 455 AffineTransform viewBoxTransform; | |
| 456 if (!hasEmptyViewBox()) { | |
| 457 FloatSize size = currentViewportSize(); | |
| 458 viewBoxTransform = viewBoxToViewTransform(size.width(), size.height()); | |
| 459 } | |
| 460 | |
| 461 AffineTransform transform; | 454 AffineTransform transform; |
| 462 if (!isOutermostSVGSVGElement()) { | 455 if (!isOutermostSVGSVGElement()) { |
| 463 SVGLengthContext lengthContext(this); | 456 SVGLengthContext lengthContext(this); |
| 464 transform.translate(m_x->currentValue()->value(lengthContext), | 457 transform.translate(m_x->currentValue()->value(lengthContext), |
| 465 m_y->currentValue()->value(lengthContext)); | 458 m_y->currentValue()->value(lengthContext)); |
| 466 } else if (mode == SVGElement::ScreenScope) { | |
| 467 if (LayoutObject* layoutObject = this->layoutObject()) { | |
| 468 FloatPoint location; | |
| 469 float zoomFactor = 1; | |
| 470 | |
| 471 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the | |
| 472 // localToBorderBoxTransform to map an element from SVG viewport | |
| 473 // coordinates to CSS box coordinates. LayoutSVGRoot's localToAbsolute | |
| 474 // method expects CSS box coordinates. We also need to adjust for the | |
| 475 // zoom level factored into CSS coordinates (bug #96361). | |
| 476 if (layoutObject->isSVGRoot()) { | |
| 477 location = toLayoutSVGRoot(layoutObject) | |
| 478 ->localToBorderBoxTransform() | |
| 479 .mapPoint(location); | |
| 480 zoomFactor = 1 / layoutObject->style()->effectiveZoom(); | |
| 481 } | |
| 482 | |
| 483 // Translate in our CSS parent coordinate space | |
| 484 // FIXME: This doesn't work correctly with CSS transforms. | |
| 485 location = layoutObject->localToAbsolute(location, UseTransforms); | |
| 486 location.scale(zoomFactor, zoomFactor); | |
| 487 | |
| 488 // Be careful here! localToBorderBoxTransform() included the x/y offset | |
| 489 // coming from the viewBoxToViewTransform(), so we have to subtract it | |
| 490 // here (original cause of bug #27183) | |
| 491 transform.translate(location.x() - viewBoxTransform.e(), | |
| 492 location.y() - viewBoxTransform.f()); | |
| 493 | |
| 494 // Respect scroll offset. | |
| 495 if (FrameView* view = document().view()) { | |
| 496 LayoutSize scrollOffset(view->getScrollOffset()); | |
| 497 scrollOffset.scale(zoomFactor); | |
| 498 transform.translate(-scrollOffset.width(), -scrollOffset.height()); | |
| 499 } | |
| 500 } | |
| 501 } | 459 } |
| 502 | 460 if (!hasEmptyViewBox()) { |
| 503 return transform.multiply(viewBoxTransform); | 461 FloatSize size = currentViewportSize(); |
| 462 transform.multiply(viewBoxToViewTransform(size.width(), size.height())); |
| 463 } |
| 464 return transform; |
| 504 } | 465 } |
| 505 | 466 |
| 506 bool SVGSVGElement::layoutObjectIsNeeded(const ComputedStyle& style) { | 467 bool SVGSVGElement::layoutObjectIsNeeded(const ComputedStyle& style) { |
| 507 // FIXME: We should respect display: none on the documentElement svg element | 468 // FIXME: We should respect display: none on the documentElement svg element |
| 508 // but many things in FrameView and SVGImage depend on the LayoutSVGRoot when | 469 // but many things in FrameView and SVGImage depend on the LayoutSVGRoot when |
| 509 // they should instead depend on the LayoutView. | 470 // they should instead depend on the LayoutView. |
| 510 // https://bugs.webkit.org/show_bug.cgi?id=103493 | 471 // https://bugs.webkit.org/show_bug.cgi?id=103493 |
| 511 if (document().documentElement() == this) | 472 if (document().documentElement() == this) |
| 512 return true; | 473 return true; |
| 513 | 474 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 visitor->trace(m_width); | 724 visitor->trace(m_width); |
| 764 visitor->trace(m_height); | 725 visitor->trace(m_height); |
| 765 visitor->trace(m_translation); | 726 visitor->trace(m_translation); |
| 766 visitor->trace(m_timeContainer); | 727 visitor->trace(m_timeContainer); |
| 767 visitor->trace(m_viewSpec); | 728 visitor->trace(m_viewSpec); |
| 768 SVGGraphicsElement::trace(visitor); | 729 SVGGraphicsElement::trace(visitor); |
| 769 SVGFitToViewBox::trace(visitor); | 730 SVGFitToViewBox::trace(visitor); |
| 770 } | 731 } |
| 771 | 732 |
| 772 } // namespace blink | 733 } // namespace blink |
| OLD | NEW |