Fix scrolling on root element

eca0acf459 uncovered a bug in the way that
the scrolling area of `window` was calculated and broke scrolling on the
root element. This change does two things in order to fix that:

1. Does a partial revert of eca0acf459 in
   order to get scrolling from script working again on the window
   object.
2. Has the compositor always generate a frame for scrolls starting from
   script and waits for them. This is speculative fix for flakiness in
   root scrolling tests on CI.
This commit is contained in:
Martin Robinson 2023-05-03 17:22:39 +02:00
parent 121b2c9871
commit edeb24b30f
15 changed files with 55 additions and 20 deletions

View file

@ -1708,13 +1708,18 @@ impl Window {
let body = self.Document().GetBody();
let (x, y) = match body {
Some(e) => {
let scroll_area = e.upcast::<Node>().scroll_area();
// This doesn't properly take into account the overflow set on <body>
// and the root element, which might affect how much the root can
// scroll. That requires properly handling propagating those values
// according to the rules defined in in the specification at:
// https://w3c.github.io/csswg-drafts/css-overflow/#overflow-propagation
let scroll_area = e.upcast::<Node>().bounding_content_box_or_zero();
(
xfinite
.min(scroll_area.width() as f64 - viewport.width as f64)
.min(scroll_area.width().to_f64_px() - viewport.width as f64)
.max(0.0f64),
yfinite
.min(scroll_area.height() as f64 - viewport.height as f64)
.min(scroll_area.height().to_f64_px() - viewport.height as f64)
.max(0.0f64),
)
},