Skip to content

Stylist::set_device shoud check stylesheet media queries #14279

@SimonSapin

Description

@SimonSapin

In components/style/selector_matching.rs, the set_device method of Stylist recursively finds @media rules inside stylesheets and checks if the evaluation of any media query has changed. But stylesheets can also have media queries (for example <style media="(min-width: 400px)">…</style>) and these are currently not checked. This MQ is stored in the media attribute of the Stylesheet struct.

Before fixing this, it would be best to write a test that is currently buggy. On way to do this might be to have an iframe whose width changes, and have JS code inside it that uses getComputedStyle before and after the change to observe the value of some property affected by a stylesheet media query. With selector_matching.rs as in current master, the value after should be the same as before because style has not be recomputed when it should have. Changing selector_matching.rs to check stylesheet.media should fix that bug and make the test pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/cssInteracting with CSS from web content (parsing, serializing, introspection)C-assignedThere is someone working on resolving the issueC-has-open-prThere is a PR open that resolves the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the issI-wrongAn incorrect behaviour is observed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions