Commit 4c8b6869 authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

Store the color and keyword in StyleColor for system colors

While CSSSystemColorComputeToSelf is under development, store the
color and keyword associated with a system color in StyleColor. This
will allow Forced Colors Mode to access the system color keyword until
CSSSystemColorComputeToSelf is enabled by default.

Bug: 970285,1081945
Change-Id: Idbf3d2ba0960574faace503d79afd9e55f405d1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2373268
Commit-Queue: Alison Maher <almaher@microsoft.com>
Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801870}
parent e2d52ecc
......@@ -1549,8 +1549,11 @@ StyleColor StyleBuilderConverter::ConvertStyleColor(StyleResolverState& state,
return StyleColor::CurrentColor();
if (StyleColor::IsSystemColor(value_id)) {
CountSystemColorComputeToSelfUsage(state);
if (RuntimeEnabledFeatures::CSSSystemColorComputeToSelfEnabled())
return StyleColor(value_id);
return StyleColor(
state.GetDocument().GetTextLinkColors().ColorFromCSSValue(
value, Color(), state.Style()->UsedColorScheme(),
for_visited_link),
value_id);
}
}
return StyleColor(state.GetDocument().GetTextLinkColors().ColorFromCSSValue(
......
......@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/css/style_color.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
......@@ -12,7 +13,7 @@ Color StyleColor::Resolve(Color current_color,
WebColorScheme color_scheme) const {
if (IsCurrentColor())
return current_color;
if (color_keyword_ != CSSValueID::kInvalid)
if (EffectiveColorKeyword() != CSSValueID::kInvalid)
return ColorFromKeyword(color_keyword_, color_scheme);
return color_;
}
......@@ -60,4 +61,12 @@ bool StyleColor::IsSystemColor(CSSValueID id) {
id == CSSValueID::kMenu;
}
CSSValueID StyleColor::EffectiveColorKeyword() const {
if (!RuntimeEnabledFeatures::CSSSystemColorComputeToSelfEnabled()) {
return IsSystemColor(color_keyword_) ? CSSValueID::kInvalid
: color_keyword_;
}
return color_keyword_;
}
} // namespace blink
......@@ -32,22 +32,30 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_STYLE_COLOR_H_
#include "third_party/blink/public/platform/web_color_scheme.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink {
class StyleColor {
class CORE_EXPORT StyleColor {
DISALLOW_NEW();
public:
StyleColor() : color_keyword_(CSSValueID::kCurrentcolor) {}
StyleColor() = default;
explicit StyleColor(Color color)
: color_(color), color_keyword_(CSSValueID::kInvalid) {}
explicit StyleColor(RGBA32 color)
: color_(color), color_keyword_(CSSValueID::kInvalid) {}
explicit StyleColor(CSSValueID keyword) : color_keyword_(keyword) {}
// TODO(1081945): We need to store the color and keyword for system colors
// to allow forced colors mode to access system color keywords while the
// CSSSystemColorComputeToSelf feature is under development. Once
// CSSSystemColorComputeToSelf is enabled, we can remove this ctr and
// EffectiveColorKeyword() and use color_keyword_ directly, instead.
StyleColor(Color color, CSSValueID keyword)
: color_(color), color_keyword_(keyword) {}
static StyleColor CurrentColor() { return StyleColor(); }
bool IsCurrentColor() const {
......@@ -80,11 +88,15 @@ class StyleColor {
inline bool IsValid() const {
// At least one of color_keyword_ and color_ should retain its default
// value.
return color_keyword_ == CSSValueID::kInvalid || color_ == Color();
return EffectiveColorKeyword() == CSSValueID::kInvalid ||
color_ == Color() || IsSystemColor(EffectiveColorKeyword());
}
Color color_;
CSSValueID color_keyword_;
CSSValueID color_keyword_ = CSSValueID::kCurrentcolor;
private:
CSSValueID EffectiveColorKeyword() const;
};
} // namespace blink
......
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