Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGSVGElement.cpp

Issue 1827793003: Support currentScale for embedded SVG (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 float SVGSVGElement::currentScale() const 116 float SVGSVGElement::currentScale() const
117 { 117 {
118 if (!inDocument() || !isOutermostSVGSVGElement()) 118 if (!inDocument() || !isOutermostSVGSVGElement())
119 return 1; 119 return 1;
120 120
121 LocalFrame* frame = document().frame(); 121 LocalFrame* frame = document().frame();
122 if (!frame) 122 if (!frame)
123 return 1; 123 return 1;
124 124
125 const FrameTree& frameTree = frame->tree(); 125 return frame->pageZoomFactor();
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 } 126 }
132 127
133 void SVGSVGElement::setCurrentScale(float scale) 128 void SVGSVGElement::setCurrentScale(float scale)
134 { 129 {
135 ASSERT(std::isfinite(scale)); 130 ASSERT(std::isfinite(scale));
136 if (!inDocument() || !isOutermostSVGSVGElement()) 131 if (!inDocument() || !isOutermostSVGSVGElement())
137 return; 132 return;
138 133
139 LocalFrame* frame = document().frame(); 134 LocalFrame* frame = document().frame();
140 if (!frame) 135 if (!frame)
141 return; 136 return;
142 137
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); 138 frame->setPageZoomFactor(scale);
152 } 139 }
153 140
154 class SVGCurrentTranslateTearOff : public SVGPointTearOff { 141 class SVGCurrentTranslateTearOff : public SVGPointTearOff {
155 public: 142 public:
156 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme nt* contextElement) 143 static PassRefPtrWillBeRawPtr<SVGCurrentTranslateTearOff> create(SVGSVGEleme nt* contextElement)
157 { 144 {
158 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement) ); 145 return adoptRefWillBeNoop(new SVGCurrentTranslateTearOff(contextElement) );
159 } 146 }
160 147
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 visitor->trace(m_width); 749 visitor->trace(m_width);
763 visitor->trace(m_height); 750 visitor->trace(m_height);
764 visitor->trace(m_translation); 751 visitor->trace(m_translation);
765 visitor->trace(m_timeContainer); 752 visitor->trace(m_timeContainer);
766 visitor->trace(m_viewSpec); 753 visitor->trace(m_viewSpec);
767 SVGGraphicsElement::trace(visitor); 754 SVGGraphicsElement::trace(visitor);
768 SVGFitToViewBox::trace(visitor); 755 SVGFitToViewBox::trace(visitor);
769 } 756 }
770 757
771 } // namespace blink 758 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698