mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Make Animation's owning element an AbstractElement
From the spec: > The owning element of a transition refers to the element or pseudo-element to which the transition-property property was applied that generated the animation. https://drafts.csswg.org/css-transitions-2/#owning-element Previously we only stored the element.
This commit is contained in:
parent
b61c857c64
commit
d717dd64b3
Notes:
github-actions[bot]
2025-12-03 12:31:08 +00:00
Author: https://github.com/AtkinsSJ
Commit: d717dd64b3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6998
6 changed files with 22 additions and 20 deletions
|
|
@ -26,11 +26,11 @@ int CSSAnimation::class_specific_composite_order(GC::Ref<Animations::Animation>
|
|||
|
||||
// The existence of an owning element determines the animation class, so both animations should have their owning
|
||||
// element in the same state
|
||||
VERIFY(!owning_element() == !other->owning_element());
|
||||
VERIFY(owning_element().has_value() == other->owning_element().has_value());
|
||||
|
||||
// Within the set of CSS Animations with an owning element, two animations A and B are sorted in composite order
|
||||
// (first to last) as follows:
|
||||
if (owning_element()) {
|
||||
if (owning_element().has_value()) {
|
||||
// 1. If the owning element of A and B differs, sort A and B by tree order of their corresponding owning elements.
|
||||
// With regard to pseudo-elements, the sort order is as follows:
|
||||
// - element
|
||||
|
|
@ -40,7 +40,7 @@ int CSSAnimation::class_specific_composite_order(GC::Ref<Animations::Animation>
|
|||
// codepoints that make up each selector
|
||||
// - ::after
|
||||
// - element children
|
||||
if (owning_element().ptr() != other->owning_element().ptr()) {
|
||||
if (owning_element() != other->owning_element()) {
|
||||
// FIXME: Sort by tree order
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ int CSSAnimation::class_specific_composite_order(GC::Ref<Animations::Animation>
|
|||
|
||||
Animations::AnimationClass CSSAnimation::animation_class() const
|
||||
{
|
||||
if (owning_element())
|
||||
if (owning_element().has_value())
|
||||
return Animations::AnimationClass::CSSAnimationWithOwningElement;
|
||||
return Animations::AnimationClass::CSSAnimationWithoutOwningElement;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ int CSSTransition::class_specific_composite_order(GC::Ref<Animations::Animation>
|
|||
// follows:
|
||||
|
||||
// 1. If neither A nor B has an owning element, sort based on their relative position in the global animation list.
|
||||
if (!owning_element() && !other->owning_element())
|
||||
if (!owning_element().has_value() && !other->owning_element().has_value())
|
||||
return global_animation_list_order() - other->global_animation_list_order();
|
||||
|
||||
// 2. Otherwise, if only one of A or B has an owning element, let the animation with an owning element sort first.
|
||||
if (owning_element() && !other->owning_element())
|
||||
if (owning_element().has_value() && !other->owning_element().has_value())
|
||||
return -1;
|
||||
if (!owning_element() && other->owning_element())
|
||||
if (!owning_element().has_value() && other->owning_element().has_value())
|
||||
return 1;
|
||||
|
||||
// 3. Otherwise, if the owning element of A and B differs, sort A and B by tree order of their corresponding owning
|
||||
|
|
@ -64,7 +64,7 @@ int CSSTransition::class_specific_composite_order(GC::Ref<Animations::Animation>
|
|||
// codepoints that make up each selector
|
||||
// - ::after
|
||||
// - element children
|
||||
if (owning_element().ptr() != other->owning_element().ptr()) {
|
||||
if (owning_element() != other->owning_element()) {
|
||||
// FIXME: Actually sort by tree order
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::AbstractElement abstract_ele
|
|||
|
||||
m_keyframe_effect->set_key_frame_set(key_frame_set);
|
||||
set_timeline(abstract_element.document().timeline());
|
||||
set_owning_element(abstract_element.element());
|
||||
set_owning_element(abstract_element);
|
||||
set_effect(m_keyframe_effect);
|
||||
abstract_element.element().set_transition(abstract_element.pseudo_element(), m_transition_property, *this);
|
||||
|
||||
|
|
|
|||
|
|
@ -1176,7 +1176,7 @@ void StyleComputer::process_animation_definitions(ComputedProperties const& comp
|
|||
auto animation = CSSAnimation::create(document.realm());
|
||||
animation->set_animation_name(animation_properties.name);
|
||||
animation->set_timeline(document.timeline());
|
||||
animation->set_owning_element(abstract_element.element());
|
||||
animation->set_owning_element(abstract_element);
|
||||
|
||||
auto effect = Animations::KeyframeEffect::create(document.realm());
|
||||
animation->set_effect(effect);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue