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

Properly handle scroll offsets in hit testing #16865

Merged
merged 1 commit into from May 16, 2017

Conversation

@mrobinson
Copy link
Member

mrobinson commented May 15, 2017

Scroll roots are no longer nested containers holding items, so instead
we need to track the offsets of each, carefully handling fixed position
items and stacking contexts that create new reference frames.
Additionally, we remove the complexity of the pre-computed page scroll
offset, instead opting to send script scrolls to the layout task in
order to more quickly have a ScrollState there that matches the
script's idea of the scroll world.

Fixes #16405.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #16405.
  • There are tests for these changes OR
  • These changes do not require tests because it is currently impossible to test interactive scrolling with Servo's test infrastructure. Existing tests verify the script part though.

This change is Reviewable

@highfive
Copy link

highfive commented May 15, 2017

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/document.rs, components/script/dom/window.rs, components/script_layout_interface/message.rs, components/script_traits/lib.rs, components/script_traits/lib.rs
  • @fitzgen: components/script/dom/document.rs, components/script/dom/window.rs, components/script_layout_interface/message.rs, components/script_traits/lib.rs, components/script_traits/lib.rs
  • @emilio: components/layout/query.rs
@highfive
Copy link

highfive commented May 15, 2017

warning Warning warning

  • These commits modify gfx, layout, and script code, but no tests are modified. Please consider adding a test!
@mrobinson
Copy link
Member Author

mrobinson commented May 15, 2017

There is still a lot of code duplication in DisplayList, but I hope to fix that in a later PR.

@mrobinson mrobinson closed this May 15, 2017
@mrobinson mrobinson reopened this May 15, 2017
@bors-servo
Copy link
Contributor

bors-servo commented May 15, 2017

The latest upstream changes (presumably #16295) made this pull request unmergeable. Please resolve the merge conflicts.

@jonathandturner
Copy link

jonathandturner commented May 16, 2017

Initial results look great. Seems to have fixed the issue I was seeing.

@mrobinson mrobinson force-pushed the mrobinson:scroll-offsets-fix branch from 7387e13 to ae6ef35 May 16, 2017
@mrobinson
Copy link
Member Author

mrobinson commented May 16, 2017

@jonathandturner That's great to hear! I've updated the PR to fix the merge conflicts.

@mrobinson mrobinson requested review from glennw and emilio May 16, 2017
@emilio
emilio approved these changes May 16, 2017
Copy link
Member

emilio left a comment

Looks good to me, thanks for fixing this!

Only a few nits, and this is ready to land IMO.

}

fn full_offset_for_scroll_root(&mut self, id: &ClipId) -> Point2D<f32> {
match self.calculated_total_offsets.get(id) {

This comment has been minimized.

Copy link
@emilio

emilio May 16, 2017

Member

nit: use if let here?

This comment has been minimized.

Copy link
@emilio

emilio May 16, 2017

Member

Though this may be cleaner and slightly more efficient using the entry API.

This comment has been minimized.

Copy link
@mrobinson

mrobinson May 16, 2017

Author Member

I cannot use the entry API here, because I'm recursing causing a double mutable borrow. if let is a lot cleaner though.

let mut point = *point - stacking_context.bounds.origin;
if stacking_context.scroll_policy == ScrollPolicy::Fixed {
let old_offset = offset_lookup.calculated_total_offsets.get(&clip_id).cloned();
offset_lookup.calculated_total_offsets.insert(clip_id, Point2D::zero());

This comment has been minimized.

Copy link
@emilio

emilio May 16, 2017

Member

When can a clip_id correspond to different StackingContext? Perhaps it would be nice to describe how Clips and StackingContext relate to each other, either here or in webrender's CLIPPING.md.

In any case, this looks correct to me.

This comment has been minimized.

Copy link
@mrobinson

mrobinson May 16, 2017

Author Member

We chatted about this on IRC, but the plan is that I will document everything after the last major API change. Hopefully that will happen in the next few weeks.

Scroll roots are no longer nested containers holding items, so instead
we need to track the offsets of each, carefully handling fixed position
items and stacking contexts that create new reference frames.
Additionally, we remove the complexity of the pre-computed page scroll
offset, instead opting to send script scrolls to the layout task in
order to more quickly have a ScrollState there that matches the
script's idea of the scroll world.

Fixes #16405.
@mrobinson mrobinson force-pushed the mrobinson:scroll-offsets-fix branch from ae6ef35 to 9fd2df5 May 16, 2017
@mrobinson
Copy link
Member Author

mrobinson commented May 16, 2017

@bors-servo r=emilio

@highfive highfive assigned emilio and unassigned KiChjang May 16, 2017
@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2017

📌 Commit 9fd2df5 has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2017

Testing commit 9fd2df5 with merge d855c92...

bors-servo added a commit that referenced this pull request May 16, 2017
Properly handle scroll offsets in hit testing

Scroll roots are no longer nested containers holding items, so instead
we need to track the offsets of each, carefully handling fixed position
items and stacking contexts that create new reference frames.
Additionally, we remove the complexity of the pre-computed page scroll
offset, instead opting to send script scrolls to the layout task in
order to more quickly have a ScrollState there that matches the
script's idea of the scroll world.

Fixes #16405.

<!-- 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 #16405.

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because it is currently impossible to test interactive scrolling with Servo's test infrastructure. Existing tests verify the script part though.

<!-- 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/16865)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 16, 2017

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-msvc-dev
Approved by: emilio
Pushing d855c92 to master...

@bors-servo bors-servo merged commit 9fd2df5 into servo:master May 16, 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
@mrobinson mrobinson deleted the mrobinson:scroll-offsets-fix branch May 16, 2017
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.

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