mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
LibWeb: Return overflow rect width from Element::scroll_width()
Spec says that this function has to return "width of the element scrolling area" which is width of "scrolling overflow rect" in our model.
This commit is contained in:
parent
89319cd0c9
commit
9f581d0bc9
3 changed files with 28 additions and 1 deletions
1
Tests/LibWeb/Text/expected/DOM/element-scroll-width.txt
Normal file
1
Tests/LibWeb/Text/expected/DOM/element-scroll-width.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Item 1Item 2Item 3Item 4Item 5Item 6Item 7Item 8Item 9Item 10Item 11Item 12 1200
|
26
Tests/LibWeb/Text/input/DOM/element-scroll-width.html
Normal file
26
Tests/LibWeb/Text/input/DOM/element-scroll-width.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
outline: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollable {
|
||||||
|
width: 300px;
|
||||||
|
overflow-x: auto;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="scrollable"><span>Item 1</span><span>Item 2</span><span>Item 3</span><span>Item 4</span><span>Item 5</span><span>Item 6</span><span>Item 7</span><span>Item 8</span><span>Item 9</span><span>Item 10</span><span>Item 11</span><span>Item 12</span></div>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const scrollable = document.querySelector(".scrollable");
|
||||||
|
println(scrollable.scrollWidth);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1394,7 +1394,7 @@ int Element::scroll_width() const
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// 7. Return the width of the element’s scrolling area.
|
// 7. Return the width of the element’s scrolling area.
|
||||||
return paintable_box()->border_box_width().to_int();
|
return paintable_box()->scrollable_overflow_rect()->width().to_int();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-scrollheight
|
// https://drafts.csswg.org/cssom-view/#dom-element-scrollheight
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue