mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-25 11:48:06 +00:00
LibWeb/CSS: Implement the scrollbar-color
property
This allows the user to set the scrollbar thumb and track colors.
This commit is contained in:
parent
285bc005cb
commit
e2d0d8e2b9
Notes:
github-actions[bot]
2025-06-01 22:18:57 +00:00
Author: https://github.com/tcl3
Commit: e2d0d8e2b9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4893
24 changed files with 212 additions and 10 deletions
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ScrollbarColorStyleValue.h"
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
ValueComparingNonnullRefPtr<ScrollbarColorStyleValue const> ScrollbarColorStyleValue::create(NonnullRefPtr<CSSStyleValue const> thumb_color, NonnullRefPtr<CSSStyleValue const> track_color)
|
||||
{
|
||||
return adopt_ref(*new ScrollbarColorStyleValue(move(thumb_color), move(track_color)));
|
||||
}
|
||||
|
||||
String ScrollbarColorStyleValue::to_string(SerializationMode mode) const
|
||||
{
|
||||
return MUST(String::formatted("{} {}", m_thumb_color->to_string(mode), m_track_color->to_string(mode)));
|
||||
}
|
||||
|
||||
}
|
38
Libraries/LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h
Normal file
38
Libraries/LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibWeb/CSS/CSSStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSColorValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class ScrollbarColorStyleValue final : public StyleValueWithDefaultOperators<ScrollbarColorStyleValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<ScrollbarColorStyleValue const> create(NonnullRefPtr<CSSStyleValue const> thumb_color, NonnullRefPtr<CSSStyleValue const> track_color);
|
||||
virtual ~ScrollbarColorStyleValue() override = default;
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
bool properties_equal(ScrollbarColorStyleValue const& other) const { return m_thumb_color == other.m_thumb_color && m_track_color == other.m_track_color; }
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> thumb_color() const { return m_thumb_color; }
|
||||
NonnullRefPtr<CSSStyleValue const> track_color() const { return m_track_color; }
|
||||
|
||||
private:
|
||||
explicit ScrollbarColorStyleValue(NonnullRefPtr<CSSStyleValue const> thumb_color, NonnullRefPtr<CSSStyleValue const> track_color)
|
||||
: StyleValueWithDefaultOperators(Type::ScrollbarColor)
|
||||
, m_thumb_color(move(thumb_color))
|
||||
, m_track_color(move(track_color))
|
||||
{
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSSStyleValue const> m_thumb_color;
|
||||
NonnullRefPtr<CSSStyleValue const> m_track_color;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue