mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
LibWeb: Use border box rect in getBoundingClientRect()
With this change we scroll to correct position on Acid2 :)
This commit is contained in:
parent
ef71f46da6
commit
6bed27cca9
3 changed files with 20 additions and 1 deletions
1
Tests/LibWeb/Text/expected/get-bounding-client-rect.txt
Normal file
1
Tests/LibWeb/Text/expected/get-bounding-client-rect.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"x":8,"y":500,"width":784,"height":150,"top":500,"right":792,"bottom":650,"left":8}
|
18
Tests/LibWeb/Text/input/get-bounding-client-rect.html
Normal file
18
Tests/LibWeb/Text/input/get-bounding-client-rect.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<style type="text/css">
|
||||||
|
#box {
|
||||||
|
margin-top: 500px;
|
||||||
|
padding-top: 100px;
|
||||||
|
background-color: navy;
|
||||||
|
width: 100%;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div id="box"></div>
|
||||||
|
<script src="include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const rect = document.getElementById("box").getBoundingClientRect();
|
||||||
|
println(JSON.stringify(rect));
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -868,7 +868,7 @@ JS::NonnullGCPtr<Geometry::DOMRect> Element::get_bounding_client_rect() const
|
||||||
VERIFY(document().navigable());
|
VERIFY(document().navigable());
|
||||||
auto viewport_offset = document().navigable()->viewport_scroll_offset();
|
auto viewport_offset = document().navigable()->viewport_scroll_offset();
|
||||||
|
|
||||||
return Geometry::DOMRect::create(realm(), paintable_box->absolute_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type<float>());
|
return Geometry::DOMRect::create(realm(), paintable_box->absolute_border_box_rect().translated(-viewport_offset.x(), -viewport_offset.y()).to_type<float>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue