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

Changeset 279050 in webkit


Ignore:
Timestamp:
Jun 19, 2021, 1:31:11 PM (5 years ago)
Author:
Darin Adler
Message:

Fix CSS serialization issues affecting css-counter-styles tests
https://bugs.webkit.org/show_bug.cgi?id=226708

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-counter-styles/counter-style-additive-symbols-syntax-expected.txt:
  • web-platform-tests/css/css-counter-styles/counter-style-symbols-syntax-expected.txt:
  • web-platform-tests/css/css-syntax/url-whitespace-consumption-expected.txt:

Updated to reflect progressions.

Source/WebCore:

Fix two serialization isssues affecting css-counter-styles tests:

1) URLs were serializing the full resolved URL, rather than the

partial URL string from the style sheet.

2) Items in additive-symbols that had both an integer and a string

would incorrectly serialize with a comma within the item.

  • css/CSSCrossfadeValue.cpp:

(WebCore::CSSCrossfadeValue::valueWithStylesResolved): Added.
Calls resolveImageStyles on the image values.

  • css/CSSCrossfadeValue.h: Updated for the above.
  • css/CSSCursorImageValue.cpp:

(WebCore::CSSCursorImageValue::CSSCursorImageValue): Changed the hot spot
to use std::optional instead of a separate boolean.
(WebCore::CSSCursorImageValue::create): Moved this out of the header
because it's not better for inlining to have it there.
(WebCore::CSSCursorImageValue::customCSSText const): Updated for the
m_hotSpot changes.
(WebCore::CSSCursorImageValue::updateCursorElement): Removed unneeded
check of hasFragmentIdentifier, which is already done by the
SVGURIReference::targetElementFromIRIString function. Updated to use
m_originalSpecifiedURLString, and added a FIXME about the strange way
this just keeps accumulating more and more clients in a set, but did
not change that behavior.
(WebCore::CSSCursorImageValue::cursorElementRemoved): Added a FIXME.
(WebCore::CSSCursorImageValue::cursorElementChanged): Updated for the
change to m_hotSpot and addded some FIXME.
(WebCore::CSSCursorImageValue::equals const): Updated for the m_hotSpot
change; much simpler since std::optional does the right thing.
(WebCore::CSSCursorImageValue::valueWithStylesResolved): Added.
Calls resolveImageStyles on the image value.

  • css/CSSCursorImageValue.h: Updated for the above changes.
  • css/CSSFilterImageValue.cpp:

(WebCore::CSSFilterImageValue::valueWithStylesResolved): Added.
Calls resolveImageStyles on the image value and also calls
createFilterOperations.

  • css/CSSFilterImageValue.h: Updated for the above.
  • css/CSSGradientValue.cpp:

(WebCore::CSSGradientValue::valueWithStylesResolved): Renamed from
gradientWithStylesResolved.

  • css/CSSGradientValue.h: Updated for the above.
  • css/CSSImageSetValue.cpp:

(WebCore::CSSImageSetValue::valueWithStylesResolved): Renamed from
imageSetWithStylesResolved. Optimized the case where the resolved
version is not different to re-use the original CSSImageSetValue.

  • css/CSSImageSetValue.h: Updated for the above.
  • css/CSSImageValue.cpp:

(WebCore::operator==): Added. Check if two ResolvedURL are equal.
(WebCore::makeResolvedURL): Added. Make a ResolvedURL from an
existing URL without the original specified string.
(WebCore::CSSImageValue::CSSImageValue): Take ResolvedURL instead
of a URL. Also updated to use std::optional instead of a separate
m_accessedImage boolean.
(WebCore::CSSImageValue::create): Added an overload that takes
ResolvedURL argument and also moved here from the header since we
don't get any benefit from inlining.
(WebCore::CSSImageValue::isPending const): Updates since m_cachedImage
is now a std::optional, and the std::nullopt case is used for this.
(WebCore::CSSImageValue::reresolvedURL const): Added. Used so we can
share code between the following functions.
(WebCore::CSSImageValue::valueWithStylesResolved): Added. Computes
the fully resolved URL and makes a new image value if needed that
always uses it. Also points the new value at the old one so we can
update m_cachedImage in both.
(WebCore::CSSImageValue::loadImage): Use the new reresolvedURL function.
Also update m_cachedImage in any underlying objects.
(WebCore::CSSImageValue::traverseSubresources): Updated for change
to m_cachedImage.
(WebCore::CSSImageValue::equals const): Updated for change to use
ResolvedURL.
(WebCore::CSSImageValue::customCSSText const): Ditto. This is the
only place where we use specifiedURLString.
(WebCore::CSSImageValue::createDeprecatedCSSOMWrapper const): Updated
for change from m_url.
(WebCore::CSSImageValue::knownToBeOpaque const): Updated for change
to m_cachedImage.

  • css/CSSImageValue.h: Added ResolvedURL, new create

overloads. Replaced url() function with location() function, which
returns a string. Note that this always returns the resolved string,
only customCSSText returns the original string. Replaced m_url with
m_location, eliminated m_accessedImage and made m_cachedImage use
std::optional instead. Added m_unresolvedValue.

  • css/StyleSheetContents.cpp:

(WebCore::StyleSheetContents::completeURL const): Deleted unused function.

  • css/StyleSheetContents.h: Ditto.
  • css/parser/CSSParserContext.cpp:

(WebCore::CSSParserContext::completeURL const): Updated to return
ResolvedURL instead of a URL.

  • css/parser/CSSParserContext.h: Ditto.
  • css/parser/CSSParserIdioms.cpp:

(WebCore::completeURL): Deleted unused function.

  • css/parser/CSSParserIdioms.h: Ditto.
  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeCursor): Use std::optional for the hot spot.
(WebCore::consumeCounterStyleAdditiveSymbols): Put the integer/symbol
pair into a separate space-separated list instead of appending both
to the top level command-separated list. Also removed support for
non-standard "image without symbol" and "symbol without image".
Neither the specification nor the web platform tests currently call
for that.

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumeImage): Call the new
overload of CSSImageValue::create, passing a ResolvedURL.

  • css/parser/CSSPropertyParserWorkerSafe.cpp:

(WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontFaceSrcURI):
Update for the change to completeURL and refactor a bit. Later we could
make the same kind of fix for CSSFontFaceSrcValue that we did in this
patch for CSSImageValue, but did not try that for now.

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::addCursor): Updated to take a std::optional for
the hot spot.

  • rendering/style/RenderStyle.h: Ditto.
  • rendering/style/StyleCachedImage.cpp:

(WebCore::StyleCachedImage::imageURL): Updated for CSSImageValue::imageURL.

  • style/StyleBuilderCustom.h:

(WebCore::Style::BuilderCustom::applyValueContent): Call
resolveImageStyles consistently.

  • style/StyleBuilderState.cpp:

(WebCore::Style::BuilderState::resolveImageStyles): Call the new
valueWithStylesResolved function on all the different image value
types. This unifies the approach across all 6 classes.
(WebCore::Style::BuilderState::createStyleImage): Tweaked style.

LayoutTests:

  • fast/css/parse-border-image-repeat-null-crash-expected.txt: Update to reflect correct

path; the path is not really relevant to what was being tested here either way.

  • fast/css/uri-token-parsing-expected.txt: Updated to expect behavior that is sensible

and also matches Firefox.

  • fast/css/uri-token-parsing.html: Ditto.
  • fast/fast/css/url-with-multi-byte-unicode-escape-expected.txt: Updated to expect that

URL is still encoded as UTF-8, not yet re-URL-encoded as it will be for loading. The
one that will be used for loading can still be seen in computed style. The test still
covers correclty parsig this URL.

  • fast/fast/css/url-with-multi-byte-unicode-escape.html: Ditto.
  • fast/filter-image/parse-filter-image-expected.txt: Updated to no longer test addition

of trailing slashes to peculiar URLs that are made by using filenames as host names.
Now this checks URLs that just contain filenames, which makes more logical sense, and
no trailing slash addition is expected.

  • fast/filter-image/parse-filter-image.html: Ditto.
  • fast/innerHTML/innerHTML-uri-resolution.html: Updated test to use computed style so

it no longer depends on WebKit-only behavior to run correctly.

