Skip to content
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

Issue 7720: Add target selector and update when scrolling to fragment #11726

Merged
merged 1 commit into from Aug 3, 2016

Conversation

@sjmelia
Copy link
Contributor

sjmelia commented Jun 11, 2016

Add the target pseudo selector and set/unset it during scrolling to fragment. This change is not complete as no repaint is triggered after the selector is added - it will only take effect after a repaint is triggered by e.g. hovering over another element. (See manual test)

I would like some help because i'm not sure how to resolve this; I can only think to call window.reflow.

I added a manual test case, don't think this counts really! I think the applicable automated test is in /tests/wpt/web-platform-tests/dom/nodes/Element-matches.html but it currently fails, I think due to the above.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #7720 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Jun 11, 2016

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @metajack (or someone else) soon.

@highfive
Copy link

highfive commented Jun 11, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/element_state.rs, components/style/selector_impl.rs
  • @KiChjang: components/script/dom/document.rs, components/script/dom/element.rs, components/script/script_thread.rs
@highfive
Copy link

highfive commented Jun 11, 2016

warning Warning warning

  • These commits modify style, layout, and script code, but no tests are modified. Please consider adding a test!
@mbrubeck mbrubeck assigned mbrubeck and unassigned metajack Jun 12, 2016
@mbrubeck
Copy link
Contributor

mbrubeck commented Jun 12, 2016

I can review this but I'll be travelling for the next couple of days so I may not be online much. If another reviewer can get to it sooner, feel free to steal it.

I would like some help because i'm not sure how to resolve this; I can only think to call window.reflow.

Yes, calling window.reflow is correct. You can look at Document::handle_mouse_move_event for reference; it calls window.reflow after calling element.set_hover_state.

(Side note: While glancing at this code I noticed that Element::active_state and set_active_state seem to be unused. If you (or anyone else) would like to figure out why that is (are they no longer needed? or are we missing some code that should be calling them?) and file an issue or PR, that would be great.)

@sjmelia
Copy link
Contributor Author

sjmelia commented Jun 12, 2016

Thanks Matt, I'll add the reflow call and more than happy to investigate active_state!

@sjmelia
Copy link
Contributor Author

sjmelia commented Jun 14, 2016

Ok added the reflow (I chose ReflowReason::DocumentLoaded) then did some more flailing;

I think that (a) the script_thread.handle_navigate function is dealing with Step 7 of https://html.spec.whatwg.org/multipage/browsers.html#navigating-across-documents and is functional, but that (b) loading a new document with an URL fragment is Step 6 of https://html.spec.whatwg.org/multipage/browsers.html#update-the-session-history-with-the-new-page and is currently non-functional.

There is a sporadic scroll; but this occurs due to handle_resize_event so i'm not sure it's intentional and didn't look like the right place to add code setting the pseudo-selector.

For this reason; i've added a second commit to the PR that scrolls to the fragment and adds the pseudoselector after the document loads. I'm not convinced it's in the right place, and the test no longer fails; but instead times out... so i'm not sure that's much progress.

I think I still need to add a test for scenario a) - if so, do I just commit one to the web-platform-tests?

@sjmelia sjmelia force-pushed the sjmelia:7720_add_target_selector branch from d3898c3 to 7ba80c8 Jun 14, 2016
@highfive
Copy link

highfive commented Jun 14, 2016

New code was committed to pull request.

@sjmelia
Copy link
Contributor Author

sjmelia commented Jun 15, 2016

active state is not yet implemented; it's referenced in an existing issue, #8719

@Manishearth Manishearth self-assigned this Jun 15, 2016
@mbrubeck
Copy link
Contributor

mbrubeck commented Jun 16, 2016

This looks good! Some minor comments below.

For this reason; i've added a second commit to the PR that scrolls to the fragment and adds the pseudoselector after the document loads. I'm not convinced it's in the right place, and the test no longer fails; but instead times out... so i'm not sure that's much progress.

I think that scrolling on load is correct. It looks like this test is just so big that it always times out in debug builds (even without these changes). In a release build it passes.

-S-awaiting-review +S-needs-code-changes


