Skip to content

[css-cascade-5] Cascade Layers need CSSOM support #6576

Closed

Description

@anttijk

CSSLayerRule interface needs to be specified.

Activity

  1. assigned and unassigned on Sep 3, 2021
  2. xiaochengh commented on Sep 3, 2021

    @xiaochengh
    Contributor

    This is not entirely trivial. Since we have two types of @layer rules, the empty statement and the block rule, do we want the same interface for both of them, or different interfaces?

    I don't have a strong preference. Just putting the options here for discussion.


    If we use different interfaces, the following seems pretty straightforward:

    [Exposed=Window]
    interface CSSLayerStatementRule : CSSRule {
      readonly attribute CSSOMString names;
    };
    
    [Exposed=Window]
    interface CSSLayerBlockRule : CSSGroupingRule {
      readonly attribute CSSOMString name; // empty string for anonymous layer
    };

    If we use the same interface, it would probably be like

    [Exposed=Window]
    interface CSSLayerRule : CSSGroupingRule {
      readonly attribute CSSOMString name;
      readonly attribute boolean isEmptyStatement;
    
      unsigned long insertRule(CSSOMString rule, optional unsigned long index = 0); // Is this the correct syntax for override?
    };

    We need to override CSSGroupingRule.insertRule() so that it throws an exception when called on empty statements.

  3. tabatkins commented on Sep 3, 2021

    @tabatkins
    Member

    I think we should make them separate objects, since they have quite distinct data models - one vs N names, child rules vs not. They're the same name for authoring convenience, but that doesn't need to translate to them being the same object type.

  4. emilio commented on Sep 3, 2021

    @emilio
    Collaborator

    I'd prefer not having two interfaces for this, fwiw... Also, for the @layer a, b, c; case we need a sequence of names, not just one name, right?

  5. tabatkins commented on Sep 3, 2021

    @tabatkins
    Member

    Yup, that's what I meant by "one vs N names". @xiaochengh's example supports that, it just exposes the N names as a single CSSOMString rather than as a list of them.

  6. anttijk commented on Sep 4, 2021

    @anttijk
    Author

    Having two separate interfaces might actually make sense as there is nothing that can be shared.

    CSSImportRule also needs an extension.

  7. emilio commented on Sep 4, 2021

    @emilio
    Collaborator

    Yeah, I guess that's fine / alright, specially given we've given up on making CSSRule.type return something meaningful for these.

  8. anttijk commented on Sep 4, 2021

    @anttijk
    Author

    On the other hand these interfaces are pretty useless anyway so I'm equally fine with a generic object that exposes nothing but cssText and the tree structure.

  9. emilio commented on Sep 6, 2021

    @emilio
    Collaborator

    That'd be totally ok for me too.

  10. emilio commented on Sep 8, 2021

    @emilio
    Collaborator

    FYI. Not ideal, but I needed some OM support to make DevTools etc work in Firefox.

    What I did for now is implementing it as:

    interface CSSLayerRule : CSSGroupingRule {};
    

    Where cssRules will return null for statement layers. Again, probably not ideal, it was just the easiest to implement.

  11. 19 remaining items

  12. mirisuzanne commented on Nov 16, 2021

    @mirisuzanne
    Contributor

    @anttijk @xiaochengh @emilio let us know if the edits in 6e8482b satisfy the question here.

  13. foolip commented on Nov 22, 2021

    @foolip
    Member
  14. xiaochengh commented on Nov 22, 2021

    @xiaochengh
    Contributor

    b7c7a15 lgtm

  15. xiaochengh commented on Nov 24, 2021

    @xiaochengh
    Contributor

    Wait, there's one last thing missing: We need to be able to distinguish whether a CSSImportRule is unlayered or in an anonymous layer.

    How about making layerName nullable (readonly attribute CSSOMString? layerName;), so that it returns null when the rule is not layered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions