mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Add null check for get_client_rects() on non paintable elements
This commit is contained in:
parent
c186ab96ac
commit
1a1e5aaf54
Notes:
sideshowbarker
2024-07-17 06:40:35 +09:00
Author: https://github.com/Cnidarias Commit: https://github.com/SerenityOS/serenity/commit/1a1e5aaf54 Pull-request: https://github.com/SerenityOS/serenity/pull/23990 Issue: https://github.com/SerenityOS/serenity/issues/23829
3 changed files with 13 additions and 7 deletions
|
@ -1 +1,3 @@
|
|||
|
||||
{"x":0,"y":0,"width":0,"height":0,"top":0,"right":0,"bottom":0,"left":0}
|
||||
{"x":0,"y":0,"width":0,"height":0,"top":0,"right":0,"bottom":0,"left":0}
|
||||
|
|
|
@ -3,10 +3,14 @@
|
|||
#box { display: none; }
|
||||
</style>
|
||||
<div id="box"></div>
|
||||
<br id="br"/>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const rect = document.getElementById("box").getBoundingClientRect();
|
||||
println(JSON.stringify(rect));
|
||||
|
||||
const br_rect = document.getElementById("br").getBoundingClientRect();
|
||||
println(JSON.stringify(br_rect));
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -884,16 +884,16 @@ JS::NonnullGCPtr<Geometry::DOMRectList> Element::get_client_rects() const
|
|||
const_cast<Document&>(document()).update_paint_and_hit_testing_properties_if_needed();
|
||||
|
||||
Gfx::AffineTransform transform;
|
||||
if (auto const* paintable_box = this->paintable_box())
|
||||
transform = Gfx::extract_2d_affine_transform(paintable_box->transform());
|
||||
CSSPixelPoint scroll_offset;
|
||||
for (auto const* containing_block = paintable()->containing_block(); containing_block; containing_block = containing_block->containing_block()) {
|
||||
transform = Gfx::extract_2d_affine_transform(containing_block->transform()).multiply(transform);
|
||||
scroll_offset.translate_by(containing_block->scroll_offset());
|
||||
}
|
||||
|
||||
auto const* paintable = this->paintable();
|
||||
|
||||
if (auto const* paintable_box = this->paintable_box()) {
|
||||
transform = Gfx::extract_2d_affine_transform(paintable_box->transform());
|
||||
for (auto const* containing_block = paintable->containing_block(); containing_block; containing_block = containing_block->containing_block()) {
|
||||
transform = Gfx::extract_2d_affine_transform(containing_block->transform()).multiply(transform);
|
||||
scroll_offset.translate_by(containing_block->scroll_offset());
|
||||
}
|
||||
|
||||
auto absolute_rect = paintable_box->absolute_border_box_rect();
|
||||
auto transformed_rect = transform.map(absolute_rect.translated(-paintable_box->transform_origin()).to_type<float>())
|
||||
.to_type<CSSPixels>()
|
||||
|
|
Loading…
Reference in a new issue