Skip to content

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

Merged
bors-servo merged 1 commit into
servo:masterfrom
mbrubeck:seen-viewport-percentages
Mar 19, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
mbrubeck:seen-viewport-percentages

Conversation

@mbrubeck

@mbrubeck mbrubeck commented Mar 4, 2016

Copy link
Copy Markdown
Contributor

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

Review on Reviewable

@highfive

highfive commented Mar 4, 2016

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

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

@highfive

highfive commented Mar 4, 2016

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style and script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 4, 2016
@mbrubeck mbrubeck added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Mar 4, 2016
rules: vec![CSSRule::Viewport(translated_rule)],
origin: Origin::Author,
media: None,
depends_on_viewport_size: true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 seen-viewport-percentages branch from 070b1fd to 88d9b65 Compare March 4, 2016 22:37
@SimonSapin

Copy link
Copy Markdown
Member

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 seen-viewport-percentages branch from 88d9b65 to 7cc42c3 Compare March 19, 2016 00:00
@mbrubeck

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

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 seen-viewport-percentages branch 2 times, most recently from d3d424d to f4598fc Compare March 19, 2016 18:48
@mbrubeck

Copy link
Copy Markdown
Contributor Author

@bors-servo r=SimonSapin

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit f4598fc has been approved by SimonSapin

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 19, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit f4598fc with merge fb375d5...

bors-servo pushed a commit that referenced this pull request Mar 19, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-dev

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Mar 19, 2016
@SimonSapin

Copy link
Copy Markdown
Member
/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 seen-viewport-percentages branch from f4598fc to 25c1bce Compare March 19, 2016 20:23
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Mar 19, 2016
@mbrubeck

Copy link
Copy Markdown
Contributor Author

@bors-servo r=SimonSapin

fixed the unit test error

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 25c1bce has been approved by SimonSapin

@highfive highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Mar 19, 2016
@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 19, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 25c1bce with merge a4251c8...

bors-servo pushed a commit that referenced this pull request Mar 19, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor

@bors-servo
bors-servo merged commit 25c1bce into servo:master Mar 19, 2016
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 pushed 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 -->
@mbrubeck
mbrubeck deleted the seen-viewport-percentages branch May 11, 2016 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants