Title: [259585] trunk
Revision
259585
Author
an...@apple.com
Date
2020-04-06 11:54:09 -0700 (Mon, 06 Apr 2020)

Log Message

'currentcolor' doesn't need setHasExplicitlyInheritedProperties marking anymore
https://bugs.webkit.org/show_bug.cgi?id=210017

Reviewed by Darin Adler.

Source/WebCore:

Removing this marking reveals problems in style update avoidance code in CSSComputedStyleDeclaration
that also need to be addressed. The problems are not specific to exlicit 'currentcolor', they also reproduce
with the initial value (thus the new test).

Test: fast/css/currentColor-initial-style-update.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::nonInheritedColorPropertyHasValueCurrentColor):

Add a helper.

(WebCore::hasValidStyleForProperty):

Treat a non-inherited color property as inherited if it is 'currentcolor'.

(WebCore::updateStyleIfNeededForProperty):

Expand shorthands so properties like border-color test correctly.

* css/CSSProperty.cpp:
(WebCore::CSSProperty::isColorProperty):

Move here from CSSParserFastPaths.

* css/CSSProperty.h:
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::maybeParseValue):
(WebCore::isColorPropertyID): Deleted.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::unresolvedColorForProperty const):

Factor into a helper.
Handle all color values.

(WebCore::RenderStyle::colorResolvingCurrentColor const):

Renamed for clarity and some cleanups.

(WebCore::RenderStyle::visitedDependentColor const):
(WebCore::RenderStyle::colorIncludingFallback const): Deleted.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::isCurrentColor):
* style/StyleBuilderState.cpp:
(WebCore::Style::BuilderState::colorFromPrimitiveValue const):

Remove setHasExplicitlyInheritedProperties marking.

LayoutTests:

* fast/css/currentColor-initial-style-update-expected.txt: Added.
* fast/css/currentColor-initial-style-update.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (259584 => 259585)


--- trunk/LayoutTests/ChangeLog	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/LayoutTests/ChangeLog	2020-04-06 18:54:09 UTC (rev 259585)
@@ -1,3 +1,13 @@
+2020-04-06  Antti Koivisto  <an...@apple.com>
+
+        'currentcolor' doesn't need setHasExplicitlyInheritedProperties marking anymore
+        https://bugs.webkit.org/show_bug.cgi?id=210017
+
+        Reviewed by Darin Adler.
+
+        * fast/css/currentColor-initial-style-update-expected.txt: Added.
+        * fast/css/currentColor-initial-style-update.html: Added.
+
 2020-04-06  Cathie Chen  <cathiec...@igalia.com>
 
         The change of zoom shouldn't affect ResizeObserverSize

Added: trunk/LayoutTests/fast/css/currentColor-initial-style-update-expected.txt (0 => 259585)


--- trunk/LayoutTests/fast/css/currentColor-initial-style-update-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/currentColor-initial-style-update-expected.txt	2020-04-06 18:54:09 UTC (rev 259585)
@@ -0,0 +1,59 @@
+Test that the properties that use the CSS Value "currentcolor" to define the color are updated correctly when the inherited color changes.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+Initial state.
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderLeftColor is "rgb(4, 5, 6)"
+
+Let's override the style of the wrapper through their style object.
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderLeftColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderLeftColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderLeftColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderColor is "rgb(7, 8, 9)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderLeftColor is "rgb(7, 8, 9)"
+
+Let's remove the style attribute on the wrapper.
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderLeftColor is "rgb(4, 5, 6)"
+
+Let's remove class on the wrappers.
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderLeftColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderLeftColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderLeftColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderColor is "rgb(1, 2, 3)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderLeftColor is "rgb(1, 2, 3)"
+
+Then add it back.
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[0]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[1]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[2]).borderLeftColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderColor is "rgb(4, 5, 6)"
+PASS getComputedStyle(document.querySelectorAll(".test-case target")[3]).borderLeftColor is "rgb(4, 5, 6)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/css/currentColor-initial-style-update.html (0 => 259585)


--- trunk/LayoutTests/fast/css/currentColor-initial-style-update.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/currentColor-initial-style-update.html	2020-04-06 18:54:09 UTC (rev 259585)
@@ -0,0 +1,86 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<style>
+    .test-case {
+        color: rgb(1, 2, 3);
+    }
+    .wrapper {
+        color: rgb(4, 5, 6);
+    }
+    target {
+        // border-color has initial value 'currentcolor'.
+    }
+</style>
+<script>
+    jsTestIsAsync = true;
+    function testColor(expectedColor) {
+        var allTargets = document.querySelectorAll(".test-case target");
+        for (var i = 0; i < allTargets.length; ++i) {
+            shouldBeEqualToString('getComputedStyle(document.querySelectorAll(".test-case target")[' + i + ']).borderColor', expectedColor);
+            shouldBeEqualToString('getComputedStyle(document.querySelectorAll(".test-case target")[' + i + ']).borderLeftColor', expectedColor);
+        }
+    }
+
+    function runTest() {
+        description('Test that the properties that use the CSS Value "currentcolor" to define the color are updated correctly when the inherited color changes.');
+
+        debug("");
+        debug("Initial state.");
+        testColor("rgb(4, 5, 6)");
+
+        debug("");
+        debug("Let's override the style of the wrapper through their style object.");
+        var allWrappers = document.querySelectorAll(".wrapper");
+        for (var i = 0; i < allWrappers.length; ++i) {
+            allWrappers[i].style.color = "rgb(7, 8, 9)";
+        }
+        testColor("rgb(7, 8, 9)");
+
+        debug("");
+        debug("Let's remove the style attribute on the wrapper.");
+        for (var i = 0; i < allWrappers.length; ++i) {
+            allWrappers[i].removeAttribute("style");
+        }
+        testColor("rgb(4, 5, 6)");
+
+        debug("");
+        debug("Let's remove class on the wrappers.");
+        for (var i = 0; i < allWrappers.length; ++i) {
+            allWrappers[i].classList.remove("wrapper");
+        }
+        testColor("rgb(1, 2, 3)");
+
+        debug("");
+        debug("Then add it back.");
+        for (var i = 0; i < allWrappers.length; ++i) {
+            allWrappers[i].classList.add("wrapper");
+        }
+        testColor("rgb(4, 5, 6)");
+
+        finishJSTest();
+    }
+    window.addEventListener("load", runTest);
+</script>
+</head>
+<body>
+    <div class="test-case">
+        <div class="wrapper">
+            <target></target>
+        </div>
+        <div class="wrapper">
+            <target></target>
+        </div>
+    </div>
+    <div class="test-case" style="display:none;">
+        <div class="wrapper">
+            <target></target>
+        </div>
+        <div class="wrapper">
+            <target></target>
+        </div>
+    </div>
+</body>
+<script src=""
+</html>

Modified: trunk/Source/WebCore/ChangeLog (259584 => 259585)


--- trunk/Source/WebCore/ChangeLog	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/ChangeLog	2020-04-06 18:54:09 UTC (rev 259585)
@@ -1,3 +1,57 @@
+2020-04-06  Antti Koivisto  <an...@apple.com>
+
+        'currentcolor' doesn't need setHasExplicitlyInheritedProperties marking anymore
+        https://bugs.webkit.org/show_bug.cgi?id=210017
+
+        Reviewed by Darin Adler.
+
+        Removing this marking reveals problems in style update avoidance code in CSSComputedStyleDeclaration
+        that also need to be addressed. The problems are not specific to exlicit 'currentcolor', they also reproduce
+        with the initial value (thus the new test).
+
+        Test: fast/css/currentColor-initial-style-update.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::nonInheritedColorPropertyHasValueCurrentColor):
+
+        Add a helper.
+
+        (WebCore::hasValidStyleForProperty):
+
+        Treat a non-inherited color property as inherited if it is 'currentcolor'.
+
+        (WebCore::updateStyleIfNeededForProperty):
+
+        Expand shorthands so properties like border-color test correctly.
+
+        * css/CSSProperty.cpp:
+        (WebCore::CSSProperty::isColorProperty):
+
+        Move here from CSSParserFastPaths.
+
+        * css/CSSProperty.h:
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::maybeParseValue):
+        (WebCore::isColorPropertyID): Deleted.
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::unresolvedColorForProperty const):
+
+        Factor into a helper.
+        Handle all color values.
+
+        (WebCore::RenderStyle::colorResolvingCurrentColor const):
+
+        Renamed for clarity and some cleanups.
+
+        (WebCore::RenderStyle::visitedDependentColor const):
+        (WebCore::RenderStyle::colorIncludingFallback const): Deleted.
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::isCurrentColor):
+        * style/StyleBuilderState.cpp:
+        (WebCore::Style::BuilderState::colorFromPrimitiveValue const):
+
+        Remove setHasExplicitlyInheritedProperties marking.
+
 2020-04-06  Simon Fraser  <simon.fra...@apple.com>
 
         Make RenderObject TextStream-loggable

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (259584 => 259585)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2020-04-06 18:54:09 UTC (rev 259585)
@@ -2119,6 +2119,17 @@
     }
 }
 
+static bool nonInheritedColorPropertyHasValueCurrentColor(CSSPropertyID propertyID, const RenderStyle* style)
+{
+    if (CSSProperty::isInheritedProperty(propertyID) || !CSSProperty::isColorProperty(propertyID))
+        return false;
+
+    if (!style)
+        return true;
+
+    return RenderStyle::isCurrentColor(style->unresolvedColorForProperty(propertyID));
+}
+
 // In CSS 2.1 the returned object should actually contain the "used values"
 // rather then the "computed values" (despite the name saying otherwise).
 //
@@ -2155,6 +2166,10 @@
 
         if (maybeExplicitlyInherited) {
             auto* style = currentElement->renderStyle();
+            // While most color properties are not inherited, the value 'currentcolor' resolves to the value of the inherited 'color' property.
+            if (nonInheritedColorPropertyHasValueCurrentColor(propertyID, style))
+                isInherited = true;
+
             maybeExplicitlyInherited = !style || style->hasExplicitlyInheritedProperties();
         }
 
@@ -2176,7 +2191,19 @@
 
     document.styleScope().flushPendingUpdate();
 
-    if (hasValidStyleForProperty(element, propertyID))
+    auto hasValidStyle = [&] {
+        auto shorthand = shorthandForProperty(propertyID);
+        if (shorthand.length()) {
+            for (size_t i = 0; i < shorthand.length(); ++i) {
+                if (!hasValidStyleForProperty(element, shorthand.properties()[i]))
+                    return false;
+            }
+            return true;
+        }
+        return hasValidStyleForProperty(element, propertyID);
+    }();
+
+    if (hasValidStyle)
         return false;
 
     document.updateStyleIfNeeded();

Modified: trunk/Source/WebCore/css/CSSProperty.cpp (259584 => 259585)


--- trunk/Source/WebCore/css/CSSProperty.cpp	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/css/CSSProperty.cpp	2020-04-06 18:54:09 UTC (rev 259585)
@@ -212,4 +212,36 @@
     }
 }
 
+bool CSSProperty::isColorProperty(CSSPropertyID propertyId)
+{
+    switch (propertyId) {
+    case CSSPropertyColor:
+    case CSSPropertyBackgroundColor:
+    case CSSPropertyBorderBottomColor:
+    case CSSPropertyBorderLeftColor:
+    case CSSPropertyBorderRightColor:
+    case CSSPropertyBorderTopColor:
+    case CSSPropertyFill:
+    case CSSPropertyFloodColor:
+    case CSSPropertyLightingColor:
+    case CSSPropertyOutlineColor:
+    case CSSPropertyStopColor:
+    case CSSPropertyStroke:
+    case CSSPropertyStrokeColor:
+    case CSSPropertyBorderBlockEndColor:
+    case CSSPropertyBorderBlockStartColor:
+    case CSSPropertyBorderInlineEndColor:
+    case CSSPropertyBorderInlineStartColor:
+    case CSSPropertyColumnRuleColor:
+    case CSSPropertyWebkitTextEmphasisColor:
+    case CSSPropertyWebkitTextFillColor:
+    case CSSPropertyWebkitTextStrokeColor:
+    case CSSPropertyTextDecorationColor:
+    case CSSPropertyCaretColor:
+        return true;
+    default:
+        return false;
+    }
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/CSSProperty.h (259584 => 259585)


--- trunk/Source/WebCore/css/CSSProperty.h	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/css/CSSProperty.h	2020-04-06 18:54:09 UTC (rev 259585)
@@ -81,6 +81,7 @@
     static Vector<String> aliasesForProperty(CSSPropertyID);
     static bool isDirectionAwareProperty(CSSPropertyID);
     static bool isDescriptorOnly(CSSPropertyID);
+    static bool isColorProperty(CSSPropertyID);
 
     const StylePropertyMetadata& metadata() const { return m_metadata; }
 

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (259584 => 259585)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2020-04-06 18:54:09 UTC (rev 259585)
@@ -179,37 +179,6 @@
     return CSSPrimitiveValue::create(number, unit);
 }
 
-static inline bool isColorPropertyID(CSSPropertyID propertyId)
-{
-    switch (propertyId) {
-    case CSSPropertyColor:
-    case CSSPropertyBackgroundColor:
-    case CSSPropertyBorderBottomColor:
-    case CSSPropertyBorderLeftColor:
-    case CSSPropertyBorderRightColor:
-    case CSSPropertyBorderTopColor:
-    case CSSPropertyFill:
-    case CSSPropertyFloodColor:
-    case CSSPropertyLightingColor:
-    case CSSPropertyOutlineColor:
-    case CSSPropertyStopColor:
-    case CSSPropertyStroke:
-    case CSSPropertyStrokeColor:
-    case CSSPropertyBorderBlockEndColor:
-    case CSSPropertyBorderBlockStartColor:
-    case CSSPropertyBorderInlineEndColor:
-    case CSSPropertyBorderInlineStartColor:
-    case CSSPropertyColumnRuleColor:
-    case CSSPropertyWebkitTextEmphasisColor:
-    case CSSPropertyWebkitTextFillColor:
-    case CSSPropertyWebkitTextStrokeColor:
-    case CSSPropertyTextDecorationColor:
-        return true;
-    default:
-        return false;
-    }
-}
-
 // Returns the number of characters which form a valid double
 // and are terminated by the given terminator character
 template <typename CharacterType>
@@ -1311,7 +1280,7 @@
         return result;
     if (propertyID == CSSPropertyCaretColor)
         return parseCaretColor(string, context.mode);
-    if (isColorPropertyID(propertyID))
+    if (CSSProperty::isColorProperty(propertyID))
         return parseColor(string, context.mode, CSSValuePool::singleton());
     if (auto result = parseKeywordValue(propertyID, string, context))
         return result;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (259584 => 259585)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-04-06 18:54:09 UTC (rev 259585)
@@ -1947,74 +1947,93 @@
     }
 }
 
-Color RenderStyle::colorIncludingFallback(CSSPropertyID colorProperty, bool visitedLink) const
+Color RenderStyle::unresolvedColorForProperty(CSSPropertyID colorProperty, bool visitedLink) const
 {
-    Color result;
-    BorderStyle borderStyle = BorderStyle::None;
     switch (colorProperty) {
+    case CSSPropertyColor:
+        return visitedLink ? visitedLinkColor() : color();
     case CSSPropertyBackgroundColor:
-        result = visitedLink ? visitedLinkBackgroundColor() : backgroundColor();
-        break;
+        return visitedLink ? visitedLinkBackgroundColor() : backgroundColor();
+    case CSSPropertyBorderBottomColor:
+        return visitedLink ? visitedLinkBorderBottomColor() : borderBottomColor();
     case CSSPropertyBorderLeftColor:
-        result = visitedLink ? visitedLinkBorderLeftColor() : borderLeftColor();
-        borderStyle = borderLeftStyle();
-        break;
+        return visitedLink ? visitedLinkBorderLeftColor() : borderLeftColor();
     case CSSPropertyBorderRightColor:
-        result = visitedLink ? visitedLinkBorderRightColor() : borderRightColor();
-        borderStyle = borderRightStyle();
-        break;
+        return visitedLink ? visitedLinkBorderRightColor() : borderRightColor();
     case CSSPropertyBorderTopColor:
-        result = visitedLink ? visitedLinkBorderTopColor() : borderTopColor();
-        borderStyle = borderTopStyle();
-        break;
-    case CSSPropertyBorderBottomColor:
-        result = visitedLink ? visitedLinkBorderBottomColor() : borderBottomColor();
-        borderStyle = borderBottomStyle();
-        break;
-    case CSSPropertyCaretColor:
-        result = visitedLink ? visitedLinkCaretColor() : caretColor();
-        break;
-    case CSSPropertyColor:
-        result = visitedLink ? visitedLinkColor() : color();
-        break;
+        return visitedLink ? visitedLinkBorderTopColor() : borderTopColor();
+    case CSSPropertyFill:
+        return fillPaintColor();
+    case CSSPropertyFloodColor:
+        return floodColor();
+    case CSSPropertyLightingColor:
+        return lightingColor();
     case CSSPropertyOutlineColor:
-        result = visitedLink ? visitedLinkOutlineColor() : outlineColor();
-        break;
+        return visitedLink ? visitedLinkOutlineColor() : outlineColor();
+    case CSSPropertyStopColor:
+        return stopColor();
+    case CSSPropertyStroke:
+        return strokePaintColor();
+    case CSSPropertyStrokeColor:
+        return visitedLink ? visitedLinkStrokeColor() : strokeColor();
+    case CSSPropertyBorderBlockEndColor:
+    case CSSPropertyBorderBlockStartColor:
+    case CSSPropertyBorderInlineEndColor:
+    case CSSPropertyBorderInlineStartColor:
+        return unresolvedColorForProperty(CSSProperty::resolveDirectionAwareProperty(colorProperty, direction(), writingMode()));
     case CSSPropertyColumnRuleColor:
-        result = visitedLink ? visitedLinkColumnRuleColor() : columnRuleColor();
-        break;
-    case CSSPropertyTextDecorationColor:
-        // Text decoration color fallback is handled in RenderObject::decorationColor.
-        return visitedLink ? visitedLinkTextDecorationColor() : textDecorationColor();
+        return visitedLink ? visitedLinkColumnRuleColor() : columnRuleColor();
     case CSSPropertyWebkitTextEmphasisColor:
-        result = visitedLink ? visitedLinkTextEmphasisColor() : textEmphasisColor();
-        break;
+        return visitedLink ? visitedLinkTextEmphasisColor() : textEmphasisColor();
     case CSSPropertyWebkitTextFillColor:
-        result = visitedLink ? visitedLinkTextFillColor() : textFillColor();
-        break;
+        return visitedLink ? visitedLinkTextFillColor() : textFillColor();
     case CSSPropertyWebkitTextStrokeColor:
-        result = visitedLink ? visitedLinkTextStrokeColor() : textStrokeColor();
-        break;
-    case CSSPropertyStrokeColor:
-        result = visitedLink ? visitedLinkStrokeColor() : strokeColor();
-        break;
+        return visitedLink ? visitedLinkTextStrokeColor() : textStrokeColor();
+    case CSSPropertyTextDecorationColor:
+        return visitedLink ? visitedLinkTextDecorationColor() : textDecorationColor();
+    case CSSPropertyCaretColor:
+        return visitedLink ? visitedLinkCaretColor() : caretColor();
     default:
         ASSERT_NOT_REACHED();
         break;
     }
 
-    if (!result.isValid()) {
+    return { };
+}
+
+Color RenderStyle::colorResolvingCurrentColor(CSSPropertyID colorProperty, bool visitedLink) const
+{
+    auto computeBorderStyle = [&] {
+        switch (colorProperty) {
+        case CSSPropertyBorderLeftColor:
+            return borderLeftStyle();
+        case CSSPropertyBorderRightColor:
+            return borderRightStyle();
+        case CSSPropertyBorderTopColor:
+            return borderTopStyle();
+        case CSSPropertyBorderBottomColor:
+            return borderBottomStyle();
+        default:
+            return BorderStyle::None;
+        }
+    };
+
+    auto result = unresolvedColorForProperty(colorProperty, visitedLink);
+
+    if (isCurrentColor(result)) {
+        auto borderStyle = computeBorderStyle();
         if (!visitedLink && (borderStyle == BorderStyle::Inset || borderStyle == BorderStyle::Outset || borderStyle == BorderStyle::Ridge || borderStyle == BorderStyle::Groove))
-            result = Color(238, 238, 238);
-        else
-            result = visitedLink ? visitedLinkColor() : color();
+            return Color(238, 238, 238);
+
+        return visitedLink ? visitedLinkColor() : color();
     }
+
     return result;
 }
 
 Color RenderStyle::colorResolvingCurrentColor(const Color& color) const
 {
-    if (color == currentColor())
+    if (isCurrentColor(color))
         return this->color();
 
     return color;
@@ -2022,11 +2041,11 @@
 
 Color RenderStyle::visitedDependentColor(CSSPropertyID colorProperty) const
 {
-    Color unvisitedColor = colorIncludingFallback(colorProperty, false);
+    Color unvisitedColor = colorResolvingCurrentColor(colorProperty, false);
     if (insideLink() != InsideLink::InsideVisited)
         return unvisitedColor;
 
-    Color visitedColor = colorIncludingFallback(colorProperty, true);
+    Color visitedColor = colorResolvingCurrentColor(colorProperty, true);
 
     // Text decoration color validity is preserved (checked in RenderObject::decorationColor).
     if (colorProperty == CSSPropertyTextDecorationColor)

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (259584 => 259585)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-04-06 18:54:09 UTC (rev 259585)
@@ -1440,7 +1440,9 @@
     bool lastChildState() const { return m_nonInheritedFlags.lastChildState; }
     void setLastChildState() { setUnique(); m_nonInheritedFlags.lastChildState = true; }
 
+    Color unresolvedColorForProperty(CSSPropertyID colorProperty, bool visitedLink = false) const;
     Color colorResolvingCurrentColor(const Color&) const;
+
     WEBCORE_EXPORT Color visitedDependentColor(CSSPropertyID) const;
     WEBCORE_EXPORT Color visitedDependentColorWithColorFilter(CSSPropertyID) const;
 
@@ -1734,6 +1736,8 @@
 
     // In RenderStyle invalid color value is used to signify 'currentcolor' which resolves to color().
     static Color currentColor() { return { }; }
+    static bool isCurrentColor(const Color& color) { return !color.isValid(); }
+
     const Color& borderLeftColor() const { return m_surroundData->border.left().color(); }
     const Color& borderRightColor() const { return m_surroundData->border.right().color(); }
     const Color& borderTopColor() const { return m_surroundData->border.top().color(); }
@@ -1866,7 +1870,7 @@
     static bool isDisplayGridBox(DisplayType);
     static bool isDisplayFlexibleOrGridBox(DisplayType);
 
-    Color colorIncludingFallback(CSSPropertyID colorProperty, bool visitedLink) const;
+    Color colorResolvingCurrentColor(CSSPropertyID colorProperty, bool visitedLink) const;
 
     bool changeAffectsVisualOverflow(const RenderStyle&) const;
     bool changeRequiresLayout(const RenderStyle&, OptionSet<StyleDifferenceContextSensitiveProperty>& changedContextSensitiveProperties) const;

Modified: trunk/Source/WebCore/style/StyleBuilderState.cpp (259584 => 259585)


--- trunk/Source/WebCore/style/StyleBuilderState.cpp	2020-04-06 18:48:38 UTC (rev 259584)
+++ trunk/Source/WebCore/style/StyleBuilderState.cpp	2020-04-06 18:54:09 UTC (rev 259585)
@@ -311,8 +311,6 @@
     case CSSValueWebkitFocusRingColor:
         return RenderTheme::singleton().focusRingColor(document().styleColorOptions(&m_style));
     case CSSValueCurrentcolor:
-        // Color is an inherited property so depending on it effectively makes the property inherited.
-        m_style.setHasExplicitlyInheritedProperties();
         return RenderStyle::currentColor();
     default:
         return StyleColor::colorFromKeyword(identifier, document().styleColorOptions(&m_style));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to