Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement Home end key scroll #540
Conversation
|
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. | |||
This comment has been minimized.
This comment has been minimized.
| @@ -378,7 +404,7 @@ impl Frame { | |||
| } | |||
|
|
|||
| scrolled_a_layer | |||
| } | |||
| } | |||
This comment has been minimized.
This comment has been minimized.
| @@ -319,6 +319,32 @@ impl Frame { | |||
| continue; | |||
| } | |||
|
|
|||
| let mut delta:Point2D<f32> = match scroll_location { | |||
This comment has been minimized.
This comment has been minimized.
| }, | ||
| ScrollLocation::End => { | ||
| let end_pos = -layer.content_size.height + | ||
| (layer.local_viewport_rect.size.height); |
This comment has been minimized.
This comment has been minimized.
glennw
Nov 8, 2016
Member
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; |
This comment has been minimized.
This comment has been minimized.
glennw
Nov 8, 2016
Member
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 |
|
Got a few minor points and some questions. |
| @@ -319,6 +319,31 @@ impl Frame { | |||
| continue; | |||
| } | |||
|
|
|||
| let mut delta:Point2D<f32> = match scroll_location { | |||
This comment has been minimized.
This comment has been minimized.
| return true; | ||
| }, | ||
| ScrollLocation::End => { | ||
| let end_pos = -layer.content_size.height + |
This comment has been minimized.
This comment has been minimized.
| let end_pos = -layer.content_size.height + | ||
| (layer.local_viewport_rect.size.height); | ||
|
|
||
| if layer.scrolling.offset.y.round() == end_pos { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
samuknet
Nov 17, 2016
•
Author
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; |
This comment has been minimized.
This comment has been minimized.
kvark
Nov 11, 2016
Member
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. | |||
This comment has been minimized.
This comment has been minimized.
kvark
Nov 11, 2016
Member
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; |
This comment has been minimized.
This comment has been minimized.
gterzian
Nov 13, 2016
•
Member
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;?
This comment has been minimized.
This comment has been minimized.
samuknet
Nov 17, 2016
•
Author
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
|
|
|
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; |
This comment has been minimized.
This comment has been minimized.
glennw
Nov 18, 2016
Member
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; | ||
| }, |
This comment has been minimized.
This comment has been minimized.
|
@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. |
|
|
|
@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... |
|
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+ |
|
|
|
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 -->
|
|
|
@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
samuknet commentedNov 8, 2016
•
edited
Addressing issue servo/servo#13082.
Supporting servo/servo#14141.
ScrollLocationtype inwebrender_traits.ScrollLocationwebrender/src/frame.rsfn scroll(...)using newScrollLocationstruct passed in.This change is