LibWeb: Protect ad-hoc scroll against a potentially null paintable box

We perform such a check in other users of the paintable box in this file
as the box may be null before layout completes. This prevents UB seen in
some CI runs.
This commit is contained in:
Timothy Flynn 2023-10-24 11:32:48 -04:00 committed by Andreas Kling
parent 4db9996cc0
commit 4e0a926737
Notes: sideshowbarker 2024-07-17 02:05:41 +09:00

View file

@ -1924,7 +1924,8 @@ HashMap<DeprecatedFlyString, CSS::StyleProperty> const& Element::custom_properti
void Element::scroll(double x, double y)
{
// AD-HOC:
paintable_box()->scroll_by(x, y);
if (auto* paintable_box = this->paintable_box())
paintable_box->scroll_by(x, y);
}
// https://drafts.csswg.org/cssom-view/#dom-element-scroll