Title: [278985] trunk
Revision
278985
Author
obru...@igalia.com
Date
2021-06-17 06:13:49 -0700 (Thu, 17 Jun 2021)

Log Message

[css-logical] Implement logical property groups
https://bugs.webkit.org/show_bug.cgi?id=226878

Reviewed by Antti Koivisto.

Source/WebCore:

In order to have proper CSSOM support for logical properties, we will
need to determine whether two properties belong to the same logical
property group but with a different mapping logic.

Before this patch, we only knew the physical properties belonging to the
same logical property group as a given logical property. But given a
physical property, we didn't know if there were logical properties that
could map to it.

Therefore this patch changes CSSProperties.json so that both logical and
physical properties specify their logical property group.

The code for resolving a logical property into its physical equivalent
is now automatically generated.

The CSSOM fix will be done in a follow-up (bug 226461).

This patch introduces no behavior changes.

* css/CSSProperties.json:
* css/CSSProperty.cpp:
* css/makeprop.pl:
(nameToId):
(addProperty):
* platform/RectEdges.h:
(WebCore::RectEdges::before):
(WebCore::RectEdges::after):
(WebCore::RectEdges::start):
(WebCore::RectEdges::end):
(WebCore::RectEdges::before const):
(WebCore::RectEdges::after const):
(WebCore::RectEdges::start const):
(WebCore::RectEdges::end const):
* platform/text/WritingMode.h:
(WebCore::mapLogicalAxisToPhysicalAxis):

Tools:

Add validator for new codegen property "logical-property-group",
replacing the old "direction-aware-property".

* Scripts/webkitpy/style/checkers/jsonchecker.py:
(JSONCSSPropertiesChecker.validate_logical_property_group):
(JSONCSSPropertiesChecker.check_codegen_properties):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (278984 => 278985)


--- trunk/Source/WebCore/ChangeLog	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Source/WebCore/ChangeLog	2021-06-17 13:13:49 UTC (rev 278985)
@@ -1,3 +1,46 @@
+2021-06-17  Oriol Brufau  <obru...@igalia.com>
+
+        [css-logical] Implement logical property groups
+        https://bugs.webkit.org/show_bug.cgi?id=226878
+
+        Reviewed by Antti Koivisto.
+
+        In order to have proper CSSOM support for logical properties, we will
+        need to determine whether two properties belong to the same logical
+        property group but with a different mapping logic.
+
+        Before this patch, we only knew the physical properties belonging to the
+        same logical property group as a given logical property. But given a
+        physical property, we didn't know if there were logical properties that
+        could map to it.
+
+        Therefore this patch changes CSSProperties.json so that both logical and
+        physical properties specify their logical property group.
+
+        The code for resolving a logical property into its physical equivalent
+        is now automatically generated.
+
+        The CSSOM fix will be done in a follow-up (bug 226461).
+
+        This patch introduces no behavior changes.
+
+        * css/CSSProperties.json:
+        * css/CSSProperty.cpp:
+        * css/makeprop.pl:
+        (nameToId):
+        (addProperty):
+        * platform/RectEdges.h:
+        (WebCore::RectEdges::before):
+        (WebCore::RectEdges::after):
+        (WebCore::RectEdges::start):
+        (WebCore::RectEdges::end):
+        (WebCore::RectEdges::before const):
+        (WebCore::RectEdges::after const):
+        (WebCore::RectEdges::start const):
+        (WebCore::RectEdges::end const):
+        * platform/text/WritingMode.h:
+        (WebCore::mapLogicalAxisToPhysicalAxis):
+
 2021-06-17  Enrique Ocaña González  <eoca...@igalia.com>
 
         [GStreamer] Refactor MediaPlayerPrivateGStreamer::notifyPlayerOf*

Modified: trunk/Source/WebCore/css/CSSProperties.json (278984 => 278985)


--- trunk/Source/WebCore/css/CSSProperties.json	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Source/WebCore/css/CSSProperties.json	2021-06-17 13:13:49 UTC (rev 278985)
@@ -92,9 +92,21 @@
         "Indicates that this CSS property is color-related (populates",
         "CSSProperty::isColorProperty().",
         "",
-        "* direction-aware-property:",
-        "Indicates that this CSS property is direction aware (populates.",
-        "CSSProperty::isDirectionAwareProperty().",
+        "* logical-property-group:",
+        "Indicates that this CSS property belongs to a logical property group",
+        "(https://drafts.csswg.org/css-logical/#logical-property-group)",
+        "This is used for both logical properties that depend on writing-mode",
+        "and/or text-direction (for which CSSProperty::isDirectionAwareProperty()",
+        "returns true), and also for their physical counterparts.",
+        "If set, the value must be an object with these properties:",
+        " - name: a string identifying the logical property group. All logical",
+        "   and physical properties in the same group should have the same name.",
+        "   Examples: \"border-radius\", \"margin\", \"min-size\".",
+        " - resolver: a string with the mapping that will be used to convert to",
+        "   the equivalent physical or logical property within the same group.",
+        "   Also identifies the mapping logic of the group",
+        "   (https://drafts.csswg.org/css-logical-1/#mapping-logic).",
+        "   Examples: \"top-left\", \"block-start\", \"horizontal\".",
         "",
         "* descriptor-only:",
         "Indicates that this CSS property is descriptor only (populates.",
@@ -1223,7 +1235,10 @@
                     "-webkit-logical-height"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "size",
+                    "resolver": "block"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1290,7 +1305,10 @@
                     "border-block-end-style",
                     "border-block-end-color"
                 ],
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1304,7 +1322,10 @@
                 ],
                 "skip-builder": true,
                 "color-property": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1329,7 +1350,10 @@
                     "-webkit-border-after-style"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1342,7 +1366,10 @@
                     "-webkit-border-after-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1359,7 +1386,10 @@
                     "border-block-start-style",
                     "border-block-start-color"
                 ],
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1373,7 +1403,10 @@
                 ],
                 "skip-builder": true,
                 "color-property": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1398,7 +1431,10 @@
                     "-webkit-border-before-style"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1411,7 +1447,10 @@
                     "-webkit-border-before-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1448,7 +1487,11 @@
                     "border-bottom-width",
                     "border-bottom-style",
                     "border-bottom-color"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1459,7 +1502,11 @@
             "codegen-properties": {
                 "initial": "currentColor",
                 "visited-link-color-support": true,
-                "color-property": true
+                "color-property": true,
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1472,7 +1519,11 @@
                     "-webkit-border-bottom-left-radius"
                 ],
                 "initial": "initialBorderRadius",
-                "custom": "Inherit|Value"
+                "custom": "Inherit|Value",
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "bottom-left"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1485,7 +1536,11 @@
                     "-webkit-border-bottom-right-radius"
                 ],
                 "initial": "initialBorderRadius",
-                "custom": "Inherit|Value"
+                "custom": "Inherit|Value",
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "bottom-right"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1506,7 +1561,11 @@
                 "double"
             ],
             "codegen-properties": {
-                "initial": "initialBorderStyle"
+                "initial": "initialBorderStyle",
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1516,7 +1575,11 @@
         "border-bottom-width": {
             "codegen-properties": {
                 "initial": "initialBorderWidth",
-                "converter": "LineWidth<float>"
+                "converter": "LineWidth<float>",
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1555,7 +1618,10 @@
         "border-end-end-radius": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "end-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1565,7 +1631,10 @@
         "border-end-start-radius": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "end-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1670,7 +1739,10 @@
                     "border-inline-end-style",
                     "border-inline-end-color"
                 ],
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1684,7 +1756,10 @@
                 ],
                 "skip-builder": true,
                 "color-property": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1709,7 +1784,10 @@
                     "-webkit-border-end-style"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1722,7 +1800,10 @@
                     "-webkit-border-end-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1739,7 +1820,10 @@
                     "border-inline-start-style",
                     "border-inline-start-color"
                 ],
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1753,7 +1837,10 @@
                 ],
                 "skip-builder": true,
                 "color-property": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1778,7 +1865,10 @@
                     "-webkit-border-start-style"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1791,7 +1881,10 @@
                     "-webkit-border-start-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1828,7 +1921,11 @@
                     "border-left-width",
                     "border-left-style",
                     "border-left-color"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1839,7 +1936,11 @@
             "codegen-properties": {
                 "initial": "currentColor",
                 "visited-link-color-support": true,
-                "color-property": true
+                "color-property": true,
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1860,7 +1961,11 @@
                 "double"
             ],
             "codegen-properties": {
-                "initial": "initialBorderStyle"
+                "initial": "initialBorderStyle",
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1870,7 +1975,11 @@
         "border-left-width": {
             "codegen-properties": {
                 "initial": "initialBorderWidth",
-                "converter": "LineWidth<float>"
+                "converter": "LineWidth<float>",
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1897,7 +2006,11 @@
                     "border-right-width",
                     "border-right-style",
                     "border-right-color"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1908,7 +2021,11 @@
             "codegen-properties": {
                 "initial": "currentColor",
                 "visited-link-color-support": true,
-                "color-property": true
+                "color-property": true,
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1929,7 +2046,11 @@
                 "double"
             ],
             "codegen-properties": {
-                "initial": "initialBorderStyle"
+                "initial": "initialBorderStyle",
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1939,7 +2060,11 @@
         "border-right-width": {
             "codegen-properties": {
                 "initial": "initialBorderWidth",
-                "converter": "LineWidth<float>"
+                "converter": "LineWidth<float>",
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -1962,7 +2087,10 @@
         "border-start-end-radius": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "start-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1972,7 +2100,10 @@
         "border-start-start-radius": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "start-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -1999,7 +2130,11 @@
                     "border-top-width",
                     "border-top-style",
                     "border-top-color"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "border",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -2010,7 +2145,11 @@
             "codegen-properties": {
                 "initial": "currentColor",
                 "visited-link-color-support": true,
-                "color-property": true
+                "color-property": true,
+                "logical-property-group": {
+                    "name": "border-color",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -2023,7 +2162,11 @@
                     "-webkit-border-top-left-radius"
                 ],
                 "initial": "initialBorderRadius",
-                "custom": "Inherit|Value"
+                "custom": "Inherit|Value",
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "top-left"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -2036,7 +2179,11 @@
                     "-webkit-border-top-right-radius"
                 ],
                 "initial": "initialBorderRadius",
-                "custom": "Inherit|Value"
+                "custom": "Inherit|Value",
+                "logical-property-group": {
+                    "name": "border-radius",
+                    "resolver": "top-right"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -2057,7 +2204,11 @@
                 "double"
             ],
             "codegen-properties": {
-                "initial": "initialBorderStyle"
+                "initial": "initialBorderStyle",
+                "logical-property-group": {
+                    "name": "border-style",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -2067,7 +2218,11 @@
         "border-top-width": {
             "codegen-properties": {
                 "initial": "initialBorderWidth",
-                "converter": "LineWidth<float>"
+                "converter": "LineWidth<float>",
+                "logical-property-group": {
+                    "name": "border-width",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-backgrounds",
@@ -2091,7 +2246,11 @@
         "bottom": {
             "codegen-properties": {
                 "initial": "initialOffset",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -2610,7 +2769,11 @@
         "height": {
             "codegen-properties": {
                 "initial": "initialSize",
-                "converter": "LengthSizing"
+                "converter": "LengthSizing",
+                "logical-property-group": {
+                    "name": "size",
+                    "resolver": "vertical"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -2677,7 +2840,10 @@
                     "-webkit-logical-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "size",
+                    "resolver": "inline"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -2713,7 +2879,10 @@
         "inset-block-end": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -2723,7 +2892,10 @@
         "inset-block-start": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -2745,7 +2917,10 @@
         "inset-inline-end": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -2755,7 +2930,10 @@
         "inset-inline-start": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -2776,7 +2954,11 @@
         "left": {
             "codegen-properties": {
                 "initial": "initialOffset",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -2982,7 +3164,10 @@
                     "-webkit-margin-after"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -2995,7 +3180,10 @@
                     "-webkit-margin-before"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3005,7 +3193,11 @@
         "margin-bottom": {
             "codegen-properties": {
                 "initial": "initialMargin",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3030,7 +3222,10 @@
                     "-webkit-margin-end"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3043,7 +3238,10 @@
                     "-webkit-margin-start"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3053,7 +3251,11 @@
         "margin-left": {
             "codegen-properties": {
                 "initial": "initialMargin",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3063,7 +3265,11 @@
         "margin-right": {
             "codegen-properties": {
                 "initial": "initialMargin",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3073,7 +3279,11 @@
         "margin-top": {
             "codegen-properties": {
                 "initial": "initialMargin",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "margin",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3170,7 +3380,10 @@
                     "-webkit-max-logical-height"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "max-size",
+                    "resolver": "block"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3180,7 +3393,11 @@
         "max-height": {
             "codegen-properties": {
                 "initial": "initialMaxSize",
-                "converter": "LengthMaxSizing"
+                "converter": "LengthMaxSizing",
+                "logical-property-group": {
+                    "name": "max-size",
+                    "resolver": "vertical"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3193,7 +3410,10 @@
                     "-webkit-max-logical-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "max-size",
+                    "resolver": "inline"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3203,7 +3423,11 @@
         "max-width": {
             "codegen-properties": {
                 "initial": "initialMaxSize",
-                "converter": "LengthMaxSizing"
+                "converter": "LengthMaxSizing",
+                "logical-property-group": {
+                    "name": "max-size",
+                    "resolver": "horizontal"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3216,7 +3440,10 @@
                     "-webkit-min-logical-height"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "min-size",
+                    "resolver": "block"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3226,7 +3453,11 @@
         "min-height": {
             "codegen-properties": {
                 "initial": "initialMinSize",
-                "converter": "LengthSizing"
+                "converter": "LengthSizing",
+                "logical-property-group": {
+                    "name": "min-size",
+                    "resolver": "vertical"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3239,7 +3470,10 @@
                     "-webkit-min-logical-width"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "min-size",
+                    "resolver": "inline"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3249,7 +3483,11 @@
         "min-width": {
             "codegen-properties": {
                 "initial": "initialMinSize",
-                "converter": "LengthSizing"
+                "converter": "LengthSizing",
+                "logical-property-group": {
+                    "name": "min-size",
+                    "resolver": "horizontal"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3504,7 +3742,10 @@
                     "-webkit-padding-after"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3517,7 +3758,10 @@
                     "-webkit-padding-before"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3527,7 +3771,11 @@
         "padding-bottom": {
             "codegen-properties": {
                 "initial": "initialPadding",
-                "converter": "Length"
+                "converter": "Length",
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3552,7 +3800,10 @@
                     "-webkit-padding-end"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3565,7 +3816,10 @@
                     "-webkit-padding-start"
                 ],
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-logical-props",
@@ -3575,7 +3829,11 @@
         "padding-left": {
             "codegen-properties": {
                 "initial": "initialPadding",
-                "converter": "Length"
+                "converter": "Length",
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3585,7 +3843,11 @@
         "padding-right": {
             "codegen-properties": {
                 "initial": "initialPadding",
-                "converter": "Length"
+                "converter": "Length",
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3595,7 +3857,11 @@
         "padding-top": {
             "codegen-properties": {
                 "initial": "initialPadding",
-                "converter": "Length"
+                "converter": "Length",
+                "logical-property-group": {
+                    "name": "padding",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -3735,7 +4001,11 @@
         "right": {
             "codegen-properties": {
                 "initial": "initialOffset",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -4293,7 +4563,11 @@
         "top": {
             "codegen-properties": {
                 "initial": "initialOffset",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "inset",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -4493,7 +4767,11 @@
         "width": {
             "codegen-properties": {
                 "initial": "initialSize",
-                "converter": "LengthSizing"
+                "converter": "LengthSizing",
+                "logical-property-group": {
+                    "name": "size",
+                    "resolver": "horizontal"
+                }
             },
             "specification": {
                 "category": "css-22",
@@ -6850,7 +7128,11 @@
                 "converter": "Length",
                 "aliases": [
                     "scroll-snap-margin-bottom"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6863,7 +7145,11 @@
                 "converter": "Length",
                 "aliases": [
                     "scroll-snap-margin-left"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6876,7 +7162,11 @@
                 "converter": "Length",
                 "aliases": [
                     "scroll-snap-margin-right"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6889,7 +7179,11 @@
                 "converter": "Length",
                 "aliases": [
                     "scroll-snap-margin-top"
-                ]
+                ],
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6899,7 +7193,10 @@
         "scroll-margin-inline-start": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6909,7 +7206,10 @@
         "scroll-margin-block-start": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6919,7 +7219,10 @@
         "scroll-margin-inline-end": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6929,7 +7232,10 @@
         "scroll-margin-block-end": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-margin",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6977,7 +7283,11 @@
         "scroll-padding-bottom": {
             "codegen-properties": {
                 "initial": "initialScrollPadding",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "bottom"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6987,7 +7297,11 @@
         "scroll-padding-left": {
             "codegen-properties": {
                 "initial": "initialScrollPadding",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "left"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -6997,7 +7311,11 @@
         "scroll-padding-right": {
             "codegen-properties": {
                 "initial": "initialScrollPadding",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "right"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -7007,7 +7325,11 @@
         "scroll-padding-top": {
             "codegen-properties": {
                 "initial": "initialScrollPadding",
-                "converter": "LengthOrAuto"
+                "converter": "LengthOrAuto",
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "top"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -7017,7 +7339,10 @@
         "scroll-padding-inline-start": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "inline-start"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -7027,7 +7352,10 @@
         "scroll-padding-block-start": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "block-start"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -7037,7 +7365,10 @@
         "scroll-padding-inline-end": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "inline-end"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",
@@ -7047,7 +7378,10 @@
         "scroll-padding-block-end": {
             "codegen-properties": {
                 "skip-builder": true,
-                "direction-aware-property": true
+                "logical-property-group": {
+                    "name": "scroll-padding",
+                    "resolver": "block-end"
+                }
             },
             "specification": {
                 "category": "css-scroll-snap",

Modified: trunk/Source/WebCore/css/CSSProperty.cpp (278984 => 278985)


--- trunk/Source/WebCore/css/CSSProperty.cpp	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Source/WebCore/css/CSSProperty.cpp	2021-06-17 13:13:49 UTC (rev 278985)
@@ -23,7 +23,6 @@
 
 #include "CSSValueList.h"
 #include "StylePropertyShorthand.h"
-#include "StylePropertyShorthandFunctions.h"
 #include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
@@ -52,144 +51,4 @@
     m_value = WTFMove(list);
 }
 
-static CSSPropertyID resolveToPhysicalProperty(TextDirection direction, WritingMode writingMode, LogicalBoxSide logicalSide, const StylePropertyShorthand& shorthand)
-{
-    RELEASE_ASSERT(shorthand.length() == 4);
-    return shorthand.properties()[static_cast<size_t>(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), logicalSide))];
-}
-
-static CSSPropertyID resolveToPhysicalProperty(TextDirection direction, WritingMode writingMode, LogicalBoxCorner logicalBoxCorner, const StylePropertyShorthand& shorthand)
-{
-    RELEASE_ASSERT(shorthand.length() == 4);
-    return shorthand.properties()[static_cast<size_t>(mapLogicalCornerToPhysicalCorner(makeTextFlow(writingMode, direction), logicalBoxCorner))];
-}
-
-enum LogicalExtent { LogicalWidth, LogicalHeight };
-
-static CSSPropertyID resolveToPhysicalProperty(WritingMode writingMode, LogicalExtent logicalSide, const CSSPropertyID (&properties)[2])
-{
-    if (writingMode == WritingMode::TopToBottom || writingMode == WritingMode::BottomToTop)
-        return properties[logicalSide];
-    return logicalSide == LogicalWidth ? properties[1] : properties[0];
-}
-
-static const StylePropertyShorthand& borderDirections()
-{
-    static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSPropertyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft };
-    static const StylePropertyShorthand borderDirections(CSSPropertyBorder, properties);
-    return borderDirections;
-}
-
-CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyID, TextDirection direction, WritingMode writingMode)
-{
-    switch (propertyID) {
-    case CSSPropertyInsetInlineEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, insetShorthand());
-    case CSSPropertyInsetInlineStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, insetShorthand());
-    case CSSPropertyInsetBlockStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, insetShorthand());
-    case CSSPropertyInsetBlockEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, insetShorthand());
-    case CSSPropertyMarginInlineEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, marginShorthand());
-    case CSSPropertyMarginInlineStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, marginShorthand());
-    case CSSPropertyMarginBlockStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, marginShorthand());
-    case CSSPropertyMarginBlockEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, marginShorthand());
-    case CSSPropertyPaddingInlineEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, paddingShorthand());
-    case CSSPropertyPaddingInlineStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, paddingShorthand());
-    case CSSPropertyPaddingBlockStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, paddingShorthand());
-    case CSSPropertyPaddingBlockEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, paddingShorthand());
-    case CSSPropertyBorderInlineEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderDirections());
-    case CSSPropertyBorderInlineStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderDirections());
-    case CSSPropertyBorderBlockStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderDirections());
-    case CSSPropertyBorderBlockEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderDirections());
-    case CSSPropertyBorderInlineEndColor:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderColorShorthand());
-    case CSSPropertyBorderInlineStartColor:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderColorShorthand());
-    case CSSPropertyBorderBlockStartColor:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderColorShorthand());
-    case CSSPropertyBorderBlockEndColor:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderColorShorthand());
-    case CSSPropertyBorderInlineEndStyle:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderStyleShorthand());
-    case CSSPropertyBorderInlineStartStyle:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderStyleShorthand());
-    case CSSPropertyBorderBlockStartStyle:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderStyleShorthand());
-    case CSSPropertyBorderBlockEndStyle:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderStyleShorthand());
-    case CSSPropertyBorderInlineEndWidth:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, borderWidthShorthand());
-    case CSSPropertyBorderInlineStartWidth:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, borderWidthShorthand());
-    case CSSPropertyBorderBlockStartWidth:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, borderWidthShorthand());
-    case CSSPropertyBorderBlockEndWidth:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, borderWidthShorthand());
-    case CSSPropertyInlineSize: {
-        const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeight };
-        return resolveToPhysicalProperty(writingMode, LogicalWidth, properties);
-    }
-    case CSSPropertyBlockSize: {
-        const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeight };
-        return resolveToPhysicalProperty(writingMode, LogicalHeight, properties);
-    }
-    case CSSPropertyMinInlineSize: {
-        const CSSPropertyID properties[2] = { CSSPropertyMinWidth, CSSPropertyMinHeight };
-        return resolveToPhysicalProperty(writingMode, LogicalWidth, properties);
-    }
-    case CSSPropertyMinBlockSize: {
-        const CSSPropertyID properties[2] = { CSSPropertyMinWidth, CSSPropertyMinHeight };
-        return resolveToPhysicalProperty(writingMode, LogicalHeight, properties);
-    }
-    case CSSPropertyMaxInlineSize: {
-        const CSSPropertyID properties[2] = { CSSPropertyMaxWidth, CSSPropertyMaxHeight };
-        return resolveToPhysicalProperty(writingMode, LogicalWidth, properties);
-    }
-    case CSSPropertyMaxBlockSize: {
-        const CSSPropertyID properties[2] = { CSSPropertyMaxWidth, CSSPropertyMaxHeight };
-        return resolveToPhysicalProperty(writingMode, LogicalHeight, properties);
-    }
-    case CSSPropertyBorderStartStartRadius:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxCorner::StartStart, borderRadiusShorthand());
-    case CSSPropertyBorderStartEndRadius:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxCorner::StartEnd, borderRadiusShorthand());
-    case CSSPropertyBorderEndStartRadius:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxCorner::EndStart, borderRadiusShorthand());
-    case CSSPropertyBorderEndEndRadius:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxCorner::EndEnd, borderRadiusShorthand());
-    case CSSPropertyScrollMarginInlineStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, scrollMarginShorthand());
-    case CSSPropertyScrollMarginInlineEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, scrollMarginShorthand());
-    case CSSPropertyScrollMarginBlockStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, scrollMarginShorthand());
-    case CSSPropertyScrollMarginBlockEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, scrollMarginShorthand());
-    case CSSPropertyScrollPaddingInlineStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Start, scrollPaddingShorthand());
-    case CSSPropertyScrollPaddingInlineEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::End, scrollPaddingShorthand());
-    case CSSPropertyScrollPaddingBlockStart:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::Before, scrollPaddingShorthand());
-    case CSSPropertyScrollPaddingBlockEnd:
-        return resolveToPhysicalProperty(direction, writingMode, LogicalBoxSide::After, scrollPaddingShorthand());
-    default:
-        return propertyID;
-    }
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/makeprop.pl (278984 => 278985)


--- trunk/Source/WebCore/css/makeprop.pl	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Source/WebCore/css/makeprop.pl	2021-06-17 13:13:49 UTC (rev 278985)
@@ -67,10 +67,36 @@
 my $numPredefinedProperties = 2;
 my %nameIsColorProperty;
 my %nameIsDescriptorOnly;
-my %nameIsDirectionAwareProperty;
 my %nameIsHighPriority;
 my %nameIsInherited;
 my %namePriorityShouldSink;
+my %logicalPropertyGroups;
+my %resolverKinds = (
+    "logical" => {
+        "block" => "axis",
+        "inline" => "axis",
+        "block-start" => "side",
+        "block-end" => "side",
+        "inline-start" => "side",
+        "inline-end" => "side",
+        "start-start" => "corner",
+        "start-end" => "corner",
+        "end-start" => "corner",
+        "end-end" => "corner",
+    },
+    "physical" => {
+        "horizontal" => "axis",
+        "vertical" => "axis",
+        "top" => "side",
+        "right" => "side",
+        "bottom" => "side",
+        "left" => "side",
+        "top-left" => "corner",
+        "top-right" => "corner",
+        "bottom-right" => "corner",
+        "bottom-left" => "corner",
+    },
+);
 my %propertiesWithStyleBuilderOptions;
 my %styleBuilderOptions = (
     "animatable" => 1, # Defined in Source/WebCore/style/StyleBuilderConverter.h
@@ -107,6 +133,22 @@
     }
 }
 
+while (my ($groupName, $logicalPropertyGroup) = each %logicalPropertyGroups) {
+    for my $logic (keys %resolverKinds) {
+        my $properties = $logicalPropertyGroup->{$logic};
+        if (!$properties) {
+            die "Logical property group \"$groupName\" has no \"$logic\" property.";
+        }
+        while (my ($resolver, $kind) = each %{ $resolverKinds{$logic} }) {
+            if ($kind eq $logicalPropertyGroup->{"kind"}) {
+                if (!$properties->{$resolver}) {
+                    die "Logical property group \"$groupName\" requires a \"$resolver\" property.";
+                }
+            }
+        }
+    }
+}
+
 sub matchEnableFlags($)
 {
     my ($enable_flag) = @_;
@@ -223,6 +265,13 @@
     return matchEnableFlags($codegen_properties->{"enable-if"});
 }
 
+sub nameToId
+{
+    my $name = shift;
+    $name =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
+    return $name;
+}
+
 sub addProperty($$)
 {
     my ($name, $optionsHashRef) = @_;
@@ -229,9 +278,7 @@
 
     push @names, $name;
 
-    my $id = $name;
-    $id =~ s/(^[^-])|-(.)/uc($1||$2)/ge;
-    $nameToId{$name} = $id;
+    $nameToId{$name} = nameToId($name);
 
     for my $optionName (keys %{$optionsHashRef}) {
         if ($optionName eq "codegen-properties") {
@@ -262,8 +309,28 @@
                     $settingsFlags{$name} = $codegenProperties->{"settings-flag"};
                 } elsif ($codegenOptionName eq "color-property") {
                     $nameIsColorProperty{$name} = 1;
-                } elsif ($codegenOptionName eq "direction-aware-property") {
-                    $nameIsDirectionAwareProperty{$name} = 1;
+                } elsif ($codegenOptionName eq "logical-property-group") {
+                    my $groupName = $codegenProperties->{$codegenOptionName}{"name"};
+                    my $resolver = $codegenProperties->{$codegenOptionName}{"resolver"};
+                    my $kind;
+                    my $logic;
+                    if ($kind = $resolverKinds{"logical"}{$resolver}) {
+                        $logic = "logical";
+                    } elsif ($kind = $resolverKinds{"physical"}{$resolver}) {
+                        $logic = "physical";
+                    } else {
+                        die "Unrecognized resolver \"$resolver\" for codegen property \"$codegenOptionName\" for $name property.";
+                    }
+                    my $otherKind = $logicalPropertyGroups{$groupName}{"kind"};
+                    if ($otherKind && $otherKind ne $kind) {
+                        die "Logical property group \"$groupName\" has resolvers of different kinds: $kind and $otherKind.";
+                    }
+                    $logicalPropertyGroups{$groupName}{"kind"} = $kind;
+                    my $otherName = $logicalPropertyGroups{$groupName}{$logic}{$resolver};
+                    if ($otherName) {
+                        die "Logical property group \"$groupName\" has multiple \"$resolver\" properties: $name and $otherName.";
+                    }
+                    $logicalPropertyGroups{$groupName}{$logic}{$resolver} = $name;
                 } elsif ($codegenOptionName eq "descriptor-only") {
                     $nameIsDescriptorOnly{$name} = 1;
                 } else {
@@ -578,11 +645,10 @@
 {
     switch (id) {
 EOF
-for my $name (@names) {
-    if (!$nameIsDirectionAwareProperty{$name}) {
-        next;
+for my $logicalPropertyGroup (values %logicalPropertyGroups) {
+    for my $name (values %{ $logicalPropertyGroup->{"logical"} }) {
+        print GPERF "    case CSSPropertyID::CSSProperty" . $nameToId{$name} . ":\n";
     }
-    print GPERF "    case CSSPropertyID::CSSProperty" . $nameToId{$name} . ":\n";
 }
 
 print GPERF << "EOF";
@@ -592,6 +658,41 @@
     }
 }
 
+CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyID, TextDirection direction, WritingMode writingMode)
+{
+    const TextFlow& textflow = makeTextFlow(writingMode, direction);
+    switch (propertyID) {
+EOF
+
+for my $logicalPropertyGroup (values %logicalPropertyGroups) {
+    while (my ($resolver, $name) = each %{ $logicalPropertyGroup->{"logical"} }) {
+        my $kind = $logicalPropertyGroup->{"kind"};
+        my $kindId = nameToId($kind);
+        my $resolverEnum = "LogicalBox" . $kindId . "::" . nameToId($resolver);
+        my @physicals;
+        if ($kind eq "side") {
+            @physicals = ("top", "right", "bottom", "left");
+        } elsif ($kind eq "corner") {
+            @physicals = ("top-left", "top-right", "bottom-right", "bottom-left");
+        } elsif ($kind eq "axis") {
+            @physicals = ("horizontal", "vertical");
+        } else {
+            die "Property \"$name\" belongs to a logical property group of unrecognized kind \"$kind\".";
+        }
+        my @properties = map { "CSSProperty" . $nameToId{$logicalPropertyGroup->{"physical"}{$_}} } @physicals;
+        print GPERF "    case CSSPropertyID::CSSProperty" . $nameToId{$name} . ": {\n";
+        print GPERF "        static constexpr CSSPropertyID properties[" . scalar(@properties) . "] = { " . join(", ", @properties) . " };\n";
+        print GPERF "        return properties[static_cast<size_t>(mapLogical" . $kindId . "ToPhysical" . $kindId . "(textflow, " . $resolverEnum . "))];\n";
+        print GPERF "    }\n";
+    }
+}
+
+print GPERF << "EOF";
+    default:
+        return propertyID;
+    }
+}
+
 bool CSSProperty::isDescriptorOnly(CSSPropertyID id)
 {
     switch (id) {

Modified: trunk/Source/WebCore/platform/RectEdges.h (278984 => 278985)


--- trunk/Source/WebCore/platform/RectEdges.h	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Source/WebCore/platform/RectEdges.h	2021-06-17 13:13:49 UTC (rev 278985)
@@ -72,15 +72,15 @@
     void setBottom(const T& bottom) { setAt(BoxSide::Bottom, bottom); }
     void setLeft(const T& left) { setAt(BoxSide::Left, left); }
 
-    T& before(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); }
-    T& after(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); }
-    T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); }
-    T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); }
+    T& before(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::BlockStart)); }
+    T& after(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::BlockEnd)); }
+    T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::InlineStart)); }
+    T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::InlineEnd)); }
 
-    const T& before(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); }
-    const T& after(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); }
-    const T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); }
-    const T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); }
+    const T& before(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::BlockStart)); }
+    const T& after(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::BlockEnd)); }
+    const T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::InlineStart)); }
+    const T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::InlineEnd)); }
 
     void setBefore(const T& before, WritingMode writingMode) { this->before(writingMode) = before; }
     void setAfter(const T& after, WritingMode writingMode) { this->after(writingMode) = after; }

Modified: trunk/Source/WebCore/platform/text/WritingMode.h (278984 => 278985)


--- trunk/Source/WebCore/platform/text/WritingMode.h	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Source/WebCore/platform/text/WritingMode.h	2021-06-17 13:13:49 UTC (rev 278985)
@@ -115,10 +115,10 @@
 }
 
 enum class LogicalBoxSide : uint8_t {
-    Before,
-    End,
-    After,
-    Start
+    BlockStart,
+    InlineEnd,
+    BlockEnd,
+    InlineStart
 };
 
 enum class BoxSide : uint8_t {
@@ -144,6 +144,16 @@
     BottomLeft
 };
 
+enum class LogicalBoxAxis : uint8_t {
+    Inline,
+    Block
+};
+
+enum class BoxAxis : uint8_t {
+    Horizontal,
+    Vertical
+};
+
 constexpr std::array<BoxSide, 4> allBoxSides = { BoxSide::Top, BoxSide::Right, BoxSide::Bottom, BoxSide::Left };
 
 constexpr inline bool isHorizontalPhysicalSide(BoxSide physicalSide)
@@ -199,4 +209,11 @@
     return BoxCorner::TopRight;
 }
 
+constexpr inline BoxAxis mapLogicalAxisToPhysicalAxis(TextFlow textflow, LogicalBoxAxis logicalAxis)
+{
+    if (isVerticalTextFlow(textflow))
+        return logicalAxis == LogicalBoxAxis::Inline ? BoxAxis::Vertical : BoxAxis::Horizontal;
+    return logicalAxis == LogicalBoxAxis::Inline ? BoxAxis::Horizontal : BoxAxis::Vertical;
+}
+
 } // namespace WebCore

