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

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

Issue 2537223006: Cleanup after removal of the SVGViewSpec interface (Closed)
Patch Set: SVGViewSpec& Created 4 years 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, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org>
4 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "core/svg/SVGFitToViewBox.h" 22 #include "core/svg/SVGFitToViewBox.h"
23 23
24 #include "core/dom/Attribute.h"
25 #include "core/svg/SVGDocumentExtensions.h"
26 #include "core/svg/SVGElement.h" 24 #include "core/svg/SVGElement.h"
27 #include "core/svg/SVGParserUtilities.h" 25 #include "core/svg/SVGParsingError.h"
28 #include "platform/geometry/FloatRect.h" 26 #include "platform/geometry/FloatRect.h"
29 #include "platform/transforms/AffineTransform.h" 27 #include "platform/transforms/AffineTransform.h"
30 #include "wtf/text/StringImpl.h"
31 28
32 namespace blink { 29 namespace blink {
33 30
34 class SVGAnimatedViewBoxRect : public SVGAnimatedRect { 31 class SVGAnimatedViewBoxRect : public SVGAnimatedRect {
35 public: 32 public:
36 static SVGAnimatedRect* create(SVGElement* contextElement) { 33 static SVGAnimatedRect* create(SVGElement* contextElement) {
37 return new SVGAnimatedViewBoxRect(contextElement); 34 return new SVGAnimatedViewBoxRect(contextElement);
38 } 35 }
39 36
40 SVGParsingError setBaseValueAsString(const String&) override; 37 SVGParsingError setBaseValueAsString(const String&) override;
41 38
42 protected: 39 protected:
43 SVGAnimatedViewBoxRect(SVGElement* contextElement) 40 SVGAnimatedViewBoxRect(SVGElement* contextElement)
44 : SVGAnimatedRect(contextElement, SVGNames::viewBoxAttr) {} 41 : SVGAnimatedRect(contextElement, SVGNames::viewBoxAttr) {}
45 }; 42 };
46 43
47 SVGParsingError SVGAnimatedViewBoxRect::setBaseValueAsString( 44 SVGParsingError SVGAnimatedViewBoxRect::setBaseValueAsString(
48 const String& value) { 45 const String& value) {
49 SVGParsingError parseStatus = SVGAnimatedRect::setBaseValueAsString(value); 46 SVGParsingError parseStatus = SVGAnimatedRect::setBaseValueAsString(value);
50 47
51 if (parseStatus == SVGParseStatus::NoError && 48 if (parseStatus == SVGParseStatus::NoError &&
52 (baseValue()->width() < 0 || baseValue()->height() < 0)) { 49 (baseValue()->width() < 0 || baseValue()->height() < 0)) {
53 parseStatus = SVGParseStatus::NegativeValue; 50 parseStatus = SVGParseStatus::NegativeValue;
54 baseValue()->setInvalid(); 51 baseValue()->setInvalid();
55 } 52 }
56 return parseStatus; 53 return parseStatus;
57 } 54 }
58 55
59 SVGFitToViewBox::SVGFitToViewBox(SVGElement* element, 56 SVGFitToViewBox::SVGFitToViewBox(SVGElement* element)
60 PropertyMapPolicy propertyMapPolicy)
61 : m_viewBox(SVGAnimatedViewBoxRect::create(element)), 57 : m_viewBox(SVGAnimatedViewBoxRect::create(element)),
62 m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create( 58 m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(
63 element, 59 element,
64 SVGNames::preserveAspectRatioAttr)) { 60 SVGNames::preserveAspectRatioAttr)) {
65 ASSERT(element); 61 DCHECK(element);
66 if (propertyMapPolicy == PropertyMapPolicyAdd) { 62 element->addToPropertyMap(m_viewBox);
67 element->addToPropertyMap(m_viewBox); 63 element->addToPropertyMap(m_preserveAspectRatio);
68 element->addToPropertyMap(m_preserveAspectRatio);
69 }
70 } 64 }
71 65
72 DEFINE_TRACE(SVGFitToViewBox) { 66 DEFINE_TRACE(SVGFitToViewBox) {
73 visitor->trace(m_viewBox); 67 visitor->trace(m_viewBox);
74 visitor->trace(m_preserveAspectRatio); 68 visitor->trace(m_preserveAspectRatio);
75 } 69 }
76 70
77 AffineTransform SVGFitToViewBox::viewBoxToViewTransform( 71 AffineTransform SVGFitToViewBox::viewBoxToViewTransform(
78 const FloatRect& viewBoxRect, 72 const FloatRect& viewBoxRect,
79 SVGPreserveAspectRatio* preserveAspectRatio, 73 SVGPreserveAspectRatio* preserveAspectRatio,
80 float viewWidth, 74 float viewWidth,
81 float viewHeight) { 75 float viewHeight) {
82 if (!viewBoxRect.width() || !viewBoxRect.height() || !viewWidth || 76 if (!viewBoxRect.width() || !viewBoxRect.height() || !viewWidth ||
83 !viewHeight) 77 !viewHeight)
84 return AffineTransform(); 78 return AffineTransform();
85 79
86 return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(), 80 return preserveAspectRatio->getCTM(viewBoxRect.x(), viewBoxRect.y(),
87 viewBoxRect.width(), viewBoxRect.height(), 81 viewBoxRect.width(), viewBoxRect.height(),
88 viewWidth, viewHeight); 82 viewWidth, viewHeight);
89 } 83 }
90 84
91 bool SVGFitToViewBox::isKnownAttribute(const QualifiedName& attrName) { 85 bool SVGFitToViewBox::isKnownAttribute(const QualifiedName& attrName) {
92 return attrName == SVGNames::viewBoxAttr || 86 return attrName == SVGNames::viewBoxAttr ||
93 attrName == SVGNames::preserveAspectRatioAttr; 87 attrName == SVGNames::preserveAspectRatioAttr;
94 } 88 }
95 89
96 void SVGFitToViewBox::updateViewBox(const FloatRect& rect) {
97 ASSERT(m_viewBox);
98 m_viewBox->baseValue()->setValue(rect);
99 }
100
101 } // namespace blink 90 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGFitToViewBox.h ('k') | third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698