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

Implement CSS Properties & Values API in Servo. #18167

Closed
wants to merge 13 commits into from
Closed

Implement CSS Properties & Values API in Servo. #18167

wants to merge 13 commits into from

Commits on Aug 23, 2017

  1. style: Refine custom_properties::parse_name; disallow extra tokens.

    Part 1 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  2. resources: Add a pref for CSS Properties & Values API.

    The pref is layout.css.properties-and-values.enabled, and it currently
    defaults to false. Future patches in this series will add code that uses
    this pref.
    
    Part 2 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  3. script: Add WebIDL and stubs for CSS.(un)registerProperty.

    Part 3 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  4. style: Expose transform::SpecifiedValue's internals.

    A later patch in this series will use this when to inspect transform
    values for typed custom properties.
    
    Part 4 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  5. style: Add/refactor types of custom_properties for Properties & Values.

    Add a new ExtraData enum. We carry it along with a custom property's
    specified value in order to compute it, if it ends up being registered
    as being able to contain URLs through Properties & Values. When the
    specified value comes from a declaration, we keep track of the
    associated UrlExtraData in the Specified variant. However, specified
    values will also (implemented by a later patch in this series) be able
    to come from animations: in that case we are able to carry along a copy
    of the computed value in the Precomputed variant, to save us from
    recomputation and also to save us from having to re-resolve the URL.
    
    Add a new BorrowedExtraData enum, which is used for
    BorrowedSpecifiedValues. We use BorrowedSpecifiedValues when resolving
    custom properties; in the case that we inherit an untyped custom
    property, we create one from its computed value, which is a token
    stream. In this case we don't have a UrlExtraData or (Properties &
    Values) ComputedValue to compute with, and in fact we don't want to
    perform any computation. The BorrowedExtraData enum thus has an
    additional InheritedUntyped variant for that case.
    
    Pull out the css, first_token_type, and last_token_type fields of
    SpecifiedValue, BorrowedSpecifiedValue, and ComputedValue into a
    TokenStream struct (ComptuedValue then becomes a type alias of
    TokenStream). We'll use the TokenStream to store computed token stream
    values for typed custom properties: it wouldn't make sense to use
    SpecifiedValue because we have no need of the additional information
    (and that would also lead to properties_and_values::ComputedValue
    containing a SpecifiedValue which contains an ExtraData which may
    contain a properties_and_values::ComputedValue, which the compiler does
    not like).
    
    The properties_and_values module is addded by a later patch in this
    series, so we omit the Precomputed variant for now.
    
    Part 5 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  6. style: Add a properties_and_values module for CSS Properties & Values.

    Typed custom properties are exactly the same as regular custom
    properties except when it comes to inheritance, computed values, and
    animation, so this module is intended to be as independent from
    custom_properties as possible (they do use types from each other,
    though, where it would be clumsy to do otherwise).
    
    This commit doesn't hook up the module to anything: that's handled by
    later patches in this series.
    
    Part 6 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  7. script: Store typed custom property registrations on the document.

    CSS Properties & Values API says the set of registered properties should
    be associated with the document.
    
    Part 7 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  8. layout_thread, style: Add guard for the registered property set.

    Add a guard to StylesheetGuards for the RegisteredPropertySet.
    
    Part 8 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  9. layout_thread, style: Attach registered property set to the Stylist.

    We store a pointer to the registered property set on the Stylist because
    that seems to be the cleanest way to give access to it to all the
    functions that might need to cascade or compute typed custom properties.
    
    This also lets us use the Stylist's existing mechanism for determining
    we need to rebuild styles: if it last saw the registered property set
    with an older generation than the current generation, we should do
    things again.
    
    This is handled by the same path in layout_thread::lib as the device
    being dirtied or the stylesheets changing.
    
    Also update the comment on Stylist::rebuild, which appears not to have
    been updated when stylesheets_changed was replaced with
    origins_to_rebuild.
    
    Part 9 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  10. style: Fix comments in style::properties.

    "An CSS-wide keyword" should be "A CSS-wide keyword." Also, the
    PropertyDeclaration::Custom variant must not contain a
    DeclaredValueOwned::WithVariables variant: this is in fact already
    asserted in style::custom_properties::cascade.
    
    Part 10 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  11. style: Update cascade to take account of typed custom properties.

    We have to do some additional work to compute typed custom properties
    and to handle cyclical declarations involving font-size.
    
    (Unfortunately there doesn't seem to be a really good way to split this
    patch up without spending a ton of effort, and I don't think it'd make
    the patch more clear. Sorry!)
    
    Make custom_properties::OrderedMap::remove public, so that we can remove
    cyclical custom property declarations from properties. We also need to
    insert the initial value (possibly typed) if necessary and detect if
    font size is cyclical and remove it in that case, so it makes sense to
    handle them in the same place instead of custom_properties mutating
    things behind the scenes and making it worry about typed custom
    properties.
    
    custom_properties::cascade takes two function arguments,
    inherited_computed and handle_keyword. This allows us to maintain
    separation of concerns wrt typed custom property registrations (also
    makes it clearer who is getting data from where).
    
    custom_properties::substitute_all and custom_properties::substitute_one
    gains function arguments compute handle_invalid with the same
    justification.
    
    custom_properties::finish_cascade is replaced by
    custom_properties::compute_ordering, which computes whether or not
    font-size's declaration is cycles, the custom properties to compute before
    early properties (including those upon which early properties depend),
    and the set of properties that are cyclical.
    
    Fix the comment on substitute, which does not type.
    
    Have Gecko's ComputedValuesInner::get_custom_properties return a
    properties_and_values::CustomPropertiesMap instead of a
    custom_properties::CustomPropertiesMap. This stores typed computed
    values as well.
    
    Replace Servo's Stylist::custom_properties with
    get_custom_properties, which returns a reference instead of an Arc,
    because it doesn't make sense to clone the Arc when we never need it as
    one. Also add get_parent_custom_properties, so a later patch in the
    series can inherit typed custom property values.
    
    Note that this also requires a change to ServoBindings.toml to account
    for replacing custom_properties::CustomPropertiesMap with
    properties_and_values::CustomPropertiesMap.
    
    Part 11 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  12. script: Implement CSS.(un)registerProperty.

    Part 12 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
  13. tests: Add tests for CSS Properties & Values API.

    Some disabled tests:
    - We don't implement <transform-list> serialization.
    - We don't serialize colors according to spec & as Gecko does.
    - We don't round floats correctly (see rust-cssparser/#173).
    - We don't implement <resolution>.
    
    It's not clear whether or not we actually need initialValue (see css-houdini-drafts/#286).
    
    Part 13 of a series of patches to implement the CSS Properties & Values API.
    jyc committed Aug 23, 2017
You can’t perform that action at this time.