mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Parse transition property as a coordinating list shorthand
We don't need all this specific logic for parsing the `transition` property - we also now maintain `none` as such until use time which gains us a couple extra tests
This commit is contained in:
parent
94c788f2e0
commit
8417d74328
Notes:
github-actions[bot]
2025-10-23 09:11:05 +00:00
Author: https://github.com/Calme1709
Commit: 8417d74328
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6508
Reviewed-by: https://github.com/AtkinsSJ ✅
10 changed files with 27 additions and 247 deletions
|
|
@ -70,7 +70,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/TextUnderlinePositionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransitionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/TreeCountingFunctionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/URLStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/UnicodeRangeStyleValue.h>
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ namespace Web::CSS {
|
|||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(TextUnderlinePosition, text_underline_position, TextUnderlinePositionStyleValue) \
|
||||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Time, time, TimeStyleValue) \
|
||||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Transformation, transformation, TransformationStyleValue) \
|
||||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Transition, transition, TransitionStyleValue) \
|
||||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(TreeCountingFunction, tree_counting_function, TreeCountingFunctionStyleValue) \
|
||||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(UnicodeRange, unicode_range, UnicodeRangeStyleValue) \
|
||||
__ENUMERATE_CSS_STYLE_VALUE_TYPE(Unresolved, unresolved, UnresolvedStyleValue) \
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransitionStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
String TransitionStyleValue::to_string(SerializationMode mode) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
bool first = true;
|
||||
for (auto const& transition : m_transitions) {
|
||||
if (!first)
|
||||
builder.append(", "sv);
|
||||
first = false;
|
||||
builder.appendff("{} {} {} {}", transition.property_name->to_string(mode), transition.duration, transition.easing->to_string(mode), transition.delay);
|
||||
if (transition.transition_behavior != TransitionBehavior::Normal)
|
||||
builder.appendff(" {}", CSS::to_string(transition.transition_behavior));
|
||||
}
|
||||
|
||||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
bool TransitionStyleValue::properties_equal(TransitionStyleValue const& other) const
|
||||
{
|
||||
if (m_transitions.size() != other.m_transitions.size())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < m_transitions.size(); i++) {
|
||||
if (m_transitions[i] != other.m_transitions[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/CalculatedOr.h>
|
||||
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
||||
#include <LibWeb/CSS/Time.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
class TransitionStyleValue final : public StyleValueWithDefaultOperators<TransitionStyleValue> {
|
||||
public:
|
||||
struct Transition {
|
||||
ValueComparingRefPtr<StyleValue const> property_name;
|
||||
TimeOrCalculated duration { CSS::Time::make_seconds(0.0) };
|
||||
TimeOrCalculated delay { CSS::Time::make_seconds(0.0) };
|
||||
ValueComparingRefPtr<StyleValue const> easing;
|
||||
TransitionBehavior transition_behavior { TransitionBehavior::Normal };
|
||||
|
||||
bool operator==(Transition const&) const = default;
|
||||
};
|
||||
|
||||
static ValueComparingNonnullRefPtr<TransitionStyleValue const> create(Vector<Transition> transitions)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) TransitionStyleValue(move(transitions)));
|
||||
}
|
||||
|
||||
virtual ~TransitionStyleValue() override = default;
|
||||
|
||||
auto const& transitions() const { return m_transitions; }
|
||||
|
||||
virtual String to_string(SerializationMode) const override;
|
||||
|
||||
bool properties_equal(TransitionStyleValue const& other) const;
|
||||
|
||||
private:
|
||||
explicit TransitionStyleValue(Vector<Transition> transitions)
|
||||
: StyleValueWithDefaultOperators(Type::Transition)
|
||||
, m_transitions(move(transitions))
|
||||
{
|
||||
}
|
||||
|
||||
Vector<Transition> m_transitions;
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue