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

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

Issue 2097383002: Added support of calc() for SVGLength (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 5 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, 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,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 CSSPrimitiveValue::UnitType typeWithCalcResolved() const { return m_value->t ypeWithCalcResolved(); } 50 CSSPrimitiveValue::UnitType typeWithCalcResolved() const { return m_value->t ypeWithCalcResolved(); }
51 void setUnitType(CSSPrimitiveValue::UnitType); 51 void setUnitType(CSSPrimitiveValue::UnitType);
52 SVGLengthMode unitMode() const { return static_cast<SVGLengthMode>(m_unitMod e); } 52 SVGLengthMode unitMode() const { return static_cast<SVGLengthMode>(m_unitMod e); }
53 53
54 bool operator==(const SVGLength&) const; 54 bool operator==(const SVGLength&) const;
55 bool operator!=(const SVGLength& other) const { return !operator==(other); } 55 bool operator!=(const SVGLength& other) const { return !operator==(other); }
56 56
57 float value(const SVGLengthContext&) const; 57 float value(const SVGLengthContext&) const;
58 void setValue(float, const SVGLengthContext&); 58 void setValue(float, const SVGLengthContext&);
59 void setValueAsNumber(float);
59 60
60 float valueInSpecifiedUnits() const { return m_value->getFloatValue(); } 61 float valueInSpecifiedUnits() const { return m_value->getFloatValue(); }
61 void setValueInSpecifiedUnits(float value) 62 void setValueInSpecifiedUnits(float value)
62 { 63 {
63 m_value = CSSPrimitiveValue::create(value, m_value->typeWithCalcResolved ()); 64 m_value = CSSPrimitiveValue::create(value, m_value->typeWithCalcResolved ());
64 } 65 }
65 66
66 const CSSPrimitiveValue* asCSSPrimitiveValue() const { return m_value.get(); } 67 const CSSPrimitiveValue* asCSSPrimitiveValue() const { return m_value.get(); }
67 68
68 // Resolves LengthTypePercentage into a normalized floating point number (fu ll value is 1.0). 69 // Resolves LengthTypePercentage into a normalized floating point number (fu ll value is 1.0).
69 float valueAsPercentage() const; 70 float valueAsPercentage() const;
70 71
71 // Returns a number to be used as percentage (so full value is 100) 72 // Returns a number to be used as percentage (so full value is 100)
72 float valueAsPercentage100() const; 73 float valueAsPercentage100() const;
73 74
74 // Scale the input value by this SVGLength. Higher precision than input * va lueAsPercentage(). 75 // Scale the input value by this SVGLength. Higher precision than input * va lueAsPercentage().
75 float scaleByPercentage(float) const; 76 float scaleByPercentage(float) const;
76 77
77 String valueAsString() const override; 78 String valueAsString() const override;
78 SVGParsingError setValueAsString(const String&); 79 SVGParsingError setValueAsString(const String&);
79 80
80 void newValueSpecifiedUnits(CSSPrimitiveValue::UnitType, float valueInSpecif iedUnits); 81 void newValueSpecifiedUnits(CSSPrimitiveValue::UnitType, float valueInSpecif iedUnits);
81 void convertToSpecifiedUnits(CSSPrimitiveValue::UnitType, const SVGLengthCon text&); 82 void convertToSpecifiedUnits(CSSPrimitiveValue::UnitType, const SVGLengthCon text&);
82 83
83 // Helper functions 84 // Helper functions
84 inline bool isRelative() const { return CSSPrimitiveValue::isRelativeUnit(m_ value->typeWithCalcResolved()); } 85 inline bool isRelative() const { return CSSPrimitiveValue::isRelativeUnit(m_ value->typeWithCalcResolved()); }
86 inline bool isCalculated() const { return m_value->isCalculated(); }
85 87
86 bool isZero() const 88 bool isZero() const
87 { 89 {
88 return m_value->getFloatValue() == 0; 90 return m_value->getFloatValue() == 0;
89 } 91 }
90 92
91 static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedNam e&); 93 static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedNam e&);
92 static bool negativeValuesForbiddenForAnimatedLengthAttribute(const Qualifie dName&); 94 static bool negativeValuesForbiddenForAnimatedLengthAttribute(const Qualifie dName&);
93 95
94 void add(SVGPropertyBase*, SVGElement*) override; 96 void add(SVGPropertyBase*, SVGElement*) override;
95 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, SVGPropertyBase* from, SVGPropertyBase* to, SVGPropertyBase* toAtE ndOfDurationValue, SVGElement* contextElement) override; 97 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, SVGPropertyBase* from, SVGPropertyBase* to, SVGPropertyBase* toAtE ndOfDurationValue, SVGElement* contextElement) override;
96 float calculateDistance(SVGPropertyBase* to, SVGElement* contextElement) ove rride; 98 float calculateDistance(SVGPropertyBase* to, SVGElement* contextElement) ove rride;
97 99
98 static AnimatedPropertyType classType() { return AnimatedLength; } 100 static AnimatedPropertyType classType() { return AnimatedLength; }
99 AnimatedPropertyType type() const override { return classType(); } 101 AnimatedPropertyType type() const override { return classType(); }
100 102
103 static CSSPrimitiveValue::UnitType toUnitType(int lengthUnitType)
104 {
105 return static_cast<CSSPrimitiveValue::UnitType>(CSSPrimitiveValue::lengt hUnitTypeToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(lengthUnitTyp e)));
fs 2016/07/16 21:13:02 Shouldn't need to cast what lengthUnitTypeToUnitTy
Shanmuga Pandi 2016/07/18 13:35:33 Done.
106 }
101 private: 107 private:
102 SVGLength(SVGLengthMode); 108 SVGLength(SVGLengthMode);
103 SVGLength(const SVGLength&); 109 SVGLength(const SVGLength&);
104 110
111 float resolveCalcValue(const SVGLengthContext&) const;
105 Member<const CSSPrimitiveValue> m_value; 112 Member<const CSSPrimitiveValue> m_value;
106 unsigned m_unitMode : 2; 113 unsigned m_unitMode : 2;
107 }; 114 };
108 115
109 DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGLength); 116 DEFINE_SVG_PROPERTY_TYPE_CASTS(SVGLength);
110 117
111 } // namespace blink 118 } // namespace blink
112 119
113 #endif // SVGLength_h 120 #endif // SVGLength_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698