Skip to content

Commit

Permalink
Rename RenderStyle effectiveAccentColor() to usedAccentColor()
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270632

Reviewed by Aditya Keerthi.

This aligns it with terminology used in CSS standards.

* Source/WebCore/platform/adwaita/ThemeAdwaita.cpp:
(WebCore::ThemeAdwaita::paint):
(WebCore::ThemeAdwaita::paintCheckbox):
(WebCore::ThemeAdwaita::paintRadio):
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::extractControlStyleForRenderer const):
(WebCore::RenderTheme::paint):
* Source/WebCore/rendering/adwaita/RenderThemeAdwaita.cpp:
(WebCore::getAccentColor):
(WebCore::RenderThemeAdwaita::paintMenuList):
* Source/WebCore/rendering/ios/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::adjustButtonLikeControlStyle const):
(WebCore::RenderThemeIOS::controlTintColor const):
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::usedAccentColor const):
(WebCore::RenderStyle::effectiveAccentColor const): Deleted.
* Source/WebCore/rendering/style/RenderStyle.h:

Canonical link: https://commits.webkit.org/275833@main
  • Loading branch information
annevk committed Mar 8, 2024
1 parent 319ecb9 commit 0268a59
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions Source/WebCore/platform/adwaita/ThemeAdwaita.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ LengthBox ThemeAdwaita::controlBorder(StyleAppearance appearance, const FontCasc
return Theme::controlBorder(appearance, font, zoomedBox, zoomFactor);
}

