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

vh and vw units are not recalculated after window resize #8754

Closed
gordonbrander opened this issue Nov 30, 2015 · 6 comments
Closed

vh and vw units are not recalculated after window resize #8754

gordonbrander opened this issue Nov 30, 2015 · 6 comments
Assignees
Labels
A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-layout/uncategorized

Comments

@gordonbrander
Copy link

vh and vw units are not recalculated after a window resize. Here's a minimal test case.

screen shot 2015-11-30 at 11 49 40

- This issue is present in both normal and "browser.html" modes. - This issue is **not** present with percentage-based sizes ([test case](https://gordonbrander.github.io/servo-testcases/resize-percent/))
@gordonbrander
Copy link
Author

As might be expected, this is also affecting the positioning of child elements (test case).

screen shot 2015-11-30 at 12 40 23

gordonbrander added a commit to gordonbrander/browser.html that referenced this issue Nov 30, 2015
gordonbrander added a commit to gordonbrander/browser.html that referenced this issue Nov 30, 2015
gordonbrander added a commit to gordonbrander/browser.html that referenced this issue Nov 30, 2015
@mbrubeck mbrubeck added the A-content/css Interacting with CSS from web content (parsing, serializing, introspection) label Dec 1, 2015
@mbrubeck
Copy link
Contributor

mbrubeck commented Dec 1, 2015

Currently Stylist::set_device sets its is_device_dirty flag on resize if any stylesheet contains an @media query that is affected by the resize. We could fix this by also checking if any stylesheet contains a rule with a vh or vw value, and setting the same dirty flag.

This is_device_dirty flag causes all stylesheets to be re-added to the document and all nodes to be dirtied by the layout task. We could possibly do something smarter to dirty only the nodes affected by the rule containing the vh or vw value.

@mbrubeck
Copy link
Contributor

mbrubeck commented Dec 3, 2015

Alternately we could change the types likecomputed::LengthOrPercentageOrAuto preserve the viewport units, so they can be converted to an absolute length at layout time (like percentages are) rather than at cascade time (like they are currently).

@SimonSapin
Copy link
Member

I’d rather not do that. It would add significant complexity everywhere in the layout code: when accessing any length from the style system, any piece of layout code would need to also have access to the viewport size and call something to resolve to an absolute length.

@mbrubeck
Copy link
Contributor

mbrubeck commented Dec 3, 2015

It would add significant complexity everywhere in the layout code: when accessing any length from the style system, any piece of layout code would need to also have access to the viewport size…

Layout code can access the viewport size pretty easily because it's part of the LayoutContext, which we already thread through all of the layout traversals.

…and call something to resolve to an absolute length.

We need to do this anyway because of percentage lengths.

@SimonSapin
Copy link
Member

Not every <length> can be a <percentage> (for example border width) but every length can have viewport units.

This also deviates from the spec, and although I haven’t managed to come up with a case where the difference is observable I don’t know if they don’t exist. (The computed value is what’s inherited, and any property can take the value inherit).

@mbrubeck mbrubeck self-assigned this Mar 4, 2016
mbrubeck added a commit to mbrubeck/rust-cssparser that referenced this issue Mar 4, 2016
Used to tell Servo to recalulate styles on window resize (servo/servo#8754).
mbrubeck added a commit to mbrubeck/servo that referenced this issue Mar 4, 2016
mbrubeck added a commit to mbrubeck/servo that referenced this issue Mar 4, 2016
mbrubeck added a commit to mbrubeck/rust-cssparser that referenced this issue Mar 18, 2016
Used to tell Servo to recalulate styles on window resize (servo/servo#8754).
mbrubeck added a commit to mbrubeck/servo that referenced this issue Mar 19, 2016
bors-servo pushed a commit to servo/rust-cssparser that referenced this issue Mar 19, 2016
Record whether viewport percentage dimensions are seen

Used to tell Servo to recalulate styles on window resize (servo/servo#8754).

r? @SimonSapin

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/99)
<!-- Reviewable:end -->
mbrubeck added a commit to mbrubeck/servo that referenced this issue Mar 19, 2016
mbrubeck added a commit to mbrubeck/servo that referenced this issue Mar 19, 2016
bors-servo pushed a commit that referenced this issue 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 -->
mbrubeck added a commit to mbrubeck/servo that referenced this issue Mar 19, 2016
bors-servo pushed a commit that referenced this issue 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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/css Interacting with CSS from web content (parsing, serializing, introspection) A-layout/uncategorized
Projects
None yet
Development

No branches or pull requests

5 participants