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

Unified Diff: Source/core/svg/SVGLength.h

Issue 1162453002: [svg2] Make SVGLength wrap a CSSPrimitiveValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: nit Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGAnimatedLength.cpp ('k') | Source/core/svg/SVGLength.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGLength.h
diff --git a/Source/core/svg/SVGLength.h b/Source/core/svg/SVGLength.h
index b228627f63c79aa57386ce2a89cece9349166cda..eff5dbce4e63fcfc2c7af127d6dd45f0d6037ac4 100644
--- a/Source/core/svg/SVGLength.h
+++ b/Source/core/svg/SVGLength.h
@@ -47,23 +47,21 @@ public:
return adoptRefWillBeNoop(new SVGLength(mode));
}
+ DECLARE_VIRTUAL_TRACE();
+
PassRefPtrWillBeRawPtr<SVGLength> clone() const;
virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override;
- SVGLengthType unitType() const { return static_cast<SVGLengthType>(m_unitType); }
+ CSSPrimitiveValue::UnitType primitiveType() const { return m_value->primitiveType(); }
+
CSSPrimitiveValue::UnitType cssUnitTypeQuirk() const
{
- if (m_unitType == LengthTypeNumber)
+ if (m_value->primitiveType() == CSSPrimitiveValue::UnitType::CSS_NUMBER)
return CSSPrimitiveValue::UnitType::CSS_PX;
- if (m_unitType == LengthTypeREMS)
- return CSSPrimitiveValue::UnitType::CSS_REMS;
- if (m_unitType == LengthTypeCHS)
- return CSSPrimitiveValue::UnitType::CSS_CHS;
-
- return static_cast<CSSPrimitiveValue::UnitType>(m_unitType);
+ return m_value->primitiveType();
}
- void setUnitType(SVGLengthType);
+ void setUnitType(CSSPrimitiveValue::UnitType);
SVGLengthMode unitMode() const { return static_cast<SVGLengthMode>(m_unitMode); }
bool operator==(const SVGLength&) const;
@@ -72,8 +70,11 @@ public:
float value(const SVGLengthContext&) const;
void setValue(float, const SVGLengthContext&);
- float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
- void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value; }
+ float valueInSpecifiedUnits() const { return m_value->getFloatValue(); }
+ void setValueInSpecifiedUnits(float value)
+ {
+ m_value = CSSPrimitiveValue::create(value, m_value->primitiveType());
+ }
// Resolves LengthTypePercentage into a normalized floating point number (full value is 1.0).
float valueAsPercentage() const;
@@ -87,27 +88,27 @@ public:
virtual String valueAsString() const override;
void setValueAsString(const String&, ExceptionState&);
- void newValueSpecifiedUnits(SVGLengthType, float valueInSpecifiedUnits);
- void convertToSpecifiedUnits(SVGLengthType, const SVGLengthContext&);
+ void newValueSpecifiedUnits(CSSPrimitiveValue::UnitType, float valueInSpecifiedUnits);
+ void convertToSpecifiedUnits(CSSPrimitiveValue::UnitType, const SVGLengthContext&);
// Helper functions
- static inline bool isRelativeUnit(SVGLengthType unitType)
+ static inline bool isRelativeUnit(CSSPrimitiveValue::UnitType unitType)
{
- return unitType == LengthTypePercentage
- || unitType == LengthTypeEMS
- || unitType == LengthTypeEXS
- || unitType == LengthTypeREMS
- || unitType == LengthTypeCHS;
+ return unitType == CSSPrimitiveValue::CSS_PERCENTAGE
+ || unitType == CSSPrimitiveValue::CSS_EMS
+ || unitType == CSSPrimitiveValue::CSS_EXS
+ || unitType == CSSPrimitiveValue::CSS_REMS
+ || unitType == CSSPrimitiveValue::CSS_CHS;
}
- inline bool isRelative() const { return isRelativeUnit(unitType()); }
+ inline bool isRelative() const { return isRelativeUnit(m_value->primitiveType()); }
bool isZero() const
{
- return !m_valueInSpecifiedUnits;
+ return m_value->getFloatValue() == 0;
}
static PassRefPtrWillBeRawPtr<SVGLength> fromCSSPrimitiveValue(CSSPrimitiveValue*);
- static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> toCSSPrimitiveValue(PassRefPtrWillBeRawPtr<SVGLength>);
+
static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedName&);
PassRefPtrWillBeRawPtr<SVGLength> blend(PassRefPtrWillBeRawPtr<SVGLength> from, float progress) const;
@@ -122,9 +123,8 @@ private:
SVGLength(SVGLengthMode);
SVGLength(const SVGLength&);
- float m_valueInSpecifiedUnits;
+ RefPtrWillBeMember<CSSPrimitiveValue> m_value;
unsigned m_unitMode : 2;
- unsigned m_unitType : 4;
};
inline PassRefPtrWillBeRawPtr<SVGLength> toSVGLength(PassRefPtrWillBeRawPtr<SVGPropertyBase> passBase)
« no previous file with comments | « Source/core/svg/SVGAnimatedLength.cpp ('k') | Source/core/svg/SVGLength.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698