Index: third_party/WebKit/Source/core/css/StyleColor.h |
diff --git a/third_party/WebKit/Source/core/css/StyleColor.h b/third_party/WebKit/Source/core/css/StyleColor.h |
index c5925f2753d7050acf7f3f4c2319cc9cafb2dfa3..c1f0cbb16ae7e6b5f105ecbb5adab87fcc671c33 100644 |
--- a/third_party/WebKit/Source/core/css/StyleColor.h |
+++ b/third_party/WebKit/Source/core/css/StyleColor.h |
@@ -41,18 +41,21 @@ class StyleColor { |
DISALLOW_NEW(); |
public: |
- StyleColor() : m_currentColor(true) {} |
- StyleColor(Color color) : m_color(color), m_currentColor(false) {} |
+ StyleColor() : m_type(CurrentColor) {} |
+ StyleColor(Color color) : m_color(color), m_type(SpecifiedColor) {} |
static StyleColor currentColor() { return StyleColor(); } |
+ static StyleColor autoColor() { return StyleColor(AutoColor); } |
- bool isCurrentColor() const { return m_currentColor; } |
+ bool isAutoColor() const { return m_type == AutoColor; } |
+ bool isCurrentColor() const { return m_type == CurrentColor; } |
Color getColor() const { |
- ASSERT(!isCurrentColor()); |
+ DCHECK(!isAutoColor()); |
+ DCHECK(!isCurrentColor()); |
return m_color; |
} |
Color resolve(Color currentColor) const { |
- return m_currentColor ? currentColor : m_color; |
+ return m_type == SpecifiedColor ? m_color : currentColor; |
} |
static Color colorFromKeyword(CSSValueID); |
@@ -60,13 +63,17 @@ class StyleColor { |
static bool isSystemColor(CSSValueID); |
private: |
+ enum ColorType { AutoColor, CurrentColor, SpecifiedColor }; |
Timothy Loh
2016/11/22 02:17:35
I'd prefer if we didn't add Auto to StyleColor. Th
yosin_UTC9
2016/11/22 02:25:10
nit: Let's use |enum class|.
|ColorType| is ambig
Manuel Rego
2016/11/22 09:36:01
I can create a different class, but I don't see ho
Manuel Rego
2016/11/22 09:36:01
Good suggestion, anyway as @timloh suggested I can
|
+ StyleColor(ColorType type) : m_type(type) {} |
Color m_color; |
- bool m_currentColor; |
+ ColorType m_type; |
}; |
inline bool operator==(const StyleColor& a, const StyleColor& b) { |
if (a.isCurrentColor() || b.isCurrentColor()) |
return a.isCurrentColor() && b.isCurrentColor(); |
+ if (a.isAutoColor() || b.isAutoColor()) |
+ return a.isAutoColor() && b.isAutoColor(); |
return a.getColor() == b.getColor(); |
} |