You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vh and vw units are not recalculated after window resize #8754
vh and vw units are not recalculated after a window resize. Here's a minimal test case.
- 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/))
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.
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).
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.
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.
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).
Activity
gordonbrander commentedon Nov 30, 2015
As might be expected, this is also affecting the positioning of child elements (test case).
Workaround vw/vh resizing issue in Servo
Workaround lack of vh/vw resizing for body, html
Further workarounds for servo/#8754
mbrubeck commentedon Dec 1, 2015
Currently Stylist::set_device sets its
is_device_dirtyflag on resize if any stylesheet contains an@mediaquery that is affected by the resize. We could fix this by also checking if any stylesheet contains a rule with avhorvwvalue, and setting the same dirty flag.This
is_device_dirtyflag 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 thevhorvwvalue.mbrubeck commentedon Dec 3, 2015
Alternately we could change the types like
computed::LengthOrPercentageOrAutopreserve 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 commentedon Dec 3, 2015
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 commentedon Dec 3, 2015
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.
We need to do this anyway because of percentage lengths.
SimonSapin commentedon Dec 3, 2015
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).Record whether viewport percentage dimensions are seen
Recompute viewport-dependent styles on viewport size change
Recompute viewport-dependent styles on viewport size change
Record whether viewport percentage dimensions are seen
Recompute viewport-dependent styles on viewport size change
Auto merge of #99 - mbrubeck:seen-viewport-percentages, r=SimonSapin
Recompute viewport-dependent styles on viewport size change
Recompute viewport-dependent styles on viewport size change
Auto merge of #9876 - mbrubeck:seen-viewport-percentages, r=SimonSapin
Recompute viewport-dependent styles on viewport size change
Auto merge of #9876 - mbrubeck:seen-viewport-percentages, r=SimonSapin
Record whether viewport percentage dimensions are seen
Auto merge of #99 - mbrubeck:seen-viewport-percentages, r=SimonSapin