Reviewed 7 of 7 files at r1, 3 of 3 files at r2, 3 of 3 files at r3.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/script/dom/document.rs, line 1844 [r1] (raw file):

    pub fn set_target_element(&self, node: Option<&Element>) {
        match self.target_element.get()  {

Suggestion: This function could be simplified slightly by using if let instead of match.


components/script/dom/document.rs, line 1859 [r2] (raw file):

        self.window.reflow(ReflowGoal::ForDisplay,
                               ReflowQueryType::NoQuery,
                               ReflowReason::DocumentLoaded);

I think we should add a new ReflowReason, something like ElementStateChanged.


Comments from Reviewable

@sjmelia sjmelia force-pushed the sjmelia:7720_add_target_selector branch from 7ba80c8 to 697b9a2 Jun 16, 2016
@Manishearth
Copy link
Member

Manishearth commented Jun 20, 2016

Looks ready to merge?

@Ms2ger
Copy link
Contributor

Ms2ger commented Jun 20, 2016

I'd like to take a look; hopefully today, but might be tomorrow.

@Manishearth Manishearth removed their assignment Jun 20, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Jun 20, 2016

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

@sjmelia sjmelia force-pushed the sjmelia:7720_add_target_selector branch from 697b9a2 to cd4f734 Jun 20, 2016
@sjmelia
Copy link
Contributor Author

sjmelia commented Jun 20, 2016

I've rebased this - maybe the label will get removed next time Homu visits?

@emilio
Copy link
Member

emilio commented Jul 3, 2016

ping @Ms2ger? You wanted to review this :)

@sjmelia sjmelia force-pushed the sjmelia:7720_add_target_selector branch from 9596c97 to 04f5369 Aug 3, 2016
@sjmelia
Copy link
Contributor Author

sjmelia commented Aug 3, 2016

...sorry about that. have removed the entries from ParentNode-querySelector-all-xht.xht

@jdm
Copy link
Member

jdm commented Aug 3, 2016

@bors-servo: r=mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

📌 Commit 04f5369 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

Testing commit 04f5369 with merge 1936da9...

bors-servo added a commit that referenced this pull request Aug 3, 2016
Issue 7720: Add target selector and update when scrolling to fragment

<!-- Please describe your changes on the following line: -->
Add the target pseudo selector and set/unset it during scrolling to fragment. This change is not complete as no repaint is triggered after the selector is added - it will only take effect after a repaint is triggered by e.g. hovering over another element. (See manual test)

I would like some help because i'm not sure how to resolve this; I can only think to call window.reflow.

I added a manual test case, don't think this counts really! I think the applicable automated test is in /tests/wpt/web-platform-tests/dom/nodes/Element-matches.html but it currently fails, I think due to the above.

---
<!-- 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 #7720  (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11726)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

💔 Test failed - mac-rel-css

@highfive
Copy link

highfive commented Aug 3, 2016

  ▶ TIMEOUT [expected PASS] /css21_dev/html4/colors-005.htm

  ▶ TIMEOUT [expected PASS] /css21_dev/html4/colors-006.htm
@jdm
Copy link
Member

jdm commented Aug 3, 2016

bors-servo added a commit that referenced this pull request Aug 3, 2016
Issue 7720: Add target selector and update when scrolling to fragment

<!-- Please describe your changes on the following line: -->
Add the target pseudo selector and set/unset it during scrolling to fragment. This change is not complete as no repaint is triggered after the selector is added - it will only take effect after a repaint is triggered by e.g. hovering over another element. (See manual test)

I would like some help because i'm not sure how to resolve this; I can only think to call window.reflow.

I added a manual test case, don't think this counts really! I think the applicable automated test is in /tests/wpt/web-platform-tests/dom/nodes/Element-matches.html but it currently fails, I think due to the above.

---
<!-- 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 #7720  (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11726)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

Testing commit 04f5369 with merge 71fa006...

@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

💔 Test failed - mac-rel-wpt

@emilio
Copy link
Member

emilio commented Aug 3, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

Testing commit 04f5369 with merge 7a7bdf5...

bors-servo added a commit that referenced this pull request Aug 3, 2016
Issue 7720: Add target selector and update when scrolling to fragment

<!-- Please describe your changes on the following line: -->
Add the target pseudo selector and set/unset it during scrolling to fragment. This change is not complete as no repaint is triggered after the selector is added - it will only take effect after a repaint is triggered by e.g. hovering over another element. (See manual test)

I would like some help because i'm not sure how to resolve this; I can only think to call window.reflow.

I added a manual test case, don't think this counts really! I think the applicable automated test is in /tests/wpt/web-platform-tests/dom/nodes/Element-matches.html but it currently fails, I think due to the above.

---
<!-- 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 #7720  (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11726)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 3, 2016

@bors-servo bors-servo merged commit 04f5369 into servo:master Aug 3, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

You can’t perform that action at this time.