Skip to content

Truly independent web browser

LibWeb: Rebuild the stacking context a clock lane's style moves

Aliaksandr Kalenik2aaaae0c57ac
diff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
index aced2ffb58b..8ec530e8397 100644
--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs
@@ -2552,17 +2552,21 @@ impl LayoutNodeArena {
}
/// Notes the visual contexts a style move with `damage`, an `FfiStyleInvalidationField` word, moves for `slot`'s
- /// box, which the next recording builds again.
+ /// box, which the next recording builds again: those up to the level the word carries, and the nodes of the box's
+ /// stacking context where the move rebuilds it, as a z-index change does alone.
pub(crate) fn note_style_visual_context_moves(&self, slot: NodeSlotId, damage: u32) {
use crate::css::style::bridge::FfiStyleInvalidationField;
use crate::painting::visual_context::dirty::VisualContextBoxDirtyKind;
let visual_contexts = (damage >> FfiStyleInvalidationField::VisualContextShift as u32)
& FfiStyleInvalidationField::LevelMask as u32;
- if visual_contexts == 0 || !crate::painting::paint_read::GeometryRead::paintable_row_is_populated(self, slot) {
+ let rebuilds_stacking_context = damage & FfiStyleInvalidationField::RebuildStackingContext as u32 != 0;
+ if (visual_contexts == 0 && !rebuilds_stacking_context)
+ || !crate::painting::paint_read::GeometryRead::paintable_row_is_populated(self, slot)
+ {
return;
}
- let kind = match visual_contexts {
- 1 => VisualContextBoxDirtyKind::StyleValueChange,
+ let kind = match (visual_contexts, rebuilds_stacking_context) {
+ (1, false) => VisualContextBoxDirtyKind::StyleValueChange,
_ => VisualContextBoxDirtyKind::StyleStructuralChange,
};
self.note_visual_context_box_dirty(slot, kind);
diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-raises-a-box-over-another.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-raises-a-box-over-another.txt
new file mode 100644
index 00000000000..302bd3a635f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-raises-a-box-over-another.txt
@@ -0,0 +1,2 @@
+last frame presented by: clock
+a, b hovered: true false
diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-raises-a-box-over-another.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-raises-a-box-over-another.html
new file mode 100644
index 00000000000..9519ab26195
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-raises-a-box-over-another.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<script src="frame-in-flight.js"></script>
+<style>
+ body { margin: 0; }
+ #a, #b { position: absolute; top: 0; width: 100px; height: 100px; }
+ #a { left: 0; z-index: 1; background: rgb(0, 0, 255); }
+ #b { left: 50px; z-index: 2; background: rgb(255, 0, 0); }
+ #a:hover { z-index: 10; background: rgb(0, 128, 0); }
+</style>
+<div id="a"></div>
+<div id="b"></div>
+<script>
+ // A lane's hover raises the box it hovers over the one beside it, which the frame it presents paints, and hit tests,
+ // in the new order.
+ asyncTest(async done => {
+ const presentedBy = await whileLaneHovers(() => {
+ internals.injectHoverPointer(25, 50);
+ internals.injectHoverPointer(75, 50);
+ return internals.lastFramePresentedBy(document);
+ });
+ println(`last frame presented by: ${presentedBy}`);
+ await nextFrame();
+ println(`a, b hovered: ${a.matches(":hover")} ${b.matches(":hover")}`);
+ done();
+ });
+</script>