⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259532 in webkit


Ignore:
Timestamp:
Apr 4, 2020, 11:16:25 AM (6 years ago)
Author:
Antti Koivisto
Message:

Implement the css-color-4 behavior for inheritance of currentColor
https://bugs.webkit.org/show_bug.cgi?id=193171
<rdar://problem/47287516>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-text-decor/parsing/text-decoration-color-computed-expected.txt:
  • web-platform-tests/css/css-transitions/currentcolor-animation-001-expected.txt:
  • web-platform-tests/svg/pservers/scripted/stop-color-inheritance-currentcolor-expected.txt:

Source/WebCore:

In CSS3/4 'currentcolor' inherits as 'currentcolor' instead of as a resolved color value.

Value 'currentcolor' is represented in RenderStyle as invalid Color object. This has been true
even before the explicit property value for it was added. Fallback to 'color' has always been
the default behavior of most color properties.

As a result the correct behavior falls pretty easily from WebKit code. It essentially amounts to allowing
color properties to inherit normally even when they are invalid/currentcolor.

In future we might want to wrap RenderStyle color values into a type that makes 'currentcolor' more explicit.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):

  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::gradientWithStylesResolved):

  • css/CSSProperties.json:
  • Remove 'no-default-color' which triggered to old inheritance behavior.
  • Rename initial value invalidColor to currentColor for clarity.
  • css/makeprop.pl:

Code for 'no-default-color' generation is not needed anymore.

(generateInheritValueSetter):

  • page/animation/CSSPropertyAnimation.cpp:

(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::colorIncludingFallback const):

Resolve 'background-color' like the rest so setting it to 'currentcolor' works correctly.

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::currentColor):
(WebCore::RenderStyle::invalidColor): Deleted.

  • style/StyleBuilderCustom.h:

(WebCore::Style::BuilderCustom::applyTextOrBoxShadowValue):

  • style/StyleBuilderState.cpp:

(WebCore::Style::BuilderState::createFilterOperations):
(WebCore::Style::BuilderState::colorFromPrimitiveValue const):

Don't resolve 'currentcolor', instead return it as a value.

(WebCore::Style::BuilderState::colorFromPrimitiveValueWithResolvedCurrentColor const):

Helper for a few cases where we still resolve current color during style building time. It is
used for filters and generated images.

  • style/StyleBuilderState.h:
  • svg/SVGStopElement.cpp:

(WebCore::SVGStopElement::stopColorIncludingOpacity const):

Resolve 'currentcolor' during use time for svg color stops.

LayoutTests:

  • TestExpectations:
  • fast/borders/border-color-inherit-expected.html: Copied from LayoutTests/fast/borders/border-color-inherit.html.
  • fast/borders/border-color-inherit.html:

Fix for the new behavior and make it a reftest.

  • fast/css/webkit-text-fill-color-inherit.html:
  • platform/gtk/fast/borders/border-color-inherit-expected.png: Removed.
  • platform/gtk/fast/borders/border-color-inherit-expected.txt: Removed.
  • platform/ios/fast/borders/border-color-inherit-expected.txt: Removed.
  • platform/mac/fast/borders/border-color-inherit-expected.png: Removed.
  • platform/mac/fast/borders/border-color-inherit-expected.txt: Removed.
  • platform/win/fast/borders/border-color-inherit-expected.txt: Removed.
  • platform/wincairo/fast/borders/border-color-inherit-expected.txt: Removed.
  • platform/wpe/fast/borders/border-color-inherit-expected.txt: Removed.
Location:
trunk
Files:
8 deleted
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r259531 r259532  
     12020-04-04  Antti Koivisto  <antti@apple.com>
     2
     3        Implement the css-color-4 behavior for inheritance of currentColor
     4        https://bugs.webkit.org/show_bug.cgi?id=193171
     5        <rdar://problem/47287516>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * TestExpectations:
     10        * fast/borders/border-color-inherit-expected.html: Copied from LayoutTests/fast/borders/border-color-inherit.html.
     11        * fast/borders/border-color-inherit.html:
     12
     13        Fix for the new behavior and make it a reftest.
     14
     15        * fast/css/webkit-text-fill-color-inherit.html:
     16        * platform/gtk/fast/borders/border-color-inherit-expected.png: Removed.
     17        * platform/gtk/fast/borders/border-color-inherit-expected.txt: Removed.
     18        * platform/ios/fast/borders/border-color-inherit-expected.txt: Removed.
     19        * platform/mac/fast/borders/border-color-inherit-expected.png: Removed.
     20        * platform/mac/fast/borders/border-color-inherit-expected.txt: Removed.
     21        * platform/win/fast/borders/border-color-inherit-expected.txt: Removed.
     22        * platform/wincairo/fast/borders/border-color-inherit-expected.txt: Removed.
     23        * platform/wpe/fast/borders/border-color-inherit-expected.txt: Removed.
     24
    1252020-04-04  Peng Liu  <peng.liu6@apple.com>
    226
  • trunk/LayoutTests/TestExpectations

    r259452 r259532  
    18161816webkit.org/b/148650 fast/repaint/add-table-overpaint.html [ Pass Failure ]
    18171817
    1818 imported/w3c/web-platform-tests/css/css-cascade/all-prop-inherit-color.html [ ImageOnlyFailure ]
    1819 imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-color.html [ ImageOnlyFailure ]
    1820 imported/w3c/web-platform-tests/css/css-cascade/all-prop-unset-color.html [ ImageOnlyFailure ]
    18211818imported/w3c/web-platform-tests/css/css-cascade/important-prop.html [ ImageOnlyFailure ]
    18221819webkit.org/b/187093 [ Debug ] imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml.html [ Skip ]
     
    18441841
    18451842# Initial failures on the import of css-color
    1846 imported/w3c/web-platform-tests/css/css-color/currentcolor-002.html [ ImageOnlyFailure ]
    18471843imported/w3c/web-platform-tests/css/css-color/t31-color-text-a.xht [ ImageOnlyFailure ]
    1848 imported/w3c/web-platform-tests/css/css-color/t44-currentcolor-inherited-c.xht [ ImageOnlyFailure ]
    18491844
    18501845# Need to re-import canvas tests
     
    18971892imported/w3c/web-platform-tests/css/css-multicol/multicol-nested-margin-005.xht [ ImageOnlyFailure ]
    18981893webkit.org/b/148816 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-004.xht [ ImageOnlyFailure ]
    1899 imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-color-inherit-002.xht [ ImageOnlyFailure ]
    19001894imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-nested-balancing-001.html
    19011895imported/w3c/web-platform-tests/css/css-multicol/multicol-rule-nested-balancing-002.html
  • trunk/LayoutTests/fast/borders/border-color-inherit-expected.html

    r259531 r259532  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
     1<!doctype html>
    22<html>
    33 <head>
     
    55  <style type="text/css">
    66   .test { display: block; color: green; border: none;}
    7    .test .inner { border-color: inherit; border-style: solid; color: red; }
    8    .test .inner .text { color: green;}
     7   .test .inner { border-color: inherit; border-style: solid; }
    98   .test2 {margin: 1em 0 0;}
    109   .test2 .inner {border-right-color: inherit; border-bottom-color: inherit; border-top-color: inherit;}
    11    .test3 {margin: 1em 0 0; border: 3px solid;}
     10   .test3 {margin: 1em 0 0; border: 3px solid; }
    1211   .test3 .inner {border-top: inherit; border-right: inherit; border-left: inherit; border-bottom: inherit; border-top-width: 3px; border-top-style: solid; border-right-width: 3px; border-right-style: solid; border-left-width: 3px; border-left-style: solid; border-bottom-width: 3px; border-bottom-style: solid;}
    1312  </style>
     
    1716   <div class="inner">
    1817    <div class="text">
    19      This should have a green border, because the computed value of
    20      'border-color' set to its initial value is the computed value
    21      of 'color', which is then inherited as a color.
     18     This should have a green border.
    2219    </div>
    2320   </div>
  • trunk/LayoutTests/fast/borders/border-color-inherit.html

    r32421 r259532  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
     1<!doctype html>
    22<html>
    33 <head>
    44  <title>CSS inheritance: border-color</title>
    55  <style type="text/css">
    6    .test { display: block; color: green; border: none;}
    7    .test .inner { border-color: inherit; border-style: solid; color: red; }
     6   .test { display: block; color: red; border: none;}
     7   .test .inner { border-color: inherit; border-style: solid; color: green; }
    88   .test .inner .text { color: green;}
    99   .test2 {margin: 1em 0 0;}
    1010   .test2 .inner {border-right-color: inherit; border-bottom-color: inherit; border-top-color: inherit;}
    11    .test3 {margin: 1em 0 0; border: 3px solid;}
     11   .test3 {margin: 1em 0 0; border: 3px solid; color: green }
    1212   .test3 .inner {border-top: inherit; border-right: inherit; border-left: inherit; border-bottom: inherit; border-top-width: 3px; border-top-style: solid; border-right-width: 3px; border-right-style: solid; border-left-width: 3px; border-left-style: solid; border-bottom-width: 3px; border-bottom-style: solid;}
    1313  </style>
     
    1717   <div class="inner">
    1818    <div class="text">
    19      This should have a green border, because the computed value of
    20      'border-color' set to its initial value is the computed value
    21      of 'color', which is then inherited as a color.
     19     This should have a green border.
    2220    </div>
    2321   </div>
  • trunk/LayoutTests/fast/css/webkit-text-fill-color-inherit.html

    r231805 r259532  
    22<html>
    33<body>
    4     <div style="color: green">
    5         <div id="undefined-parent" style="color: red; -webkit-text-fill-color: inherit">Green</div>
     4    <div style="color: red">
     5        <div id="undefined-parent" style="color: green; -webkit-text-fill-color: inherit">Green</div>
    66    </div>
    77    <div style="color: purple; -webkit-text-fill-color: green">
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r259261 r259532  
     12020-04-04  Antti Koivisto  <antti@apple.com>
     2
     3        Implement the css-color-4 behavior for inheritance of currentColor
     4        https://bugs.webkit.org/show_bug.cgi?id=193171
     5        <rdar://problem/47287516>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * web-platform-tests/css/css-text-decor/parsing/text-decoration-color-computed-expected.txt:
     10        * web-platform-tests/css/css-transitions/currentcolor-animation-001-expected.txt:
     11        * web-platform-tests/svg/pservers/scripted/stop-color-inheritance-currentcolor-expected.txt:
     12
    1132020-03-30  Devin Rousso  <drousso@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-text-decor/parsing/text-decoration-color-computed-expected.txt

    r251689 r259532  
    22PASS Property text-decoration-color value 'rgb(0, 0, 255)' computes to 'rgb(0, 0, 255)'
    33PASS Property text-decoration-color value 'currentcolor' computes to 'rgb(0, 255, 0)'
    4 FAIL Property text-decoration-color value 'inherit' computes to 'rgb(0, 255, 0)' assert_equals: expected "rgb(0, 255, 0)" but got "rgb(255, 0, 0)"
     4PASS Property text-decoration-color value 'inherit' computes to 'rgb(0, 255, 0)'
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-transitions/currentcolor-animation-001-expected.txt

    r251591 r259532  
    11
    2 FAIL Transition does not occur when the value is currentcolor and color changes assert_true: expected true got false
     2PASS Transition does not occur when the value is currentcolor and color changes
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/svg/pservers/scripted/stop-color-inheritance-currentcolor-expected.txt

    r251777 r259532  
    11
    2 FAIL "currentcolor" is inherited as a keyword assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     2PASS "currentcolor" is inherited as a keyword
    33
  • trunk/Source/WebCore/ChangeLog

    r259531 r259532  
     12020-04-04  Antti Koivisto  <antti@apple.com>
     2
     3        Implement the css-color-4 behavior for inheritance of currentColor
     4        https://bugs.webkit.org/show_bug.cgi?id=193171
     5        <rdar://problem/47287516>
     6
     7        Reviewed by Simon Fraser.
     8
     9        In CSS3/4 'currentcolor' inherits as 'currentcolor' instead of as a resolved color value.
     10
     11        Value 'currentcolor' is represented in RenderStyle as invalid Color object. This has been true
     12        even before the explicit property value for it was added. Fallback to 'color' has always been
     13        the default behavior of most color properties.
     14
     15        As a result the correct behavior falls pretty easily from WebKit code. It essentially amounts to allowing
     16        color properties to inherit normally even when they are invalid/currentcolor.
     17
     18        In future we might want to wrap RenderStyle color values into a type that makes 'currentcolor' more explicit.
     19
     20        * css/CSSComputedStyleDeclaration.cpp:
     21        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
     22        * css/CSSGradientValue.cpp:
     23        (WebCore::CSSGradientValue::gradientWithStylesResolved):
     24        * css/CSSProperties.json:
     25
     26        - Remove 'no-default-color' which triggered to old inheritance behavior.
     27        - Rename initial value invalidColor to currentColor for clarity.
     28
     29        * css/makeprop.pl:
     30
     31        Code for 'no-default-color' generation is not needed anymore.
     32
     33        (generateInheritValueSetter):
     34        * page/animation/CSSPropertyAnimation.cpp:
     35        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
     36        * rendering/style/RenderStyle.cpp:
     37        (WebCore::RenderStyle::colorIncludingFallback const):
     38
     39        Resolve 'background-color' like the rest so setting it to 'currentcolor' works correctly.
     40
     41        * rendering/style/RenderStyle.h:
     42        (WebCore::RenderStyle::currentColor):
     43        (WebCore::RenderStyle::invalidColor): Deleted.
     44        * style/StyleBuilderCustom.h:
     45        (WebCore::Style::BuilderCustom::applyTextOrBoxShadowValue):
     46        * style/StyleBuilderState.cpp:
     47        (WebCore::Style::BuilderState::createFilterOperations):
     48        (WebCore::Style::BuilderState::colorFromPrimitiveValue const):
     49
     50        Don't resolve 'currentcolor', instead return it as a value.
     51
     52        (WebCore::Style::BuilderState::colorFromPrimitiveValueWithResolvedCurrentColor const):
     53
     54        Helper for a few cases where we still resolve current color during style building time. It is
     55        used for filters and generated images.
     56
     57        * style/StyleBuilderState.h:
     58        * svg/SVGStopElement.cpp:
     59        (WebCore::SVGStopElement::stopColorIncludingOpacity const):
     60
     61        Resolve 'currentcolor' during use time for svg color stops.
     62
    1632020-04-04  Peng Liu  <peng.liu6@apple.com>
    264
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r259006 r259532  
    24572457
    24582458        case CSSPropertyBackgroundColor:
    2459             return cssValuePool.createColorValue(m_allowVisitedStyle? style.visitedDependentColor(CSSPropertyBackgroundColor) : style.backgroundColor());
     2459            return m_allowVisitedStyle ? cssValuePool.createColorValue(style.visitedDependentColor(CSSPropertyBackgroundColor)) : currentColorOrValidColor(&style, style.backgroundColor());
    24602460        case CSSPropertyBackgroundImage:
    24612461        case CSSPropertyWebkitMaskImage: {
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r257966 r259532  
    112112    auto result = hasColorDerivedFromElement() ? clone(*this) : makeRef(*this);
    113113    resolveStopColors(result->m_stops, [&](const CSSPrimitiveValue& colorValue) {
    114         return builderState.colorFromPrimitiveValue(colorValue);
     114        return builderState.colorFromPrimitiveValueWithResolvedCurrentColor(colorValue);
    115115    });
    116116    return result;
  • trunk/Source/WebCore/css/CSSProperties.json

    r259006 r259532  
    8989        "StyleResolver::applyPropertyToRegularStyle() returns true.",
    9090        "",
    91         "* no-default-color:",
    92         "Should only be used with \"VisitedLinkColorSupport\". It indicates that when",
    93         "setting the inherited value, it will not fallback to using the parent's",
    94         "\"color\" property if the inherited color is invalid.",
    95         "",
    9691        "* font-property:",
    9792        "Indicates that this CSS property is font-related. It must have corresponding",
     
    185180            "inherited": true,
    186181            "codegen-properties": {
    187                 "initial": "invalidColor",
     182                "initial": "currentColor",
    188183                "visited-link-color-support": true
    189184            },
     
    197192            "codegen-properties": {
    198193                "visited-link-color-support": true,
    199                 "no-default-color": true,
    200194                "high-priority": true
    201195            },
     
    10601054        "background-color": {
    10611055            "codegen-properties": {
    1062                 "visited-link-color-support": true,
    1063                 "no-default-color": true
     1056                "visited-link-color-support": true
    10641057            },
    10651058            "specification": {
     
    14211414        "border-bottom-color": {
    14221415            "codegen-properties": {
    1423                 "initial": "invalidColor",
     1416                "initial": "currentColor",
    14241417                "visited-link-color-support": true
    14251418            },
     
    17741767        "border-left-color": {
    17751768            "codegen-properties": {
    1776                 "initial": "invalidColor",
     1769                "initial": "currentColor",
    17771770                "visited-link-color-support": true
    17781771            },
     
    18421835        "border-right-color": {
    18431836            "codegen-properties": {
    1844                 "initial": "invalidColor",
     1837                "initial": "currentColor",
    18451838                "visited-link-color-support": true
    18461839            },
     
    19231916        "border-top-color": {
    19241917            "codegen-properties": {
    1925                 "initial": "invalidColor",
     1918                "initial": "currentColor",
    19261919                "visited-link-color-support": true
    19271920            },
     
    31973190        "outline-color": {
    31983191            "codegen-properties": {
    3199                 "initial": "invalidColor",
     3192                "initial": "currentColor",
    32003193                "visited-link-color-support": true
    32013194            },
     
    37443737            "codegen-properties": {
    37453738                "custom": "Value",
    3746                 "initial": "invalidColor",
     3739                "initial": "currentColor",
    37473740                "visited-link-color-support": true
    37483741            },
     
    48424835                    "-webkit-column-rule-color"
    48434836                ],
    4844                 "initial": "invalidColor",
     4837                "initial": "currentColor",
    48454838                "visited-link-color-support": true
    48464839            },
     
    61766169        "text-decoration-color": {
    61776170            "codegen-properties": {
    6178                 "initial": "invalidColor",
     6171                "initial": "currentColor",
    61796172                "visited-link-color-support": true,
    61806173                "aliases": [
     
    62896282                    "text-emphasis-color"
    62906283                ],
    6291                 "initial": "invalidColor",
     6284                "initial": "currentColor",
    62926285                "visited-link-color-support": true
    62936286            },
     
    63366329            "inherited": true,
    63376330            "codegen-properties": {
    6338                 "initial": "invalidColor",
     6331                "initial": "currentColor",
    63396332                "visited-link-color-support": true
    63406333            },
     
    63676360            "inherited": true,
    63686361            "codegen-properties": {
    6369                 "initial": "invalidColor",
     6362                "initial": "currentColor",
    63706363                "visited-link-color-support": true
    63716364            },
  • trunk/Source/WebCore/css/makeprop.pl

    r259006 r259532  
    7878    "longhands" => 1,
    7979    "name-for-methods" => 1,
    80     "no-default-color" => 1,
    8180    "svg" => 1,
    8281    "skip-builder" => 1,
     
    981980  } elsif (exists $propertiesWithStyleBuilderOptions{$name}{"visited-link-color-support"}) {
    982981    $setterContent .= $indent . "    Color color = " . $parentStyle . "." . $getter . "();\n";
    983     if (!exists($propertiesWithStyleBuilderOptions{$name}{"no-default-color"})) {
    984       $setterContent .= $indent . "    if (!color.isValid())\n";
    985       $setterContent .= $indent . "        color = " . $parentStyle . ".color();\n";
    986     }
    987982    $setterContent .= generateColorValueSetter($name, "color", $indent . "    ");
    988983    $didCallSetValue = 1;
  • trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp

    r254861 r259532  
    15881588        new PropertyWrapperVisitedAffectedColor(CSSPropertyColor, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::visitedLinkColor, &RenderStyle::setVisitedLinkColor),
    15891589
    1590         new PropertyWrapperVisitedAffectedColor(CSSPropertyBackgroundColor, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::visitedLinkBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor),
     1590        new PropertyWrapperVisitedAffectedColor(CSSPropertyBackgroundColor, MaybeInvalidColor, &RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, &RenderStyle::visitedLinkBackgroundColor, &RenderStyle::setVisitedLinkBackgroundColor),
    15911591
    15921592        new FillLayersPropertyWrapper(CSSPropertyBackgroundImage, &RenderStyle::backgroundLayers, &RenderStyle::ensureBackgroundLayers),
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r258416 r259532  
    19541954    switch (colorProperty) {
    19551955    case CSSPropertyBackgroundColor:
    1956         return visitedLink ? visitedLinkBackgroundColor() : backgroundColor(); // Background color doesn't fall back.
     1956        result = visitedLink ? visitedLinkBackgroundColor() : backgroundColor();
     1957        break;
    19571958    case CSSPropertyBorderLeftColor:
    19581959        result = visitedLink ? visitedLinkBorderLeftColor() : borderLeftColor();
     
    20102011    }
    20112012    return result;
     2013}
     2014
     2015Color RenderStyle::colorResolvingCurrentColor(const Color& color) const
     2016{
     2017    if (color == currentColor())
     2018        return this->color();
     2019
     2020    return color;
    20122021}
    20132022
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r258416 r259532  
    14411441    void setLastChildState() { setUnique(); m_nonInheritedFlags.lastChildState = true; }
    14421442
     1443    Color colorResolvingCurrentColor(const Color&) const;
    14431444    WEBCORE_EXPORT Color visitedDependentColor(CSSPropertyID) const;
    14441445    WEBCORE_EXPORT Color visitedDependentColorWithColorFilter(CSSPropertyID) const;
     
    15851586    static Length initialPerspectiveOriginY() { return Length(50.0f, Percent); }
    15861587    static Color initialBackgroundColor() { return Color::transparent; }
    1587     static Color initialTextEmphasisColor() { return Color(); }
     1588    static Color initialTextEmphasisColor() { return currentColor(); }
    15881589    static TextEmphasisFill initialTextEmphasisFill() { return TextEmphasisFill::Filled; }
    15891590    static TextEmphasisMark initialTextEmphasisMark() { return TextEmphasisMark::None; }
     
    17321733    void getShadowBlockDirectionExtent(const ShadowData*, LayoutUnit& logicalTop, LayoutUnit& logicalBottom) const;
    17331734
    1734     static Color invalidColor() { return Color(); }
     1735    // In RenderStyle invalid color value is used to signify 'currentcolor' which resolves to color().
     1736    static Color currentColor() { return { }; }
    17351737    const Color& borderLeftColor() const { return m_surroundData->border.left().color(); }
    17361738    const Color& borderRightColor() const { return m_surroundData->border.right().color(); }
  • trunk/Source/WebCore/style/StyleBuilderCustom.h

    r259006 r259532  
    820820        Color color;
    821821        if (shadowValue.color)
    822             color = builderState.colorFromPrimitiveValue(*shadowValue.color);
     822            color = builderState.colorFromPrimitiveValueWithResolvedCurrentColor(*shadowValue.color);
    823823        else
    824824            color = builderState.style().color();
     825
    825826        auto shadowData = makeUnique<ShadowData>(LayoutPoint(x, y), blur, spread, shadowStyle, property == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent);
    826827        if (property == CSSPropertyTextShadow)
  • trunk/Source/WebCore/style/StyleBuilderState.cpp

    r255490 r259532  
    268268            Color color;
    269269            if (item.color)
    270                 color = colorFromPrimitiveValue(*item.color);
     270                color = colorFromPrimitiveValueWithResolvedCurrentColor(*item.color);
    271271
    272272            operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent));
     
    313313    case CSSValueCurrentcolor:
    314314        // Color is an inherited property so depending on it effectively makes the property inherited.
    315         // FIXME: Setting the flag as a side effect of calling this function is a bit oblique. Can we do better?
     315        m_style.setHasExplicitlyInheritedProperties();
     316        return RenderStyle::currentColor();
     317    default:
     318        return StyleColor::colorFromKeyword(identifier, document().styleColorOptions(&m_style));
     319    }
     320}
     321
     322Color BuilderState::colorFromPrimitiveValueWithResolvedCurrentColor(const CSSPrimitiveValue& value) const
     323{
     324    // FIXME: 'currentcolor' should be resolved at use time to make it inherit correctly. https://bugs.webkit.org/show_bug.cgi?id=210005
     325    if (value.valueID() == CSSValueCurrentcolor) {
     326        // Color is an inherited property so depending on it effectively makes the property inherited.
    316327        m_style.setHasExplicitlyInheritedProperties();
    317328        return m_style.color();
    318     default:
    319         return StyleColor::colorFromKeyword(identifier, document().styleColorOptions(&m_style));
    320     }
     329    }
     330
     331    return colorFromPrimitiveValue(value);
    321332}
    322333
  • trunk/Source/WebCore/style/StyleBuilderState.h

    r254861 r259532  
    8989    static bool isColorFromPrimitiveValueDerivedFromElement(const CSSPrimitiveValue&);
    9090    Color colorFromPrimitiveValue(const CSSPrimitiveValue&, bool forVisitedLink = false) const;
     91    // FIXME: Remove. 'currentcolor' should be resolved at use time. All call sites are broken with inheritance.
     92    Color colorFromPrimitiveValueWithResolvedCurrentColor(const CSSPrimitiveValue&) const;
    9193
    9294    const Vector<AtomString>& registeredContentAttributes() const { return m_registeredContentAttributes; }
  • trunk/Source/WebCore/svg/SVGStopElement.cpp

    r246490 r259532  
    8888Color SVGStopElement::stopColorIncludingOpacity() const
    8989{
    90     auto* style = renderer() ? &renderer()->style() : nullptr;
    91     // FIXME: This check for null style exists to address Bug WK 90814, a rare crash condition in which the renderer or style is null.
    92     if (!style)
     90    if (!renderer())
    9391        return Color(Color::transparent, true);
    9492
    95     const SVGRenderStyle& svgStyle = style->svgStyle();
    96     float colorAlpha = svgStyle.stopColor().alpha() / 255.0;
     93    auto& style = renderer()->style();
     94    auto& svgStyle = style.svgStyle();
     95    auto stopColor = style.colorResolvingCurrentColor(svgStyle.stopColor());
     96
     97    float colorAlpha = stopColor.alpha() / 255.0;
    9798    // FIXME: This should use colorWithAlphaMultipliedBy() but that has different rounding of the alpha component.
    98     return colorWithOverrideAlpha(svgStyle.stopColor().rgb(), colorAlpha * svgStyle.stopOpacity());
     99    return colorWithOverrideAlpha(stopColor.rgb(), colorAlpha * svgStyle.stopOpacity());
    99100}
    100101
Note: See TracChangeset for help on using the changeset viewer.