From 44bb2b7e3284960fbcc7e8eef628a72d096416c6 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 29 Dec 2024 12:43:57 +1300 Subject: [PATCH] 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. --- Libraries/LibWeb/HTML/HTMLElement.cpp | 4 +- .../widgets/button-layout/display-other.txt | 24 +++++++++ .../widgets/button-layout/display-other.html | 52 +++++++++++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/html/rendering/widgets/button-layout/display-other.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/html/rendering/widgets/button-layout/display-other.html diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index 944fc1c9ee2..476d0b16137 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -460,7 +460,7 @@ int HTMLElement::offset_top() const // NOTE: Ensure that layout is up-to-date before looking at metrics. const_cast(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(document()).update_layout(); - if (!layout_node()) + if (!paintable_box()) return 0; CSSPixels left_border_edge_of_element = paintable_box()->absolute_border_box_rect().x(); diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/rendering/widgets/button-layout/display-other.txt b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/widgets/button-layout/display-other.txt new file mode 100644 index 00000000000..b615d8746ff --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/rendering/widgets/button-layout/display-other.txt @@ -0,0 +1,24 @@ +Harness status: OK + +Found 18 tests + +3 Pass +15 Fail +Fail display: block +Pass display: run-in +Pass display: flow +Fail display: flow-root +Fail display: table +Pass display: list-item +Fail display: table-row-group +Fail display: table-header-group +Fail display: table-footer-group +Fail display: table-row +Fail display: table-cell +Fail display: table-column-group +Fail display: table-column +Fail display: table-caption +Fail display: ruby-base +Fail display: ruby-text +Fail display: ruby-base-container +Fail display: ruby-text-container \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html/rendering/widgets/button-layout/display-other.html b/Tests/LibWeb/Text/input/wpt-import/html/rendering/widgets/button-layout/display-other.html new file mode 100644 index 00000000000..92db86d89eb --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/rendering/widgets/button-layout/display-other.html @@ -0,0 +1,52 @@ + +button with other display values + + + +
+after +