Title: [293543] trunk
Revision
293543
Author
obru...@igalia.com
Date
2022-04-27 15:58:31 -0700 (Wed, 27 Apr 2022)

Log Message

LayoutTests/imported/w3c:
Fix CSS cascade regarding logical properties
https://bugs.webkit.org/show_bug.cgi?id=236199

Reviewed by Darin Adler.

Expect animation-004.html to pass.
Add new test logicalprops-with-deferred-writing-mode.html

* web-platform-tests/css/css-logical/animation-004-expected.txt:
* web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt: Added.
* web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html: Added.

Source/WebCore:
Reland "Fix CSS cascade regarding logical properties"
https://bugs.webkit.org/show_bug.cgi?id=236199

Reviewed by Antti Koivisto.

This is a reland of https://commits.webkit.org/r291546, which was
reverted due to a performance regression. This problem should have been
addressed by bug 238260.

Original summary:
> The CSS cascade was trying to resolve logical properties into physical
> ones too early. This failed if we still didn't know the direction or
> writing-mode, e.g. because they were set to a variable or to a CSS-wide
> keyword.
>
> This patch keeps logical properties as-is during the cascade. They are
> only resolved when finally applied. Also, both logical properties and
> their physical equivalents are now set to apply in parse order, since
> 'height: 0px; block-size: 1px' and 'block-size: 1px; height: 0px' can be
> different, the order matters.

Tests: imported/w3c/web-platform-tests/css/css-logical/animation-004.html
       imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html

* css/makeprop.pl:
(addProperty):
(sortByDescendingPriorityAndName):
Defer properties that belong to a logical property group.

* css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValueWithVariableReferences):
Logical properties no longer need special handling for variables.

* style/PropertyCascade.cpp:
(WebCore::Style::PropertyCascade::PropertyCascade):
Remove members no longer needed.

(WebCore::Style::PropertyCascade::set):
This method is no longer used for properties in a logical property
group. Remove dead code and add assert.

(WebCore::Style::PropertyCascade::setDeferred):
Remove assert, logical properties are now handled here.

(WebCore::Style::PropertyCascade::lastDeferredPropertyResolvingRelated const):
Take into account that properties in a logical property group are now
deferred.

(WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode const): Deleted.
(WebCore::Style::PropertyCascade::direction const): Deleted.
Remove broken logic.

* style/PropertyCascade.h:
Remove members, struct and methods no longer needed.
Update method signatures.

* style/StyleBuilder.cpp:
(WebCore::Style::Builder::Builder):
Remove argument no longer needed.

(WebCore::Style::Builder::applyProperty):
Resolve logical properties using the direction and writing-mode from the
style.

(WebCore::Style::directionFromStyle): Deleted.
Remove function no longer needed.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293542 => 293543)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-27 22:58:31 UTC (rev 293543)
@@ -1,3 +1,17 @@
+2022-04-27  Oriol Brufau  <obru...@igalia.com>
+
+        Fix CSS cascade regarding logical properties
+        https://bugs.webkit.org/show_bug.cgi?id=236199
+
+        Reviewed by Darin Adler.
+
+        Expect animation-004.html to pass.
+        Add new test logicalprops-with-deferred-writing-mode.html
+
+        * web-platform-tests/css/css-logical/animation-004-expected.txt:
+        * web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt: Added.
+        * web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html: Added.
+
 2022-04-27  Tim Nguyen  <n...@apple.com>
 
         Rebaseline imported/w3c/web-platform-tests/css/css-text/inheritance.html after r293521

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/animation-004-expected.txt (293542 => 293543)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/animation-004-expected.txt	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/animation-004-expected.txt	2022-04-27 22:58:31 UTC (rev 293543)
@@ -11,7 +11,7 @@
 PASS Filling transitions update when the writing-mode is changed
 PASS The number of interpolating properties can be increased when the writing-mode is changed
 PASS The number of interpolating properties can be decreased when the writing-mode is changed
-FAIL Transitions update when the writing-mode is changed through a CSS variable assert_equals: expected "50px" but got "0px"
+PASS Transitions update when the writing-mode is changed through a CSS variable
 PASS Transitions update when the direction is changed
 PASS Transitions from logical to physical update when the direction is changed
 PASS Transitions from physical to logical update when the direction is changed

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt (0 => 293543)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode-expected.txt	2022-04-27 22:58:31 UTC (rev 293543)
@@ -0,0 +1,8 @@
+
+PASS Writing mode with variable
+PASS Writing mode with nested variables
+PASS Writing mode with 'inherit'
+PASS Writing mode with 'initial'
+PASS Writing mode with 'revert'
+PASS Writing mode with 'revert-layer'
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html (0 => 293543)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html	2022-04-27 22:58:31 UTC (rev 293543)
@@ -0,0 +1,175 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Logical properties with deferred <code>writing-mode</code></title>
+<link rel="author" title="Oriol Brufau" href="" />
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<meta name="assert" content="Checks that logical properties are resolved correctly when the writing mode isn't known until computed-value time.">
+<style>
+#parent {
+  writing-mode: vertical-lr;
+}
+
+@layer {
+  .revert-layer {
+    writing-mode: vertical-rl;
+  }
+}
+@layer {
+  .revert-layer {
+    writing-mode: horizontal-tb;
+    writing-mode: revert-layer;
+  }
+}
+</style>
+<div id="parent">
+  <div id="target"></div>
+</div>
+<script src=""
+<script src=""
+<script>
+const target = document.getElementById("target");
+const computedStyle = getComputedStyle(target);
+
+function check(expected) {
+  for (let [prop, value] of Object.entries(expected)) {
+    assert_equals(computedStyle.getPropertyValue(prop), value, prop);
+  }
+}
+
+test(function() {
+  target.style.cssText = `
+    --wm: vertical-rl;
+    writing-mode: var(--wm);
+    margin-block-start: 1px;
+    margin-block-end: 2px;
+    margin-inline-start: 3px;
+    margin-inline-end: 4px;
+  `;
+  check({
+    // Logicals
+    "margin-block-start": "1px",
+    "margin-block-end": "2px",
+    "margin-inline-start": "3px",
+    "margin-inline-end": "4px",
+    // Physicals
+    "margin-right": "1px",
+    "margin-left": "2px",
+    "margin-top": "3px",
+    "margin-bottom": "4px",
+  });
+}, "Writing mode with variable");
+
+test(function() {
+  target.style.cssText = `
+    --wm1: vertical-rl;
+    --wm2: var(--wm1);
+    writing-mode: var(--wm2);
+    margin-block-start: 1px;
+    margin-block-end: 2px;
+    margin-inline-start: 3px;
+    margin-inline-end: 4px;
+  `;
+  check({
+    // Logicals
+    "margin-block-start": "1px",
+    "margin-block-end": "2px",
+    "margin-inline-start": "3px",
+    "margin-inline-end": "4px",
+    // Physicals
+    "margin-right": "1px",
+    "margin-left": "2px",
+    "margin-top": "3px",
+    "margin-bottom": "4px",
+  });
+}, "Writing mode with nested variables");
+
+test(function() {
+  target.style.cssText = `
+    writing-mode: inherit;
+    margin-block-start: 1px;
+    margin-block-end: 2px;
+    margin-inline-start: 3px;
+    margin-inline-end: 4px;
+  `;
+  check({
+    // Logicals
+    "margin-block-start": "1px",
+    "margin-block-end": "2px",
+    "margin-inline-start": "3px",
+    "margin-inline-end": "4px",
+    // Physicals
+    "margin-left": "1px",
+    "margin-right": "2px",
+    "margin-top": "3px",
+    "margin-bottom": "4px",
+  });
+}, "Writing mode with 'inherit'");
+
+test(function() {
+  target.style.cssText = `
+    writing-mode: initial;
+    margin-block-start: 1px;
+    margin-block-end: 2px;
+    margin-inline-start: 3px;
+    margin-inline-end: 4px;
+  `;
+  check({
+    // Logicals
+    "margin-block-start": "1px",
+    "margin-block-end": "2px",
+    "margin-inline-start": "3px",
+    "margin-inline-end": "4px",
+    // Physicals
+    "margin-top": "1px",
+    "margin-bottom": "2px",
+    "margin-left": "3px",
+    "margin-right": "4px",
+  });
+}, "Writing mode with 'initial'");
+
+test(function() {
+  target.style.cssText = `
+    writing-mode: revert;
+    margin-block-start: 1px;
+    margin-block-end: 2px;
+    margin-inline-start: 3px;
+    margin-inline-end: 4px;
+  `;
+  check({
+    // Logicals
+    "margin-block-start": "1px",
+    "margin-block-end": "2px",
+    "margin-inline-start": "3px",
+    "margin-inline-end": "4px",
+    // Physicals
+    "margin-left": "1px",
+    "margin-right": "2px",
+    "margin-top": "3px",
+    "margin-bottom": "4px",
+  });
+}, "Writing mode with 'revert'");
+
+test(function() {
+  target.className = "revert-layer";
+  target.style.cssText = `
+    margin-block-start: 1px;
+    margin-block-end: 2px;
+    margin-inline-start: 3px;
+    margin-inline-end: 4px;
+  `;
+  check({
+    // Logicals
+    "margin-block-start": "1px",
+    "margin-block-end": "2px",
+    "margin-inline-start": "3px",
+    "margin-inline-end": "4px",
+    // Physicals
+    "margin-right": "1px",
+    "margin-left": "2px",
+    "margin-top": "3px",
+    "margin-bottom": "4px",
+  });
+}, "Writing mode with 'revert-layer'");
+</script>

Modified: trunk/Source/WebCore/ChangeLog (293542 => 293543)


--- trunk/Source/WebCore/ChangeLog	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/Source/WebCore/ChangeLog	2022-04-27 22:58:31 UTC (rev 293543)
@@ -1,3 +1,72 @@
+2022-04-27  Oriol Brufau  <obru...@igalia.com>
+
+        Reland "Fix CSS cascade regarding logical properties"
+        https://bugs.webkit.org/show_bug.cgi?id=236199
+
+        Reviewed by Antti Koivisto.
+
+        This is a reland of https://commits.webkit.org/r291546, which was
+        reverted due to a performance regression. This problem should have been
+        addressed by bug 238260.
+
+        Original summary:
+        > The CSS cascade was trying to resolve logical properties into physical
+        > ones too early. This failed if we still didn't know the direction or
+        > writing-mode, e.g. because they were set to a variable or to a CSS-wide
+        > keyword.
+        >
+        > This patch keeps logical properties as-is during the cascade. They are
+        > only resolved when finally applied. Also, both logical properties and
+        > their physical equivalents are now set to apply in parse order, since
+        > 'height: 0px; block-size: 1px' and 'block-size: 1px; height: 0px' can be
+        > different, the order matters.
+
+        Tests: imported/w3c/web-platform-tests/css/css-logical/animation-004.html
+               imported/w3c/web-platform-tests/css/css-logical/logicalprops-with-deferred-writing-mode.html
+
+        * css/makeprop.pl:
+        (addProperty):
+        (sortByDescendingPriorityAndName):
+        Defer properties that belong to a logical property group.
+
+        * css/parser/CSSParser.cpp:
+        (WebCore::CSSParser::parseValueWithVariableReferences):
+        Logical properties no longer need special handling for variables.
+
+        * style/PropertyCascade.cpp:
+        (WebCore::Style::PropertyCascade::PropertyCascade):
+        Remove members no longer needed.
+
+        (WebCore::Style::PropertyCascade::set):
+        This method is no longer used for properties in a logical property
+        group. Remove dead code and add assert.
+
+        (WebCore::Style::PropertyCascade::setDeferred):
+        Remove assert, logical properties are now handled here.
+
+        (WebCore::Style::PropertyCascade::lastDeferredPropertyResolvingRelated const):
+        Take into account that properties in a logical property group are now
+        deferred.
+
+        (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode const): Deleted.
+        (WebCore::Style::PropertyCascade::direction const): Deleted.
+        Remove broken logic.
+
+        * style/PropertyCascade.h:
+        Remove members, struct and methods no longer needed.
+        Update method signatures.
+
+        * style/StyleBuilder.cpp:
+        (WebCore::Style::Builder::Builder):
+        Remove argument no longer needed.
+
+        (WebCore::Style::Builder::applyProperty):
+        Resolve logical properties using the direction and writing-mode from the
+        style.
+
+        (WebCore::Style::directionFromStyle): Deleted.
+        Remove function no longer needed.
+
 2022-04-24  Philippe Normand  <ph...@igalia.com>
 
         [GStreamer] Track handling fixes

Modified: trunk/Source/WebCore/css/makeprop.pl (293542 => 293543)


--- trunk/Source/WebCore/css/makeprop.pl	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/Source/WebCore/css/makeprop.pl	2022-04-27 22:58:31 UTC (rev 293543)
@@ -68,6 +68,7 @@
 my %nameIsColorProperty;
 my %nameIsDescriptorOnly;
 my %nameIsHighPriority;
+my %nameIsDeferred;
 my %nameIsInherited;
 my %namePriorityShouldSink;
 my %logicalPropertyGroups;
@@ -288,6 +289,7 @@
                 } elsif ($codegenOptionName eq "sink-priority") {
                     $namePriorityShouldSink{$name} = 1;
                 } elsif ($codegenOptionName eq "related-property") {
+                    $nameIsDeferred{$name} = 1;
                     $relatedProperty{$name} = $codegenProperties->{"related-property"}
                 } elsif ($codegenOptionName eq "aliases") {
                     $nameToAliases{$name} = $codegenProperties->{"aliases"};
@@ -307,6 +309,7 @@
                     $nameIsColorProperty{$name} = 1;
                 } elsif ($codegenOptionName eq "logical-property-group") {
                     die "Shorthand property $name can't belong to a logical property group\n" if exists $codegenProperties->{"longhands"};
+                    $nameIsDeferred{$name} = 1;
                     my $groupName = $codegenProperties->{$codegenOptionName}{"name"};
                     my $resolver = $codegenProperties->{$codegenOptionName}{"resolver"};
                     my $kind;
@@ -361,10 +364,10 @@
         return -1;
     }
     # Defer names with a related property to the back
-    if (!!$relatedProperty{$a} < !!$relatedProperty{$b}) {
+    if (!!$nameIsDeferred{$a} < !!$nameIsDeferred{$b}) {
         return -1;
     }
-    if (!!$relatedProperty{$a} > !!$relatedProperty{$b}) {
+    if (!!$nameIsDeferred{$a} > !!$nameIsDeferred{$b}) {
         return 1;
     }
     # Sort sunken names at the end of their priority bucket
@@ -854,7 +857,7 @@
   if ($nameIsHighPriority{$name}) {
     $firstHighPriorityPropertyName = $name if !$firstHighPriorityPropertyName;
     $lastHighPriorityPropertyName = $name;
-  } elsif (!$relatedProperty{$name}) {
+  } elsif (!$nameIsDeferred{$name}) {
     $firstLowPriorityPropertyName = $name if !$firstLowPriorityPropertyName;
     $lastLowPriorityPropertyName = $name;
   } else {

Modified: trunk/Source/WebCore/css/parser/CSSParser.cpp (293542 => 293543)


--- trunk/Source/WebCore/css/parser/CSSParser.cpp	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/Source/WebCore/css/parser/CSSParser.cpp	2022-04-27 22:58:31 UTC (rev 293543)
@@ -192,9 +192,6 @@
 RefPtr<CSSValue> CSSParser::parseValueWithVariableReferences(CSSPropertyID propID, const CSSValue& value, Style::BuilderState& builderState)
 {
     ASSERT((propID == CSSPropertyCustom && value.isCustomPropertyValue()) || (propID != CSSPropertyCustom && !value.isCustomPropertyValue()));
-    auto& style = builderState.style();
-    auto direction = style.direction();
-    auto writingMode = style.writingMode();
 
     if (is<CSSPendingSubstitutionValue>(value)) {
         // FIXME: Should have a resolvedShorthands cache to stop this from being done over and over for each longhand value.
@@ -211,10 +208,7 @@
             return nullptr;
 
         for (auto& property : parsedProperties) {
-            CSSPropertyID currentId = property.id();
-            if (CSSProperty::isDirectionAwareProperty(currentId))
-                currentId = CSSProperty::resolveDirectionAwareProperty(currentId, direction, writingMode);
-            if (currentId == propID)
+            if (property.id() == propID)
                 return property.value();
         }
 

Modified: trunk/Source/WebCore/style/PropertyCascade.cpp (293542 => 293543)


--- trunk/Source/WebCore/style/PropertyCascade.cpp	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/Source/WebCore/style/PropertyCascade.cpp	2022-04-27 22:58:31 UTC (rev 293543)
@@ -38,11 +38,10 @@
 namespace WebCore {
 namespace Style {
 
-PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties, Direction direction)
+PropertyCascade::PropertyCascade(const MatchResult& matchResult, CascadeLevel maximumCascadeLevel, IncludedProperties includedProperties)
     : m_matchResult(matchResult)
     , m_includedProperties(includedProperties)
     , m_maximumCascadeLevel(maximumCascadeLevel)
-    , m_direction(direction)
 {
     buildCascade();
 }
@@ -52,8 +51,6 @@
     , m_includedProperties(parent.m_includedProperties)
     , m_maximumCascadeLevel(maximumCascadeLevel)
     , m_maximumCascadeLayerPriorityForRollback(maximumCascadeLayerPriorityForRollback)
-    , m_direction(parent.direction())
-    , m_directionIsUnresolved(false)
 {
     buildCascade();
 }
@@ -105,11 +102,7 @@
 
 void PropertyCascade::set(CSSPropertyID id, CSSValue& cssValue, const MatchedProperties& matchedProperties, CascadeLevel cascadeLevel)
 {
-    if (CSSProperty::isDirectionAwareProperty(id)) {
-        auto direction = this->direction();
-        id = CSSProperty::resolveDirectionAwareProperty(id, direction.textDirection, direction.writingMode);
-    }
-
+    ASSERT(!CSSProperty::isInLogicalPropertyGroup(id));
     ASSERT(id < firstDeferredProperty);
 
     auto& property = m_properties[id];
@@ -140,7 +133,6 @@
 
 void PropertyCascade::setDeferred(CSSPropertyID id, CSSValue& cssValue, const MatchedProperties& matchedProperties, CascadeLevel cascadeLevel)
 {
-    ASSERT(!CSSProperty::isDirectionAwareProperty(id));
     ASSERT(id >= firstDeferredProperty);
     ASSERT(id <= lastDeferredProperty);
 
@@ -154,9 +146,15 @@
     setPropertyInternal(property, id, cssValue, matchedProperties, cascadeLevel);
 }
 
-const PropertyCascade::Property* PropertyCascade::lastDeferredPropertyResolvingRelated(CSSPropertyID propertyID) const
+const PropertyCascade::Property* PropertyCascade::lastDeferredPropertyResolvingRelated(CSSPropertyID propertyID, TextDirection direction, WritingMode writingMode) const
 {
-    auto relatedID = getRelatedPropertyId(propertyID);
+    auto relatedID = [&] {
+        if (!CSSProperty::isInLogicalPropertyGroup(propertyID))
+            return getRelatedPropertyId(propertyID);
+        if (CSSProperty::isDirectionAwareProperty(propertyID))
+            return CSSProperty::resolveDirectionAwareProperty(propertyID, direction, writingMode);
+        return CSSProperty::unresolvePhysicalProperty(propertyID, direction, writingMode);
+    }();
     if (relatedID == CSSPropertyInvalid) {
         ASSERT_NOT_REACHED();
         return hasDeferredProperty(propertyID) ? &deferredProperty(propertyID) : nullptr;
@@ -298,51 +296,6 @@
         addMatch(matchedDeclarations[match.index], cascadeLevel, true);
 }
 
-PropertyCascade::Direction PropertyCascade::resolveDirectionAndWritingMode(Direction inheritedDirection) const
-{
-    Direction result = inheritedDirection;
-
-    bool hadImportantWritingMode = false;
-    bool hadImportantDirection = false;
-
-    for (auto cascadeLevel : { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }) {
-        for (const auto& matchedProperties : declarationsForCascadeLevel(m_matchResult, cascadeLevel)) {
-            for (unsigned i = 0, count = matchedProperties.properties->propertyCount(); i < count; ++i) {
-                auto property = matchedProperties.properties->propertyAt(i);
-                if (!property.value()->isPrimitiveValue() || property.value()->isCSSWideKeyword())
-                    continue;
-                switch (property.id()) {
-                case CSSPropertyWritingMode:
-                    if (!hadImportantWritingMode || property.isImportant()) {
-                        result.writingMode = downcast<CSSPrimitiveValue>(*property.value());
-                        hadImportantWritingMode = property.isImportant();
-                    }
-                    break;
-                case CSSPropertyDirection:
-                    if (!hadImportantDirection || property.isImportant()) {
-                        result.textDirection = downcast<CSSPrimitiveValue>(*property.value());
-                        hadImportantDirection = property.isImportant();
-                    }
-                    break;
-                default:
-                    break;
-                }
-            }
-        }
-    }
-
-    return result;
-}
-
-PropertyCascade::Direction PropertyCascade::direction() const
-{
-    if (m_directionIsUnresolved) {
-        m_direction = resolveDirectionAndWritingMode(m_direction);
-        m_directionIsUnresolved = false;
-    }
-    return m_direction;
-}
-
 void PropertyCascade::sortDeferredPropertyIDs()
 {
     auto begin = m_deferredPropertyIDs.begin();

Modified: trunk/Source/WebCore/style/PropertyCascade.h (293542 => 293543)


--- trunk/Source/WebCore/style/PropertyCascade.h	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/Source/WebCore/style/PropertyCascade.h	2022-04-27 22:58:31 UTC (rev 293543)
@@ -40,12 +40,7 @@
 public:
     enum IncludedProperties { All, InheritedOnly };
 
-    struct Direction {
-        TextDirection textDirection;
-        WritingMode writingMode;
-    };
-
-    PropertyCascade(const MatchResult&, CascadeLevel, IncludedProperties, Direction);
+    PropertyCascade(const MatchResult&, CascadeLevel, IncludedProperties);
     PropertyCascade(const PropertyCascade&, CascadeLevel, std::optional<CascadeLayerPriority> maximumCascadeLayerPriorityForRollback = { });
 
     ~PropertyCascade();
@@ -64,7 +59,7 @@
 
     bool hasDeferredProperty(CSSPropertyID) const;
     const Property& deferredProperty(CSSPropertyID) const;
-    const Property* lastDeferredPropertyResolvingRelated(CSSPropertyID) const;
+    const Property* lastDeferredPropertyResolvingRelated(CSSPropertyID, TextDirection, WritingMode) const;
 
     bool hasCustomProperty(const AtomString&) const;
     Property customProperty(const AtomString&) const;
@@ -72,8 +67,6 @@
     Span<const CSSPropertyID> deferredPropertyIDs() const;
     const HashMap<AtomString, Property>& customProperties() const { return m_customProperties; }
 
-    Direction direction() const;
-
 private:
     void buildCascade();
     bool addNormalMatches(CascadeLevel);
@@ -84,7 +77,6 @@
     void setDeferred(CSSPropertyID, CSSValue&, const MatchedProperties&, CascadeLevel);
     static void setPropertyInternal(Property&, CSSPropertyID, CSSValue&, const MatchedProperties&, CascadeLevel);
 
-    Direction resolveDirectionAndWritingMode(Direction inheritedDirection) const;
 
     unsigned deferredPropertyIndex(CSSPropertyID) const;
     void setDeferredPropertyIndex(CSSPropertyID, unsigned);
@@ -94,8 +86,6 @@
     const IncludedProperties m_includedProperties;
     const CascadeLevel m_maximumCascadeLevel;
     const std::optional<CascadeLayerPriority> m_maximumCascadeLayerPriorityForRollback;
-    mutable Direction m_direction;
-    mutable bool m_directionIsUnresolved { true };
 
     // The CSSPropertyID enum is sorted like this:
     // 1. CSSPropertyInvalid and CSSPropertyCustom.

Modified: trunk/Source/WebCore/style/StyleBuilder.cpp (293542 => 293543)


--- trunk/Source/WebCore/style/StyleBuilder.cpp	2022-04-27 22:46:30 UTC (rev 293542)
+++ trunk/Source/WebCore/style/StyleBuilder.cpp	2022-04-27 22:58:31 UTC (rev 293543)
@@ -48,11 +48,6 @@
 
 static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1);
 
-inline PropertyCascade::Direction directionFromStyle(const RenderStyle& style)
-{
-    return { style.direction(), style.writingMode() };
-}
-
 inline bool isValidVisitedLinkProperty(CSSPropertyID id)
 {
     switch (id) {
@@ -81,7 +76,7 @@
 }
 
 Builder::Builder(RenderStyle& style, BuilderContext&& context, const MatchResult& matchResult, CascadeLevel cascadeLevel, PropertyCascade::IncludedProperties includedProperties)
-    : m_cascade(matchResult, cascadeLevel, includedProperties, directionFromStyle(style))
+    : m_cascade(matchResult, cascadeLevel, includedProperties)
     , m_state(*this, style, WTFMove(context))
 {
 }
@@ -271,10 +266,10 @@
     ASSERT_WITH_MESSAGE(!isShorthandCSSProperty(id), "Shorthand property id = %d wasn't expanded at parsing time", id);
 
     auto valueToApply = resolveValue(id, value);
+    auto& style = m_state.style();
 
     if (CSSProperty::isDirectionAwareProperty(id)) {
-        auto direction = m_cascade.direction();
-        CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, direction.textDirection, direction.writingMode);
+        CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, style.direction(), style.writingMode());
         ASSERT(newId != id);
         return applyProperty(newId, valueToApply.get(), linkMatchMask);
     }
@@ -322,7 +317,7 @@
                     applyRollbackCascadeProperty(property, linkMatchMask);
                     return;
                 }
-            } else if (auto* property = rollbackCascade->lastDeferredPropertyResolvingRelated(id)) {
+            } else if (auto* property = rollbackCascade->lastDeferredPropertyResolvingRelated(id, style.direction(), style.writingMode())) {
                 applyRollbackCascadeProperty(*property, linkMatchMask);
                 return;
             }
@@ -346,7 +341,7 @@
     }
 
     if (isInherit && !CSSProperty::isInheritedProperty(id))
-        m_state.style().setHasExplicitlyInheritedProperties();
+        style.setHasExplicitlyInheritedProperties();
 
 #if ENABLE(CSS_PAINTING_API)
     if (is<CSSPaintImageValue>(valueToApply)) {
@@ -355,7 +350,7 @@
             Locker locker { paintWorklet->paintDefinitionLock() };
             if (auto* registration = paintWorklet->paintDefinitionMap().get(name)) {
                 for (auto& property : registration->inputProperties)
-                    m_state.style().addCustomPaintWatchProperty(property);
+                    style.addCustomPaintWatchProperty(property);
             }
         }
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to