Skip to content

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

Closed

Description

@gordonbrander

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/))

Activity

  1. gordonbrander commented on Nov 30, 2015

    @gordonbrander
    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

  2. added
    A-content/css
    on Dec 1, 2015
  3. mbrubeck commented on Dec 1, 2015

    @mbrubeck
    Contributor

    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.

  4. mbrubeck commented on Dec 3, 2015

    @mbrubeck
    Contributor

    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).

  5. SimonSapin commented on Dec 3, 2015

    @SimonSapin
    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.

  6. mbrubeck commented on Dec 3, 2015

    @mbrubeck
    Contributor

    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.

  7. SimonSapin commented on Dec 3, 2015

    @SimonSapin
    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).

  8. self-assigned this
    on Mar 4, 2016
  9. added a commit that references this issue on Mar 19, 2016
  10. added 2 commits that reference this issue on Mar 19, 2016
    d3d424d
    f4598fc
  11. added a commit that references this issue on Mar 19, 2016
    fb375d5
  12. added a commit that references this issue on Mar 19, 2016
    25c1bce
  13. added a commit that references this issue on Mar 19, 2016
    a4251c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-content/cssA-layout/uncategorized

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions