LibWeb/CSS: Implement the scrollbar-color property

This allows the user to set the scrollbar thumb and track colors.
This commit is contained in:
Tim Ledbetter 2025-05-26 22:36:12 +01:00 committed by Alexander Kalenik
commit e2d0d8e2b9
Notes: github-actions[bot] 2025-06-01 22:18:57 +00:00
24 changed files with 212 additions and 10 deletions

View file

@ -31,6 +31,7 @@
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
#include <LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
@ -1852,6 +1853,22 @@ Vector<CounterData> ComputedProperties::counter_data(PropertyID property_id) con
return {};
}
ScrollbarColorData ComputedProperties::scrollbar_color(Layout::NodeWithStyle const& layout_node) const
{
auto const& value = property(PropertyID::ScrollbarColor);
if (value.is_keyword() && value.as_keyword().keyword() == Keyword::Auto)
return InitialValues::scrollbar_color();
if (value.is_scrollbar_color()) {
auto& scrollbar_color_value = value.as_scrollbar_color();
auto thumb_color = scrollbar_color_value.thumb_color()->to_color(layout_node);
auto track_color = scrollbar_color_value.track_color()->to_color(layout_node);
return { thumb_color, track_color };
}
return {};
}
ScrollbarWidth ComputedProperties::scrollbar_width() const
{
auto const& value = property(PropertyID::ScrollbarWidth);