diff --git a/Tests/LibWeb/Text/expected/query-scroll-size-of-inline-node.txt b/Tests/LibWeb/Text/expected/query-scroll-size-of-inline-node.txt new file mode 100644 index 00000000000..e6db6ac12bc --- /dev/null +++ b/Tests/LibWeb/Text/expected/query-scroll-size-of-inline-node.txt @@ -0,0 +1 @@ +Scroll Height: 0px, Scroll Width: 0px diff --git a/Tests/LibWeb/Text/input/query-scroll-size-of-inline-node.html b/Tests/LibWeb/Text/input/query-scroll-size-of-inline-node.html new file mode 100644 index 00000000000..bdba7060b2a --- /dev/null +++ b/Tests/LibWeb/Text/input/query-scroll-size-of-inline-node.html @@ -0,0 +1,11 @@ + + + + diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 4b8e88abf3a..834442bdc32 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1455,7 +1455,10 @@ int Element::scroll_width() const return 0; // 7. Return the width of the element’s scrolling area. - return paintable_box()->scrollable_overflow_rect()->width().to_int(); + if (auto scrollable_overflow_rect = paintable_box()->scrollable_overflow_rect(); scrollable_overflow_rect.has_value()) { + return scrollable_overflow_rect->width().to_int(); + } + return 0; } // https://drafts.csswg.org/cssom-view/#dom-element-scrollheight @@ -1491,7 +1494,10 @@ int Element::scroll_height() const return 0; // 7. Return the height of the element’s scrolling area. - return paintable_box()->scrollable_overflow_rect()->height().to_int(); + if (auto scrollable_overflow_rect = paintable_box()->scrollable_overflow_rect(); scrollable_overflow_rect.has_value()) { + return scrollable_overflow_rect->height().to_int(); + } + return 0; } // https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled