Skip to content
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

Merged
merged 1 commit into from Jun 23, 2017
Merged

Conversation

@pyfisch
Copy link
Contributor

pyfisch commented Jun 17, 2017

  • 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 in servo with and without this change.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #17342 (github issue number if applicable).
  • There are tests for these changes (partially)

This change is Reviewable

@highfive
Copy link

highfive commented Jun 17, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/element.rs, components/script/dom/window.rs
  • @KiChjang: components/script/dom/element.rs, components/script/dom/window.rs
@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 17, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jun 17, 2017

Trying commit 6ab0a71 with merge f4876f0...

bors-servo added a commit that referenced this pull request Jun 17, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 17, 2017

💔 Test failed - android

@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 17, 2017

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?

@stshine
Copy link
Contributor

stshine commented Jun 17, 2017

@highfive highfive assigned mrobinson and unassigned nox Jun 17, 2017
@jdm
Copy link
Member

jdm commented Jun 17, 2017

./mach update-manifest

@pyfisch pyfisch force-pushed the pyfisch:better-scroll branch from 6ab0a71 to 1a70a02 Jun 17, 2017
@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 17, 2017

Thanks. Ran ./mach update-manifest.

@@ -169897,6 +169897,66 @@
{}
]
],
"_certs/064162.pem": [

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jun 17, 2017

Author Contributor

Should these lines really be here? To me they look more like some left-over temporary files.

ReflowReason::Query) {
return;
}

self.scroll_offsets.borrow_mut().insert(node.to_untrusted_node_address(),

This comment has been minimized.

Copy link
@mrobinson

mrobinson Jun 19, 2017

Member

Currently these scroll offsets come from WebRender. What is the issue here with waiting until WebRender updates the scroll offset map?

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jun 19, 2017

Author Contributor

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).

This comment has been minimized.

Copy link
@mrobinson

mrobinson Jun 19, 2017

Member

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.

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jun 19, 2017

Author Contributor

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.)

This comment has been minimized.

Copy link
@mrobinson

mrobinson Jun 19, 2017

Member

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.

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jun 19, 2017

Author Contributor

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.

@@ -397231,6 +397291,54 @@
"b960bef807da94c0146ed2f537eaa1e05ec9a0ab",
"testharness"
],
"_certs/064162.pem": [

This comment has been minimized.

Copy link
@mrobinson

mrobinson Jun 19, 2017

Member

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!

This comment has been minimized.

Copy link
@pyfisch

pyfisch Jun 19, 2017

Author Contributor

Thanks for the explanation. I will do so.

@pyfisch pyfisch force-pushed the pyfisch:better-scroll branch from 1a70a02 to 5a87833 Jun 19, 2017
@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 19, 2017

Added a comment and removed lines from manifest.

@mrobinson can you please r+?

@bors-servo try

@bors-servo
Copy link
Contributor

bors-servo commented Jun 19, 2017

Trying commit 5a87833 with merge dd1230f33443231864af970e48a7c6bf787d3c6e...

Copy link
Member

mrobinson left a comment

Thanks! This looks good.

@mrobinson
Copy link
Member

mrobinson commented Jun 19, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jun 19, 2017

📌 Commit 5a87833 has been approved by mrobinson

@bors-servo
Copy link
Contributor

bors-servo commented Jun 19, 2017

Testing commit 5a87833 with merge 2ff7ce783a9c144b80be492f3d0ad5468fc26edc...

@bors-servo
Copy link
Contributor

bors-servo commented Jun 19, 2017

💔 Test failed - mac-rel-wpt2

@jdm
Copy link
Member

jdm commented Jun 19, 2017

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/003.html:
  │ FAIL [expected PASS] Fragment Navigation: Updating scroll position
  │   → assert_true: expected true got false
  │ 
  │ @http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/003.html:17:3
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  │ test@http://web-platform.test:8000/resources/testharness.js:497:9
  └ @http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/003.html:12:1

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html:
  │ FAIL [expected PASS] Fragment Navigation: fragment id should be percent-decoded
  │   → assert_equals: expected 200 but got 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html:17:9
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html:40:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html:
  │ FAIL [expected PASS] Fragment Navigation: scroll to anchor name is lower priority than equal id
  │   → assert_equals: expected 200 but got 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html:16:9
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html:34:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html:
  │ FAIL [expected PASS] Fragment Navigation: TOP is a valid element id, which overrides navigating to top of the document
  │   → assert_equals: expected 200 but got 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html:14:7
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html:32:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html:
  │ FAIL [expected PASS] Fragment Navigation: When fragid is TOP scroll to the top of the document
  │   → assert_not_equals: got disallowed value 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html:14:7
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html:41:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20
* 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.
@pyfisch pyfisch force-pushed the pyfisch:better-scroll branch from 5a87833 to 284cb8a Jun 19, 2017
@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 19, 2017

▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/003.html:
  │ FAIL [expected PASS] Fragment Navigation: Updating scroll position
  │   → assert_true: expected true got false
  │ 
  │ @http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/003.html:17:3
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  │ test@http://web-platform.test:8000/resources/testharness.js:497:9
  └ @http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/003.html:12:1

This is a standards mode document (<!doctype html>). It is scrolled to some fragments. Then document.body.scrollTop is requested. It should be nonzero if the document is scrolled. The spec states that this is only true in quirks mode, in standards mode document.documentElement is scrolled. (The test passes if one replaces document.body with document.documentElement). Test is wrong. (This passed before because servo scrolled both body and root element.)

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html:
  │ FAIL [expected PASS] Fragment Navigation: fragment id should be percent-decoded
  │   → assert_equals: expected 200 but got 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html:17:9
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-frag-percent-encoded.html:40:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html:
  │ FAIL [expected PASS] Fragment Navigation: scroll to anchor name is lower priority than equal id
  │   → assert_equals: expected 200 but got 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html:16:9
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html:34:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html:
  │ FAIL [expected PASS] Fragment Navigation: TOP is a valid element id, which overrides navigating to top of the document
  │   → assert_equals: expected 200 but got 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html:14:7
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html:32:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html:
  │ FAIL [expected PASS] Fragment Navigation: When fragid is TOP scroll to the top of the document
  │   → assert_not_equals: got disallowed value 0
  │ 
  │ steps<.handler@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html:14:7
  │ runNextStep/listener<@http://web-platform.test:8000/html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-top.html:41:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  └ Test.prototype.step_func/<@http://web-platform.test:8000/resources/testharness.js:1430:20

These failures are real bugs caused by me removing the line self.update_viewport_for_scroll(x, y);. I am still not sure how perform_a_scroll works on elements, maybe someone can explain it? But it is necessary to do the scrolls.

I have updated the pull request to disable the first test and added update_viewport_for_scroll at two places.

@jdm
Copy link
Member

jdm commented Jun 19, 2017

Let's file an issue upstream about 003.html in that case.

@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 20, 2017

Filed an issue at web-platform-tests/wpt#6289.

@pyfisch
Copy link
Contributor Author

pyfisch commented Jun 22, 2017

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.

@mrobinson
Copy link
Member

mrobinson commented Jun 23, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Jun 23, 2017

📌 Commit 284cb8a has been approved by mrobinson

@bors-servo
Copy link
Contributor

bors-servo commented Jun 23, 2017

🌲 The tree is currently closed for pull requests below priority 9000, this pull request will be tested once the tree is reopened

@bors-servo
Copy link
Contributor

bors-servo commented Jun 23, 2017

Testing commit 284cb8a with merge 626c029...

bors-servo added a commit that referenced this pull request Jun 23, 2017
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 23, 2017

@bors-servo bors-servo merged commit 284cb8a into servo:master Jun 23, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.