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

Conversation

weinig
Copy link
Contributor

@weinig weinig commented Dec 18, 2022

229a3a2

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

a29649e

Misc iOS, tvOS & watchOS macOS Linux Windows
❌ πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ webkitpy ❌ πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim

@weinig weinig self-assigned this Dec 18, 2022
@weinig weinig added the CSS Cascading Style Sheets implementation label Dec 18, 2022
@weinig weinig requested a review from anttijk December 18, 2022 22:01
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 18, 2022
@weinig weinig removed the merging-blocked Applied to prevent a change from being merged label Dec 19, 2022
@weinig weinig force-pushed the eng/Split-descriptors-out-of-properties-dictionary-in-CSSProperties-json branch from 3aa5d12 to bd465e7 Compare December 19, 2022 02:45
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 19, 2022
@weinig weinig removed the merging-blocked Applied to prevent a change from being merged label Dec 19, 2022
@weinig weinig force-pushed the eng/Split-descriptors-out-of-properties-dictionary-in-CSSProperties-json branch from bd465e7 to d23b9ea Compare December 19, 2022 03:18
@weinig weinig force-pushed the eng/Split-descriptors-out-of-properties-dictionary-in-CSSProperties-json branch from d23b9ea to a29649e Compare December 19, 2022 14:37
@weinig
Copy link
Contributor Author

weinig commented Dec 19, 2022

Ready to rock and roll.

"inherits": {
"codegen-properties": {
"settings-flag": "cssCustomPropertiesAndValuesEnabled",
"parser-grammar": "true | false"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@weinig weinig added the merge-queue Applied to send a pull request to merge-queue label Dec 19, 2022
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
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Split-descriptors-out-of-properties-dictionary-in-CSSProperties-json branch from a29649e to 229a3a2 Compare December 19, 2022 19:31
@webkit-commit-queue
Copy link
Collaborator

Committed 258084@main (229a3a2): https://commits.webkit.org/258084@main

Reviewed commits have been landed. Closing PR #7832 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 229a3a2 into WebKit:main Dec 19, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Cascading Style Sheets implementation
Projects
None yet
5 participants