Modified: trunk/Tools/ChangeLog (278984 => 278985)


--- trunk/Tools/ChangeLog	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Tools/ChangeLog	2021-06-17 13:13:49 UTC (rev 278985)
@@ -1,3 +1,17 @@
+2021-06-17  Oriol Brufau  <obru...@igalia.com>
+
+        [css-logical] Implement logical property groups
+        https://bugs.webkit.org/show_bug.cgi?id=226878
+
+        Reviewed by Antti Koivisto.
+
+        Add validator for new codegen property "logical-property-group",
+        replacing the old "direction-aware-property".
+
+        * Scripts/webkitpy/style/checkers/jsonchecker.py:
+        (JSONCSSPropertiesChecker.validate_logical_property_group):
+        (JSONCSSPropertiesChecker.check_codegen_properties):
+
 2021-06-17  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GLIB] Pass a GTlsCertificate to soup_server_new()

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py (278984 => 278985)


--- trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py	2021-06-17 13:05:46 UTC (rev 278984)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py	2021-06-17 13:13:49 UTC (rev 278985)
@@ -199,6 +199,16 @@
         else:
             self.check_codegen_properties(property_name, value)
 
+    def validate_logical_property_group(self, property_name, property_key, key, value):
+        self.validate_type(property_name, property_key, key, value, dict)
+
+        for subKey, value in value.items():
+            if subKey in ('name', 'resolver'):
+                self.validate_string(property_name, key, subKey, value)
+            else:
+                self._handle_style_error(0, 'json/syntax', 5, 'dictionary for "%s" of property "%s" has unexpected key "%s".' % (key, property_name, subKey))
+                return
+
     def validate_status(self, property_name, property_key, key, value):
         if isinstance(value, dict):
             keys_and_validators = {
@@ -279,7 +289,6 @@
             'converter': self.validate_string,
             'custom': self.validate_string,
             'descriptor-only': self.validate_boolean,
-            'direction-aware-property': self.validate_boolean,
             'enable-if': self.validate_string,
             'fill-layer-property': self.validate_boolean,
             'font-property': self.validate_boolean,
@@ -287,6 +296,7 @@
             'high-priority': self.validate_boolean,
             'initial': self.validate_string,
             'internal-only': self.validate_boolean,
+            'logical-property-group': self.validate_logical_property_group,
             'longhands': self.validate_array,
             'name-for-methods': self.validate_string,
             'no-default-color': self.validate_boolean,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to