LibWeb: Parse scroll() for the animation-timeline CSS property

This commit is contained in:
Callum Law 2025-11-22 16:58:10 +13:00 committed by Sam Atkins
parent 5bbcd0a48f
commit 7d70714eac
Notes: github-actions[bot] 2025-11-28 13:25:32 +00:00
16 changed files with 181 additions and 34 deletions

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "ScrollFunctionStyleValue.h"
namespace Web::CSS {
String ScrollFunctionStyleValue::to_string(SerializationMode) const
{
StringBuilder builder;
builder.append("scroll("sv);
if (m_scroller != Scroller::Nearest)
builder.append(CSS::to_string(m_scroller));
if (m_axis != Axis::Block) {
if (m_scroller != Scroller::Nearest)
builder.append(' ');
builder.append(CSS::to_string(m_axis));
}
builder.append(')');
return builder.to_string_without_validation();
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
class ScrollFunctionStyleValue final : public StyleValueWithDefaultOperators<ScrollFunctionStyleValue> {
public:
static ValueComparingNonnullRefPtr<ScrollFunctionStyleValue const> create(Scroller scroller, Axis axis)
{
return adopt_ref(*new ScrollFunctionStyleValue(scroller, axis));
}
virtual ~ScrollFunctionStyleValue() override = default;
virtual String to_string(SerializationMode) const override;
bool properties_equal(ScrollFunctionStyleValue const& other) const { return m_scroller == other.m_scroller && m_axis == other.m_axis; }
Scroller scroller() const { return m_scroller; }
Axis axis() const { return m_axis; }
private:
explicit ScrollFunctionStyleValue(Scroller scroller, Axis axis)
: StyleValueWithDefaultOperators(Type::ScrollFunction)
, m_scroller(scroller)
, m_axis(axis)
{
}
Scroller m_scroller;
Axis m_axis;
};
}

View file

@ -59,6 +59,7 @@
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
#include <LibWeb/CSS/StyleValues/RepeatStyleStyleValue.h>
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
#include <LibWeb/CSS/StyleValues/ScrollFunctionStyleValue.h>
#include <LibWeb/CSS/StyleValues/ScrollbarColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/ScrollbarGutterStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>

View file

@ -79,6 +79,7 @@ namespace Web::CSS {
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Resolution, resolution, ResolutionStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(ScrollbarColor, scrollbar_color, ScrollbarColorStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(ScrollbarGutter, scrollbar_gutter, ScrollbarGutterStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(ScrollFunction, scroll_function, ScrollFunctionStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Shadow, shadow, ShadowStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Shorthand, shorthand, ShorthandStyleValue) \
__ENUMERATE_CSS_STYLE_VALUE_TYPE(String, string, StringStyleValue) \