| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2009 Google, Inc. | 5 * Copyright (C) 2009 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. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/rendering/svg/RenderSVGViewportContainer.h" | 24 #include "core/layout/svg/LayoutSVGViewportContainer.h" |
| 25 | 25 |
| 26 #include "core/layout/PaintInfo.h" | 26 #include "core/layout/PaintInfo.h" |
| 27 #include "core/layout/svg/SVGLayoutSupport.h" | 27 #include "core/layout/svg/SVGLayoutSupport.h" |
| 28 #include "core/paint/SVGContainerPainter.h" | 28 #include "core/paint/SVGContainerPainter.h" |
| 29 #include "core/svg/SVGSVGElement.h" | 29 #include "core/svg/SVGSVGElement.h" |
| 30 #include "core/svg/SVGUseElement.h" | 30 #include "core/svg/SVGUseElement.h" |
| 31 #include "platform/graphics/GraphicsContext.h" | 31 #include "platform/graphics/GraphicsContext.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 RenderSVGViewportContainer::RenderSVGViewportContainer(SVGElement* node) | 35 LayoutSVGViewportContainer::LayoutSVGViewportContainer(SVGElement* node) |
| 36 : LayoutSVGContainer(node) | 36 : LayoutSVGContainer(node) |
| 37 , m_didTransformToRootUpdate(false) | 37 , m_didTransformToRootUpdate(false) |
| 38 , m_isLayoutSizeChanged(false) | 38 , m_isLayoutSizeChanged(false) |
| 39 , m_needsTransformUpdate(true) | 39 , m_needsTransformUpdate(true) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 void RenderSVGViewportContainer::determineIfLayoutSizeChanged() | 43 void LayoutSVGViewportContainer::determineIfLayoutSizeChanged() |
| 44 { | 44 { |
| 45 ASSERT(element()); | 45 ASSERT(element()); |
| 46 if (!isSVGSVGElement(*element())) | 46 if (!isSVGSVGElement(*element())) |
| 47 return; | 47 return; |
| 48 | 48 |
| 49 m_isLayoutSizeChanged = toSVGSVGElement(element())->hasRelativeLengths() &&
selfNeedsLayout(); | 49 m_isLayoutSizeChanged = toSVGSVGElement(element())->hasRelativeLengths() &&
selfNeedsLayout(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void RenderSVGViewportContainer::calcViewport() | 52 void LayoutSVGViewportContainer::calcViewport() |
| 53 { | 53 { |
| 54 SVGElement* element = this->element(); | 54 SVGElement* element = this->element(); |
| 55 ASSERT(element); | 55 ASSERT(element); |
| 56 if (!isSVGSVGElement(*element)) | 56 if (!isSVGSVGElement(*element)) |
| 57 return; | 57 return; |
| 58 SVGSVGElement* svg = toSVGSVGElement(element); | 58 SVGSVGElement* svg = toSVGSVGElement(element); |
| 59 FloatRect oldViewport = m_viewport; | 59 FloatRect oldViewport = m_viewport; |
| 60 | 60 |
| 61 SVGLengthContext lengthContext(element); | 61 SVGLengthContext lengthContext(element); |
| 62 m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext), svg->
y()->currentValue()->value(lengthContext), svg->width()->currentValue()->value(l
engthContext), svg->height()->currentValue()->value(lengthContext)); | 62 m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext), svg->
y()->currentValue()->value(lengthContext), svg->width()->currentValue()->value(l
engthContext), svg->height()->currentValue()->value(lengthContext)); |
| 63 | 63 |
| 64 if (oldViewport != m_viewport) { | 64 if (oldViewport != m_viewport) { |
| 65 setNeedsBoundariesUpdate(); | 65 setNeedsBoundariesUpdate(); |
| 66 setNeedsTransformUpdate(); | 66 setNeedsTransformUpdate(); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool RenderSVGViewportContainer::calculateLocalTransform() | 70 bool LayoutSVGViewportContainer::calculateLocalTransform() |
| 71 { | 71 { |
| 72 m_didTransformToRootUpdate = m_needsTransformUpdate || SVGLayoutSupport::tra
nsformToRootChanged(parent()); | 72 m_didTransformToRootUpdate = m_needsTransformUpdate || SVGLayoutSupport::tra
nsformToRootChanged(parent()); |
| 73 if (!m_needsTransformUpdate) | 73 if (!m_needsTransformUpdate) |
| 74 return false; | 74 return false; |
| 75 | 75 |
| 76 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi
ewport.y()) * viewportTransform(); | 76 m_localToParentTransform = AffineTransform::translation(m_viewport.x(), m_vi
ewport.y()) * viewportTransform(); |
| 77 m_needsTransformUpdate = false; | 77 m_needsTransformUpdate = false; |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 | 80 |
| 81 AffineTransform RenderSVGViewportContainer::viewportTransform() const | 81 AffineTransform LayoutSVGViewportContainer::viewportTransform() const |
| 82 { | 82 { |
| 83 ASSERT(element()); | 83 ASSERT(element()); |
| 84 if (isSVGSVGElement(*element())) { | 84 if (isSVGSVGElement(*element())) { |
| 85 SVGSVGElement* svg = toSVGSVGElement(element()); | 85 SVGSVGElement* svg = toSVGSVGElement(element()); |
| 86 return svg->viewBoxToViewTransform(m_viewport.width(), m_viewport.height
()); | 86 return svg->viewBoxToViewTransform(m_viewport.width(), m_viewport.height
()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 return AffineTransform(); | 89 return AffineTransform(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool RenderSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& poi
ntInParent) | 92 bool LayoutSVGViewportContainer::pointIsInsideViewportClip(const FloatPoint& poi
ntInParent) |
| 93 { | 93 { |
| 94 // Respect the viewport clip (which is in parent coords) | 94 // Respect the viewport clip (which is in parent coords) |
| 95 if (!SVGLayoutSupport::isOverflowHidden(this)) | 95 if (!SVGLayoutSupport::isOverflowHidden(this)) |
| 96 return true; | 96 return true; |
| 97 | 97 |
| 98 return m_viewport.contains(pointInParent); | 98 return m_viewport.contains(pointInParent); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void RenderSVGViewportContainer::paint(const PaintInfo& paintInfo, const LayoutP
oint& paintOffset) | 101 void LayoutSVGViewportContainer::paint(const PaintInfo& paintInfo, const LayoutP
oint& paintOffset) |
| 102 { | 102 { |
| 103 SVGContainerPainter(*this).paint(paintInfo); | 103 SVGContainerPainter(*this).paint(paintInfo); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } | 106 } |
| OLD | NEW |