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

Recompute styles on viewport size change if they contain viewport percentages #9876

Merged
merged 1 commit into from Mar 19, 2016

Conversation

@mbrubeck
Copy link
Contributor

mbrubeck commented Mar 4, 2016

Fixes #8754. Depends on servo/rust-cssparser#99. r? @SimonSapin

Review on Reviewable

@highfive
Copy link

highfive commented Mar 4, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/selector_matching.rs, components/style/stylesheets.rs
@highfive
Copy link

highfive commented Mar 4, 2016

warning Warning warning

  • These commits modify style and script code, but no tests are modified. Please consider adding a test!
@@ -73,6 +73,7 @@ impl HTMLMetaElement {
rules: vec![CSSRule::Viewport(translated_rule)],
origin: Origin::Author,
media: None,
depends_on_viewport_size: true,

This comment has been minimized.

@mbrubeck

mbrubeck Mar 4, 2016

Author Contributor

On second thought, maybe this stylesheet (one that contains a generated @viewport rule) should have the flag set to false, since viewport constraints are already recalculated on resize and shouldn't require the whole page to be recomputed.

@mbrubeck mbrubeck force-pushed the mbrubeck:seen-viewport-percentages branch from 070b1fd to 88d9b65 Mar 4, 2016
@SimonSapin
Copy link
Member

SimonSapin commented Mar 18, 2016

The is_device_dirty bit causes Stylist::update to re-create the selector hash maps in Stylist in case some conditional rules (@media, @supports when we support it) start or stop applying. But this seems to be a lot more work than necessary for just updating the computed values of vh and vw units, which could be done by running cascade on elements again. (Since we don’t save the specified values for an element, intermediate result of cascade before to_computed_value.)

And the dirty_on_viewport_size_change bits are only effective if none of the stylesheets use vh/vw at all.

To sum up, I think that this PR is correct but that we can do better (possibly later in follow ups) to avoid no-op work. Maybe tracking which elements (rather than which stylesheets) are affected by vh/vw. (Though would have to "infect" subtrees, because of inheritance.)


Reviewed 3 of 3 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


components/style/selector_matching.rs, line 228 [r2] (raw file):
Is it possible to reach this code path without changing the viewport size (as used by vh/vw)? If so, this code might set the dirty bit more often than necessary.


Comments from the review on Reviewable.io

@mbrubeck mbrubeck force-pushed the mbrubeck:seen-viewport-percentages branch from 88d9b65 to 7cc42c3 Mar 19, 2016
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Mar 19, 2016

To sum up, I think that this PR is correct but that we can do better (possibly later in follow ups) to avoid no-op work. Maybe tracking which elements (rather than which stylesheets) are affected by vh/vw.

Yes, I agree.


Review status: 2 of 3 files reviewed at latest revision, 2 unresolved discussions.


components/style/selector_matching.rs, line 228 [r2] (raw file):
It is possible. I've added a check to fix this.


Comments from the review on Reviewable.io

@SimonSapin
Copy link
Member

SimonSapin commented Mar 19, 2016

r=me, pending servo/rust-cssparser#99


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from the review on Reviewable.io

@mbrubeck mbrubeck force-pushed the mbrubeck:seen-viewport-percentages branch 2 times, most recently from d3d424d to f4598fc Mar 19, 2016
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Mar 19, 2016

@bors-servo r=SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

📌 Commit f4598fc has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

Testing commit f4598fc with merge fb375d5...

bors-servo added a commit that referenced this pull request Mar 19, 2016
Recompute styles on viewport size change if they contain viewport percentages

Fixes #8754.  Depends on servo/rust-cssparser#99.  r? @SimonSapin

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9876)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

💔 Test failed - linux-dev

@SimonSapin
Copy link
Member

SimonSapin commented Mar 19, 2016

/home/servo/buildbot/slave/linux-dev/build/tests/unit/style/stylesheets.rs:29:28: 143:6 error: missing field `dirty_on_viewport_size_change` in initializer of `style::stylesheets::Stylesheet<style::selector_impl::ServoSelectorImpl>` [E0063]
/home/servo/buildbot/slave/linux-dev/build/tests/unit/style/stylesheets.rs: 29     assert_eq!(stylesheet, Stylesheet {
@mbrubeck mbrubeck force-pushed the mbrubeck:seen-viewport-percentages branch from f4598fc to 25c1bce Mar 19, 2016
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Mar 19, 2016

@bors-servo r=SimonSapin

fixed the unit test error

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

📌 Commit 25c1bce has been approved by SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

Testing commit 25c1bce with merge a4251c8...

bors-servo added a commit that referenced this pull request Mar 19, 2016
Recompute styles on viewport size change if they contain viewport percentages

Fixes #8754.  Depends on servo/rust-cssparser#99.  r? @SimonSapin

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9876)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

@bors-servo bors-servo merged commit 25c1bce into servo:master Mar 19, 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
mbrubeck added a commit to mbrubeck/servo that referenced this pull request Mar 21, 2016
This is a follow-up to servo#9876.  It avoids clearing and rebuilding SelectorMaps
when vh and vw units need to be recomputed. Instead it just dirties all nodes,
to force elements to be re-cascaded.

Filed servo#10104 for later follow-up work to dirty only affected nodes.
bors-servo added a commit that referenced this pull request Mar 22, 2016
Don't re-add stylesheets to recompute vw/vh lengths

This is a follow-up to #9876.  It avoids clearing and rebuilding SelectorMaps
when vh and vw units need to be recomputed. Instead it just dirties all nodes,
to force elements to be re-cascaded.

Filed #10104 for later follow-up work to dirty only affected nodes.

r? @SimonSapin

<!-- 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/10105)
<!-- Reviewable:end -->
tyagiarpit added a commit to tyagiarpit/servo that referenced this pull request Mar 23, 2016
This is a follow-up to servo#9876.  It avoids clearing and rebuilding SelectorMaps
when vh and vw units need to be recomputed. Instead it just dirties all nodes,
to force elements to be re-cascaded.

Filed servo#10104 for later follow-up work to dirty only affected nodes.
@mbrubeck mbrubeck deleted the mbrubeck:seen-viewport-percentages branch May 11, 2016
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.

None yet

4 participants
You can’t perform that action at this time.