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

Split descriptors out of properties dictionary in CSSProperties.json #7832

Commits on Dec 19, 2022

  1. Split descriptors out of properties dictionary in CSSProperties.json

    https://bugs.webkit.org/show_bug.cgi?id=249558
    rdar://103497902
    
    Reviewed by Antti Koivisto.
    
    Adds a new top level object to CSSProperties.json, "descriptors", which contains
    mappings from CSS rule types (e.g. @font-face, @counter-style) to a map of the
    descriptors that rule type supports. This allows us to remove the 'descriptor-only'
    properties from the main 'properties' map, and also accurately specify the
    descriptors that shared names with properties. This is important as some descriptors
    share a name with a property but have different grammars.
    
    With the new data in CSSProperties.json, we now generate parse functions for
    the new rule types specified: @counter-style, @font-face, @font-palette-values.
    and @Property. While not too many of the descriptors can be generated right now,
    the main "parse...Descriptor" functions can be, and this adds the foundation for
    generating more as we add more capabilities to the parser.
    
    To differentiate between style properties and descriptors when exporting consumer
    functions, descriptors have a prefix based on their rule type added. For example,
    @font-face defines a "font-display" descriptor, which is needed elsewhere, so we
    export a function called `CSSPropertyParsing::consumeFontFaceFontDisplay()`.
    
    * Source/WebCore/css/CSSProperties.json:
    Move/copy descriptors to new section. Remove support for descriptor-only now
    that it can be inferred.
    
    * Source/WebCore/css/parser/CSSParserFastPaths.cpp:
    (WebCore::CSSParserFastPaths::isKeywordValidForStyleProperty):
    (WebCore::CSSParserFastPaths::isKeywordFastPathEligibleStyleProperty):
    (WebCore::parseKeywordValue):
    (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue): Deleted.
    (WebCore::CSSParserFastPaths::isKeywordPropertyID): Deleted.
    * Source/WebCore/css/parser/CSSParserFastPaths.h:
    Update for more precise names that differentiate between properties
    and descriptors.
    
    * Source/WebCore/css/parser/CSSPropertyParser.cpp:
    (WebCore::CSSPropertyParser::parseValue):
    Remove unnecessary passing of the CSSParserContext to a member
    function. It can access it via *this.
    
    (WebCore::CSSPropertyParser::parseSingleValue):
    Update for rename from parse() to parseStyleProperty().
    
    (WebCore::CSSPropertyParser::parseCounterStyleDescriptor):
    (WebCore::CSSPropertyParser::parseFontFaceDescriptor):
    (WebCore::CSSPropertyParser::parseFontFaceDescriptorShorthand):
    (WebCore::CSSPropertyParser::parseFontPaletteValuesDescriptor):
    Call through to the new generated parsers.
    
    (WebCore::consumeCounterStyleSystem): Deleted.
    (WebCore::consumeCounterStyleSymbol): Deleted.
    (WebCore::consumeCounterStyleNegative): Deleted.
    (WebCore::consumeCounterStyleRangeBound): Deleted.
    (WebCore::consumeCounterStyleRange): Deleted.
    (WebCore::consumeCounterStylePad): Deleted.
    (WebCore::consumeCounterStyleSymbols): Deleted.
    (WebCore::consumeCounterStyleAdditiveSymbols): Deleted.
    (WebCore::consumeCounterStyleSpeakAs): Deleted.
    (WebCore::consumeBasePaletteDescriptor): Deleted.
    (WebCore::consumeOverrideColorsDescriptor): Deleted.
    Moved to CSSPropertyParserHelpers.cpp for consistency.
    
    * Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
    (WebCore::CSSPropertyParserHelpers::consumeBackgroundSize):
    (WebCore::CSSPropertyParserHelpers::consumeFontFaceFontFamily):
    (WebCore::CSSPropertyParserHelpers::consumeFontPaletteValuesOverrideColors):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleSystem):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleSymbol):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleNegative):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleRangeBound):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleRange):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStylePad):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleSymbols):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleAdditiveSymbols):
    (WebCore::CSSPropertyParserHelpers::consumeCounterStyleSpeakAs):
    (WebCore::CSSPropertyParserHelpers::consumeFontFamilyDescriptor): Deleted.
    * Source/WebCore/css/parser/CSSPropertyParserHelpers.h:
    Moved functions from CSSPropertyParser. Renamed consumeFontFamilyDescriptor
    to consumeFontFaceFontFamily to better align with naming convention.
    
    * Source/WebCore/css/process-css-properties.py:
    Adds support for the new 'descriptors' top level object and generalizes
    parser code generation to support them.
    
    * Source/WebCore/inspector/agents/InspectorCSSAgent.cpp:
    (WebCore::InspectorCSSAgent::getSupportedCSSProperties):
    Update for renames.
    
    * Tools/Scripts/webkitpy/style/checkers/jsonchecker.py:
    Add checker support for the new sections. Remove support for descriptor-only.
    
    Canonical link: https://commits.webkit.org/258084@main
    weinig authored and Sam Weinig committed Dec 19, 2022
    Configuration menu
    Copy the full SHA
    229a3a2 View commit details
    Browse the repository at this point in the history