Truly independent web browser
LibWeb: Show a starting transition’s value in anonymous boxes
sideshowbarkerf3045204394a
diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cppindex 6eba1b510eb..90a37d30a1c 100644--- a/Libraries/LibWeb/CSS/StyleComputer.cpp+++ b/Libraries/LibWeb/CSS/StyleComputer.cpp@@ -1125,6 +1125,16 @@ RequiredInvalidationAfterStyleChange StyleComputer::run_transition_step_for_instStyleEngineFFI::FfiAnimationOverlayPublication publication;publish_sampled_animation_overlays(read, { &overlay, 1 }, { &publication, 1 });element.refresh_computed_style(read, pseudo_element, InstalledStyle::adopt(publication.record));+ // NB: refresh_computed_style() shows the new record on the element's own layout node. A transition that starts+ // with an inherited property moves what that node's anonymous descendants inherit, too, and applying the+ // style reaches them; otherwise they show the after-change value until the next animation frame.+ auto* layout_node = pseudo_element.has_value() ? element.pseudo_element_unsafe_layout_node(read, *pseudo_element) : element.unsafe_layout_node(read);+ if (layout_node) {+ if (publication.invalidation.requires_layout_node_style_application)+ layout_node->apply_style(element.style_record_identity(pseudo_element));+ else if (publication.invalidation.requires_style_resource_update)+ layout_node->attach_style_resources();+ }if (auto* svg_element = as_if<SVG::SVGElement>(element); svg_element && !pseudo_element.has_value())svg_element->note_svg_paint_resource_description_may_have_changed();return decode_style_invalidation(publication.invalidation.invalidation);diff --git a/Tests/LibWeb/Text/expected/css/transition-of-inherited-property-reaches-anonymous-box-at-start.txt b/Tests/LibWeb/Text/expected/css/transition-of-inherited-property-reaches-anonymous-box-at-start.txtnew file mode 100644index 00000000000..c9ab6ff4e5f--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/transition-of-inherited-property-reaches-anonymous-box-at-start.txt@@ -0,0 +1,2 @@+flex: computed 0px, text moved by 0px+block: computed 0px, text moved by 0pxdiff --git a/Tests/LibWeb/Text/input/css/transition-of-inherited-property-reaches-anonymous-box-at-start.html b/Tests/LibWeb/Text/input/css/transition-of-inherited-property-reaches-anonymous-box-at-start.htmlnew file mode 100644index 00000000000..14723a1ba03--- /dev/null+++ b/Tests/LibWeb/Text/input/css/transition-of-inherited-property-reaches-anonymous-box-at-start.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<style>+ .container { transition: text-indent 300ms linear; font: 20px monospace; }+ .container.indented { text-indent: 100px; }+</style>+<!-- The text of a flex container lays out in an anonymous block, which inherits text-indent from it. -->+<div class="container" id="flex" style="display: flex">Text</div>+<div class="container" id="block" style="display: block">Text</div>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ await new Promise(requestAnimationFrame);+ const textLeft = element => {+ const range = document.createRange();+ range.selectNodeContents(element);+ return range.getBoundingClientRect().left;+ };+ for (const id of ["flex", "block"]) {+ const element = document.getElementById(id);+ const before = textLeft(element);+ element.classList.add("indented");+ // The transition starts at the before-change value, so the text hasn't moved yet.+ println(`${id}: computed ${getComputedStyle(element).textIndent}, text moved by ${textLeft(element) - before}px`);+ }+ });+</script>