-
Notifications
You must be signed in to change notification settings - Fork 299
Implement scroll handoff #533
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
Conversation
@glennw @mrobinson Any input appreciated, pls tell me more about how this would fit in the approach chosen in #517 If we all agree it's 'good enough', we could ask @pcwalton for a review as originally planned? |
@mrobinson is probably best to comment on this stuff. |
@gterzian You'll need to scroll all the layers that have the same scroll root. Otherwise the contents of scrollable divs will be out of sync. I'll be on #servo if you want to discuss in real-time. |
1abd21e
to
deddeb5
Compare
@glennw OK I have taken @mrobinson feedback into account, should we ask for a review? |
deddeb5
to
624aff8
Compare
r? @pcwalton (I think this looks OK, but I don't know the overscroll stuff super well). |
let scroll_root_id = match (switch_layer, scroll_layer_id.info, root_scroll_layer_id.info) { | ||
(true, _, ScrollLayerInfo::Scrollable(_, scroll_root_id)) => scroll_root_id, | ||
(true, ScrollLayerInfo::Scrollable(_, scroll_root_id), ScrollLayerInfo::Fixed) => scroll_root_id, | ||
(false, ScrollLayerInfo::Scrollable(_, scroll_root_id), _) => scroll_root_id, |
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.
Combine this with the first in an or-pattern, perhaps?
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, it's done...
624aff8
to
ecf7e16
Compare
@pcwalton I have noticed, that when I 'switch layer', the overscrolling layer that I am switching out 'jumps' up and comes down only when the scroll has ended, perhaps because I am interfering with some of the overscroll behavior? And this seems to be intermittent by the way... |
@gterzian Sorry this has languished for a bit - Unfortunately the overscrolling is on mac only (and the only mac I have available is a mac mini without trackpad). Do you know if that intermittent behaviour you mention above also happens without your patch? If it does, it's probably fine to merge this. |
b58fe56
to
20b500a
Compare
@glennw @pcwalton I finally found what caused that intermittent 'jumping' behaviour, it was the mutation of Since the |
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.
Looks good! A few minor things to fix then this should be good to go.
}, | ||
(ScrollEventPhase::Start, None, _) => return false, | ||
(_, _, Some(scroll_layer_id)) => scroll_layer_id, | ||
(_, _, None) => return false, |
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.
We should probably have a condition here that sets the current scroll layer back to None at the end of the scroll event?
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 have tried this, and on Mac it makes the scroll stop right in it's track when you stop scrolling, as opposed to the default 'natural continuous scroll'. I think we can consider leaving things as they are, to retain the default behavior on Mac.
}; | ||
|
||
let mut scrolled_a_layer = false; | ||
for (layer_id, layer) in self.layers.iter_mut() { | ||
let mut inner_delta = delta; |
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.
Perhaps call this layer_delta? And we should be able to remove the mut
from the function parameter for delta, I think?
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.
good one, done.
@@ -380,12 +416,11 @@ impl Frame { | |||
if CAN_OVERSCROLL { | |||
layer.stretch_overscroll_spring(); | |||
} | |||
|
|||
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.
nit: extra space
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.
removed...
let scroll_root_id = match scroll_layer_id.info { | ||
ScrollLayerInfo::Scrollable(_, scroll_root_id) => scroll_root_id, | ||
ScrollLayerInfo::Fixed => unreachable!("Tried to scroll a fixed position layer."), | ||
let switch_layer = match phase { |
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 completely understand what the non_root_overscroll is doing - could you add some comments explaining?
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 have added a few comments, please let me know what you think.
20b500a
to
4a79187
Compare
pub struct ScrollingState { | ||
pub offset: Point2D<f32>, | ||
pub spring: Spring, | ||
pub started_bouncing_back: bool, | ||
pub bouncing_back: bool, | ||
pub should_handoff_scroll: bool |
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.
@glennw I renamed the field on layer
, so that it simply states it's purpose from the layer's point of view...
7426272
to
6fbc6f9
Compare
I was just doing some testing with this, but it seems to break scrolling on Linux altogether. I'm not sure if that's because of the Linux scroll implementation, or because I rebased this on top of master before testing. Are you able to test this on a Linux machine? (You may be able to repro it on a mac by switching the CAN_OVERSCROLL constant, which is set based on mac/linux). |
@glennw thanks for testing. I don't have a Linux machine readily available, however I might be able to run it into a VM of some sorts, given more time. I did already follow your suggestion of setting
Can I rebase/edit and push the above mentioned changes? I guess it should not create any problems unless you were to work off the branch that you pulled for testing... |
UPDATE: I have now also tested after a rebase off master (using servo/servo#14286 on the servo side), and it seems to work on Mac, even with overscrolling turned off. @glennw could you describe the Linux problems in more details? Does the scrolling simply not work at all? |
@gterzian Yep - the scrolling was completely broken. Even on a really simple page with a single scroll layer (like https://news.ycombinator.com) I was unable to scroll at all. But when I reverted the commits in this branch and ran, I could scroll again. That's quite strange that changing CAN_OVERSCROLL doesn't reproduce it - I'm not aware of any other obvious differences between the linux/mac scrolling implementations... |
@glennw thanks for the update! Ok, I guess I will need to debug that using linux on virtualbox... |
☔ The latest upstream changes (presumably #590) made this pull request unmergeable. Please resolve the merge conflicts. |
0f15516
to
ecaec50
Compare
ecaec50
to
26a3b05
Compare
@glennw Due to resource constraints on my current machine, I'm having some troubles building and running Servo in a Linux VM for testing. In an attempt to try to move things forward while I find a solution, I've broken up this PR into two ones, since we're actually doing two separate things here, and I have a feeling it's only one of the two that has the potential to completely break scrolling on Linux. Could I ask you to please test this one on your machine: #599 ? I am hopeful it will work on Linux, while I will have to further debug this one later: #600 |
@gterzian Sure, I'll test those patches on Linux today and report back the results. |
WIP for servo/servo#13249
To summarize what was discussed in the issue:
This change is