Truly independent web browser
LibWeb: Don't clip negative coordinates on an overflow visible axis
Andreas Klingaab48b31de8c
diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rsindex a04aff0e635..27445f2f7e4 100644--- a/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/node_values.rs@@ -832,14 +832,17 @@ pub(crate) fn compute_clip_data(layout_arena: &impl PaintRead, slot: NodeSlotId,let padding_box = paintable_geometry::absolute_padding_box_rect(layout_arena, slot);let overflow_clip_edge = overflow_clip_edge_rect(style, layout_arena, slot);- let extent_limit = CssPixels::from_integer(crate::css::css_pixels::MAX_INTEGER_VALUE as i64);+ // NB: An axis that is not clipped must extend into negative coordinates too, since content can be laid out above or+ // to the left of the origin (e.g. inside a scroll container with flex-direction: column-reverse). Half the+ // range on each side keeps the rect's size from saturating.+ let extent_limit = CssPixels::from_integer(crate::css::css_pixels::MAX_INTEGER_VALUE as i64 / 2);let (left, right) = match overflow_x {- overflow::VISIBLE => (CssPixels::from_raw(0), extent_limit),+ overflow::VISIBLE => (-extent_limit, extent_limit),overflow::CLIP => (overflow_clip_edge.x, overflow_clip_edge.x + overflow_clip_edge.width),_ => (padding_box.x, padding_box.x + padding_box.width),};let (top, bottom) = match overflow_y {- overflow::VISIBLE => (CssPixels::from_raw(0), extent_limit),+ overflow::VISIBLE => (-extent_limit, extent_limit),overflow::CLIP => (overflow_clip_edge.y, overflow_clip_edge.y + overflow_clip_edge.height),_ => (padding_box.y, padding_box.y + padding_box.height),};diff --git a/Tests/LibWeb/Ref/expected/overflow-x-clip-in-column-reverse-scroll-container-ref.html b/Tests/LibWeb/Ref/expected/overflow-x-clip-in-column-reverse-scroll-container-ref.htmlnew file mode 100644index 00000000000..14c9b25d969--- /dev/null+++ b/Tests/LibWeb/Ref/expected/overflow-x-clip-in-column-reverse-scroll-container-ref.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<style>+body {+ margin: 0;+}+div {+ width: 300px;+}+</style>+<div style="height: 50px; background: orange"></div>+<div style="height: 100px; background: yellow"></div>+<div style="height: 50px; background: green"></div>diff --git a/Tests/LibWeb/Ref/input/overflow-x-clip-in-column-reverse-scroll-container.html b/Tests/LibWeb/Ref/input/overflow-x-clip-in-column-reverse-scroll-container.htmlnew file mode 100644index 00000000000..c8382f4c2a7--- /dev/null+++ b/Tests/LibWeb/Ref/input/overflow-x-clip-in-column-reverse-scroll-container.html@@ -0,0 +1,34 @@+<!DOCTYPE html>+<link rel="match" href="../expected/overflow-x-clip-in-column-reverse-scroll-container-ref.html" />+<style>+body {+ margin: 0;+}+#scroller {+ width: 300px;+ height: 200px;+ overflow-y: auto;+ scrollbar-width: none;+ display: flex;+ flex-direction: column-reverse;+}+#content {+ flex-shrink: 0;+ overflow-x: clip;+}+#content > div {+ height: 100px;+}+</style>+<div id="scroller">+ <div id="content">+ <div style="background: red"></div>+ <div style="background: orange"></div>+ <div style="background: yellow"></div>+ <div style="background: green"></div>+ <div style="background: blue"></div>+ </div>+</div>+<script>+ document.getElementById("scroller").scrollTop = -150;+</script>