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.0) | |
fs
2016/03/31 10:53:04
Nit: Just 1 should do (and is what coding style pr
Shanmuga Pandi
2016/03/31 11:53:35
Done.
| |
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 24 matching lines...) Expand all Loading... | |
106 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal); | 107 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal); |
107 } | 108 } |
108 | 109 |
109 SVGViewSpec* SVGSVGElement::currentView() | 110 SVGViewSpec* SVGSVGElement::currentView() |
110 { | 111 { |
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 { | |
118 if (!inDocument() || !isOutermostSVGSVGElement()) | |
119 return 1; | |
120 | |
121 LocalFrame* frame = document().frame(); | |
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 } | |
132 | |
133 void SVGSVGElement::setCurrentScale(float scale) | 117 void SVGSVGElement::setCurrentScale(float scale) |
134 { | 118 { |
135 ASSERT(std::isfinite(scale)); | 119 ASSERT(std::isfinite(scale)); |
136 if (!inDocument() || !isOutermostSVGSVGElement()) | 120 if (!inDocument() || !isOutermostSVGSVGElement()) |
137 return; | 121 return; |
138 | 122 |
139 LocalFrame* frame = document().frame(); | 123 m_currentScale = scale; |
140 if (!frame) | 124 updateCurrentTranslate(); |
fs
2016/03/31 10:53:04
I'd suggest you rename this to make this look slig
Shanmuga Pandi
2016/03/31 11:53:35
Done.
| |
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 } | 125 } |
153 | 126 |
154 class SVGCurrentTranslateTearOff : public SVGPointTearOff { | 127 class SVGCurrentTranslateTearOff : public SVGPointTearOff { |
155 public: | 128 public: |
156 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme nt* contextElement) | 129 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme nt* contextElement) |
157 { | 130 { |
158 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement) ); | 131 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement) ); |
159 } | 132 } |
160 | 133 |
161 void commitChange() override | 134 void commitChange() override |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 visitor->trace(m_width); | 735 visitor->trace(m_width); |
763 visitor->trace(m_height); | 736 visitor->trace(m_height); |
764 visitor->trace(m_translation); | 737 visitor->trace(m_translation); |
765 visitor->trace(m_timeContainer); | 738 visitor->trace(m_timeContainer); |
766 visitor->trace(m_viewSpec); | 739 visitor->trace(m_viewSpec); |
767 SVGGraphicsElement::trace(visitor); | 740 SVGGraphicsElement::trace(visitor); |
768 SVGFitToViewBox::trace(visitor); | 741 SVGFitToViewBox::trace(visitor); |
769 } | 742 } |
770 | 743 |
771 } // namespace blink | 744 } // namespace blink |
OLD | NEW |