Location:
trunk
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r279047 r279050  
     12021-06-19  Darin Adler  <darin@apple.com>
     2
     3        Fix CSS serialization issues affecting css-counter-styles tests
     4        https://bugs.webkit.org/show_bug.cgi?id=226708
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/css/parse-border-image-repeat-null-crash-expected.txt: Update to reflect correct
     9        path; the path is not really relevant to what was being tested here either way.
     10
     11        * fast/css/uri-token-parsing-expected.txt: Updated to expect behavior that is sensible
     12        and also matches Firefox.
     13        * fast/css/uri-token-parsing.html: Ditto.
     14
     15        * fast/fast/css/url-with-multi-byte-unicode-escape-expected.txt: Updated to expect that
     16        URL is still encoded as UTF-8, not yet re-URL-encoded as it will be for loading. The
     17        one that will be used for loading can still be seen in computed style. The test still
     18        covers correclty parsig this URL.
     19        * fast/fast/css/url-with-multi-byte-unicode-escape.html: Ditto.
     20
     21        * fast/filter-image/parse-filter-image-expected.txt: Updated to no longer test addition
     22        of trailing slashes to peculiar URLs that are made by using filenames as host names.
     23        Now this checks URLs that just contain filenames, which makes more logical sense, and
     24        no trailing slash addition is expected.
     25        * fast/filter-image/parse-filter-image.html: Ditto.
     26
     27        * fast/innerHTML/innerHTML-uri-resolution.html: Updated test to use computed style so
     28        it no longer depends on WebKit-only behavior to run correctly.
     29
    1302021-06-18  Chris Dumez  <cdumez@apple.com>
    231
  • trunk/LayoutTests/fast/css/parse-border-image-repeat-null-crash-expected.txt

    r259900 r279050  
    1 CONSOLE MESSAGE: border-image-source: url("shadow-border.png"); border-image-slice: 10; border-image-repeat: stretch;
     1CONSOLE MESSAGE: border-image-source: url("images/shadow-border.png"); border-image-slice: 10; border-image-repeat: stretch;
    22This test should not crash
  • trunk/LayoutTests/fast/css/uri-token-parsing-expected.txt

    r231359 r279050  
    1010#d { content: url("f"); }
    1111#f { content: url("c"); }
    12 #g { content: url("d"); }
    13 #h { content: url("e"); }
    14 #i { content: url("f"); }
     12#g { content: url(" d"); }
     13#h { content: url("e "); }
     14#i { content: url(" f "); }
    1515#j { content: url("url(g)"); }
    1616#l { content: url("c"); }
    17 #m { content: url("d"); }
    18 #n { content: url("e"); }
    19 #o { content: url("f"); }
     17#m { content: url(" d"); }
     18#n { content: url("e "); }
     19#o { content: url(" f "); }
    2020#p { content: url("url(g)"); }
    2121#q { cursor: url("url(q)"), default; }
     
    2525#u { -webkit-border-image: url("url(u)") 1 2 3 4 fill stretch round; }
    2626#v { -webkit-mask-box-image: url("url(v)") 1 2 3 4 fill stretch round; }
    27 #w { content: url("ww"); }
    28 #x { content: url("x%20xx"); }
    29 #y { content: url("y%20yy"); }
     27#w { content: url("w\d w"); }
     28#x { content: url(" x x\9 x "); }
     29#y { content: url("y y\9 y"); }
    3030Expected result:
    3131
     
    3535#d { content: url("f"); }
    3636#f { content: url("c"); }
    37 #g { content: url("d"); }
    38 #h { content: url("e"); }
    39 #i { content: url("f"); }
     37#g { content: url(" d"); }
     38#h { content: url("e "); }
     39#i { content: url(" f "); }
    4040#j { content: url("url(g)"); }
    4141#l { content: url("c"); }
    42 #m { content: url("d"); }
    43 #n { content: url("e"); }
    44 #o { content: url("f"); }
     42#m { content: url(" d"); }
     43#n { content: url("e "); }
     44#o { content: url(" f "); }
    4545#p { content: url("url(g)"); }
    4646#q { cursor: url("url(q)"), default; }
     
    5050#u { -webkit-border-image: url("url(u)") 1 2 3 4 fill stretch round; }
    5151#v { -webkit-mask-box-image: url("url(v)") 1 2 3 4 fill stretch round; }
    52 #w { content: url("ww"); }
    53 #x { content: url("x%20xx"); }
    54 #y { content: url("y%20yy"); }
     52#w { content: url("w\d w"); }
     53#x { content: url(" x x\9 x "); }
     54#y { content: url("y y\9 y"); }
    5555
  • trunk/LayoutTests/fast/css/uri-token-parsing.html

    r231359 r279050  
    4545    var text = "";
    4646    for (var i = 0; i < rules.length; i++) {
    47         var itemText = rules.item(i).cssText;
    48 
    49         // Work around bug where WebKit completes the URLs in the CSS DOM.
    50         // The completion of the URL should be when they are used, not in the DOM.
    51         itemText = itemText.replace(/file:.*LayoutTests\/fast\/css\//, "");
    52 
    53         text += itemText;
     47        text += rules.item(i).cssText;
    5448        text += "\n";
    5549    }
     
    8478#d { content: url("f"); }
    8579#f { content: url("c"); }
    86 #g { content: url("d"); }
    87 #h { content: url("e"); }
    88 #i { content: url("f"); }
     80#g { content: url(" d"); }
     81#h { content: url("e "); }
     82#i { content: url(" f "); }
    8983#j { content: url("url(g)"); }
    9084#l { content: url("c"); }
    91 #m { content: url("d"); }
    92 #n { content: url("e"); }
    93 #o { content: url("f"); }
     85#m { content: url(" d"); }
     86#n { content: url("e "); }
     87#o { content: url(" f "); }
    9488#p { content: url("url(g)"); }
    9589#q { cursor: url("url(q)"), default; }
     
    9993#u { -webkit-border-image: url("url(u)") 1 2 3 4 fill stretch round; }
    10094#v { -webkit-mask-box-image: url("url(v)") 1 2 3 4 fill stretch round; }
    101 #w { content: url("ww"); }
    102 #x { content: url("x%20xx"); }
    103 #y { content: url("y%20yy"); }
     95#w { content: url("w\d w"); }
     96#x { content: url(" x x\9 x "); }
     97#y { content: url("y y\9 y"); }
    10498</pre>
    10599
  • trunk/LayoutTests/fast/css/url-with-multi-byte-unicode-escape-expected.txt

    r231359 r279050  
    55
    66PASS document.styleSheets[0].cssRules.length is 2
    7 PASS document.styleSheets[0].cssRules[0].style.getPropertyValue("background-image") is "url(\"data:%C4%80\")"
    8 PASS document.styleSheets[0].cssRules[0].style.getPropertyValue("border-image-source") is "url(\"data:%C4%80\")"
     7PASS document.styleSheets[0].cssRules[0].style.getPropertyValue("background-image") is "url(\"data:Ā\")"
     8PASS document.styleSheets[0].cssRules[0].style.getPropertyValue("border-image-source") is "url(\"data:Ā\")"
    99PASS document.styleSheets[0].cssRules[1].style.getPropertyValue("background-color") is "green"
    1010PASS window.getComputedStyle(document.getElementById("test")).getPropertyValue("background-color") is "rgb(0, 128, 0)"
  • trunk/LayoutTests/fast/css/url-with-multi-byte-unicode-escape.html

    r231359 r279050  
    1414    description('Test parsing a CSS URI containing a multi-byte Unicode escape sequence.');
    1515    shouldBe('document.styleSheets[0].cssRules.length', '2');
    16     shouldBeEqualToString('document.styleSheets[0].cssRules[0].style.getPropertyValue("background-image")', 'url("data:%C4%80")');
    17     shouldBeEqualToString('document.styleSheets[0].cssRules[0].style.getPropertyValue("border-image-source")', 'url("data:%C4%80")');
     16    shouldBeEqualToString('document.styleSheets[0].cssRules[0].style.getPropertyValue("background-image")', 'url("data:\u0100")');
     17    shouldBeEqualToString('document.styleSheets[0].cssRules[0].style.getPropertyValue("border-image-source")', 'url("data:\u0100")');
    1818    shouldBeEqualToString('document.styleSheets[0].cssRules[1].style.getPropertyValue("background-color")', 'green');
    1919    shouldBeEqualToString('window.getComputedStyle(document.getElementById("test")).getPropertyValue("background-color")', 'rgb(0, 128, 0)');
  • trunk/LayoutTests/fast/filter-image/parse-filter-image-expected.txt

    r231359 r279050  
    7979PASS innerStyle("background-image", "filter(linear-gradient(to top left, white, black), hue-rotate(90deg))") is "filter(linear-gradient(to left top, white, black), hue-rotate(90deg))"
    8080PASS innerStyle("background-image", "filter(linear-gradient(0deg, white -20%, blue, black 120%), hue-rotate(90deg))") is "filter(linear-gradient(0deg, white -20%, blue, black 120%), hue-rotate(90deg))"
    81 PASS innerStyle("background-image", "filter(-webkit-cross-fade(url(http://image1.png), url(http://image2.png), 50%), contrast(0.5))") is "filter(-webkit-cross-fade(url(\"http://image1.png/\"), url(\"http://image2.png/\"), 0.5), contrast(0.5))"
    82 PASS innerStyle("background-image", "filter(url(http://image1.png), brightness(50%))") is "filter(url(\"http://image1.png/\"), brightness(50%))"
    83 PASS innerStyle("background-image", "filter(url('http://image1.png'), brightness(50%))") is "filter(url(\"http://image1.png/\"), brightness(50%))"
    84 PASS innerStyle("border-image-source", "filter(url(http://image1.png), invert(50%))") is "filter(url(\"http://image1.png/\"), invert(50%))"
    85 PASS innerStyle("-webkit-mask-image", "filter(url(http://image1.png), invert(50%))") is "filter(url(\"http://image1.png/\"), invert(50%))"
    86 PASS innerStyle("-webkit-mask-box-image-source", "filter(url(http://image1.png), invert(50%))") is "filter(url(\"http://image1.png/\"), invert(50%))"
    87 PASS innerStyle("content", "filter(url(http://image1.png), invert(50%))") is "filter(url(\"http://image1.png/\"), invert(50%))"
     81PASS innerStyle("background-image", "filter(-webkit-cross-fade(url(image1.png), url(image2.png), 50%), contrast(0.5))") is "filter(-webkit-cross-fade(url(\"image1.png\"), url(\"image2.png\"), 0.5), contrast(0.5))"
     82PASS innerStyle("background-image", "filter(url(image1.png), brightness(50%))") is "filter(url(\"image1.png\"), brightness(50%))"
     83PASS innerStyle("background-image", "filter(url('image1.png'), brightness(50%))") is "filter(url(\"image1.png\"), brightness(50%))"
     84PASS innerStyle("border-image-source", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))"
     85PASS innerStyle("-webkit-mask-image", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))"
     86PASS innerStyle("-webkit-mask-box-image-source", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))"
     87PASS innerStyle("content", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))"
    8888PASS innerStyle("background-image", "filter()") is ""
    8989PASS computedStyle("background-image", "filter()") is "none"
  • trunk/LayoutTests/fast/filter-image/parse-filter-image.html

    r231359 r279050  
    346346testInner(
    347347    "background-image",
    348     "filter(-webkit-cross-fade(url(http://image1.png), url(http://image2.png), 50%), contrast(0.5))",
    349     "filter(-webkit-cross-fade(url(\"http://image1.png/\"), url(\"http://image2.png/\"), 0.5), contrast(0.5))");
    350 testInner(
    351     "background-image",
    352     "filter(url(http://image1.png), brightness(50%))",
    353     "filter(url(\"http://image1.png/\"), brightness(50%))");
    354 testInner(
    355     "background-image",
    356     "filter(url('http://image1.png'), brightness(50%))",
    357     "filter(url(\"http://image1.png/\"), brightness(50%))");
     348    "filter(-webkit-cross-fade(url(image1.png), url(image2.png), 50%), contrast(0.5))",
     349    "filter(-webkit-cross-fade(url(\"image1.png\"), url(\"image2.png\"), 0.5), contrast(0.5))");
     350testInner(
     351    "background-image",
     352    "filter(url(image1.png), brightness(50%))",
     353    "filter(url(\"image1.png\"), brightness(50%))");
     354testInner(
     355    "background-image",
     356    "filter(url('image1.png'), brightness(50%))",
     357    "filter(url(\"image1.png\"), brightness(50%))");
    358358
    359359// Test different properties, taking CSS Image values.
    360360testInner(
    361361    "border-image-source",
    362     "filter(url(http://image1.png), invert(50%))",
    363     "filter(url(\"http://image1.png/\"), invert(50%))");
     362    "filter(url(image1.png), invert(50%))",
     363    "filter(url(\"image1.png\"), invert(50%))");
    364364testInner(
    365365    "-webkit-mask-image",
    366     "filter(url(http://image1.png), invert(50%))",
    367     "filter(url(\"http://image1.png/\"), invert(50%))");
     366    "filter(url(image1.png), invert(50%))",
     367    "filter(url(\"image1.png\"), invert(50%))");
    368368testInner(
    369369    "-webkit-mask-box-image-source",
    370     "filter(url(http://image1.png), invert(50%))",
    371     "filter(url(\"http://image1.png/\"), invert(50%))");
     370    "filter(url(image1.png), invert(50%))",
     371    "filter(url(\"image1.png\"), invert(50%))");
    372372testInner(
    373373    "content",
    374     "filter(url(http://image1.png), invert(50%))",
    375     "filter(url(\"http://image1.png/\"), invert(50%))");
     374    "filter(url(image1.png), invert(50%))",
     375    "filter(url(\"image1.png\"), invert(50%))");
    376376
    377377// negative tests
  • trunk/LayoutTests/fast/innerHTML/innerHTML-uri-resolution.html

    r231359 r279050  
    1414  var currentUri = document.location.href;
    1515  var currentPath = currentUri.substring(0, currentUri.lastIndexOf('/'));
    16   var cssUriWasResolvedAgainstDocumentUri = document.getElementById("test-span").style.backgroundImage == 'url("' + currentPath + '/image.png")';
     16  var cssUriWasResolvedAgainstDocumentUri = getComputedStyle(document.getElementById("test-span")).backgroundImage == 'url("' + currentPath + '/image.png")';
    1717 
    1818  // Can't log the actual path since it's different depending on where the test is run.
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r279047 r279050  
     12021-06-19  Darin Adler  <darin@apple.com>
     2
     3        Fix CSS serialization issues affecting css-counter-styles tests
     4        https://bugs.webkit.org/show_bug.cgi?id=226708
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * web-platform-tests/css/css-counter-styles/counter-style-additive-symbols-syntax-expected.txt:
     9        * web-platform-tests/css/css-counter-styles/counter-style-symbols-syntax-expected.txt:
     10        * web-platform-tests/css/css-syntax/url-whitespace-consumption-expected.txt:
     11        Updated to reflect progressions.
     12
    1132021-06-18  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-additive-symbols-syntax-expected.txt

    r277079 r279050  
    11
    2 FAIL @counter-style 'additive-symbols: 0 "X"' is valid assert_not_equals: got disallowed value -1
    3 FAIL @counter-style 'additive-symbols: 1 "X"' is valid assert_not_equals: got disallowed value -1
    4 FAIL @counter-style 'additive-symbols: "X" 1' is valid assert_not_equals: got disallowed value -1
    5 FAIL @counter-style 'additive-symbols: 5 "V", 1 "I"' is valid assert_not_equals: got disallowed value -1
     2PASS @counter-style 'additive-symbols: 0 "X"' is valid
     3PASS @counter-style 'additive-symbols: 1 "X"' is valid
     4PASS @counter-style 'additive-symbols: "X" 1' is valid
     5PASS @counter-style 'additive-symbols: 5 "V", 1 "I"' is valid
    66PASS @counter-style 'additive-symbols: ' is invalid
    77PASS @counter-style 'additive-symbols: -1 "X"' is invalid
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-symbols-syntax-expected.txt

    r278540 r279050  
    33PASS @counter-style 'symbols: "X" "X"' is valid
    44PASS @counter-style 'symbols: ident "X"' is valid
    5 FAIL @counter-style 'symbols: ident "X" url("foo.jpg")' is valid assert_not_equals: got disallowed value -1
     5PASS @counter-style 'symbols: ident "X" url("foo.jpg")' is valid
    66PASS @counter-style 'symbols: ' is invalid
    77PASS @counter-style 'symbols: initial "X" "X"' is invalid
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/url-whitespace-consumption-expected.txt

    r251635 r279050  
    11
    2 FAIL whitespace is optional between url( token and the string token assert_equals: expected "url(\"foo\")" but got "url(\"http://localhost:8800/css/css-syntax/foo\")"
     2PASS whitespace is optional between url( token and the string token
    33
  • trunk/Source/WebCore/ChangeLog

    r279047 r279050  
     12021-06-19  Darin Adler  <darin@apple.com>
     2
     3        Fix CSS serialization issues affecting css-counter-styles tests
     4        https://bugs.webkit.org/show_bug.cgi?id=226708
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Fix two serialization isssues affecting css-counter-styles tests:
     9
     10        1) URLs were serializing the full resolved URL, rather than the
     11           partial URL string from the style sheet.
     12        2) Items in additive-symbols that had both an integer and a string
     13           would incorrectly serialize with a comma within the item.
     14
     15        * css/CSSCrossfadeValue.cpp:
     16        (WebCore::CSSCrossfadeValue::valueWithStylesResolved): Added.
     17        Calls resolveImageStyles on the image values.
     18        * css/CSSCrossfadeValue.h: Updated for the above.
     19
     20        * css/CSSCursorImageValue.cpp:
     21        (WebCore::CSSCursorImageValue::CSSCursorImageValue): Changed the hot spot
     22        to use std::optional instead of a separate boolean.
     23        (WebCore::CSSCursorImageValue::create): Moved this out of the header
     24        because it's not better for inlining to have it there.
     25        (WebCore::CSSCursorImageValue::customCSSText const): Updated for the
     26        m_hotSpot changes.
     27        (WebCore::CSSCursorImageValue::updateCursorElement): Removed unneeded
     28        check of hasFragmentIdentifier, which is already done by the
     29        SVGURIReference::targetElementFromIRIString function. Updated to use
     30        m_originalSpecifiedURLString, and added a FIXME about the strange way
     31        this just keeps accumulating more and more clients in a set, but did
     32        not change that behavior.
     33        (WebCore::CSSCursorImageValue::cursorElementRemoved): Added a FIXME.
     34        (WebCore::CSSCursorImageValue::cursorElementChanged): Updated for the
     35        change to m_hotSpot and addded some FIXME.
     36        (WebCore::CSSCursorImageValue::equals const): Updated for the m_hotSpot
     37        change; much simpler since std::optional does the right thing.
     38        (WebCore::CSSCursorImageValue::valueWithStylesResolved): Added.
     39        Calls resolveImageStyles on the image value.
     40        * css/CSSCursorImageValue.h: Updated for the above changes.
     41
     42        * css/CSSFilterImageValue.cpp:
     43        (WebCore::CSSFilterImageValue::valueWithStylesResolved): Added.
     44        Calls resolveImageStyles on the image value and also calls
     45        createFilterOperations.
     46        * css/CSSFilterImageValue.h: Updated for the above.
     47
     48        * css/CSSGradientValue.cpp:
     49        (WebCore::CSSGradientValue::valueWithStylesResolved): Renamed from
     50        gradientWithStylesResolved.
     51        * css/CSSGradientValue.h: Updated for the above.
     52
     53        * css/CSSImageSetValue.cpp:
     54        (WebCore::CSSImageSetValue::valueWithStylesResolved): Renamed from
     55        imageSetWithStylesResolved. Optimized the case where the resolved
     56        version is not different to re-use the original CSSImageSetValue.
     57        * css/CSSImageSetValue.h: Updated for the above.
     58
     59        * css/CSSImageValue.cpp:
     60        (WebCore::operator==): Added. Check if two ResolvedURL are equal.
     61        (WebCore::makeResolvedURL): Added. Make a ResolvedURL from an
     62        existing URL without the original specified string.
     63        (WebCore::CSSImageValue::CSSImageValue): Take ResolvedURL instead
     64        of a URL. Also updated to use std::optional instead of a separate
     65        m_accessedImage boolean.
     66        (WebCore::CSSImageValue::create): Added an overload that takes
     67        ResolvedURL argument and also moved here from the header since we
     68        don't get any benefit from inlining.
     69        (WebCore::CSSImageValue::isPending const): Updates since m_cachedImage
     70        is now a std::optional, and the std::nullopt case is used for this.
     71        (WebCore::CSSImageValue::reresolvedURL const): Added. Used so we can
     72        share code between the following functions.
     73        (WebCore::CSSImageValue::valueWithStylesResolved): Added. Computes
     74        the fully resolved URL and makes a new image value if needed that
     75        always uses it. Also points the new value at the old one so we can
     76        update m_cachedImage in both.
     77        (WebCore::CSSImageValue::loadImage): Use the new reresolvedURL function.
     78        Also update m_cachedImage in any underlying objects.
     79        (WebCore::CSSImageValue::traverseSubresources): Updated for change
     80        to m_cachedImage.
     81        (WebCore::CSSImageValue::equals const): Updated for change to use
     82        ResolvedURL.
     83        (WebCore::CSSImageValue::customCSSText const): Ditto. This is the
     84        only place where we use specifiedURLString.
     85        (WebCore::CSSImageValue::createDeprecatedCSSOMWrapper const): Updated
     86        for change from m_url.
     87        (WebCore::CSSImageValue::knownToBeOpaque const): Updated for change
     88        to m_cachedImage.
     89        * css/CSSImageValue.h: Added ResolvedURL, new create
     90        overloads. Replaced url() function with location() function, which
     91        returns a string. Note that this always returns the resolved string,
     92        only customCSSText returns the original string. Replaced m_url with
     93        m_location, eliminated m_accessedImage and made m_cachedImage use
     94        std::optional instead. Added m_unresolvedValue.
     95
     96        * css/StyleSheetContents.cpp:
     97        (WebCore::StyleSheetContents::completeURL const): Deleted unused function.
     98        * css/StyleSheetContents.h: Ditto.
     99
     100        * css/parser/CSSParserContext.cpp:
     101        (WebCore::CSSParserContext::completeURL const): Updated to return
     102        ResolvedURL instead of a URL.
     103        * css/parser/CSSParserContext.h: Ditto.
     104
     105        * css/parser/CSSParserIdioms.cpp:
     106        (WebCore::completeURL): Deleted unused function.
     107        * css/parser/CSSParserIdioms.h: Ditto.
     108
     109        * css/parser/CSSPropertyParser.cpp:
     110        (WebCore::consumeCursor): Use std::optional for the hot spot.
     111        (WebCore::consumeCounterStyleAdditiveSymbols): Put the integer/symbol
     112        pair into a separate space-separated list instead of appending both
     113        to the top level command-separated list. Also removed support for
     114        non-standard "image without symbol" and "symbol without image".
     115        Neither the specification nor the web platform tests currently call
     116        for that.
     117
     118        * css/parser/CSSPropertyParserHelpers.cpp:
     119        (WebCore::CSSPropertyParserHelpers::consumeImage): Call the new
     120        overload of CSSImageValue::create, passing a ResolvedURL.
     121
     122        * css/parser/CSSPropertyParserWorkerSafe.cpp:
     123        (WebCore::CSSPropertyParserHelpersWorkerSafe::consumeFontFaceSrcURI):
     124        Update for the change to completeURL and refactor a bit. Later we could
     125        make the same kind of fix for CSSFontFaceSrcValue that we did in this
     126        patch for CSSImageValue, but did not try that for now.
     127
     128        * rendering/style/RenderStyle.cpp:
     129        (WebCore::RenderStyle::addCursor): Updated to take a std::optional for
     130        the hot spot.
     131        * rendering/style/RenderStyle.h: Ditto.
     132
     133        * rendering/style/StyleCachedImage.cpp:
     134        (WebCore::StyleCachedImage::imageURL): Updated for CSSImageValue::imageURL.
     135
     136        * style/StyleBuilderCustom.h:
     137        (WebCore::Style::BuilderCustom::applyValueContent): Call
     138        resolveImageStyles consistently.
     139
     140        * style/StyleBuilderState.cpp:
     141        (WebCore::Style::BuilderState::resolveImageStyles): Call the new
     142        valueWithStylesResolved function on all the different image value
     143        types. This unifies the approach across all 6 classes.
     144        (WebCore::Style::BuilderState::createStyleImage): Tweaked style.
     145
    11462021-06-18  Chris Dumez  <cdumez@apple.com>
    2147
  • trunk/Source/WebCore/css/CSSCrossfadeValue.cpp

    r276141 r279050  
    11/*
    2  * Copyright (C) 2011 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2011-2021 Apple Inc.  All rights reserved.
    33 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
    44 *
     
    3434#include "CrossfadeGeneratedImage.h"
    3535#include "RenderElement.h"
     36#include "StyleBuilderState.h"
    3637#include "StyleCachedImage.h"
    37 #include <wtf/text/StringBuilder.h>
    3838
    3939namespace WebCore {
     
    229229}
    230230
    231 
    232231bool CSSCrossfadeValue::equalInputImages(const CSSCrossfadeValue& other) const
    233232{
     
    235234}
    236235
     236Ref<CSSCrossfadeValue> CSSCrossfadeValue::valueWithStylesResolved(Style::BuilderState& state)
     237{
     238    auto fromValue = state.resolveImageStyles(m_fromValue.get());
     239    auto toValue = state.resolveImageStyles(m_toValue.get());
     240    if (fromValue.ptr() == m_fromValue.ptr() && toValue.ptr() == m_toValue.ptr())
     241        return *this;
     242    return create(WTFMove(fromValue), WTFMove(toValue), Ref { m_percentageValue }, m_isPrefixed);
     243}
     244
    237245} // namespace WebCore
  • trunk/Source/WebCore/css/CSSCrossfadeValue.h

    r276141 r279050  
    11/*
    2  * Copyright (C) 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6161    bool equalInputImages(const CSSCrossfadeValue&) const;
    6262
     63    Ref<CSSCrossfadeValue> valueWithStylesResolved(Style::BuilderState&);
     64
    6365private:
    6466    CSSCrossfadeValue(Ref<CSSValue>&& fromValue, Ref<CSSValue>&& toValue, Ref<CSSPrimitiveValue>&& percentageValue, bool prefixed);
  • trunk/Source/WebCore/css/CSSCursorImageValue.cpp

    r260709 r279050  
    22 * Copyright (C) 2006 Rob Buis <buis@kde.org>
    33 *           (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
    4  * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2525#include "CSSImageSetValue.h"
    2626#include "CSSImageValue.h"
    27 #include "CachedImage.h"
    28 #include "CachedResourceLoader.h"
    2927#include "SVGCursorElement.h"
    3028#include "SVGLengthContext.h"
    3129#include "SVGURIReference.h"
    3230#include <wtf/MathExtras.h>
    33 #include <wtf/text/StringBuilder.h>
    3431#include <wtf/text/WTFString.h>
    3532
    3633namespace WebCore {
    3734
    38 CSSCursorImageValue::CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource)
     35CSSCursorImageValue::CSSCursorImageValue(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource)
    3936    : CSSValue(CursorImageClass)
    4037    , m_imageValue(WTFMove(imageValue))
    41     , m_hasHotSpot(hasHotSpot)
    4238    , m_hotSpot(hotSpot)
    4339    , m_loadedFromOpaqueSource(loadedFromOpaqueSource)
    4440{
    4541    if (is<CSSImageValue>(m_imageValue.get()))
    46         m_originalURL = downcast<CSSImageValue>(m_imageValue.get()).url();
     42        m_originalURL = downcast<CSSImageValue>(m_imageValue.get()).imageURL();
     43}
     44
     45Ref<CSSCursorImageValue> CSSCursorImageValue::create(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource)
     46{
     47    return adoptRef(*new CSSCursorImageValue(WTFMove(imageValue), hotSpot, loadedFromOpaqueSource));
    4748}
    4849
     
    5657{
    5758    String text = m_imageValue.get().cssText();
    58     if (!m_hasHotSpot)
     59    if (!m_hotSpot)
    5960        return text;
    60     return makeString(text, ' ', m_hotSpot.x(), ' ', m_hotSpot.y());
     61    return makeString(text, ' ', m_hotSpot->x(), ' ', m_hotSpot->y());
    6162}
    6263
     
    6465SVGCursorElement* CSSCursorImageValue::updateCursorElement(const Document& document)
    6566{
    66     if (!m_originalURL.hasFragmentIdentifier())
    67         return nullptr;
    68 
    6967    auto element = SVGURIReference::targetElementFromIRIString(m_originalURL.string(), document).element;
    7068    if (!is<SVGCursorElement>(element))
    7169        return nullptr;
    7270
     71    // FIXME: Not right to keep old cursor elements as clients. The new one should replace the old, not join it in a set.
    7372    auto& cursorElement = downcast<SVGCursorElement>(*element);
    7473    if (m_cursorElements.add(&cursorElement).isNewEntry) {
     
    8180void CSSCursorImageValue::cursorElementRemoved(SVGCursorElement& cursorElement)
    8281{
     82    // FIXME: Not right to stay a client of a cursor element until the element is destroyed. We'd want to stop being a client once it's no longer a valid target, like when it's disconnected.
    8383    m_cursorElements.remove(&cursorElement);
    8484}
     
    8686void CSSCursorImageValue::cursorElementChanged(SVGCursorElement& cursorElement)
    8787{
    88     // FIXME: This will override hot spot specified in CSS, which is probably incorrect.
     88    // FIXME: Seems wrong that changing an old cursor element, one that that is no longer the target, changes the hot spot.
     89    // FIXME: This will override a hot spot that was specified in CSS, which is probably incorrect.
     90    // FIXME: Should we clamp from float to int instead of just casting here?
    8991    SVGLengthContext lengthContext(nullptr);
    90     m_hasHotSpot = true;
    91     float x = std::round(cursorElement.x().value(lengthContext));
    92     m_hotSpot.setX(static_cast<int>(x));
     92    m_hotSpot = IntPoint {
     93        static_cast<int>(std::round(cursorElement.x().value(lengthContext))),
     94        static_cast<int>(std::round(cursorElement.y().value(lengthContext)))
     95    };
    9396
    94     float y = std::round(cursorElement.y().value(lengthContext));
    95     m_hotSpot.setY(static_cast<int>(y));
     97    // FIXME: Why doesn't this funtion check for a change to the href of the cursor element? Why would we dynamically track changes to x/y but not href?
    9698}
    9799
     
    102104
    103105    if (auto* cursorElement = updateCursorElement(document)) {
    104         if (cursorElement->href() != downcast<CSSImageValue>(m_imageValue.get()).url())
    105             m_imageValue = CSSImageValue::create(document.completeURL(cursorElement->href()), m_loadedFromOpaqueSource);
     106        auto location = document.completeURL(cursorElement->href());
     107        if (location != downcast<CSSImageValue>(m_imageValue.get()).imageURL())
     108            m_imageValue = CSSImageValue::create(WTFMove(location), m_loadedFromOpaqueSource);
    106109    }
    107110
     
    111114bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const
    112115{
    113     return m_hasHotSpot ? other.m_hasHotSpot && m_hotSpot == other.m_hotSpot : !other.m_hasHotSpot
    114         && compareCSSValue(m_imageValue, other.m_imageValue);
     116    return m_hotSpot == other.m_hotSpot && compareCSSValue(m_imageValue, other.m_imageValue);
     117}
     118
     119Ref<CSSCursorImageValue> CSSCursorImageValue::valueWithStylesResolved(Style::BuilderState& state)
     120{
     121    auto imageValue = state.resolveImageStyles(m_imageValue.get());
     122    if (imageValue.ptr() == m_imageValue.ptr())
     123        return *this;
     124    return create(WTFMove(imageValue), m_hotSpot, m_loadedFromOpaqueSource);
    115125}
    116126
  • trunk/Source/WebCore/css/CSSCursorImageValue.h

    r254861 r279050  
    11/*
    22 * Copyright (C) 2006 Rob Buis <buis@kde.org>
    3  * Copyright (C) 2008 Apple Inc. All right reserved.
     3 * Copyright (C) 2008-2021 Apple Inc. All right reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    2828namespace WebCore {
    2929
    30 class CachedImage;
    31 class CachedResourceLoader;
    3230class Document;
    33 class Element;
    3431class SVGCursorElement;
    35 class SVGElement;
    3632
    3733struct ImageWithScale;
     
    4339class CSSCursorImageValue final : public CSSValue {
    4440public:
    45     static Ref<CSSCursorImageValue> create(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource)
    46     {
    47         return adoptRef(*new CSSCursorImageValue(WTFMove(imageValue), hasHotSpot, hotSpot, loadedFromOpaqueSource));
    48     }
    49 
     41    static Ref<CSSCursorImageValue> create(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource);
    5042    ~CSSCursorImageValue();
    5143
    52     bool hasHotSpot() const { return m_hasHotSpot; }
    53 
    54     IntPoint hotSpot() const
    55     {
    56         if (m_hasHotSpot)
    57             return m_hotSpot;
    58         return IntPoint(-1, -1);
    59     }
     44    std::optional<IntPoint> hotSpot() const { return m_hotSpot; }
    6045
    6146    const URL& imageURL() const { return m_originalURL; }
     
    6550    ImageWithScale selectBestFitImage(const Document&);
    6651
    67     void removeReferencedElement(SVGElement*);
    68 
    6952    bool equals(const CSSCursorImageValue&) const;
    7053
     
    7255    void cursorElementChanged(SVGCursorElement&);
    7356
     57    Ref<CSSCursorImageValue> valueWithStylesResolved(Style::BuilderState&);
     58
    7459private:
    75     CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource);
     60    CSSCursorImageValue(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource);
    7661
    7762    SVGCursorElement* updateCursorElement(const Document&);
     
    7964    URL m_originalURL;
    8065    Ref<CSSValue> m_imageValue;
    81 
    82     bool m_hasHotSpot;
    83     IntPoint m_hotSpot;
     66    std::optional<IntPoint> m_hotSpot;
    8467    HashSet<SVGCursorElement*> m_cursorElements;
    8568    LoadedFromOpaqueSource m_loadedFromOpaqueSource { LoadedFromOpaqueSource::No };
  • trunk/Source/WebCore/css/CSSFilterImageValue.cpp

    r277986 r279050  
    11/*
    22 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
     3 * Copyright (C) 2021 Apple Inc. All right reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3637#include "StyleBuilderState.h"
    3738#include "StyleCachedImage.h"
    38 #include <wtf/text/StringBuilder.h>
    3939
    4040namespace WebCore {
     
    174174}
    175175
     176Ref<CSSFilterImageValue> CSSFilterImageValue::valueWithStylesResolved(Style::BuilderState& state)
     177{
     178    auto imageValue = state.resolveImageStyles(m_imageValue.get());
     179    if (imageValue.ptr() == m_imageValue.ptr()) {
     180        createFilterOperations(state);
     181        return *this;
     182    }
     183    auto filterImageValue = create(WTFMove(imageValue), Ref { m_filterValue });
     184    filterImageValue->createFilterOperations(state);
     185    return filterImageValue;
     186}
     187
    176188} // namespace WebCore
  • trunk/Source/WebCore/css/CSSFilterImageValue.h

    r251916 r279050  
    11/*
    22 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
     3 * Copyright (C) 2021 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3637namespace WebCore {
    3738
    38 class CachedImage;
    3939class FilterSubimageObserverProxy;
    4040class RenderElement;
    41 class Document;
    4241
    4342namespace Style {
     
    7271    bool equalInputImages(const CSSFilterImageValue&) const;
    7372
    74     void createFilterOperations(Style::BuilderState&);
     73    const FilterOperations& filterOperations() const { return m_filterOperations; }
     74    void setFilterOperations(const FilterOperations& filterOperations) { m_filterOperations = filterOperations; }
     75    CachedImage* cachedImage() const { return m_cachedImage.get(); }
    7576
    76     const FilterOperations& filterOperations() const { return m_filterOperations; }
    77     void setFilterOperations(const FilterOperations& filterOperations)
    78     {
    79         m_filterOperations = filterOperations;
    80     }
    81     CachedImage* cachedImage() const { return m_cachedImage.get(); }
     77    Ref<CSSFilterImageValue> valueWithStylesResolved(Style::BuilderState&);
    8278
    8379private:
     
    107103
    108104    void filterImageChanged(const IntRect&);
     105    void createFilterOperations(Style::BuilderState&);
    109106
    110107    Ref<CSSValue> m_imageValue;
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r278246 r279050  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    108108}
    109109
    110 Ref<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(Style::BuilderState& builderState)
     110Ref<CSSGradientValue> CSSGradientValue::valueWithStylesResolved(Style::BuilderState& builderState)
    111111{
    112112    auto result = hasColorDerivedFromElement() ? clone(*this) : makeRef(*this);
  • trunk/Source/WebCore/css/CSSGradientValue.h

    r278253 r279050  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7979    static void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&) { }
    8080
    81     Ref<CSSGradientValue> gradientWithStylesResolved(Style::BuilderState&);
     81    Ref<CSSGradientValue> valueWithStylesResolved(Style::BuilderState&);
    8282
    8383protected:
  • trunk/Source/WebCore/css/CSSImageSetValue.cpp

    r277967 r279050  
    11/*
    2  * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    114114}
    115115
    116 Ref<CSSImageSetValue> CSSImageSetValue::imageSetWithStylesResolved(Style::BuilderState& builderState)
     116Ref<CSSImageSetValue> CSSImageSetValue::valueWithStylesResolved(Style::BuilderState& builderState)
    117117{
    118     Ref<CSSImageSetValue> result = CSSImageSetValue::create();
    119     size_t length = this->length();
    120     for (size_t i = 0; i + 1 < length; i += 2) {
     118    auto result = create();
     119    for (size_t i = 0, length = this->length(); i + 1 < length; i += 2) {
    121120        result->append(builderState.resolveImageStyles(*itemWithoutBoundsCheck(i)));
    122121        result->append(*itemWithoutBoundsCheck(i + 1));
    123122    }
    124 
    125     return result;
     123    return equals(result) ? Ref { *this } : result;
    126124}
    127125
  • trunk/Source/WebCore/css/CSSImageSetValue.h

    r260415 r279050  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6262    void updateDeviceScaleFactor(const Document&);
    6363
    64     Ref<CSSImageSetValue> imageSetWithStylesResolved(Style::BuilderState&);
     64    Ref<CSSImageSetValue> valueWithStylesResolved(Style::BuilderState&);
    6565
    6666private:
  • trunk/Source/WebCore/css/CSSImageValue.cpp

    r260709 r279050  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004-2017 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    3535namespace WebCore {
    3636
    37 CSSImageValue::CSSImageValue(URL&& url, LoadedFromOpaqueSource loadedFromOpaqueSource)
     37static bool operator==(const ResolvedURL& a, const ResolvedURL& b)
     38{
     39    return a.specifiedURLString == b.specifiedURLString && a.resolvedURL == b.resolvedURL;
     40}
     41
     42static ResolvedURL makeResolvedURL(URL&& resolvedURL)
     43{
     44    auto string = resolvedURL.string();
     45    return { WTFMove(string), WTFMove(resolvedURL) };
     46}
     47
     48CSSImageValue::CSSImageValue(ResolvedURL&& location, LoadedFromOpaqueSource loadedFromOpaqueSource)
    3849    : CSSValue(ImageClass)
    39     , m_url(WTFMove(url))
    40     , m_accessedImage(false)
     50    , m_location(WTFMove(location))
    4151    , m_loadedFromOpaqueSource(loadedFromOpaqueSource)
    4252{
     
    4555CSSImageValue::CSSImageValue(CachedImage& image)
    4656    : CSSValue(ImageClass)
    47     , m_url(image.url())
     57    , m_location { image.url().string(), image.url() }
    4858    , m_cachedImage(&image)
    49     , m_accessedImage(true)
    5059{
    5160}
    5261
     62Ref<CSSImageValue> CSSImageValue::create(ResolvedURL&& location, LoadedFromOpaqueSource loadedFromOpaqueSource)
     63{
     64    return adoptRef(*new CSSImageValue(WTFMove(location), loadedFromOpaqueSource));
     65}
     66
     67Ref<CSSImageValue> CSSImageValue::create(URL&& imageURL, LoadedFromOpaqueSource loadedFromOpaqueSource)
     68{
     69    return create(makeResolvedURL(WTFMove(imageURL)), loadedFromOpaqueSource);
     70}
     71
     72Ref<CSSImageValue> CSSImageValue::create(CachedImage& image)
     73{
     74    return adoptRef(*new CSSImageValue(image));
     75}
    5376
    5477CSSImageValue::~CSSImageValue() = default;
     
    5679bool CSSImageValue::isPending() const
    5780{
    58     return !m_accessedImage;
     81    return !m_cachedImage;
     82}
     83
     84URL CSSImageValue::reresolvedURL(const Document& document) const
     85{
     86    // Re-resolving the URL is important for cases where resolvedURL is still not an absolute URL.
     87    // This can happen if there was no absolute base URL when the value was created, like a style from a document without a base URL.
     88    return document.completeURL(m_location.resolvedURL.string());
     89}
     90
     91Ref<CSSImageValue> CSSImageValue::valueWithStylesResolved(Style::BuilderState& state)
     92{
     93    auto location = makeResolvedURL(reresolvedURL(state.document()));
     94    if (m_location == location)
     95        return *this;
     96    auto result = create(WTFMove(location), m_loadedFromOpaqueSource);
     97    result->m_cachedImage = m_cachedImage;
     98    result->m_initiatorName = m_initiatorName;
     99    result->m_unresolvedValue = this;
     100    return result;
    59101}
    60102
    61103CachedImage* CSSImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options)
    62104{
    63     if (!m_accessedImage) {
    64         m_accessedImage = true;
    65 
     105    if (!m_cachedImage) {
    66106        ResourceLoaderOptions loadOptions = options;
    67107        loadOptions.loadedFromOpaqueSource = m_loadedFromOpaqueSource;
    68         CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url.string())), loadOptions);
     108        CachedResourceRequest request(ResourceRequest(reresolvedURL(*loader.document())), loadOptions);
    69109        if (m_initiatorName.isEmpty())
    70110            request.setInitiator(cachedResourceRequestInitiators().css);
    71111        else
    72112            request.setInitiator(m_initiatorName);
    73 
    74113        if (options.mode == FetchOptions::Mode::Cors) {
    75114            ASSERT(loader.document());
     
    77116        }
    78117        m_cachedImage = loader.requestImage(WTFMove(request)).value_or(nullptr);
     118        for (auto imageValue = this; (imageValue = imageValue->m_unresolvedValue.get()); )
     119            imageValue->m_cachedImage = m_cachedImage;
    79120    }
    80     return m_cachedImage.get();
     121    return m_cachedImage.value().get();
    81122}
    82123
    83124bool CSSImageValue::traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const
    84125{
    85     if (!m_cachedImage)
    86         return false;
    87     return handler(*m_cachedImage);
     126    return m_cachedImage.value_or(nullptr) && handler(**m_cachedImage);
    88127}
    89128
    90129bool CSSImageValue::equals(const CSSImageValue& other) const
    91130{
    92     return m_url == other.m_url;
     131    return m_location == other.m_location;
    93132}
    94133
    95134String CSSImageValue::customCSSText() const
    96135{
    97     return serializeURL(m_url.string());
     136    return serializeURL(m_location.specifiedURLString);
    98137}
    99138
     
    101140{
    102141    // NOTE: We expose CSSImageValues as URI primitive values in CSSOM to maintain old behavior.
    103     return DeprecatedCSSOMPrimitiveValue::create(CSSPrimitiveValue::create(m_url.string(), CSSUnitType::CSS_URI), styleDeclaration);
     142    return DeprecatedCSSOMPrimitiveValue::create(CSSPrimitiveValue::create(m_location.resolvedURL.string(), CSSUnitType::CSS_URI), styleDeclaration);
    104143}
    105144
    106145bool CSSImageValue::knownToBeOpaque(const RenderElement& renderer) const
    107146{
    108     if (!m_cachedImage)
    109         return false;
    110     return m_cachedImage->currentFrameKnownToBeOpaque(&renderer);
     147    return m_cachedImage.value_or(nullptr) && (**m_cachedImage).currentFrameKnownToBeOpaque(&renderer);
    111148}
    112149
  • trunk/Source/WebCore/css/CSSImageValue.h

    r246490 r279050  
    11/*
    22 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
    3  * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
     3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    1010 * This library is distributed in the hope that it will be useful,
    1111 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    1313 * Library General Public License for more details.
    1414 *
     
    3535class RenderElement;
    3636
     37namespace Style {
     38class BuilderState;
     39}
     40
     41struct ResolvedURL {
     42    String specifiedURLString;
     43    URL resolvedURL;
     44};
     45
    3746class CSSImageValue final : public CSSValue {
    3847public:
    39     static Ref<CSSImageValue> create(URL&& url, LoadedFromOpaqueSource loadedFromOpaqueSource) { return adoptRef(*new CSSImageValue(WTFMove(url), loadedFromOpaqueSource)); }
    40     static Ref<CSSImageValue> create(CachedImage& image) { return adoptRef(*new CSSImageValue(image)); }
     48    static Ref<CSSImageValue> create(ResolvedURL&&, LoadedFromOpaqueSource);
     49    static Ref<CSSImageValue> create(URL&&, LoadedFromOpaqueSource);
     50    static Ref<CSSImageValue> create(CachedImage&);
    4151    ~CSSImageValue();
    4252
    4353    bool isPending() const;
    4454    CachedImage* loadImage(CachedResourceLoader&, const ResourceLoaderOptions&);
    45     CachedImage* cachedImage() const { return m_cachedImage.get(); }
     55    CachedImage* cachedImage() const { return m_cachedImage ? m_cachedImage.value().get() : nullptr; }
    4656
    47     const URL& url() const { return m_url; }
     57    const URL& imageURL() const { return m_location.resolvedURL; }
    4858
    4959    String customCSSText() const;
     
    5969    void setInitiator(const AtomString& name) { m_initiatorName = name; }
    6070
     71    Ref<CSSImageValue> valueWithStylesResolved(Style::BuilderState&);
     72
    6173private:
    62     CSSImageValue(URL&&, LoadedFromOpaqueSource);
     74    CSSImageValue(ResolvedURL&&, LoadedFromOpaqueSource);
    6375    explicit CSSImageValue(CachedImage&);
    6476
    65     URL m_url;
    66     CachedResourceHandle<CachedImage> m_cachedImage;
    67     bool m_accessedImage;
     77    URL reresolvedURL(const Document&) const;
     78
     79    ResolvedURL m_location;
     80    std::optional<CachedResourceHandle<CachedImage>> m_cachedImage;
    6881    AtomString m_initiatorName;
    6982    LoadedFromOpaqueSource m_loadedFromOpaqueSource { LoadedFromOpaqueSource::No };
     83    RefPtr<CSSImageValue> m_unresolvedValue;
    7084};
    7185
  • trunk/Source/WebCore/css/StyleSheetContents.cpp

    r276152 r279050  
    416416    Node* ownerNode = singleOwnerNode();
    417417    return ownerNode ? &ownerNode->document() : 0;
    418 }
    419 
    420 URL StyleSheetContents::completeURL(const String& url) const
    421 {
    422     return m_parserContext.completeURL(url);
    423418}
    424419
  • trunk/Source/WebCore/css/StyleSheetContents.h

    r270803 r279050  
    8787    bool loadCompleted() const { return m_loadCompleted; }
    8888
    89     URL completeURL(const String& url) const;
    9089    bool traverseRules(const WTF::Function<bool (const StyleRuleBase&)>& handler) const;
    9190    bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const;
  • trunk/Source/WebCore/css/parser/CSSParserContext.cpp

    r276488 r279050  
    2727#include "CSSParserContext.h"
    2828
     29#include "CSSImageValue.h"
    2930#include "Document.h"
    3031#include "DocumentLoader.h"
     
    221222}
    222223
    223 URL CSSParserContext::completeURL(const String& url) const
    224 {
    225     auto completedURL = [&] {
    226         if (url.isNull())
    227             return URL();
     224ResolvedURL CSSParserContext::completeURL(const String& string) const
     225{
     226    auto result = [&] () -> ResolvedURL {
     227        if (string.isNull())
     228            return { };
    228229        if (charset.isEmpty())
    229             return URL(baseURL, url);
    230         TextEncoding encoding(charset);
    231         auto& encodingForURLParsing = encoding.encodingForFormSubmissionOrURLParsing();
    232         return URL(baseURL, url, encodingForURLParsing == UTF8Encoding() ? nullptr : &encodingForURLParsing);
     230            return { string, { baseURL, string } };
     231        auto encodingForURLParsing = TextEncoding { charset }.encodingForFormSubmissionOrURLParsing();
     232        return { string, { baseURL, string, encodingForURLParsing == UTF8Encoding() ? nullptr : &encodingForURLParsing } };
    233233    }();
    234234
    235     if (mode == WebVTTMode && !completedURL.protocolIsData())
    236         return URL();
    237 
    238     return completedURL;
    239 }
    240 
    241 }
     235    if (mode == WebVTTMode && !result.resolvedURL.protocolIsData())
     236        return { };
     237
     238    return result;
     239}
     240
     241}
  • trunk/Source/WebCore/css/parser/CSSParserContext.h

    r278340 r279050  
    3737
    3838class Document;
     39
     40struct ResolvedURL;
    3941
    4042struct CSSParserContext {
     
    8991    WEBCORE_EXPORT CSSParserContext(const Document&, const URL& baseURL = URL(), const String& charset = emptyString());
    9092    bool isPropertyRuntimeDisabled(CSSPropertyID) const;
    91     URL completeURL(const String& relativeURL) const;
     93    ResolvedURL completeURL(const String&) const;
    9294};
    9395
  • trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp

    r236565 r279050  
    4646}
    4747
    48 URL completeURL(const CSSParserContext& context, const String& url)
    49 {
    50     return context.completeURL(url);
    51 }
    52 
    5348} // namespace WebCore
  • trunk/Source/WebCore/css/parser/CSSParserIdioms.h

    r238771 r279050  
    6060bool isValueAllowedInMode(unsigned short, CSSParserMode);
    6161
    62 URL completeURL(const CSSParserContext&, const String& url);
    63 
    6462} // namespace WebCore
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r278669 r279050  
    22592259{
    22602260    RefPtr<CSSValueList> list;
    2261     while (RefPtr<CSSValue> image = consumeImage(range, context, { AllowedImageType::URLFunction, AllowedImageType::ImageSet })) {
    2262         IntPoint hotSpot(-1, -1);
    2263         bool hotSpotSpecified = false;
     2261    while (auto image = consumeImage(range, context, { AllowedImageType::URLFunction, AllowedImageType::ImageSet })) {
     2262        std::optional<IntPoint> hotSpot;
    22642263        if (auto x = consumeNumberRaw(range)) {
    2265             hotSpot.setX(static_cast<int>(*x));
    22662264            auto y = consumeNumberRaw(range);
    22672265            if (!y)
    22682266                return nullptr;
    2269             hotSpot.setY(static_cast<int>(*y));
    2270             hotSpotSpecified = true;
     2267            // FIXME: Should we clamp or round instead of just casting from double to int?
     2268            hotSpot = IntPoint { static_cast<int>(*x), static_cast<int>(*y) };
    22712269        }
    22722270
     
    22742272            list = CSSValueList::createCommaSeparated();
    22752273
    2276         list->append(CSSCursorImageValue::create(image.releaseNonNull(), hotSpotSpecified, hotSpot, context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No));
     2274        list->append(CSSCursorImageValue::create(image.releaseNonNull(), hotSpot, context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No));
    22772275        if (!consumeCommaIncludingWhitespace(range))
    22782276            return nullptr;
     
    46694667{
    46704668    auto values = CSSValueList::createCommaSeparated();
    4671     RefPtr<CSSPrimitiveValue> lastInteger;
     4669    std::optional<int> lastWeight;
    46724670    do {
    4673         RefPtr<CSSPrimitiveValue> integer;
    4674         RefPtr<CSSValue> symbol;
    4675         while (!integer || !symbol) {
    4676             if (!integer) {
    4677                 integer = consumeInteger(range, 0);
    4678                 if (integer)
    4679                     continue;
    4680             }
    4681             if (!symbol) {
    4682                 symbol = consumeCounterStyleSymbol(range, context);
    4683                 if (symbol)
    4684                     continue;
    4685             }
    4686             return nullptr;
    4687         }
    4688 
    4689         if (lastInteger) {
    4690             // The additive tuples must be specified in order of strictly descending
    4691             // weight; otherwise, the declaration is invalid and must be ignored.
    4692             if (integer->intValue() >= lastInteger->intValue())
     4671        auto integer = consumeInteger(range, 0);
     4672        auto symbol = consumeCounterStyleSymbol(range, context);
     4673        if (!integer) {
     4674            if (!symbol)
    46934675                return nullptr;
    4694         }
    4695         lastInteger = integer;
    4696         values->append(integer.releaseNonNull());
    4697         values->append(symbol.releaseNonNull());
     4676            integer = consumeInteger(range, 0);
     4677            if (!integer)
     4678                return nullptr;
     4679        }
     4680
     4681        // Additive tuples must be specified in order of strictly descending weight.
     4682        auto weight = integer->intValue();
     4683        if (lastWeight && !(weight < lastWeight))
     4684            return nullptr;
     4685        lastWeight = weight;
     4686
     4687        auto pair = CSSValueList::createSpaceSeparated();
     4688        pair->append(integer.releaseNonNull());
     4689        pair->append(symbol.releaseNonNull());
     4690        values->append(WTFMove(pair));
    46984691    } while (consumeCommaIncludingWhitespace(range));
    46994692    if (!range.atEnd() || !values->length())
    47004693        return nullptr;
    4701     return values;
     4694    return WTFMove(values);
    47024695}
    47034696
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r278669 r279050  
    35033503RefPtr<CSSValue> consumeImage(CSSParserTokenRange& range, const CSSParserContext& context, OptionSet<AllowedImageType> allowedImageTypes)
    35043504{
    3505     if ((range.peek().type() == StringToken) && (allowedImageTypes.contains(AllowedImageType::RawStringAsURL))) {
    3506         auto urlStringView = range.consumeIncludingWhitespace().value();
    3507         return CSSImageValue::create(completeURL(context, urlStringView.toAtomString()), context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No);
     3505    if (range.peek().type() == StringToken && allowedImageTypes.contains(AllowedImageType::RawStringAsURL)) {
     3506        return CSSImageValue::create(context.completeURL(range.consumeIncludingWhitespace().value().toAtomString().string()),
     3507            context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No);
    35083508    }
    35093509
     
    35223522
    35233523    if (allowedImageTypes.contains(AllowedImageType::URLFunction)) {
    3524         auto uri = consumeUrlAsStringView(range);
    3525         if (!uri.isNull())
    3526             return CSSImageValue::create(completeURL(context, uri.toAtomString()), context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No);
     3524        if (auto string = consumeUrlAsStringView(range); !string.isNull()) {
     3525            return CSSImageValue::create(context.completeURL(string.toAtomString().string()),
     3526                context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No);
     3527        }
    35273528    }
    35283529
  • trunk/Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp

    r278253 r279050  
    199199namespace CSSPropertyParserHelpersWorkerSafe {
    200200
    201 static RefPtr<CSSValue> consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context)
    202 {
    203     String url = CSSPropertyParserHelpers::consumeUrlAsStringView(range).toString();
    204     if (url.isNull())
    205         return nullptr;
    206 
    207     RefPtr<CSSFontFaceSrcValue> uriValue = CSSFontFaceSrcValue::create(context.completeURL(url).string(), context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No);
    208 
    209     if (range.peek().functionId() != CSSValueFormat)
    210         return uriValue;
    211 
    212     // FIXME: https://drafts.csswg.org/css-fonts says that format() contains a comma-separated list of strings,
    213     // but CSSFontFaceSrcValue stores only one format. Allowing one format for now.
    214     // FIXME: We're allowing the format to be an identifier as well as a string, because the old
    215     // parser did. It's not clear if we need to continue to support this behavior, but we have lots of
    216     // layout tests that rely on it.
    217     CSSParserTokenRange args = CSSPropertyParserHelpers::consumeFunction(range);
    218     const CSSParserToken& arg = args.consumeIncludingWhitespace();
    219     if ((arg.type() != StringToken && arg.type() != IdentToken) || !args.atEnd())
    220         return nullptr;
    221     uriValue->setFormat(arg.value().toString());
    222     return uriValue;
     201static RefPtr<CSSFontFaceSrcValue> consumeFontFaceSrcURI(CSSParserTokenRange& range, const CSSParserContext& context)
     202{
     203    auto location = context.completeURL(CSSPropertyParserHelpers::consumeUrlAsStringView(range).toString()).resolvedURL.string();
     204    if (location.isNull())
     205        return nullptr;
     206
     207    String format;
     208    if (range.peek().functionId() == CSSValueFormat) {
     209        // https://drafts.csswg.org/css-fonts/#descdef-font-face-src
     210        // FIXME: The format should be a comma-separated list; at this time we support only one.
     211        // FIXME: We allow any identifier here and convert all to strings; specification calls for only certain identifiers.
     212        auto args = CSSPropertyParserHelpers::consumeFunction(range);
     213        auto& arg = args.consumeIncludingWhitespace();
     214        if ((arg.type() != StringToken && arg.type() != IdentToken) || !args.atEnd())
     215            return nullptr;
     216        format = arg.value().toString();
     217    }
     218
     219    // FIXME: Change CSSFontFaceSrcValue::create to take format so we don't need a separate setFormat call.
     220    auto srcValue = CSSFontFaceSrcValue::create(location, context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No);
     221    srcValue->setFormat(format);
     222    return WTFMove(srcValue);
    223223}
    224224
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r278524 r279050  
    12621262}
    12631263
    1264 void RenderStyle::addCursor(RefPtr<StyleImage>&& image, const IntPoint& hotSpot)
     1264void RenderStyle::addCursor(RefPtr<StyleImage>&& image, const std::optional<IntPoint>& hotSpot)
    12651265{
    12661266    auto& cursorData = m_rareInheritedData.access().cursorData;
    12671267    if (!cursorData)
    12681268        cursorData = CursorList::create();
    1269     cursorData->append(CursorData(WTFMove(image), hotSpot));
     1269    // Point outside the image is how we tell the cursor machinery there is no hot spot, and it should generate one (done in the Cursor class).
     1270    // FIXME: Would it be better to extend the concept of "no hot spot" deeper, into CursorData and beyond, rather than using -1/-1 for it?
     1271    cursorData->append(CursorData(WTFMove(image), hotSpot.value_or(IntPoint { -1, -1 })));
    12701272}
    12711273
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r278919 r279050  
    10721072
    10731073    void setCursor(CursorType c) { m_inheritedFlags.cursor = static_cast<unsigned>(c); }
    1074     void addCursor(RefPtr<StyleImage>&&, const IntPoint& hotSpot = IntPoint());
     1074    void addCursor(RefPtr<StyleImage>&&, const std::optional<IntPoint>& hotSpot);
    10751075    void setCursorList(RefPtr<CursorList>&&);
    10761076    void clearCursorList();
  • trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp

    r278376 r279050  
    6767URL StyleCachedImage::imageURL()
    6868{
    69     return m_cssValue->url();
     69    return m_cssValue->imageURL();
    7070}
    7171
  • trunk/Source/WebCore/style/StyleBuilderCustom.h

    r278253 r279050  
    15391539        if (is<CSSImageGeneratorValue>(item)) {
    15401540            if (is<CSSGradientValue>(item))
    1541                 builderState.style().setContent(StyleGeneratedImage::create(downcast<CSSGradientValue>(item.get()).gradientWithStylesResolved(builderState)), didSet);
     1541                builderState.style().setContent(StyleGeneratedImage::create(downcast<CSSGradientValue>(builderState.resolveImageStyles(item.get()).get())), didSet);
    15421542            else
    1543                 builderState.style().setContent(StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(item.get())), didSet);
     1543                builderState.style().setContent(StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(builderState.resolveImageStyles(item.get()).get())), didSet);
    15441544            didSet = true;
    15451545        }
    1546        
     1546
    15471547        if (is<CSSImageSetValue>(item)) {
    1548             builderState.style().setContent(StyleImageSet::create(downcast<CSSImageSetValue>(item.get()).imageSetWithStylesResolved(builderState)), didSet);
     1548            builderState.style().setContent(StyleImageSet::create(downcast<CSSImageSetValue>(builderState.resolveImageStyles(item.get()).get())), didSet);
    15491549            didSet = true;
    15501550        }
    15511551
    15521552        if (is<CSSImageValue>(item)) {
    1553             builderState.style().setContent(StyleCachedImage::create(downcast<CSSImageValue>(item.get())), didSet);
     1553            builderState.style().setContent(StyleCachedImage::create(downcast<CSSImageValue>(builderState.resolveImageStyles(item.get()).get())), didSet);
    15541554            didSet = true;
    15551555            continue;
  • trunk/Source/WebCore/style/StyleBuilderState.cpp

    r272805 r279050  
    3131#include "StyleBuilderState.h"
    3232
     33#include "CSSCrossfadeValue.h"
    3334#include "CSSCursorImageValue.h"
    3435#include "CSSFilterImageValue.h"
     
    4243#include "HTMLElement.h"
    4344#include "RenderTheme.h"
    44 #include "SVGElement.h"
    4545#include "SVGSVGElement.h"
    4646#include "Settings.h"
     
    8585Ref<CSSValue> BuilderState::resolveImageStyles(CSSValue& value)
    8686{
     87    if (is<CSSCrossfadeValue>(value))
     88        return downcast<CSSCrossfadeValue>(value).valueWithStylesResolved(*this);
     89    if (is<CSSCursorImageValue>(value))
     90        return downcast<CSSCursorImageValue>(value).valueWithStylesResolved(*this);
     91    if (is<CSSFilterImageValue>(value))
     92        return downcast<CSSFilterImageValue>(value).valueWithStylesResolved(*this);
    8793    if (is<CSSGradientValue>(value))
    88         return downcast<CSSGradientValue>(value).gradientWithStylesResolved(*this);
    89 
     94        return downcast<CSSGradientValue>(value).valueWithStylesResolved(*this);
    9095    if (is<CSSImageSetValue>(value))
    91         return downcast<CSSImageSetValue>(value).imageSetWithStylesResolved(*this);
    92 
    93     // Creating filter operations doesn't create a new CSSValue reference.
    94     if (is<CSSFilterImageValue>(value))
    95         downcast<CSSFilterImageValue>(value).createFilterOperations(*this);
    96 
     96        return downcast<CSSImageSetValue>(value).valueWithStylesResolved(*this);
     97    if (is<CSSImageValue>(value))
     98        return downcast<CSSImageValue>(value).valueWithStylesResolved(*this);
    9799    return makeRef(value);
    98100}
     
    101103{
    102104    if (is<CSSImageValue>(value))
    103         return StyleCachedImage::create(downcast<CSSImageValue>(value));
    104 
     105        return StyleCachedImage::create(downcast<CSSImageValue>(resolveImageStyles(value).get()));
    105106    if (is<CSSCursorImageValue>(value))
    106         return StyleCursorImage::create(downcast<CSSCursorImageValue>(value));
    107 
     107        return StyleCursorImage::create(downcast<CSSCursorImageValue>(resolveImageStyles(value).get()));
    108108    if (is<CSSImageGeneratorValue>(value))
    109109        return StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(resolveImageStyles(value).get()));
    110    
    111110    if (is<CSSImageSetValue>(value))
    112111        return StyleImageSet::create(downcast<CSSImageSetValue>(resolveImageStyles(value).get()));
    113 
    114112    return nullptr;
    115113}
Note: See TracChangeset for help on using the changeset viewer.