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
Implement scroll, scrollLeft, scrollTop and friends, addressing issue #9650 #9968
Conversation
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @KiChjang (or someone else) soon. |
The spec is similar, but there shouldn't be too much overlap. I wanted to implement @izgzhen: I think you're missing |
@asajeffrey There is something different, and I will try to avoid duplication by abstracting common utilities out. @danlrobertson thanks, I don't write it on the list because I haven't write a single line of code yet :P |
#9824 landed! |
☔ The latest upstream changes (presumably #9967) made this pull request unmergeable. Please resolve the merge conflicts. |
@izgzhen would you like me to start reviewing, or hold off for the moment? |
@asajeffrey Please wait for a minute, I will need a little time to rebase and think about incorporating changes introduced in PR #9824. |
@asajeffrey rebase and some more polishing is done, I am hitting the wall now :P I have two problems now:
|
I did some preliminary reading through, which makes me think that there needs to be a bit of care about what is handled by the script thread, and what is handled by the layout thread (c.f. the approach in #9824). I think you're going to need to construct a message which is sent from script to layout requesting the necessary calculated values, and there should be at most one such message for each call to a DOM method. @danlrobertson: you recently looked at this code, care to weigh in? Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions. components/script/dom/element.rs, line 173 [r4] (raw file): For the moment I think this function should just return components/script/dom/element.rs, line 180 [r4] (raw file):
This is the first method that requires computed values. Comments from the review on Reviewable.io |
Agreed. A good portion of this will definitely involve the layout thread. I'll do some more reading as well and come back with hopefully more info.
Yeah, I noticed there were a couple very small differences (for the getters). I wonder how much of it is just wording and how much of it is actually different. I can ask on IRC and hope for some responses. Which parts in particular are you talking about? Just a suggestion. For these particular methods I would focus on implementing the "working" or "hard" part of the algorithm first. In your case the last step of each method. Furthermore, I would work on the setters first. It's a bit complicated as you'll have to perform a scroll (not sure if it has been implemented yet), but once you have that, i think you might have a better foundation to work off of and it should be easier to go back and implement the restrictions. Just a suggestion... feel free not to take it 😄 Review status: 0 of 2 files reviewed at latest revision, 4 unresolved discussions. components/script/dom/element.rs, line 180 [r4] (raw file): components/script/dom/element.rs, line 1534 [r4] (raw file): components/script/dom/element.rs, line 1545 [r4] (raw file): Comments from the review on Reviewable.io |
Review status: 0 of 2 files reviewed at latest revision, 4 unresolved discussions. components/script/dom/element.rs, line 1534 [r4] (raw file): Comments from the review on Reviewable.io |
@izgzhen would you like me to dive into the current code base some more, or hold off? It sounds like we're in agreement that the code is going to need quite a bit of re-architecting to move computation from the script thread to the layout thread. |
@asajeffrey You idea sounds great. Hope I can be helpful to you. |
@izgzhen is this PR still active? |
@asajeffrey Yes, I believe so. Sorry that I have been busy with GSoC proposal and coursework these days. Also, I am kind of waiting more comments so I procrastinated :( If there is no major problem about "moving computation from the script thread to the layout thread", I am going to review the code and write some test cases this weekend. |
@asajeffrey hi, I have investigated and experimented throughly this weekend, but the result turns out to be not very pleasing. First, the Second, a lot of other scrolling utilities are not supported in As a conclusion, I think I am going to investigate a bit deeper and try to give a more complete solution. It is very rewarding process to understand and identify the problem, although there is not any fruit yet. I thin k we can leave this PR open here as a place for discussion and experimentation, but I am afraid it might linger a very long time. What is your idea? |
Now that I'm looking at the spec again, there is a chance that our current implementation might need some attention once
|
Here are some notes of my latest "discoveries": First, as stated a week ago, the Second, the The final problem is how to relate element to such a layer. As tested with The above is idea for getting, and setting should be similar (calling Up the implementation, I think I can reuse the Some other consideration is to make a new fragment iterator getting solely Plus the existing hack to retrieve the computed value of UPDATE: I have tested the idea in this commit, but it is not working due to a invalid |
In the new commits, I finally fetched the right
Despite these issues, the current code is basically working as intended. Welcome reviewing. |
Well done! 💃 |
Add new compositor message to get scroll_offset; Add new layout query for computed value of overflow-x/y; Implement layer_id method for ThreadSafeLayoutNode; Add new layout query for layer_id; Implement script interface for getting scrollTop and scrollLeft, as well as relavant helper functions.
Renamed, hope it looks better Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. Comments from Reviewable |
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. components/compositing/compositor.rs, line 723 [r14] (raw file): Comments from Reviewable |
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. components/script/dom/element.rs, line 1266 [r13] (raw file): Comments from Reviewable |
Getting there! Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. components/compositing/compositor.rs, line 723 [r14] (raw file): components/script/dom/element.rs, line 1266 [r13] (raw file): Comments from Reviewable |
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. components/script/dom/element.rs, line 1266 [r13] (raw file): Comments from Reviewable |
Reviewed 4 of 4 files at r15. Comments from Reviewable |
OK, I'm happy, ready for an r+? @danlrobertson look good to you? |
Great, thanks for helping the review these days Review status: all files reviewed at latest revision, 7 unresolved discussions. Comments from Reviewable |
Looks great! Excited to see what homu has to say! |
@bors-servo r+ |
📌 Commit 11b12f6 has been approved by |
Implement scroll, scrollLeft, scrollTop and friends, addressing issue #9650 This is a work in progress to solve #9650. Thanks a lot for helping the review. - [x] scroll - [x] scrollTo - [x] scrollBy - [x] scrollTop (setter and getter) - [x] scrollLeft (setter and getter) The setters will be implemented in another PR after this is merged. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9968) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt |
@izgzhen This is some really impressive work! |
This is a work to solve #9650. Thanks a lot for helping the review.
The setters will be implemented in another PR after this is merged.
This change is