New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix several bugs related to scrolling #17385
Conversation
@bors-servo: try |
Fix several bugs related to scrolling * scrollLeft/scrollTop returned values of parent or even document root Only the scroll of the node itself is returned. Otherwise 0.0. * Scrolling via script had set viewport. This resulted in other nodes appearing scrolled. Now scroll_offsets are updated with correct node id. These bugs caused other odd behavior like both body and document.documentElement being scrolled or the view for scrolled elements jumping. Also try scrolling this [example page](https://pyfisch.org/stuff/scrolltest.html) in servo with and without this change. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #17342 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes (partially) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17385) <!-- Reviewable:end -->
💔 Test failed - android |
The tests fail because I modified one web-platform-test to include more checks. Should web platform tests not be changed or do I need to update the manifest? |
r? @mrobinson |
./mach update-manifest |
Thanks. Ran |
tests/wpt/metadata/MANIFEST.json
Outdated
@@ -169897,6 +169897,66 @@ | |||
{} | |||
] | |||
], | |||
"_certs/064162.pem": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these lines really be here? To me they look more like some left-over temporary files.
components/script/dom/window.rs
Outdated
ReflowReason::Query) { | ||
return; | ||
} | ||
|
||
self.scroll_offsets.borrow_mut().insert(node.to_untrusted_node_address(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently these scroll offsets come from WebRender. What is the issue here with waiting until WebRender updates the scroll offset map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Webrender does not update the scroll offset map if the change is caused by a Msg::UpdateScrollStateFromScript
(per documentation). So the offset map needs to updated in script. The reason I think is that if a script does elem.scrollTop = 42
the next line may be console.log(elem.scrollTop)
. If there is some message-passing involved the log statement will print wrong information. (Another case where this is important is when a website sets scrollTop and scrollLeft at the same time as done in the tests).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm. The next time that WebRender sends new scroll offsets, the offsets really should reflect this change (otherwise that is a bug, I think). You are right though, that if we query the offsets immediately they won't reflect the new status. That's probably worth writing in a comment there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is a bug since it is described. If you scroll with mouse or keyboard the scroll state is updated by webrender. It also takes the changes from the script into account that happened before.
(Setting the offsets from webrender again in this case could be harmful. It may happen that webrender overwrites newer values.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in scroll position need to be forwarded to WebRender to proper render the scrolled content. WebRender should then return the new offsets, but they won't be available immediately. I'm not sure the documentation touches on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is how it is done for normal scrolling with mouse and keyboard. I think the note on the enum member is sufficient but maybe you want to document it other places too or give more details.
tests/wpt/metadata/MANIFEST.json
Outdated
@@ -397231,6 +397291,54 @@ | |||
"b960bef807da94c0146ed2f537eaa1e05ec9a0ab", | |||
"testharness" | |||
], | |||
"_certs/064162.pem": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The update-manifest script isn't smart enough to ignore files that it shouldn't include, so you'll need to remove all of these extraneous lines manually. Sorry, I find this behavior really annoying too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. I will do so.
Added a comment and removed lines from manifest. @mrobinson can you please r+? @bors-servo try |
⌛ Trying commit 5a87833 with merge dd1230f33443231864af970e48a7c6bf787d3c6e... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good.
@bors-servo r+ |
📌 Commit 5a87833 has been approved by |
⌛ Testing commit 5a87833 with merge 2ff7ce783a9c144b80be492f3d0ad5468fc26edc... |
💔 Test failed - mac-rel-wpt2 |
|
* scrollLeft/scrollTop returned values of parent or even document root Only the scroll of the node itself is returned. Otherwise 0.0. * Scrolling via script had set viewport. This resulted in other nodes appearing scrolled. Now scroll_offsets are updated with correct node id. These bugs caused other odd behavior like both body and document.documentElement being scrolled or the view for scrolled elements jumping.
This is a standards mode document (
These failures are real bugs caused by me removing the line I have updated the pull request to disable the first test and added |
Let's file an issue upstream about 003.html in that case. |
Filed an issue at web-platform-tests/wpt#6289. |
Is there anything still blocking this PR? The broken test is broken in Firefox too so it no servo bug. In Chrome it will work because of a known and soon fixed incompatibility. |
@bors-servo r+ |
📌 Commit 284cb8a has been approved by |
🌲 The tree is currently closed for pull requests below priority 9000, this pull request will be tested once the tree is reopened |
Fix several bugs related to scrolling * scrollLeft/scrollTop returned values of parent or even document root Only the scroll of the node itself is returned. Otherwise 0.0. * Scrolling via script had set viewport. This resulted in other nodes appearing scrolled. Now scroll_offsets are updated with correct node id. These bugs caused other odd behavior like both body and document.documentElement being scrolled or the view for scrolled elements jumping. Also try scrolling this [example page](https://pyfisch.org/stuff/scrolltest.html) in servo with and without this change. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #17342 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes (partially) <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17385) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Only the scroll of the node itself is returned. Otherwise 0.0.
This resulted in other nodes appearing scrolled.
Now scroll_offsets are updated with correct node id.
These bugs caused other odd behavior like both body and
document.documentElement being scrolled or the view for scrolled
elements jumping.
Also try scrolling this example page in servo with and without this change.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is