LibWeb: Make transition order return -1 and 1 instead of 0 and 1

The old behavior was plain incorrect for a sorting function.
This commit is contained in:
Psychpsyo 2025-11-11 20:30:04 +01:00 committed by Jelle Raaijmakers
parent 2c4f2a3cb6
commit e0b5bd7894
Notes: github-actions[bot] 2025-11-11 20:58:52 +00:00
3 changed files with 8 additions and 5 deletions

View file

@ -78,7 +78,7 @@ int CSSTransition::class_specific_composite_order(GC::Ref<Animations::Animation>
// property name of each transition (i.e. without attempting case conversion and such that -moz-column-width
// sorts before column-width).
// FIXME: This should operate on Unicode strings, not StringViews.
return transition_property() > other->transition_property();
return transition_property().compare(other->transition_property());
}
CSSTransition::CSSTransition(JS::Realm& realm, DOM::AbstractElement abstract_element, PropertyID property_id, size_t transition_generation,

View file

@ -1 +1 @@
Order: left, right, top
Order: bottom, height, left, right, top, width

View file

@ -2,20 +2,23 @@
<html>
<style>
#foo {
transition-property: top, left, right;
transition-property: top, right, left, width, height, bottom;
transition-duration: 1s;
}
</style>
<div id="foo" style="top: 0; left: 0; right: 0"></div>
<div id="foo" style="top: 0; left: 0; right: 0; width: 0; height: 0; bottom: 0"></div>
<script src="../include.js"></script>
<script>
promiseTest(async () => {
await animationFrame();
await animationFrame();
foo.style.left = "10px";
foo.style.top = "10px";
foo.style.right = "10px";
foo.style.left = "10px";
foo.style.width = "10px";
foo.style.height = "10px";
foo.style.bottom = "10px";
println("Order: " + document.getAnimations().map(animation => animation.transitionProperty).join(", "));
});