Skip to content

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

Merged
merged 6 commits into from
Nov 28, 2016
Merged

Conversation

samuknet
Copy link

@samuknet samuknet commented Nov 8, 2016

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.

This change is Reviewable

Copy link
Member

@glennw glennw left a 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.
Copy link
Member

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
}
}
Copy link
Member

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 {
Copy link
Member

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);
Copy link
Member

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;
Copy link
Member

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 ?

@samuknet
Copy link
Author

@glennw thanks 😃 Just pushed those indentation fixes.

Copy link
Member

@kvark kvark left a 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 {
Copy link
Member

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 +
Copy link
Member

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 {
Copy link
Member

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 ==?

Copy link
Author

@samuknet samuknet Nov 17, 2016

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;
Copy link
Member

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.
Copy link
Member

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;
Copy link
Member

@gterzian gterzian Nov 13, 2016

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;?

Copy link
Author

@samuknet samuknet Nov 17, 2016

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

@bors-servo
Copy link
Contributor

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

@samuknet samuknet force-pushed the home-end-key-scroll2 branch from a6ac45c to 29837e9 Compare November 17, 2016 13:27
Copy link
Member

@glennw glennw left a 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;
Copy link
Member

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;
},
Copy link
Member

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.

@glennw
Copy link
Member

glennw commented Nov 18, 2016

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

@bors-servo
Copy link
Contributor

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

@glennw
Copy link
Member

glennw commented Nov 28, 2016

@samuknet Have you got time to rebase this and fix those last couple of nits?

@samuknet
Copy link
Author

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?

@gterzian
Copy link
Member

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

@samuknet samuknet force-pushed the home-end-key-scroll2 branch from eafeeab to 0ee01f3 Compare November 28, 2016 09:17
@samuknet
Copy link
Author

samuknet commented Nov 28, 2016

I notice in webrender_traits/types.rs the previous Scroll message has now been changed to ScrollLayersWithScrollId(Point2D<f32>, PipelineId, ServoScrollRootId).

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 fn scroll_layers, i.e. should I refactor the existing home/end key scrolling code in fn scroll into fn scroll_layers? Or do we want both?

Thanks :D

@glennw
Copy link
Member

glennw commented Nov 28, 2016

The scroll_layers interface is mostly used for scrolling via JS, so it's fine to leave that as is.

@glennw
Copy link
Member

glennw commented Nov 28, 2016

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit fa805af has been approved by glennw

@glennw
Copy link
Member

glennw commented Nov 28, 2016

Thanks!

bors-servo pushed a commit that referenced this pull request Nov 28, 2016
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 -->
@bors-servo
Copy link
Contributor

⌛ Testing commit fa805af with merge 3a6725a...

@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit fa805af into servo:master Nov 28, 2016
@samuknet
Copy link
Author

@glennw Thank you!

bors-servo pushed a commit to servo/servo that referenced this pull request Jan 23, 2017
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 -->
bors-servo pushed a commit to servo/servo that referenced this pull request Jan 23, 2017
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 -->
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 4, 2017
…: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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…: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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…: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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…: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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants