Skip to content

Commit b2b889e

Browse files
Calme1709gmta
authored andcommitted
LibWeb: Ensure registered transitions are reflective of properties
Previously we would only update these if: a) We had a cascaded value for `transition-property` b) The source of that cascaded value had changed since we last registered transitions This meant that there were a lot of changes we didn't apply: - Changes exclusively to properties other than `transition-property` (e.g. `transition-duration`, `transition-behavior`, etc) - Removing the `transition-property` property - Updating the `transition-property` property in a way that didn't change it's source (e.g. setting it within inline-style) Unfortunately this does mean that we now register transitions for all properties on most elements since "all" is the initial value for "transition-property" which isn't great for performance, but that can be looked at in later commits.
1 parent 46abc0e commit b2b889e

13 files changed

+98
-45
lines changed

Libraries/LibWeb/Animations/Animatable.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace Web::Animations {
2222
struct Animatable::Transition {
2323
HashMap<CSS::PropertyID, size_t> transition_attribute_indices;
2424
Vector<TransitionAttributes> transition_attributes;
25-
GC::Ptr<CSS::CSSStyleDeclaration const> cached_transition_property_source;
2625
HashMap<CSS::PropertyID, GC::Ref<CSS::CSSTransition>> associated_transitions;
2726
};
2827

@@ -255,7 +254,6 @@ void Animatable::visit_edges(JS::Cell::Visitor& visitor)
255254

256255
for (auto const& transition : impl.transitions) {
257256
if (transition) {
258-
visitor.visit(transition->cached_transition_property_source);
259257
visitor.visit(transition->associated_transitions);
260258
}
261259
}
@@ -291,22 +289,6 @@ HashMap<FlyString, GC::Ref<Animation>>* Animatable::css_defined_animations(Optio
291289
return impl.css_defined_animations[index];
292290
}
293291

294-
GC::Ptr<CSS::CSSStyleDeclaration const> Animatable::cached_transition_property_source(Optional<CSS::PseudoElement> pseudo_element) const
295-
{
296-
auto* maybe_transition = ensure_transition(pseudo_element);
297-
if (!maybe_transition)
298-
return {};
299-
return maybe_transition->cached_transition_property_source;
300-
}
301-
302-
void Animatable::set_cached_transition_property_source(Optional<CSS::PseudoElement> pseudo_element, GC::Ptr<CSS::CSSStyleDeclaration const> value)
303-
{
304-
auto* maybe_transition = ensure_transition(pseudo_element);
305-
if (!maybe_transition)
306-
return;
307-
maybe_transition->cached_transition_property_source = value;
308-
}
309-
310292
Animatable::Impl& Animatable::ensure_impl() const
311293
{
312294
if (!m_impl)

Libraries/LibWeb/Animations/Animatable.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ class WEB_API Animatable {
5858
void add_css_animation(FlyString name, Optional<CSS::PseudoElement>, GC::Ref<Animation>);
5959
void remove_css_animation(FlyString name, Optional<CSS::PseudoElement>);
6060

61-
GC::Ptr<CSS::CSSStyleDeclaration const> cached_transition_property_source(Optional<CSS::PseudoElement>) const;
62-
void set_cached_transition_property_source(Optional<CSS::PseudoElement>, GC::Ptr<CSS::CSSStyleDeclaration const> value);
63-
6461
void add_transitioned_properties(Optional<CSS::PseudoElement>, Vector<Vector<CSS::PropertyID>> properties, CSS::StyleValueVector delays, CSS::StyleValueVector durations, CSS::StyleValueVector timing_functions, CSS::StyleValueVector transition_behaviors);
6562
Vector<CSS::PropertyID> property_ids_with_matching_transition_property_entry(Optional<CSS::PseudoElement>) const;
6663
Optional<TransitionAttributes const&> property_transition_attributes(Optional<CSS::PseudoElement>, CSS::PropertyID) const;

Libraries/LibWeb/CSS/ComputedProperties.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ ComputedProperties::~ComputedProperties() = default;
5555
void ComputedProperties::visit_edges(Visitor& visitor)
5656
{
5757
Base::visit_edges(visitor);
58-
visitor.visit(m_transition_property_source);
5958
}
6059

6160
bool ComputedProperties::is_property_important(PropertyID property_id) const

Libraries/LibWeb/CSS/ComputedProperties.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ class WEB_API ComputedProperties final : public JS::Cell {
7070
StyleValue const& property(PropertyID, WithAnimationsApplied = WithAnimationsApplied::Yes) const;
7171
void revert_property(PropertyID, ComputedProperties const& style_for_revert);
7272

73-
GC::Ptr<CSSStyleDeclaration const> transition_property_source() const { return m_transition_property_source; }
74-
void set_transition_property_source(GC::Ptr<CSSStyleDeclaration const> declaration) { m_transition_property_source = declaration; }
75-
7673
Size size_value(PropertyID) const;
7774
[[nodiscard]] Variant<LengthPercentage, NormalGap> gap_value(PropertyID) const;
7875
Length length(PropertyID) const;
@@ -291,8 +288,6 @@ class WEB_API ComputedProperties final : public JS::Cell {
291288
Vector<ShadowData> shadow(PropertyID, Layout::Node const&) const;
292289
Position position_value(PropertyID) const;
293290

294-
GC::Ptr<CSSStyleDeclaration const> m_transition_property_source;
295-
296291
Array<RefPtr<StyleValue const>, number_of_longhand_properties> m_property_values;
297292
Array<u8, ceil_div(number_of_longhand_properties, 8uz)> m_property_important {};
298293
Array<u8, ceil_div(number_of_longhand_properties, 8uz)> m_property_inherited {};

Libraries/LibWeb/CSS/StyleComputer.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,19 +1221,15 @@ static void apply_dimension_attribute(CascadedProperties& cascaded_properties, D
12211221

12221222
static void compute_transitioned_properties(ComputedProperties const& style, DOM::AbstractElement abstract_element)
12231223
{
1224-
auto const source_declaration = style.transition_property_source();
1225-
if (!source_declaration)
1226-
return;
1224+
// FIXME: For now we don't bother registering transitions on the first computation since they can't run (because
1225+
// there is nothing to transition from) but this will change once we implement @starting-style
12271226
if (!abstract_element.computed_properties())
12281227
return;
12291228
// FIXME: Add transition helpers on AbstractElement.
12301229
auto& element = abstract_element.element();
12311230
auto pseudo_element = abstract_element.pseudo_element();
1232-
if (source_declaration == element.cached_transition_property_source(pseudo_element))
1233-
return;
1234-
// Reparse this transition property
1231+
12351232
element.clear_registered_transitions(pseudo_element);
1236-
element.set_cached_transition_property_source(pseudo_element, *source_declaration);
12371233

12381234
auto coordinated_transition_list = style.assemble_coordinated_value_list(
12391235
PropertyID::TransitionProperty,
@@ -2541,10 +2537,6 @@ GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::AbstractEleme
25412537
computed_style->set_property(property_id, value.release_nonnull(), inherited, cascaded_properties.is_property_important(property_id) ? Important::Yes : Important::No);
25422538
if (animated_value.has_value())
25432539
computed_style->set_animated_property(property_id, animated_value.value(), inherited);
2544-
2545-
if (property_id == PropertyID::TransitionProperty) {
2546-
computed_style->set_transition_property_source(cascaded_properties.property_source(property_id));
2547-
}
25482540
}
25492541

25502542
// Compute the value of custom properties
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

Tests/LibWeb/Text/expected/wpt-import/css/css-pseudo/parsing/marker-supported-properties-in-animation.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Harness status: OK
22

33
Found 96 tests
44

5-
39 Pass
6-
57 Fail
5+
41 Pass
6+
55 Fail
77
Pass Animation of font in ::marker
88
Pass Animation of font-family in ::marker
99
Fail Animation of font-feature-settings in ::marker
@@ -59,7 +59,7 @@ Pass Transition of font-kerning in ::marker
5959
Fail Transition of font-size in ::marker
6060
Fail Transition of font-size-adjust in ::marker
6161
Fail Transition of font-stretch in ::marker
62-
Fail Transition of font-style in ::marker
62+
Pass Transition of font-style in ::marker
6363
Fail Transition of font-synthesis in ::marker
6464
Fail Transition of font-synthesis-small-caps in ::marker
6565
Fail Transition of font-synthesis-style in ::marker
@@ -91,7 +91,7 @@ Fail Transition of text-emphasis in ::marker
9191
Fail Transition of text-emphasis-color in ::marker
9292
Fail Transition of text-emphasis-position in ::marker
9393
Fail Transition of text-emphasis-style in ::marker
94-
Fail Transition of text-shadow in ::marker
94+
Pass Transition of text-shadow in ::marker
9595
Pass Transition of cursor in ::marker
9696
Fail Transition of display in ::marker
9797
Fail Transition of position in ::marker

Tests/LibWeb/Text/expected/wpt-import/css/css-transitions/CSSTransition-ready.tentative.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Harness status: OK
22

33
Found 2 tests
44

5-
1 Pass
6-
1 Fail
7-
Fail ready promise is rejected when a transition is canceled by updating transition-property
5+
2 Pass
6+
Pass ready promise is rejected when a transition is canceled by updating transition-property
87
Pass ready promise is rejected when a transition is canceled by changing the transition property to something not interpolable
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Harness status: OK
2+
3+
Found 1 tests
4+
5+
1 Pass
6+
Pass Removing transition and changing width applies change immediately

0 commit comments

Comments
 (0)