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

Side by Side Diff: Source/core/svg/SVGLength.h

Issue 901193002: De-ExceptionState-ify SVGLengthContext (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/svg/dom/SVGLength-px-expected.txt ('k') | Source/core/svg/SVGLength.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #ifndef SVGLength_h 21 #ifndef SVGLength_h
22 #define SVGLength_h 22 #define SVGLength_h
23 23
24 #include "bindings/core/v8/ExceptionMessages.h"
25 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
26 #include "core/svg/SVGLengthContext.h" 24 #include "core/svg/SVGLengthContext.h"
27 #include "core/svg/properties/SVGProperty.h" 25 #include "core/svg/properties/SVGProperty.h"
28 #include "platform/heap/Handle.h" 26 #include "platform/heap/Handle.h"
29 27
30 namespace blink { 28 namespace blink {
31 29
32 class CSSPrimitiveValue; 30 class CSSPrimitiveValue;
33 class ExceptionState; 31 class ExceptionState;
34 class QualifiedName; 32 class QualifiedName;
35 33
(...skipping 16 matching lines...) Expand all
52 PassRefPtrWillBeRawPtr<SVGLength> clone() const; 50 PassRefPtrWillBeRawPtr<SVGLength> clone() const;
53 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const Stri ng&) const override; 51 virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const Stri ng&) const override;
54 52
55 SVGLengthType unitType() const { return static_cast<SVGLengthType>(m_unitTyp e); } 53 SVGLengthType unitType() const { return static_cast<SVGLengthType>(m_unitTyp e); }
56 void setUnitType(SVGLengthType); 54 void setUnitType(SVGLengthType);
57 SVGLengthMode unitMode() const { return static_cast<SVGLengthMode>(m_unitMod e); } 55 SVGLengthMode unitMode() const { return static_cast<SVGLengthMode>(m_unitMod e); }
58 56
59 bool operator==(const SVGLength&) const; 57 bool operator==(const SVGLength&) const;
60 bool operator!=(const SVGLength& other) const { return !operator==(other); } 58 bool operator!=(const SVGLength& other) const { return !operator==(other); }
61 59
62 float value(const SVGLengthContext& context) const 60 float value(const SVGLengthContext&) const;
63 { 61 void setValue(float, const SVGLengthContext&);
64 return value(context, IGNORE_EXCEPTION);
65 }
66 float value(const SVGLengthContext&, ExceptionState&) const;
67 void setValue(float, const SVGLengthContext&, ExceptionState&);
68 62
69 float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; } 63 float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
70 void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value ; } 64 void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value ; }
71 65
72 // Resolves LengthTypePercentage into a normalized floating point number (fu ll value is 1.0). 66 // Resolves LengthTypePercentage into a normalized floating point number (fu ll value is 1.0).
73 float valueAsPercentage() const; 67 float valueAsPercentage() const;
74 68
75 // Returns a number to be used as percentage (so full value is 100) 69 // Returns a number to be used as percentage (so full value is 100)
76 float valueAsPercentage100() const; 70 float valueAsPercentage100() const;
77 71
78 // Scale the input value by this SVGLength. Higher precision than input * va lueAsPercentage(). 72 // Scale the input value by this SVGLength. Higher precision than input * va lueAsPercentage().
79 float scaleByPercentage(float) const; 73 float scaleByPercentage(float) const;
80 74
81 virtual String valueAsString() const override; 75 virtual String valueAsString() const override;
82 void setValueAsString(const String&, ExceptionState&); 76 void setValueAsString(const String&, ExceptionState&);
83 77
84 void newValueSpecifiedUnits(SVGLengthType, float valueInSpecifiedUnits); 78 void newValueSpecifiedUnits(SVGLengthType, float valueInSpecifiedUnits);
85 void convertToSpecifiedUnits(SVGLengthType, const SVGLengthContext&, Excepti onState&); 79 void convertToSpecifiedUnits(SVGLengthType, const SVGLengthContext&);
86 80
87 // Helper functions 81 // Helper functions
88 inline bool isRelative() const 82 static inline bool isRelativeUnit(SVGLengthType unitType)
89 { 83 {
90 return m_unitType == LengthTypePercentage 84 return unitType == LengthTypePercentage
91 || m_unitType == LengthTypeEMS 85 || unitType == LengthTypeEMS
92 || m_unitType == LengthTypeEXS; 86 || unitType == LengthTypeEXS;
93 } 87 }
88 inline bool isRelative() const { return isRelativeUnit(unitType()); }
94 89
95 bool isZero() const 90 bool isZero() const
96 { 91 {
97 return !m_valueInSpecifiedUnits; 92 return !m_valueInSpecifiedUnits;
98 } 93 }
99 94
100 static PassRefPtrWillBeRawPtr<SVGLength> fromCSSPrimitiveValue(CSSPrimitiveV alue*); 95 static PassRefPtrWillBeRawPtr<SVGLength> fromCSSPrimitiveValue(CSSPrimitiveV alue*);
101 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(PassRef PtrWillBeRawPtr<SVGLength>); 96 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(PassRef PtrWillBeRawPtr<SVGLength>);
102 static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedNam e&); 97 static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedNam e&);
103 98
(...skipping 17 matching lines...) Expand all
121 inline PassRefPtrWillBeRawPtr<SVGLength> toSVGLength(PassRefPtrWillBeRawPtr<SVGP ropertyBase> passBase) 116 inline PassRefPtrWillBeRawPtr<SVGLength> toSVGLength(PassRefPtrWillBeRawPtr<SVGP ropertyBase> passBase)
122 { 117 {
123 RefPtrWillBeRawPtr<SVGPropertyBase> base = passBase; 118 RefPtrWillBeRawPtr<SVGPropertyBase> base = passBase;
124 ASSERT(base->type() == SVGLength::classType()); 119 ASSERT(base->type() == SVGLength::classType());
125 return static_pointer_cast<SVGLength>(base.release()); 120 return static_pointer_cast<SVGLength>(base.release());
126 } 121 }
127 122
128 } // namespace blink 123 } // namespace blink
129 124
130 #endif // SVGLength_h 125 #endif // SVGLength_h
OLDNEW
« no previous file with comments | « LayoutTests/svg/dom/SVGLength-px-expected.txt ('k') | Source/core/svg/SVGLength.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698