void ThemeAdwaita::paint(StyleAppearance appearance, OptionSet<ControlStyle::State> states, GraphicsContext& context, const FloatRect& zoomedRect, bool useDarkAppearance, const Color& effectiveAccentColor)
void ThemeAdwaita::paint(StyleAppearance appearance, OptionSet<ControlStyle::State> states, GraphicsContext& context, const FloatRect& zoomedRect, bool useDarkAppearance, const Color& usedAccentColor)
{
switch (appearance) {
case StyleAppearance::Checkbox:
paintCheckbox(states, context, zoomedRect, useDarkAppearance, effectiveAccentColor);
paintCheckbox(states, context, zoomedRect, useDarkAppearance, usedAccentColor);
break;
case StyleAppearance::Radio:
paintRadio(states, context, zoomedRect, useDarkAppearance, effectiveAccentColor);
paintRadio(states, context, zoomedRect, useDarkAppearance, usedAccentColor);
break;
case StyleAppearance::PushButton:
case StyleAppearance::DefaultButton:
Expand All @@ -298,7 +298,7 @@ void ThemeAdwaita::paint(StyleAppearance appearance, OptionSet<ControlStyle::Sta
}
}

void ThemeAdwaita::paintCheckbox(OptionSet<ControlStyle::State> states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance, const Color& effectiveAccentColor)
void ThemeAdwaita::paintCheckbox(OptionSet<ControlStyle::State> states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance, const Color& usedAccentColor)
{
GraphicsContextStateSaver stateSaver(graphicsContext);

Expand All @@ -323,7 +323,7 @@ void ThemeAdwaita::paintCheckbox(OptionSet<ControlStyle::State> states, Graphics
toggleBorderHoverColor = toggleBorderHoveredColorLight;
}

Color accentColor = effectiveAccentColor.isValid() ? effectiveAccentColor : m_accentColor;
Color accentColor = usedAccentColor.isValid() ? usedAccentColor : m_accentColor;
Color foregroundColor = accentColor.luminance() > 0.5 ? Color(SRGBA<uint8_t> { 0, 0, 0, 204 }) : Color::white;
Color accentHoverColor = blendSourceOver(accentColor, foregroundColor.colorWithAlphaMultipliedBy(0.1));

Expand Down Expand Up @@ -383,7 +383,7 @@ void ThemeAdwaita::paintCheckbox(OptionSet<ControlStyle::State> states, Graphics
graphicsContext.endTransparencyLayer();
}

void ThemeAdwaita::paintRadio(OptionSet<ControlStyle::State> states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance, const Color& effectiveAccentColor)
void ThemeAdwaita::paintRadio(OptionSet<ControlStyle::State> states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance, const Color& usedAccentColor)
{
GraphicsContextStateSaver stateSaver(graphicsContext);
FloatRect fieldRect = zoomedRect;
Expand All @@ -407,7 +407,7 @@ void ThemeAdwaita::paintRadio(OptionSet<ControlStyle::State> states, GraphicsCon
toggleBorderHoverColor = toggleBorderHoveredColorLight;
}

Color accentColor = effectiveAccentColor.isValid() ? effectiveAccentColor : m_accentColor;
Color accentColor = usedAccentColor.isValid() ? usedAccentColor : m_accentColor;
Color foregroundColor = accentColor.luminance() > 0.5 ? Color(SRGBA<uint8_t> { 0, 0, 0, 204 }) : Color::white;
Color accentHoverColor = blendSourceOver(accentColor, foregroundColor.colorWithAlphaMultipliedBy(0.1));

Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/RenderTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ ControlStyle RenderTheme::extractControlStyleForRenderer(const RenderObject& ren
extractControlStyleStatesForRendererInternal(*renderer),
renderer->style().computedFontSize(),
renderer->style().effectiveZoom(),
renderer->style().effectiveAccentColor(),
renderer->style().usedAccentColor(),
renderer->style().visitedDependentColorWithColorFilter(CSSPropertyColor),
renderer->style().borderWidth()
};
Expand Down Expand Up @@ -802,7 +802,7 @@ bool RenderTheme::paint(const RenderBox& box, const PaintInfo& paintInfo, const
case StyleAppearance::Button:
case StyleAppearance::InnerSpinButton: {
auto states = extractControlStyleStatesForRenderer(box);
Theme::singleton().paint(appearance, states, paintInfo.context(), devicePixelSnappedRect, box.useDarkAppearance(), box.style().effectiveAccentColor());
Theme::singleton().paint(appearance, states, paintInfo.context(), devicePixelSnappedRect, box.useDarkAppearance(), box.style().usedAccentColor());
return false;
}
#else // !USE(THEME_ADWAITA)
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/adwaita/RenderThemeAdwaita.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static inline Color getSystemAccentColor()
static inline Color getAccentColor(const RenderObject& renderObject)
{
if (!renderObject.style().hasAutoAccentColor())
return renderObject.style().effectiveAccentColor();
return renderObject.style().usedAccentColor();

return getSystemAccentColor();
}
Expand Down Expand Up @@ -416,7 +416,7 @@ bool RenderThemeAdwaita::paintMenuList(const RenderObject& renderObject, const P
states.add(ControlStyle::State::Pressed);
if (isHovered(renderObject))
states.add(ControlStyle::State::Hovered);
Theme::singleton().paint(StyleAppearance::Button, states, graphicsContext, rect, renderObject.useDarkAppearance(), renderObject.style().effectiveAccentColor());
Theme::singleton().paint(StyleAppearance::Button, states, graphicsContext, rect, renderObject.useDarkAppearance(), renderObject.style().usedAccentColor());

auto zoomedArrowSize = menuListButtonArrowSize * renderObject.style().effectiveZoom();
FloatRect fieldRect = rect;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/ios/RenderThemeIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ static bool renderThemePaintSwitchTrack(OptionSet<ControlStyle::State>, const Re
return;

if (!style.hasAutoAccentColor()) {
auto tintColor = style.effectiveAccentColor();
auto tintColor = style.usedAccentColor();
if (isSubmitStyleButton(element))
style.setBackgroundColor(tintColor);
else
Expand Down Expand Up @@ -1232,7 +1232,7 @@ static bool renderThemePaintSwitchTrack(OptionSet<ControlStyle::State>, const Re
Color RenderThemeIOS::controlTintColor(const RenderStyle& style, OptionSet<StyleColorOptions> options) const
{
if (!style.hasAutoAccentColor())
return style.effectiveAccentColor();
return style.usedAccentColor();

return systemColor(CSSValueAppleSystemBlue, options);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/style/RenderStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,7 @@ Color RenderStyle::colorWithColorFilter(const StyleColor& color) const
return colorByApplyingColorFilter(colorResolvingCurrentColor(color));
}

Color RenderStyle::effectiveAccentColor() const
Color RenderStyle::usedAccentColor() const
{
if (hasAutoAccentColor())
return { };
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/style/RenderStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -2139,7 +2139,7 @@ class RenderStyle {
inline const StyleColor& floodColor() const;
inline const StyleColor& lightingColor() const;

Color effectiveAccentColor() const;
Color usedAccentColor() const;
inline const StyleColor& accentColor() const;
inline bool hasAutoAccentColor() const;

Expand Down

0 comments on commit 0268a59

Please sign in to comment.