Changeset 279050 in webkit
- Timestamp:
- Jun 19, 2021, 1:31:11 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 40 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/css/parse-border-image-repeat-null-crash-expected.txt (modified) (1 diff)
-
LayoutTests/fast/css/uri-token-parsing-expected.txt (modified) (4 diffs)
-
LayoutTests/fast/css/uri-token-parsing.html (modified) (3 diffs)
-
LayoutTests/fast/css/url-with-multi-byte-unicode-escape-expected.txt (modified) (1 diff)
-
LayoutTests/fast/css/url-with-multi-byte-unicode-escape.html (modified) (1 diff)
-
LayoutTests/fast/filter-image/parse-filter-image-expected.txt (modified) (1 diff)
-
LayoutTests/fast/filter-image/parse-filter-image.html (modified) (1 diff)
-
LayoutTests/fast/innerHTML/innerHTML-uri-resolution.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-additive-symbols-syntax-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-symbols-syntax-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-syntax/url-whitespace-consumption-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSCrossfadeValue.cpp (modified) (4 diffs)
-
Source/WebCore/css/CSSCrossfadeValue.h (modified) (2 diffs)
-
Source/WebCore/css/CSSCursorImageValue.cpp (modified) (8 diffs)
-
Source/WebCore/css/CSSCursorImageValue.h (modified) (6 diffs)
-
Source/WebCore/css/CSSFilterImageValue.cpp (modified) (3 diffs)
-
Source/WebCore/css/CSSFilterImageValue.h (modified) (4 diffs)
-
Source/WebCore/css/CSSGradientValue.cpp (modified) (2 diffs)
-
Source/WebCore/css/CSSGradientValue.h (modified) (2 diffs)
-
Source/WebCore/css/CSSImageSetValue.cpp (modified) (2 diffs)
-
Source/WebCore/css/CSSImageSetValue.h (modified) (2 diffs)
-
Source/WebCore/css/CSSImageValue.cpp (modified) (6 diffs)
-
Source/WebCore/css/CSSImageValue.h (modified) (4 diffs)
-
Source/WebCore/css/StyleSheetContents.cpp (modified) (1 diff)
-
Source/WebCore/css/StyleSheetContents.h (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParserContext.cpp (modified) (2 diffs)
-
Source/WebCore/css/parser/CSSParserContext.h (modified) (2 diffs)
-
Source/WebCore/css/parser/CSSParserIdioms.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParserIdioms.h (modified) (1 diff)
-
Source/WebCore/css/parser/CSSPropertyParser.cpp (modified) (3 diffs)
-
Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (modified) (2 diffs)
-
Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp (modified) (1 diff)
-
Source/WebCore/rendering/style/RenderStyle.cpp (modified) (1 diff)
-
Source/WebCore/rendering/style/RenderStyle.h (modified) (1 diff)
-
Source/WebCore/rendering/style/StyleCachedImage.cpp (modified) (1 diff)
-
Source/WebCore/style/StyleBuilderCustom.h (modified) (1 diff)
-
Source/WebCore/style/StyleBuilderState.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r279047 r279050 1 2021-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 1 30 2021-06-18 Chris Dumez <cdumez@apple.com> 2 31 -
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;1 CONSOLE MESSAGE: border-image-source: url("images/shadow-border.png"); border-image-slice: 10; border-image-repeat: stretch; 2 2 This test should not crash -
trunk/LayoutTests/fast/css/uri-token-parsing-expected.txt
r231359 r279050 10 10 #d { content: url("f"); } 11 11 #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 "); } 15 15 #j { content: url("url(g)"); } 16 16 #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 "); } 20 20 #p { content: url("url(g)"); } 21 21 #q { cursor: url("url(q)"), default; } … … 25 25 #u { -webkit-border-image: url("url(u)") 1 2 3 4 fill stretch round; } 26 26 #v { -webkit-mask-box-image: url("url(v)") 1 2 3 4 fill stretch round; } 27 #w { content: url("w w"); }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"); } 30 30 Expected result: 31 31 … … 35 35 #d { content: url("f"); } 36 36 #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 "); } 40 40 #j { content: url("url(g)"); } 41 41 #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 "); } 45 45 #p { content: url("url(g)"); } 46 46 #q { cursor: url("url(q)"), default; } … … 50 50 #u { -webkit-border-image: url("url(u)") 1 2 3 4 fill stretch round; } 51 51 #v { -webkit-mask-box-image: url("url(v)") 1 2 3 4 fill stretch round; } 52 #w { content: url("w w"); }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"); } 55 55 -
trunk/LayoutTests/fast/css/uri-token-parsing.html
r231359 r279050 45 45 var text = ""; 46 46 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; 54 48 text += "\n"; 55 49 } … … 84 78 #d { content: url("f"); } 85 79 #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 "); } 89 83 #j { content: url("url(g)"); } 90 84 #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 "); } 94 88 #p { content: url("url(g)"); } 95 89 #q { cursor: url("url(q)"), default; } … … 99 93 #u { -webkit-border-image: url("url(u)") 1 2 3 4 fill stretch round; } 100 94 #v { -webkit-mask-box-image: url("url(v)") 1 2 3 4 fill stretch round; } 101 #w { content: url("w w"); }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"); } 104 98 </pre> 105 99 -
trunk/LayoutTests/fast/css/url-with-multi-byte-unicode-escape-expected.txt
r231359 r279050 5 5 6 6 PASS 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\")"7 PASS document.styleSheets[0].cssRules[0].style.getPropertyValue("background-image") is "url(\"data:Ā\")" 8 PASS document.styleSheets[0].cssRules[0].style.getPropertyValue("border-image-source") is "url(\"data:Ā\")" 9 9 PASS document.styleSheets[0].cssRules[1].style.getPropertyValue("background-color") is "green" 10 10 PASS 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 14 14 description('Test parsing a CSS URI containing a multi-byte Unicode escape sequence.'); 15 15 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")'); 18 18 shouldBeEqualToString('document.styleSheets[0].cssRules[1].style.getPropertyValue("background-color")', 'green'); 19 19 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 79 79 PASS 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))" 80 80 PASS 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%))"81 PASS 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))" 82 PASS innerStyle("background-image", "filter(url(image1.png), brightness(50%))") is "filter(url(\"image1.png\"), brightness(50%))" 83 PASS innerStyle("background-image", "filter(url('image1.png'), brightness(50%))") is "filter(url(\"image1.png\"), brightness(50%))" 84 PASS innerStyle("border-image-source", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))" 85 PASS innerStyle("-webkit-mask-image", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))" 86 PASS innerStyle("-webkit-mask-box-image-source", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))" 87 PASS innerStyle("content", "filter(url(image1.png), invert(50%))") is "filter(url(\"image1.png\"), invert(50%))" 88 88 PASS innerStyle("background-image", "filter()") is "" 89 89 PASS computedStyle("background-image", "filter()") is "none" -
trunk/LayoutTests/fast/filter-image/parse-filter-image.html
r231359 r279050 346 346 testInner( 347 347 "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))"); 350 testInner( 351 "background-image", 352 "filter(url(image1.png), brightness(50%))", 353 "filter(url(\"image1.png\"), brightness(50%))"); 354 testInner( 355 "background-image", 356 "filter(url('image1.png'), brightness(50%))", 357 "filter(url(\"image1.png\"), brightness(50%))"); 358 358 359 359 // Test different properties, taking CSS Image values. 360 360 testInner( 361 361 "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%))"); 364 364 testInner( 365 365 "-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%))"); 368 368 testInner( 369 369 "-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%))"); 372 372 testInner( 373 373 "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%))"); 376 376 377 377 // negative tests -
trunk/LayoutTests/fast/innerHTML/innerHTML-uri-resolution.html
r231359 r279050 14 14 var currentUri = document.location.href; 15 15 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")'; 17 17 18 18 // Can't log the actual path since it's different depending on where the test is run. -
trunk/LayoutTests/imported/w3c/ChangeLog
r279047 r279050 1 2021-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 1 13 2021-06-18 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-additive-symbols-syntax-expected.txt
r277079 r279050 1 1 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 2 PASS @counter-style 'additive-symbols: 0 "X"' is valid 3 PASS @counter-style 'additive-symbols: 1 "X"' is valid 4 PASS @counter-style 'additive-symbols: "X" 1' is valid 5 PASS @counter-style 'additive-symbols: 5 "V", 1 "I"' is valid 6 6 PASS @counter-style 'additive-symbols: ' is invalid 7 7 PASS @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 3 3 PASS @counter-style 'symbols: "X" "X"' is valid 4 4 PASS @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 5 PASS @counter-style 'symbols: ident "X" url("foo.jpg")' is valid 6 6 PASS @counter-style 'symbols: ' is invalid 7 7 PASS @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 1 1 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\")" 2 PASS whitespace is optional between url( token and the string token 3 3 -
trunk/Source/WebCore/ChangeLog
r279047 r279050 1 2021-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 1 146 2021-06-18 Chris Dumez <cdumez@apple.com> 2 147 -
trunk/Source/WebCore/css/CSSCrossfadeValue.cpp
r276141 r279050 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011-2021 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 4 4 * … … 34 34 #include "CrossfadeGeneratedImage.h" 35 35 #include "RenderElement.h" 36 #include "StyleBuilderState.h" 36 37 #include "StyleCachedImage.h" 37 #include <wtf/text/StringBuilder.h>38 38 39 39 namespace WebCore { … … 229 229 } 230 230 231 232 231 bool CSSCrossfadeValue::equalInputImages(const CSSCrossfadeValue& other) const 233 232 { … … 235 234 } 236 235 236 Ref<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 237 245 } // namespace WebCore -
trunk/Source/WebCore/css/CSSCrossfadeValue.h
r276141 r279050 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 61 61 bool equalInputImages(const CSSCrossfadeValue&) const; 62 62 63 Ref<CSSCrossfadeValue> valueWithStylesResolved(Style::BuilderState&); 64 63 65 private: 64 66 CSSCrossfadeValue(Ref<CSSValue>&& fromValue, Ref<CSSValue>&& toValue, Ref<CSSPrimitiveValue>&& percentageValue, bool prefixed); -
trunk/Source/WebCore/css/CSSCursorImageValue.cpp
r260709 r279050 2 2 * Copyright (C) 2006 Rob Buis <buis@kde.org> 3 3 * (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2008-20 19Apple Inc. All rights reserved.4 * Copyright (C) 2008-2021 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 25 25 #include "CSSImageSetValue.h" 26 26 #include "CSSImageValue.h" 27 #include "CachedImage.h"28 #include "CachedResourceLoader.h"29 27 #include "SVGCursorElement.h" 30 28 #include "SVGLengthContext.h" 31 29 #include "SVGURIReference.h" 32 30 #include <wtf/MathExtras.h> 33 #include <wtf/text/StringBuilder.h>34 31 #include <wtf/text/WTFString.h> 35 32 36 33 namespace WebCore { 37 34 38 CSSCursorImageValue::CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource)35 CSSCursorImageValue::CSSCursorImageValue(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource) 39 36 : CSSValue(CursorImageClass) 40 37 , m_imageValue(WTFMove(imageValue)) 41 , m_hasHotSpot(hasHotSpot)42 38 , m_hotSpot(hotSpot) 43 39 , m_loadedFromOpaqueSource(loadedFromOpaqueSource) 44 40 { 45 41 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 45 Ref<CSSCursorImageValue> CSSCursorImageValue::create(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource loadedFromOpaqueSource) 46 { 47 return adoptRef(*new CSSCursorImageValue(WTFMove(imageValue), hotSpot, loadedFromOpaqueSource)); 47 48 } 48 49 … … 56 57 { 57 58 String text = m_imageValue.get().cssText(); 58 if (!m_h asHotSpot)59 if (!m_hotSpot) 59 60 return text; 60 return makeString(text, ' ', m_hotSpot .x(), ' ', m_hotSpot.y());61 return makeString(text, ' ', m_hotSpot->x(), ' ', m_hotSpot->y()); 61 62 } 62 63 … … 64 65 SVGCursorElement* CSSCursorImageValue::updateCursorElement(const Document& document) 65 66 { 66 if (!m_originalURL.hasFragmentIdentifier())67 return nullptr;68 69 67 auto element = SVGURIReference::targetElementFromIRIString(m_originalURL.string(), document).element; 70 68 if (!is<SVGCursorElement>(element)) 71 69 return nullptr; 72 70 71 // FIXME: Not right to keep old cursor elements as clients. The new one should replace the old, not join it in a set. 73 72 auto& cursorElement = downcast<SVGCursorElement>(*element); 74 73 if (m_cursorElements.add(&cursorElement).isNewEntry) { … … 81 80 void CSSCursorImageValue::cursorElementRemoved(SVGCursorElement& cursorElement) 82 81 { 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. 83 83 m_cursorElements.remove(&cursorElement); 84 84 } … … 86 86 void CSSCursorImageValue::cursorElementChanged(SVGCursorElement& cursorElement) 87 87 { 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? 89 91 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 }; 93 96 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? 96 98 } 97 99 … … 102 104 103 105 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); 106 109 } 107 110 … … 111 114 bool CSSCursorImageValue::equals(const CSSCursorImageValue& other) const 112 115 { 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 119 Ref<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); 115 125 } 116 126 -
trunk/Source/WebCore/css/CSSCursorImageValue.h
r254861 r279050 1 1 /* 2 2 * 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. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 28 28 namespace WebCore { 29 29 30 class CachedImage;31 class CachedResourceLoader;32 30 class Document; 33 class Element;34 31 class SVGCursorElement; 35 class SVGElement;36 32 37 33 struct ImageWithScale; … … 43 39 class CSSCursorImageValue final : public CSSValue { 44 40 public: 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); 50 42 ~CSSCursorImageValue(); 51 43 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; } 60 45 61 46 const URL& imageURL() const { return m_originalURL; } … … 65 50 ImageWithScale selectBestFitImage(const Document&); 66 51 67 void removeReferencedElement(SVGElement*);68 69 52 bool equals(const CSSCursorImageValue&) const; 70 53 … … 72 55 void cursorElementChanged(SVGCursorElement&); 73 56 57 Ref<CSSCursorImageValue> valueWithStylesResolved(Style::BuilderState&); 58 74 59 private: 75 CSSCursorImageValue(Ref<CSSValue>&& imageValue, bool hasHotSpot, const IntPoint& hotSpot, LoadedFromOpaqueSource);60 CSSCursorImageValue(Ref<CSSValue>&& imageValue, const std::optional<IntPoint>& hotSpot, LoadedFromOpaqueSource); 76 61 77 62 SVGCursorElement* updateCursorElement(const Document&); … … 79 64 URL m_originalURL; 80 65 Ref<CSSValue> m_imageValue; 81 82 bool m_hasHotSpot; 83 IntPoint m_hotSpot; 66 std::optional<IntPoint> m_hotSpot; 84 67 HashSet<SVGCursorElement*> m_cursorElements; 85 68 LoadedFromOpaqueSource m_loadedFromOpaqueSource { LoadedFromOpaqueSource::No }; -
trunk/Source/WebCore/css/CSSFilterImageValue.cpp
r277986 r279050 1 1 /* 2 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 * Copyright (C) 2021 Apple Inc. All right reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 36 37 #include "StyleBuilderState.h" 37 38 #include "StyleCachedImage.h" 38 #include <wtf/text/StringBuilder.h>39 39 40 40 namespace WebCore { … … 174 174 } 175 175 176 Ref<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 176 188 } // namespace WebCore -
trunk/Source/WebCore/css/CSSFilterImageValue.h
r251916 r279050 1 1 /* 2 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 36 37 namespace WebCore { 37 38 38 class CachedImage;39 39 class FilterSubimageObserverProxy; 40 40 class RenderElement; 41 class Document;42 41 43 42 namespace Style { … … 72 71 bool equalInputImages(const CSSFilterImageValue&) const; 73 72 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(); } 75 76 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&); 82 78 83 79 private: … … 107 103 108 104 void filterImageChanged(const IntRect&); 105 void createFilterOperations(Style::BuilderState&); 109 106 110 107 Ref<CSSValue> m_imageValue; -
trunk/Source/WebCore/css/CSSGradientValue.cpp
r278246 r279050 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 108 108 } 109 109 110 Ref<CSSGradientValue> CSSGradientValue:: gradientWithStylesResolved(Style::BuilderState& builderState)110 Ref<CSSGradientValue> CSSGradientValue::valueWithStylesResolved(Style::BuilderState& builderState) 111 111 { 112 112 auto result = hasColorDerivedFromElement() ? clone(*this) : makeRef(*this); -
trunk/Source/WebCore/css/CSSGradientValue.h
r278253 r279050 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 79 79 static void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&) { } 80 80 81 Ref<CSSGradientValue> gradientWithStylesResolved(Style::BuilderState&);81 Ref<CSSGradientValue> valueWithStylesResolved(Style::BuilderState&); 82 82 83 83 protected: -
trunk/Source/WebCore/css/CSSImageSetValue.cpp
r277967 r279050 1 1 /* 2 * Copyright (C) 2012-20 17Apple Inc. All rights reserved.2 * Copyright (C) 2012-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 114 114 } 115 115 116 Ref<CSSImageSetValue> CSSImageSetValue:: imageSetWithStylesResolved(Style::BuilderState& builderState)116 Ref<CSSImageSetValue> CSSImageSetValue::valueWithStylesResolved(Style::BuilderState& builderState) 117 117 { 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) { 121 120 result->append(builderState.resolveImageStyles(*itemWithoutBoundsCheck(i))); 122 121 result->append(*itemWithoutBoundsCheck(i + 1)); 123 122 } 124 125 return result; 123 return equals(result) ? Ref { *this } : result; 126 124 } 127 125 -
trunk/Source/WebCore/css/CSSImageSetValue.h
r260415 r279050 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 62 62 void updateDeviceScaleFactor(const Document&); 63 63 64 Ref<CSSImageSetValue> imageSetWithStylesResolved(Style::BuilderState&);64 Ref<CSSImageSetValue> valueWithStylesResolved(Style::BuilderState&); 65 65 66 66 private: -
trunk/Source/WebCore/css/CSSImageValue.cpp
r260709 r279050 1 1 /* 2 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2004-20 17Apple Inc. All rights reserved.3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 35 35 namespace WebCore { 36 36 37 CSSImageValue::CSSImageValue(URL&& url, LoadedFromOpaqueSource loadedFromOpaqueSource) 37 static bool operator==(const ResolvedURL& a, const ResolvedURL& b) 38 { 39 return a.specifiedURLString == b.specifiedURLString && a.resolvedURL == b.resolvedURL; 40 } 41 42 static ResolvedURL makeResolvedURL(URL&& resolvedURL) 43 { 44 auto string = resolvedURL.string(); 45 return { WTFMove(string), WTFMove(resolvedURL) }; 46 } 47 48 CSSImageValue::CSSImageValue(ResolvedURL&& location, LoadedFromOpaqueSource loadedFromOpaqueSource) 38 49 : CSSValue(ImageClass) 39 , m_url(WTFMove(url)) 40 , m_accessedImage(false) 50 , m_location(WTFMove(location)) 41 51 , m_loadedFromOpaqueSource(loadedFromOpaqueSource) 42 52 { … … 45 55 CSSImageValue::CSSImageValue(CachedImage& image) 46 56 : CSSValue(ImageClass) 47 , m_ url(image.url())57 , m_location { image.url().string(), image.url() } 48 58 , m_cachedImage(&image) 49 , m_accessedImage(true)50 59 { 51 60 } 52 61 62 Ref<CSSImageValue> CSSImageValue::create(ResolvedURL&& location, LoadedFromOpaqueSource loadedFromOpaqueSource) 63 { 64 return adoptRef(*new CSSImageValue(WTFMove(location), loadedFromOpaqueSource)); 65 } 66 67 Ref<CSSImageValue> CSSImageValue::create(URL&& imageURL, LoadedFromOpaqueSource loadedFromOpaqueSource) 68 { 69 return create(makeResolvedURL(WTFMove(imageURL)), loadedFromOpaqueSource); 70 } 71 72 Ref<CSSImageValue> CSSImageValue::create(CachedImage& image) 73 { 74 return adoptRef(*new CSSImageValue(image)); 75 } 53 76 54 77 CSSImageValue::~CSSImageValue() = default; … … 56 79 bool CSSImageValue::isPending() const 57 80 { 58 return !m_accessedImage; 81 return !m_cachedImage; 82 } 83 84 URL 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 91 Ref<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; 59 101 } 60 102 61 103 CachedImage* CSSImageValue::loadImage(CachedResourceLoader& loader, const ResourceLoaderOptions& options) 62 104 { 63 if (!m_accessedImage) { 64 m_accessedImage = true; 65 105 if (!m_cachedImage) { 66 106 ResourceLoaderOptions loadOptions = options; 67 107 loadOptions.loadedFromOpaqueSource = m_loadedFromOpaqueSource; 68 CachedResourceRequest request(ResourceRequest( loader.document()->completeURL(m_url.string())), loadOptions);108 CachedResourceRequest request(ResourceRequest(reresolvedURL(*loader.document())), loadOptions); 69 109 if (m_initiatorName.isEmpty()) 70 110 request.setInitiator(cachedResourceRequestInitiators().css); 71 111 else 72 112 request.setInitiator(m_initiatorName); 73 74 113 if (options.mode == FetchOptions::Mode::Cors) { 75 114 ASSERT(loader.document()); … … 77 116 } 78 117 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; 79 120 } 80 return m_cachedImage. get();121 return m_cachedImage.value().get(); 81 122 } 82 123 83 124 bool CSSImageValue::traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const 84 125 { 85 if (!m_cachedImage) 86 return false; 87 return handler(*m_cachedImage); 126 return m_cachedImage.value_or(nullptr) && handler(**m_cachedImage); 88 127 } 89 128 90 129 bool CSSImageValue::equals(const CSSImageValue& other) const 91 130 { 92 return m_ url == other.m_url;131 return m_location == other.m_location; 93 132 } 94 133 95 134 String CSSImageValue::customCSSText() const 96 135 { 97 return serializeURL(m_ url.string());136 return serializeURL(m_location.specifiedURLString); 98 137 } 99 138 … … 101 140 { 102 141 // 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); 104 143 } 105 144 106 145 bool CSSImageValue::knownToBeOpaque(const RenderElement& renderer) const 107 146 { 108 if (!m_cachedImage) 109 return false; 110 return m_cachedImage->currentFrameKnownToBeOpaque(&renderer); 147 return m_cachedImage.value_or(nullptr) && (**m_cachedImage).currentFrameKnownToBeOpaque(&renderer); 111 148 } 112 149 -
trunk/Source/WebCore/css/CSSImageValue.h
r246490 r279050 1 1 /* 2 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 2004 , 2005, 2006, 2008, 2012Apple Inc. All rights reserved.3 * Copyright (C) 2004-2021 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 10 10 * This library is distributed in the hope that it will be useful, 11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 13 * Library General Public License for more details. 14 14 * … … 35 35 class RenderElement; 36 36 37 namespace Style { 38 class BuilderState; 39 } 40 41 struct ResolvedURL { 42 String specifiedURLString; 43 URL resolvedURL; 44 }; 45 37 46 class CSSImageValue final : public CSSValue { 38 47 public: 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&); 41 51 ~CSSImageValue(); 42 52 43 53 bool isPending() const; 44 54 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; } 46 56 47 const URL& url() const { return m_url; }57 const URL& imageURL() const { return m_location.resolvedURL; } 48 58 49 59 String customCSSText() const; … … 59 69 void setInitiator(const AtomString& name) { m_initiatorName = name; } 60 70 71 Ref<CSSImageValue> valueWithStylesResolved(Style::BuilderState&); 72 61 73 private: 62 CSSImageValue( URL&&, LoadedFromOpaqueSource);74 CSSImageValue(ResolvedURL&&, LoadedFromOpaqueSource); 63 75 explicit CSSImageValue(CachedImage&); 64 76 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; 68 81 AtomString m_initiatorName; 69 82 LoadedFromOpaqueSource m_loadedFromOpaqueSource { LoadedFromOpaqueSource::No }; 83 RefPtr<CSSImageValue> m_unresolvedValue; 70 84 }; 71 85 -
trunk/Source/WebCore/css/StyleSheetContents.cpp
r276152 r279050 416 416 Node* ownerNode = singleOwnerNode(); 417 417 return ownerNode ? &ownerNode->document() : 0; 418 }419 420 URL StyleSheetContents::completeURL(const String& url) const421 {422 return m_parserContext.completeURL(url);423 418 } 424 419 -
trunk/Source/WebCore/css/StyleSheetContents.h
r270803 r279050 87 87 bool loadCompleted() const { return m_loadCompleted; } 88 88 89 URL completeURL(const String& url) const;90 89 bool traverseRules(const WTF::Function<bool (const StyleRuleBase&)>& handler) const; 91 90 bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const; -
trunk/Source/WebCore/css/parser/CSSParserContext.cpp
r276488 r279050 27 27 #include "CSSParserContext.h" 28 28 29 #include "CSSImageValue.h" 29 30 #include "Document.h" 30 31 #include "DocumentLoader.h" … … 221 222 } 222 223 223 URL CSSParserContext::completeURL(const String& url) const224 { 225 auto completedURL = [&]{226 if ( url.isNull())227 return URL();224 ResolvedURL CSSParserContext::completeURL(const String& string) const 225 { 226 auto result = [&] () -> ResolvedURL { 227 if (string.isNull()) 228 return { }; 228 229 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 } }; 233 233 }(); 234 234 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 37 37 38 38 class Document; 39 40 struct ResolvedURL; 39 41 40 42 struct CSSParserContext { … … 89 91 WEBCORE_EXPORT CSSParserContext(const Document&, const URL& baseURL = URL(), const String& charset = emptyString()); 90 92 bool isPropertyRuntimeDisabled(CSSPropertyID) const; 91 URL completeURL(const String& relativeURL) const;93 ResolvedURL completeURL(const String&) const; 92 94 }; 93 95 -
trunk/Source/WebCore/css/parser/CSSParserIdioms.cpp
r236565 r279050 46 46 } 47 47 48 URL completeURL(const CSSParserContext& context, const String& url)49 {50 return context.completeURL(url);51 }52 53 48 } // namespace WebCore -
trunk/Source/WebCore/css/parser/CSSParserIdioms.h
r238771 r279050 60 60 bool isValueAllowedInMode(unsigned short, CSSParserMode); 61 61 62 URL completeURL(const CSSParserContext&, const String& url);63 64 62 } // namespace WebCore -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r278669 r279050 2259 2259 { 2260 2260 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; 2264 2263 if (auto x = consumeNumberRaw(range)) { 2265 hotSpot.setX(static_cast<int>(*x));2266 2264 auto y = consumeNumberRaw(range); 2267 2265 if (!y) 2268 2266 return nullptr; 2269 hotSpot.setY(static_cast<int>(*y));2270 hotSpot Specified = 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) }; 2271 2269 } 2272 2270 … … 2274 2272 list = CSSValueList::createCommaSeparated(); 2275 2273 2276 list->append(CSSCursorImageValue::create(image.releaseNonNull(), hotSpot Specified, hotSpot, context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No));2274 list->append(CSSCursorImageValue::create(image.releaseNonNull(), hotSpot, context.isContentOpaque ? LoadedFromOpaqueSource::Yes : LoadedFromOpaqueSource::No)); 2277 2275 if (!consumeCommaIncludingWhitespace(range)) 2278 2276 return nullptr; … … 4669 4667 { 4670 4668 auto values = CSSValueList::createCommaSeparated(); 4671 RefPtr<CSSPrimitiveValue> lastInteger;4669 std::optional<int> lastWeight; 4672 4670 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) 4693 4675 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)); 4698 4691 } while (consumeCommaIncludingWhitespace(range)); 4699 4692 if (!range.atEnd() || !values->length()) 4700 4693 return nullptr; 4701 return values;4694 return WTFMove(values); 4702 4695 } 4703 4696 -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r278669 r279050 3503 3503 RefPtr<CSSValue> consumeImage(CSSParserTokenRange& range, const CSSParserContext& context, OptionSet<AllowedImageType> allowedImageTypes) 3504 3504 { 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); 3508 3508 } 3509 3509 … … 3522 3522 3523 3523 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 } 3527 3528 } 3528 3529 -
trunk/Source/WebCore/css/parser/CSSPropertyParserWorkerSafe.cpp
r278253 r279050 199 199 namespace CSSPropertyParserHelpersWorkerSafe { 200 200 201 static RefPtr<CSS Value> 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 old215 // parser did. It's not clear if we need to continue to support this behavior, but we have lots of216 // 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;201 static 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); 223 223 } 224 224 -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r278524 r279050 1262 1262 } 1263 1263 1264 void RenderStyle::addCursor(RefPtr<StyleImage>&& image, const IntPoint& hotSpot)1264 void RenderStyle::addCursor(RefPtr<StyleImage>&& image, const std::optional<IntPoint>& hotSpot) 1265 1265 { 1266 1266 auto& cursorData = m_rareInheritedData.access().cursorData; 1267 1267 if (!cursorData) 1268 1268 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 }))); 1270 1272 } 1271 1273 -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r278919 r279050 1072 1072 1073 1073 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); 1075 1075 void setCursorList(RefPtr<CursorList>&&); 1076 1076 void clearCursorList(); -
trunk/Source/WebCore/rendering/style/StyleCachedImage.cpp
r278376 r279050 67 67 URL StyleCachedImage::imageURL() 68 68 { 69 return m_cssValue-> url();69 return m_cssValue->imageURL(); 70 70 } 71 71 -
trunk/Source/WebCore/style/StyleBuilderCustom.h
r278253 r279050 1539 1539 if (is<CSSImageGeneratorValue>(item)) { 1540 1540 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); 1542 1542 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); 1544 1544 didSet = true; 1545 1545 } 1546 1546 1547 1547 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); 1549 1549 didSet = true; 1550 1550 } 1551 1551 1552 1552 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); 1554 1554 didSet = true; 1555 1555 continue; -
trunk/Source/WebCore/style/StyleBuilderState.cpp
r272805 r279050 31 31 #include "StyleBuilderState.h" 32 32 33 #include "CSSCrossfadeValue.h" 33 34 #include "CSSCursorImageValue.h" 34 35 #include "CSSFilterImageValue.h" … … 42 43 #include "HTMLElement.h" 43 44 #include "RenderTheme.h" 44 #include "SVGElement.h"45 45 #include "SVGSVGElement.h" 46 46 #include "Settings.h" … … 85 85 Ref<CSSValue> BuilderState::resolveImageStyles(CSSValue& value) 86 86 { 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); 87 93 if (is<CSSGradientValue>(value)) 88 return downcast<CSSGradientValue>(value).gradientWithStylesResolved(*this); 89 94 return downcast<CSSGradientValue>(value).valueWithStylesResolved(*this); 90 95 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); 97 99 return makeRef(value); 98 100 } … … 101 103 { 102 104 if (is<CSSImageValue>(value)) 103 return StyleCachedImage::create(downcast<CSSImageValue>(value)); 104 105 return StyleCachedImage::create(downcast<CSSImageValue>(resolveImageStyles(value).get())); 105 106 if (is<CSSCursorImageValue>(value)) 106 return StyleCursorImage::create(downcast<CSSCursorImageValue>(value)); 107 107 return StyleCursorImage::create(downcast<CSSCursorImageValue>(resolveImageStyles(value).get())); 108 108 if (is<CSSImageGeneratorValue>(value)) 109 109 return StyleGeneratedImage::create(downcast<CSSImageGeneratorValue>(resolveImageStyles(value).get())); 110 111 110 if (is<CSSImageSetValue>(value)) 112 111 return StyleImageSet::create(downcast<CSSImageSetValue>(resolveImageStyles(value).get())); 113 114 112 return nullptr; 115 113 }
Note:
See TracChangeset
for help on using the changeset viewer.