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

Unified Diff: third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h

Issue 2903413002: Restructure type tracking in StyleValues to work better with new numeric types (Closed)
Patch Set: rebase Created 3 years, 6 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
Index: third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h
diff --git a/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h b/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h
index ffd2703f5f909df2256ec22d8c6653ccc2c05fcb..aa084da575e30dbf248451cad97ee0f15f36ae89 100644
--- a/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h
+++ b/third_party/WebKit/Source/core/css/cssom/CSSUnitValue.h
@@ -10,30 +10,40 @@
namespace blink {
+// Represents numeric values that can be expressed as a single number plus a
+// unit (or a naked number or percentage).
+// See CSSUnitValue.idl for more information about this class.
class CORE_EXPORT CSSUnitValue final : public CSSNumericValue {
WTF_MAKE_NONCOPYABLE(CSSUnitValue);
DEFINE_WRAPPERTYPEINFO();
public:
- static CSSPrimitiveValue::UnitType UnitFromName(const String& name);
+ // The constructor defined in the IDL.
static CSSUnitValue* Create(double value,
const String& unit,
ExceptionState&);
+ // Blink-internal ways of creating CSSUnitValues.
static CSSUnitValue* Create(double value, CSSPrimitiveValue::UnitType);
static CSSUnitValue* FromCSSValue(const CSSPrimitiveValue&);
+ // Setters and getters for attributes defined in the IDL.
void setValue(double new_value) { value_ = new_value; }
double value() const { return value_; }
void setUnit(const String& new_unit, ExceptionState&);
String unit() const;
-
String type() const;
- StyleValueType GetType() const override { return StyleValueType::kUnitType; }
-
+ // Gets the Typed OM category, e.g. length, angle, etc.
+ StyleValueType GetType() const override;
+ bool ContainsPercent() const override {
+ return unit_ == CSSPrimitiveValue::UnitType::kPercentage;
+ }
+ // Gets the representation that can be applied to an inline style.
const CSSValue* ToCSSValue() const override;
private:
+ static CSSPrimitiveValue::UnitType UnitFromName(const String& name);
+
CSSUnitValue(double value, CSSPrimitiveValue::UnitType unit)
: CSSNumericValue(), value_(value), unit_(unit) {}
« no previous file with comments | « third_party/WebKit/Source/core/css/cssom/CSSStyleValue.cpp ('k') | third_party/WebKit/Source/core/css/cssom/CSSUnitValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698