Skip to content

Truly independent web browser

LibWeb: Keep range thumbs below positioned content

Andreas Kling9db5ab3f708c
diff --git a/Libraries/LibWeb/CSS/Default.css b/Libraries/LibWeb/CSS/Default.css
index c242eed188d..e55ffc44f79 100644
--- a/Libraries/LibWeb/CSS/Default.css
+++ b/Libraries/LibWeb/CSS/Default.css
@@ -160,7 +160,6 @@ input[type=range] {
&::slider-thumb {
display: block;
position: relative;
- z-index: 1;
margin-top: -6px;
width: 16px;
height: 16px;
diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index ae930fe921e..b6c7c3eb5ed 100644
--- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -1734,7 +1734,8 @@ void HTMLInputElement::update_slider_ticks()
if (!m_slider_ticks_element) {
m_slider_ticks_element = MUST(DOM::create_element(document(), HTML::TagNames::div, Namespace::HTML));
m_slider_ticks_element->set_attribute_value(HTML::AttributeNames::style, "position: absolute; inset-inline: 0; top: calc(100% + 2px); height: 4px; pointer-events: none;"_utf16);
- MUST(m_slider_runnable_track->append_child(*m_slider_ticks_element));
+ // NB: The ticks go before the thumb in tree order, so the thumb paints over them.
+ m_slider_runnable_track->insert_before(*m_slider_ticks_element, m_slider_thumb);
}
static constexpr double thumb_width = 16;
diff --git a/Tests/LibWeb/Layout/expected/input-range-datalist-ticks.txt b/Tests/LibWeb/Layout/expected/input-range-datalist-ticks.txt
index 75cbc804e97..46fd8540852 100644
--- a/Tests/LibWeb/Layout/expected/input-range-datalist-ticks.txt
+++ b/Tests/LibWeb/Layout/expected/input-range-datalist-ticks.txt
@@ -9,11 +9,11 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
Box <div> at [10,10] flex-container(row) [0+0+0 129 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
BlockContainer <div> at [10,16] positioned flex-item [0+0+0 129 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
BlockContainer <div> at [10,16] positioned [0+0+0 41.890625 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
- BlockContainer <div> at [48.6875,10] positioned [38.6875+0+0 16 0+0+74.3125] [-6+0+0 16 0+0+0] children: not-inline
BlockContainer <div> at [10,22] positioned [0+0+0 129 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
BlockContainer <div> at [17.5,22] positioned [0+0+0 1 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
BlockContainer <div> at [74,22] positioned [0+0+0 1 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
BlockContainer <div> at [130.5,22] positioned [0+0+0 1 0+0+0] [0+0+0 4 0+0+0] [BFC] children: not-inline
+ BlockContainer <div> at [48.6875,10] positioned [38.6875+0+0 16 0+0+74.3125] [-6+0+0 16 0+0+0] children: not-inline
TextNode <#text> (not painted)
BlockContainer <input> at [151,16] inline-block [2+0+0 129 0+0+2] [2+0+0 16 0+0+2] [BFC] children: not-inline
Box <div> at [151,16] flex-container(row) [0+0+0 129 0+0+0] [0+0+0 16 0+0+0] [FFC] children: not-inline
@@ -25,5 +25,5 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x42] (z-index: auto)
- SC for BlockContainer<DIV> [48.6875,10 16x16] (z-index: 1), has_transform
- SC for BlockContainer<DIV> [215.5,16 16x16] (z-index: 1), has_transform
+ SC for BlockContainer<DIV> [48.6875,10 16x16] (z-index: auto), has_transform
+ SC for BlockContainer<DIV> [215.5,16 16x16] (z-index: auto), has_transform
diff --git a/Tests/LibWeb/Layout/expected/input-range-stretch-in-grid.txt b/Tests/LibWeb/Layout/expected/input-range-stretch-in-grid.txt
index c66ee3eec35..f71fcc51dab 100644
--- a/Tests/LibWeb/Layout/expected/input-range-stretch-in-grid.txt
+++ b/Tests/LibWeb/Layout/expected/input-range-stretch-in-grid.txt
@@ -16,4 +16,4 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x36] (z-index: auto)
- SC for BlockContainer<DIV> [127.8125,10 16x16] (z-index: 1), has_transform
+ SC for BlockContainer<DIV> [127.8125,10 16x16] (z-index: auto), has_transform
diff --git a/Tests/LibWeb/Layout/expected/input-range.txt b/Tests/LibWeb/Layout/expected/input-range.txt
index 0951610d59c..9ca67bf7fd5 100644
--- a/Tests/LibWeb/Layout/expected/input-range.txt
+++ b/Tests/LibWeb/Layout/expected/input-range.txt
@@ -17,5 +17,5 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x38] (z-index: auto)
- SC for BlockContainer<DIV> [110,10 16x16] (z-index: 1), has_transform
- SC for BlockContainer<DIV> [234,10 16x16] (z-index: 1), has_transform
+ SC for BlockContainer<DIV> [110,10 16x16] (z-index: auto), has_transform
+ SC for BlockContainer<DIV> [234,10 16x16] (z-index: auto), has_transform
diff --git a/Tests/LibWeb/Ref/expected/input/range-thumb-under-positioned-overlay-ref.html b/Tests/LibWeb/Ref/expected/input/range-thumb-under-positioned-overlay-ref.html
new file mode 100644
index 00000000000..df4b7ce8ebf
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/input/range-thumb-under-positioned-overlay-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<style>
+ div {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 200px;
+ height: 40px;
+ background: green;
+ }
+</style>
+<div></div>
diff --git a/Tests/LibWeb/Ref/input/range-thumb-under-positioned-overlay.html b/Tests/LibWeb/Ref/input/range-thumb-under-positioned-overlay.html
new file mode 100644
index 00000000000..9ceafd2efac
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/range-thumb-under-positioned-overlay.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<link rel="match" href="../expected/input/range-thumb-under-positioned-overlay-ref.html" />
+<style>
+ div {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 200px;
+ height: 40px;
+ background: green;
+ z-index: 1;
+ }
+</style>
+<div></div>
+<input type="range">