| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 inline SVGSVGElement::SVGSVGElement(Document& doc) | 62 inline SVGSVGElement::SVGSVGElement(Document& doc) |
| 63 : SVGGraphicsElement(SVGNames::svgTag, doc) | 63 : SVGGraphicsElement(SVGNames::svgTag, doc) |
| 64 , SVGFitToViewBox(this) | 64 , SVGFitToViewBox(this) |
| 65 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(SVG
LengthMode::Width))) | 65 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(SVG
LengthMode::Width))) |
| 66 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(SVG
LengthMode::Height))) | 66 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(SVG
LengthMode::Height))) |
| 67 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(SVGLengthMode::Width))) | 67 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(SVGLengthMode::Width))) |
| 68 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(SVGLengthMode::Height))) | 68 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(SVGLengthMode::Height))) |
| 69 , m_useCurrentView(false) | 69 , m_useCurrentView(false) |
| 70 , m_timeContainer(SMILTimeContainer::create(*this)) | 70 , m_timeContainer(SMILTimeContainer::create(*this)) |
| 71 , m_translation(SVGPoint::create()) | 71 , m_translation(SVGPoint::create()) |
| 72 , m_currentScale(1) |
| 72 { | 73 { |
| 73 m_width->setDefaultValueAsString("100%"); | 74 m_width->setDefaultValueAsString("100%"); |
| 74 m_height->setDefaultValueAsString("100%"); | 75 m_height->setDefaultValueAsString("100%"); |
| 75 | 76 |
| 76 addToPropertyMap(m_x); | 77 addToPropertyMap(m_x); |
| 77 addToPropertyMap(m_y); | 78 addToPropertyMap(m_y); |
| 78 addToPropertyMap(m_width); | 79 addToPropertyMap(m_width); |
| 79 addToPropertyMap(m_height); | 80 addToPropertyMap(m_height); |
| 80 | 81 |
| 81 UseCounter::count(doc, UseCounter::SVGSVGElement); | 82 UseCounter::count(doc, UseCounter::SVGSVGElement); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 111 if (!m_viewSpec) | 112 if (!m_viewSpec) |
| 112 m_viewSpec = SVGViewSpec::create(this); | 113 m_viewSpec = SVGViewSpec::create(this); |
| 113 return m_viewSpec.get(); | 114 return m_viewSpec.get(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 float SVGSVGElement::currentScale() const | 117 float SVGSVGElement::currentScale() const |
| 117 { | 118 { |
| 118 if (!inDocument() || !isOutermostSVGSVGElement()) | 119 if (!inDocument() || !isOutermostSVGSVGElement()) |
| 119 return 1; | 120 return 1; |
| 120 | 121 |
| 121 LocalFrame* frame = document().frame(); | 122 return m_currentScale; |
| 122 if (!frame) | |
| 123 return 1; | |
| 124 | |
| 125 const FrameTree& frameTree = frame->tree(); | |
| 126 | |
| 127 // The behaviour of currentScale() is undefined, when we're dealing with non
-standalone SVG documents. | |
| 128 // If the svg is embedded, the scaling is handled by the host layoutObject,
so when asking from inside | |
| 129 // the SVG document, a scale value of 1 seems reasonable, as it doesn't know
anything about the parent scale. | |
| 130 return frameTree.parent() ? 1 : frame->pageZoomFactor(); | |
| 131 } | 123 } |
| 132 | 124 |
| 133 void SVGSVGElement::setCurrentScale(float scale) | 125 void SVGSVGElement::setCurrentScale(float scale) |
| 134 { | 126 { |
| 135 ASSERT(std::isfinite(scale)); | 127 ASSERT(std::isfinite(scale)); |
| 136 if (!inDocument() || !isOutermostSVGSVGElement()) | 128 if (!inDocument() || !isOutermostSVGSVGElement()) |
| 137 return; | 129 return; |
| 138 | 130 |
| 139 LocalFrame* frame = document().frame(); | 131 m_currentScale = scale; |
| 140 if (!frame) | 132 updateUserTransform(); |
| 141 return; | |
| 142 | |
| 143 const FrameTree& frameTree = frame->tree(); | |
| 144 | |
| 145 // The behaviour of setCurrentScale() is undefined, when we're dealing with
non-standalone SVG documents. | |
| 146 // We choose the ignore this call, it's pretty useless to support calling se
tCurrentScale() from within | |
| 147 // an embedded SVG document, for the same reasons as in currentScale() - nee
ds resolution by SVG WG. | |
| 148 if (frameTree.parent()) | |
| 149 return; | |
| 150 | |
| 151 frame->setPageZoomFactor(scale); | |
| 152 } | 133 } |
| 153 | 134 |
| 154 class SVGCurrentTranslateTearOff : public SVGPointTearOff { | 135 class SVGCurrentTranslateTearOff : public SVGPointTearOff { |
| 155 public: | 136 public: |
| 156 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme
nt* contextElement) | 137 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme
nt* contextElement) |
| 157 { | 138 { |
| 158 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement)
); | 139 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement)
); |
| 159 } | 140 } |
| 160 | 141 |
| 161 void commitChange() override | 142 void commitChange() override |
| 162 { | 143 { |
| 163 ASSERT(contextElement()); | 144 ASSERT(contextElement()); |
| 164 toSVGSVGElement(contextElement())->updateCurrentTranslate(); | 145 toSVGSVGElement(contextElement())->updateUserTransform(); |
| 165 } | 146 } |
| 166 | 147 |
| 167 private: | 148 private: |
| 168 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement) | 149 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement) |
| 169 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert
yIsNotAnimVal) | 150 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert
yIsNotAnimVal) |
| 170 { | 151 { |
| 171 } | 152 } |
| 172 }; | 153 }; |
| 173 | 154 |
| 174 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavas
cript() | 155 PassRefPtrWillBeRawPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavas
cript() |
| 175 { | 156 { |
| 176 return SVGCurrentTranslateTearOff::create(this); | 157 return SVGCurrentTranslateTearOff::create(this); |
| 177 } | 158 } |
| 178 | 159 |
| 179 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) | 160 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) |
| 180 { | 161 { |
| 181 m_translation->setValue(point); | 162 m_translation->setValue(point); |
| 182 updateCurrentTranslate(); | 163 updateUserTransform(); |
| 183 } | 164 } |
| 184 | 165 |
| 185 void SVGSVGElement::updateCurrentTranslate() | 166 void SVGSVGElement::updateUserTransform() |
| 186 { | 167 { |
| 187 if (LayoutObject* object = layoutObject()) | 168 if (LayoutObject* object = layoutObject()) |
| 188 object->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason:
:Unknown); | 169 object->setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason:
:Unknown); |
| 189 } | 170 } |
| 190 | 171 |
| 191 bool SVGSVGElement::zoomAndPanEnabled() const | 172 bool SVGSVGElement::zoomAndPanEnabled() const |
| 192 { | 173 { |
| 193 const SVGZoomAndPan* currentViewSpec = this; | 174 const SVGZoomAndPan* currentViewSpec = this; |
| 194 if (m_useCurrentView) | 175 if (m_useCurrentView) |
| 195 currentViewSpec = m_viewSpec.get(); | 176 currentViewSpec = m_viewSpec.get(); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 visitor->trace(m_width); | 743 visitor->trace(m_width); |
| 763 visitor->trace(m_height); | 744 visitor->trace(m_height); |
| 764 visitor->trace(m_translation); | 745 visitor->trace(m_translation); |
| 765 visitor->trace(m_timeContainer); | 746 visitor->trace(m_timeContainer); |
| 766 visitor->trace(m_viewSpec); | 747 visitor->trace(m_viewSpec); |
| 767 SVGGraphicsElement::trace(visitor); | 748 SVGGraphicsElement::trace(visitor); |
| 768 SVGFitToViewBox::trace(visitor); | 749 SVGFitToViewBox::trace(visitor); |
| 769 } | 750 } |
| 770 | 751 |
| 771 } // namespace blink | 752 } // namespace blink |
| OLD | NEW |