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

Changeset 286061 in webkit


Ignore:
Timestamp:
Nov 19, 2021, 7:37:03 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

LayoutTests/imported/w3c:
Import css/css-values/urls web-platform-tests
Don't modify fragment-only or empty image URLs
https://bugs.webkit.org/show_bug.cgi?id=229917

Patch by Matt Woodrow <matt.woodrow@gmail.com> on 2021-11-19
Reviewed by Darin Adler.

Change handling of empty and fragment url()s for images to not convert to a fully resolved
path, and instead preserve them as-is, to match css-values4 requirements.

Import new tests in css/css-values/urls from 5e3187856a311f583124735cad5a03baa61951b3 and
add expectations for the new tests.

  • resources/import-expectations.json:
  • web-platform-tests/css/css-values/urls/empty-expected.txt:
  • web-platform-tests/css/css-values/urls/empty.html:
  • web-platform-tests/css/css-values/urls/fragment-only-expected.txt: Added.
  • web-platform-tests/css/css-values/urls/fragment-only.html: Added.
  • web-platform-tests/css/css-values/urls/resolve-relative-to-base-expected.txt: Added.
  • web-platform-tests/css/css-values/urls/resolve-relative-to-base.html: Added.
  • web-platform-tests/css/css-values/urls/resolve-relative-to-stylesheet-expected.txt: Added.
  • web-platform-tests/css/css-values/urls/resolve-relative-to-stylesheet.html: Added.
  • web-platform-tests/css/css-values/urls/support/fragment-only-urls.css: Added.

(:root):
(#external-unquoted):
(#external-quoted):
(#external-variable):

  • web-platform-tests/css/css-values/urls/support/relative-urls.css: Added.

(:root):
(#stylesheet-relative-image):
(#stylesheet-relative-variable-image):
(#stylesheet-relative-document-variable-image):

  • web-platform-tests/css/css-values/urls/support/w3c-import.log:
  • web-platform-tests/css/css-values/urls/w3c-import.log:

Source/WebCore:
Don't modify fragment-only or empty image URLs
https://bugs.webkit.org/show_bug.cgi?id=229917

Patch by Matt Woodrow <matt.woodrow@gmail.com> on 2021-11-19
Reviewed by Darin Adler.

Don't modify fragment-only or empty image URLs, as-per css-values-4

Existing web-platform-tests are marked as passing.

  • css/CSSImageValue.cpp:

(WebCore::CSSImageValue::reresolvedURL const):

  • css/parser/CSSParserContext.cpp:

(WebCore::CSSParserContext::completeURL const):

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::consumeImage):

  • dom/Document.cpp:

(WebCore::Document::completeURL const):

Location:
trunk
Files:
8 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/fast/css/invalid-cursor-property-crash.html

    r231359 r286061  
    88        var d = document.getElementById('theDiv');
    99        var style = document.defaultView.getComputedStyle(d, '');
    10        
    11         if (style && style.cursor == 'url("' + document.location + '"), auto')
     10
     11        if (style && style.cursor == 'url(""), auto')
    1212            document.getElementById('result').innerHTML = 'SUCCESS';           
    1313    }
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r286044 r286061  
     12021-11-19  Matt Woodrow  <matt.woodrow@gmail.com>
     2
     3        Import css/css-values/urls web-platform-tests
     4        Don't modify fragment-only or empty image URLs
     5        https://bugs.webkit.org/show_bug.cgi?id=229917
     6
     7        Reviewed by Darin Adler.
     8
     9        Change handling of empty and fragment url()s for images to not convert to a fully resolved
     10        path, and instead preserve them as-is, to match css-values4 requirements.
     11
     12        Import new tests in css/css-values/urls from 5e3187856a311f583124735cad5a03baa61951b3 and
     13        add expectations for the new tests.
     14
     15        * resources/import-expectations.json:
     16        * web-platform-tests/css/css-values/urls/empty-expected.txt:
     17        * web-platform-tests/css/css-values/urls/empty.html:
     18        * web-platform-tests/css/css-values/urls/fragment-only-expected.txt: Added.
     19        * web-platform-tests/css/css-values/urls/fragment-only.html: Added.
     20        * web-platform-tests/css/css-values/urls/resolve-relative-to-base-expected.txt: Added.
     21        * web-platform-tests/css/css-values/urls/resolve-relative-to-base.html: Added.
     22        * web-platform-tests/css/css-values/urls/resolve-relative-to-stylesheet-expected.txt: Added.
     23        * web-platform-tests/css/css-values/urls/resolve-relative-to-stylesheet.html: Added.
     24        * web-platform-tests/css/css-values/urls/support/fragment-only-urls.css: Added.
     25        (:root):
     26        (#external-unquoted):
     27        (#external-quoted):
     28        (#external-variable):
     29        * web-platform-tests/css/css-values/urls/support/relative-urls.css: Added.
     30        (:root):
     31        (#stylesheet-relative-image):
     32        (#stylesheet-relative-variable-image):
     33        (#stylesheet-relative-document-variable-image):
     34        * web-platform-tests/css/css-values/urls/support/w3c-import.log:
     35        * web-platform-tests/css/css-values/urls/w3c-import.log:
     36
    1372021-11-18  Ben Nham  <nham@apple.com>
    238
  • trunk/LayoutTests/imported/w3c/resources/import-expectations.json

    r286002 r286061  
    145145    "web-platform-tests/css/css-transitions": "import",
    146146    "web-platform-tests/css/css-ui": "import",
     147    "web-platform-tests/css/css-values/urls": "import",
    147148    "web-platform-tests/css/css-variables": "import",
    148149    "web-platform-tests/css/css-will-change": "import",
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/empty.html

    r251521 r286061  
    88#inline-unquoted {
    99    background-image: url();
     10    cursor: url(), pointer;
    1011}
    1112
    1213#inline-quoted {
    1314    background-image: url("");
     15    cursor: url(""), pointer;
    1416}
    1517</style>
     
    2729];
    2830
    29 const inline_url = location.href;
    30 const external_url = new URL(document.querySelector("link[rel=stylesheet]").href, location.href).href;
    31 
    3231for (let id of ids) {
    3332    test(function() {
    3433        const el = document.getElementById(id);
    35         const expected = id.startsWith("inline-") ? inline_url : external_url;
    3634        const style = window.getComputedStyle(el);
    37         assert_equals(style["background-image"], 'url("' + expected + '")');
     35        assert_equals(style["background-image"], 'url("")');
     36        assert_equals(style["cursor"], 'url(""), pointer');
    3837    }, "empty URL: " + id);
    3938}
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/support/empty-urls.css

    r251521 r286061  
    11#external-unquoted {
    22    background-image: url();
     3    cursor: url(), pointer;
    34}
    45
    56#external-quoted {
    67    background-image: url("");
     8    cursor: url(""), pointer;
    79}
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/support/w3c-import.log

    r251521 r286061  
    1616List of files:
    1717/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/support/empty-urls.css
     18/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/support/fragment-only-urls.css
     19/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/support/relative-urls.css
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/w3c-import.log

    r251521 r286061  
    1616List of files:
    1717/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/empty.html
     18/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/fragment-only.html
     19/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/resolve-relative-to-base.html
     20/LayoutTests/imported/w3c/web-platform-tests/css/css-values/urls/resolve-relative-to-stylesheet.html
  • trunk/Source/WebCore/ChangeLog

    r286059 r286061  
     12021-11-19  Matt Woodrow  <matt.woodrow@gmail.com>
     2
     3        Don't modify fragment-only or empty image URLs
     4        https://bugs.webkit.org/show_bug.cgi?id=229917
     5
     6        Reviewed by Darin Adler.
     7
     8        Don't modify fragment-only or empty image URLs, as-per css-values-4
     9
     10        Existing web-platform-tests are marked as passing.
     11
     12        * css/CSSImageValue.cpp:
     13        (WebCore::CSSImageValue::reresolvedURL const):
     14        * css/parser/CSSParserContext.cpp:
     15        (WebCore::CSSParserContext::completeURL const):
     16        * css/parser/CSSPropertyParserHelpers.cpp:
     17        (WebCore::CSSPropertyParserHelpers::consumeImage):
     18        * dom/Document.cpp:
     19        (WebCore::Document::completeURL const):
     20
    1212021-11-19  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Source/WebCore/css/CSSImageValue.cpp

    r284857 r286061  
    8585URL CSSImageValue::reresolvedURL(const Document& document) const
    8686{
     87    if (isCSSLocalURL(m_location.resolvedURL.string()))
     88        return m_location.resolvedURL;
     89
    8790    // Re-resolving the URL is important for cases where resolvedURL is still not an absolute URL.
    8891    // 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.
  • trunk/Source/WebCore/css/CSSValue.cpp

    r285822 r286061  
    233233}
    234234
     235bool CSSValue::isCSSLocalURL(StringView relativeURL)
     236{
     237    return relativeURL.isEmpty() || relativeURL.startsWith('#');
     238}
     239
    235240String CSSValue::cssText() const
    236241{
  • trunk/Source/WebCore/css/CSSValue.h

    r285822 r286061  
    156156    bool operator==(const CSSValue& other) const { return equals(other); }
    157157
     158    // https://www.w3.org/TR/css-values-4/#local-urls
     159    // Empty URLs and fragment-only URLs should not be resolved relative to the base URL.
     160    static bool isCSSLocalURL(StringView relativeURL);
     161
    158162protected:
    159163
  • trunk/Source/WebCore/css/parser/CSSParserContext.cpp

    r284176 r286061  
    246246{
    247247    auto result = [&] () -> ResolvedURL {
     248        // See also Document::completeURL(const String&)
    248249        if (string.isNull())
    249250            return { };
     251
     252        if (CSSValue::isCSSLocalURL(string))
     253            return { string, { URL(), string } };
     254
    250255        if (charset.isEmpty())
    251256            return { string, { baseURL, string } };
  • trunk/Source/WebCore/dom/Document.cpp

    r286012 r286061  
    55925592URL Document::completeURL(const String& url, const URL& baseURLOverride, ForceUTF8 forceUTF8) const
    55935593{
     5594    // See also CSSParserContext::completeURL(const String&)
     5595
    55945596    // Always return a null URL when passed a null string.
    55955597    // FIXME: Should we change the URL constructor to have this behavior?
    5596     // See also [CSS]StyleSheet::completeURL(const String&)
    55975598    if (url.isNull())
    55985599        return URL();
     5600
    55995601    const URL& baseURL = ((baseURLOverride.isEmpty() || baseURLOverride == aboutBlankURL()) && parentDocument()) ? parentDocument()->baseURL() : baseURLOverride;
    56005602    if (!m_decoder || forceUTF8 == ForceUTF8::Yes)
Note: See TracChangeset for help on using the changeset viewer.