mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Add missing check if scrollable overflow defined for paintable
With 6a549f6270
we need to check if
optional scrollable overflow exists for paintable box, because it's not
computed for inline nodes.
Fixes crashing after navigating into direct messages screen on Discord.
This commit is contained in:
parent
27928cd28c
commit
629a3ac61e
Notes:
github-actions[bot]
2024-10-21 13:58:16 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/629a3ac61e5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1898
3 changed files with 20 additions and 2 deletions
|
@ -0,0 +1 @@
|
|||
Scroll Height: 0px, Scroll Width: 0px
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<span id="empty-span"></span>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const hiddenDiv = document.getElementById('empty-span');
|
||||
const scrollHeight = hiddenDiv.scrollHeight;
|
||||
const scrollWidth = hiddenDiv.scrollWidth;
|
||||
println(`Scroll Height: ${scrollHeight}px, Scroll Width: ${scrollWidth}px`);
|
||||
});
|
||||
</script>
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue