Commit 4732a44b authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Store keyword for unresolved StyleColor.

We currently store a bool saying if the StyleColor represents
currentcolor or not since currentcolor computes to itself and will
inherit as currentcolor. If [1] is resolved, we need to do the same for
system colors. Store a CSSValueID in preparation for that.

This CL should not have any behavioral changes.

[1] https://github.com/w3c/csswg-drafts/issues/3847

Bug: 939811
Change-Id: I5908a09b311c549c9d194bdf4180e24ba7baae5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1771413Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690897}
parent 6f7091f6
...@@ -42,29 +42,34 @@ class StyleColor { ...@@ -42,29 +42,34 @@ class StyleColor {
DISALLOW_NEW(); DISALLOW_NEW();
public: public:
StyleColor() : current_color_(true) {} StyleColor() : color_keyword_(CSSValueID::kCurrentcolor) {}
StyleColor(Color color) : color_(color), current_color_(false) {} StyleColor(Color color)
: color_(color), color_keyword_(CSSValueID::kInvalid) {}
static StyleColor CurrentColor() { return StyleColor(); } static StyleColor CurrentColor() { return StyleColor(); }
bool IsCurrentColor() const { return current_color_; } bool IsCurrentColor() const {
return color_keyword_ == CSSValueID::kCurrentcolor;
}
Color GetColor() const { Color GetColor() const {
DCHECK(!IsCurrentColor()); DCHECK(!IsCurrentColor());
return color_; return color_;
} }
Color Resolve(Color current_color) const { Color Resolve(Color current_color) const {
return current_color_ ? current_color : color_; return IsCurrentColor() ? current_color : color_;
} }
bool HasAlpha() const { return !current_color_ && color_.HasAlpha(); } bool HasAlpha() const { return !IsCurrentColor() && color_.HasAlpha(); }
static Color ColorFromKeyword(CSSValueID, WebColorScheme color_scheme); static Color ColorFromKeyword(CSSValueID, WebColorScheme color_scheme);
static bool IsColorKeyword(CSSValueID); static bool IsColorKeyword(CSSValueID);
static bool IsSystemColor(CSSValueID); static bool IsSystemColor(CSSValueID);
private: private:
explicit StyleColor(CSSValueID keyword) : color_keyword_(keyword) {}
Color color_; Color color_;
bool current_color_; CSSValueID color_keyword_;
}; };
inline bool operator==(const StyleColor& a, const StyleColor& b) { inline bool operator==(const StyleColor& a, const StyleColor& b) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment