LibWeb/HTML: Use paintable box for 'associated CSS layout box' check

This is consistent with other functions such as
HTMLElement::offset_width and fixes a crash for the included test.
Returning an offset of zero is not correct for this case, but this is
still an improvement to not crash.
This commit is contained in:
Shannon Booth 2024-12-29 12:43:57 +13:00 committed by Andreas Kling
commit 44bb2b7e32
Notes: github-actions[bot] 2025-01-02 10:29:35 +00:00
3 changed files with 78 additions and 2 deletions

View file

@ -460,7 +460,7 @@ int HTMLElement::offset_top() const
// NOTE: Ensure that layout is up-to-date before looking at metrics.
const_cast<DOM::Document&>(document()).update_layout();
if (!layout_node())
if (!paintable_box())
return 0;
CSSPixels top_border_edge_of_element = paintable_box()->absolute_border_box_rect().y();
@ -502,7 +502,7 @@ int HTMLElement::offset_left() const
// NOTE: Ensure that layout is up-to-date before looking at metrics.
const_cast<DOM::Document&>(document()).update_layout();
if (!layout_node())
if (!paintable_box())
return 0;
CSSPixels left_border_edge_of_element = paintable_box()->absolute_border_box_rect().x();