[webkit-changes] [WebKit/WebKit] 229a3a: Split descriptors out of properties dictionary in ...

Sam Weinig noreply at github.com
Mon Dec 19 11:31:50 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 229a3a2d8a276a217a5fb2b3910a12edd3d78d02
      https://github.com/WebKit/WebKit/commit/229a3a2d8a276a217a5fb2b3910a12edd3d78d02
  Author: Sam Weinig <weinig at apple.com>
  Date:   2022-12-19 (Mon, 19 Dec 2022)

  Changed paths:
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/parser/CSSParserFastPaths.cpp
    M Source/WebCore/css/parser/CSSParserFastPaths.h
    M Source/WebCore/css/parser/CSSPropertyParser.cpp
    M Source/WebCore/css/parser/CSSPropertyParser.h
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.h
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp
    M Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.h
    M Source/WebCore/css/process-css-properties.py
    M Source/WebCore/inspector/agents/InspectorCSSAgent.cpp
    M Tools/Scripts/webkitpy/style/checkers/jsonchecker.py

  Log Message:
  -----------
  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




More information about the webkit-changes mailing list