-
Notifications
You must be signed in to change notification settings - Fork 291
Implement Home end key scroll #540
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
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.
Nice! Left a few minor style comments, and a question for @mrobinson
@@ -282,9 +282,9 @@ impl Frame { | |||
result | |||
} | |||
|
|||
/// Returns true if any layers actually changed position or false otherwise. | |||
/// Returns true if any layers actually changed position or false otherwise. |
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: indentation
@@ -378,7 +404,7 @@ impl Frame { | |||
} | |||
|
|||
scrolled_a_layer | |||
} | |||
} |
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: indentation
@@ -319,6 +319,32 @@ impl Frame { | |||
continue; | |||
} | |||
|
|||
let mut delta:Point2D<f32> = match scroll_location { |
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: indentation of this block
}, | ||
ScrollLocation::End => { | ||
let end_pos = -layer.content_size.height + | ||
(layer.local_viewport_rect.size.height); |
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.
This is probably clearer as layer.local_viewport_rect.size.height - layer.content_size.height
ScrollLocation::Start => { | ||
if layer.scrolling.offset.y.round() == 0.0 { | ||
// Nothing to do. | ||
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.
I think that we don't want to return straight away here (or below) due to the recent scroll root changes that have been made. Is that correct @mrobinson ?
@glennw thanks 😃 Just pushed those indentation fixes. |
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.
Got a few minor points and some questions.
@@ -319,6 +319,31 @@ impl Frame { | |||
continue; | |||
} | |||
|
|||
let mut delta:Point2D<f32> = match scroll_location { |
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.
is the explicit type required here?
return true; | ||
}, | ||
ScrollLocation::End => { | ||
let end_pos = -layer.content_size.height + |
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.
weird indentation and brackets
let end_pos = -layer.content_size.height + | ||
(layer.local_viewport_rect.size.height); | ||
|
||
if layer.scrolling.offset.y.round() == end_pos { |
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 it be >=
instead of ==
?
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.
ahh yeah I think >=
makes sense, I also have done it for the ScrollLocation::End
case, making replacing the ==
with <=
.
} | ||
|
||
layer.scrolling.offset.y = 0.0; | ||
return true; |
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.
So if it's Start
or End
you don't want to even proceed to the rest of the function body, even if the scroll happened?
@@ -439,6 +439,13 @@ pub enum ScrollPolicy { | |||
Fixed, | |||
} | |||
|
|||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)] | |||
pub enum ScrollLocation { | |||
Delta(Point2D<f32>), // Scroll by a certain amount. |
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.
please move those comments atop of the elements, preceded by ///
for some real documentation
ScrollLocation::Start => { | ||
if layer.scrolling.offset.y.round() == 0.0 { | ||
// Nothing to do. | ||
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.
from my own discussions with @mrobinson with regards to #533 I am pretty much certain that, as @glennw suggested in #540 (comment), those return
statements could be turned into continue
, because the loop still needs to scroll any other layer with the same scroll_root_id
.
So instead of returning a boolean, have you considered doing something like scrolled_a_layer = scrolled_a_layer || your_boolean
, followed by continue;
?
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.
okay :)
I was thinking something like this would work for these blocks:
ScrollLocation::Start => {
if layer.scrolling.offset.y.round() == 0.0 {
// Nothing to do on this layer.
continue;
}
layer.scrolling.offset.y = 0.0;
scrolled_a_layer = true;
continue;
},
What do you think? I have put these changes in and updated with latest WR master in the latest push
☔ The latest upstream changes (presumably #552) made this pull request unmergeable. Please resolve the merge conflicts. |
a6ac45c
to
29837e9
Compare
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 to me! I added a couple of nits - they are extremely minor - but since this needs a rebase anyway, we might as well fix them up at the same time. Once rebased, this is ready to merge!
}, | ||
ScrollLocation::End => { | ||
let end_pos = -layer.content_size.height + | ||
layer.local_viewport_rect.size.height; |
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.
Let's make this layer.local_viewport_rect.size.height - layer.content_size.height (just reads a bit better switching the order around).
layer.scrolling.offset.y = 0.0; | ||
scrolled_a_layer = true; | ||
continue; | ||
}, |
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 comma here and in the section below aren't necessary.
@samuknet Ah, I hadn't realised this was already rebased. Let's fix those last couple of minor nits, squash in to one commit, and then r=me. |
☔ The latest upstream changes (presumably #568) made this pull request unmergeable. Please resolve the merge conflicts. |
@samuknet Have you got time to rebase this and fix those last couple of nits? |
Sure! One issue I was having, is getting Servo to compile once the Webrender version has changed. I noticed webrender has had changes to its API/type signatures which means I can no longer compile and test Servo with the new scrolling code. Is there an easy way to check that everything still works together? |
@samuknet Have you considered rebasing your branch of the uptream master? It seems a bunch of traits file have indeed changed, so it could help solve the problems you describe. If that isn't enough, you could also try to rebase the servo repository as well... |
eafeeab
to
0ee01f3
Compare
I notice in And that now this messages makes a call to: pub fn scroll_layers(&mut self,
origin: Point2D<f32>,
pipeline_id: PipelineId,
scroll_root_id: ServoScrollRootId) Is this effectively the new Thanks :D |
The scroll_layers interface is mostly used for scrolling via JS, so it's fine to leave that as is. |
@bors-servo r+ |
📌 Commit fa805af has been approved by |
Thanks! |
Implement Home end key scroll Addressing issue servo/servo#13082. Supporting servo/servo#14141. * Adds `ScrollLocation` type in `webrender_traits`. * Refactor api to use new `ScrollLocation` * Implement home/end scrolling in `webrender/src/frame.rs` `fn scroll(...)` using new `ScrollLocation` struct passed in. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/540) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
@glennw Thank you! |
Implement home end key scrolling <!-- Please describe your changes on the following line: --> * Refactor all scroll related code to use a new `ScrollLocation` struct which can either be a `delta` (as before) or a `Start` or `End` request, to represent the desire to scroll to the start and end of the page. Effectively, everywhere a delta was used, there is now a `ScrollLocation` struct instead. * Add key press listeners for HOME and END keys so as to cause a scroll to be queued with `ScrollLocation::Start` (in HOME case) or `ScrollLocation::End` (in END case). * These changes depend on added support for the new `ScrollLocation` in webrender and webrender_traits. See servo/webrender#540. --- <!-- 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 #13082 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because scrolling I/O <!-- 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/14141) <!-- Reviewable:end -->
Implement home end key scrolling <!-- Please describe your changes on the following line: --> * Refactor all scroll related code to use a new `ScrollLocation` struct which can either be a `delta` (as before) or a `Start` or `End` request, to represent the desire to scroll to the start and end of the page. Effectively, everywhere a delta was used, there is now a `ScrollLocation` struct instead. * Add key press listeners for HOME and END keys so as to cause a scroll to be queued with `ScrollLocation::Start` (in HOME case) or `ScrollLocation::End` (in END case). * These changes depend on added support for the new `ScrollLocation` in webrender and webrender_traits. See servo/webrender#540. --- <!-- 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 #13082 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because scrolling I/O <!-- 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/14141) <!-- Reviewable:end -->
…:home-end-key-scroll2); r=glennw <!-- Please describe your changes on the following line: --> * Refactor all scroll related code to use a new `ScrollLocation` struct which can either be a `delta` (as before) or a `Start` or `End` request, to represent the desire to scroll to the start and end of the page. Effectively, everywhere a delta was used, there is now a `ScrollLocation` struct instead. * Add key press listeners for HOME and END keys so as to cause a scroll to be queued with `ScrollLocation::Start` (in HOME case) or `ScrollLocation::End` (in END case). * These changes depend on added support for the new `ScrollLocation` in webrender and webrender_traits. See servo/webrender#540. --- <!-- 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 #13082 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because scrolling I/O <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1706ffd6e5a02f26f69970b3b41536a8a85ef6fe
…:home-end-key-scroll2); r=glennw <!-- Please describe your changes on the following line: --> * Refactor all scroll related code to use a new `ScrollLocation` struct which can either be a `delta` (as before) or a `Start` or `End` request, to represent the desire to scroll to the start and end of the page. Effectively, everywhere a delta was used, there is now a `ScrollLocation` struct instead. * Add key press listeners for HOME and END keys so as to cause a scroll to be queued with `ScrollLocation::Start` (in HOME case) or `ScrollLocation::End` (in END case). * These changes depend on added support for the new `ScrollLocation` in webrender and webrender_traits. See servo/webrender#540. --- <!-- 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 #13082 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because scrolling I/O <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1706ffd6e5a02f26f69970b3b41536a8a85ef6fe UltraBlame original commit: 43657bf6458152f8a99e25af3bd99094669f6642
…:home-end-key-scroll2); r=glennw <!-- Please describe your changes on the following line: --> * Refactor all scroll related code to use a new `ScrollLocation` struct which can either be a `delta` (as before) or a `Start` or `End` request, to represent the desire to scroll to the start and end of the page. Effectively, everywhere a delta was used, there is now a `ScrollLocation` struct instead. * Add key press listeners for HOME and END keys so as to cause a scroll to be queued with `ScrollLocation::Start` (in HOME case) or `ScrollLocation::End` (in END case). * These changes depend on added support for the new `ScrollLocation` in webrender and webrender_traits. See servo/webrender#540. --- <!-- 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 #13082 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because scrolling I/O <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1706ffd6e5a02f26f69970b3b41536a8a85ef6fe UltraBlame original commit: 43657bf6458152f8a99e25af3bd99094669f6642
…:home-end-key-scroll2); r=glennw <!-- Please describe your changes on the following line: --> * Refactor all scroll related code to use a new `ScrollLocation` struct which can either be a `delta` (as before) or a `Start` or `End` request, to represent the desire to scroll to the start and end of the page. Effectively, everywhere a delta was used, there is now a `ScrollLocation` struct instead. * Add key press listeners for HOME and END keys so as to cause a scroll to be queued with `ScrollLocation::Start` (in HOME case) or `ScrollLocation::End` (in END case). * These changes depend on added support for the new `ScrollLocation` in webrender and webrender_traits. See servo/webrender#540. --- <!-- 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 #13082 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because scrolling I/O <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 1706ffd6e5a02f26f69970b3b41536a8a85ef6fe UltraBlame original commit: 43657bf6458152f8a99e25af3bd99094669f6642
Addressing issue servo/servo#13082.
Supporting servo/servo#14141.
ScrollLocation
type inwebrender_traits
.ScrollLocation
webrender/src/frame.rs
fn scroll(...)
using newScrollLocation
struct passed in.This change is