Bug 198512 - Presence of CSS variable causes a background url() to get resolved with a different base
Summary: Presence of CSS variable causes a background url() to get resolved with a dif...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar
: 190807 217124 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-06-03 19:14 PDT by Simon Fraser (smfr)
Modified: 2021-04-02 03:54 PDT (History)
16 users (show)

See Also:


Attachments
Testcase (245.30 KB, application/zip)
2019-06-03 19:14 PDT, Simon Fraser (smfr)
no flags Details
Patch (9.69 KB, patch)
2020-10-03 18:01 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (9.69 KB, patch)
2020-10-04 16:12 PDT, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2019-06-03 19:14:35 PDT
Created attachment 371239 [details]
Testcase

If the background shorthand has a variable reference in it:
    background: url('images/ducky.png') var(--darkGreen);

then URLs in that shorthand are resolved relative to the document URL, not the style sheet URL, which is wrong.
Comment 1 Radar WebKit Bug Importer 2019-06-03 19:14:52 PDT
<rdar://problem/51379244>
Comment 2 Simon Fraser (smfr) 2019-06-03 19:22:02 PDT
The CSSParserContext's baseURL is different in the two cases.
Comment 3 Simon Fraser (smfr) 2019-06-03 19:24:29 PDT
...and that's because StyleResolver::resolvedVariableValue() makes a CSSParser parser(document()), so with the document's baseURL, rather than the stylesheet's.
Comment 4 JC Simpson 2020-10-01 23:40:42 PDT
*** Bug 217124 has been marked as a duplicate of this bug. ***
Comment 5 Tyler Wilcock 2020-10-03 18:01:57 PDT
Created attachment 410448 [details]
Patch
Comment 6 Darin Adler 2020-10-04 14:54:04 PDT
Comment on attachment 410448 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=410448&action=review

> Source/WebCore/css/CSSPendingSubstitutionValue.h:40
> +    static Ref<CSSPendingSubstitutionValue> create(CSSPropertyID shorthandPropertyId, Ref<CSSVariableReferenceValue>&& shorthandValue, const URL baseURL)

"const URL" is not the type we want for this argument. Could use "const URL&" or "URL".

> Source/WebCore/css/CSSPendingSubstitutionValue.h:47
> +    const URL baseURL() const { return m_baseURL; }

Same here with return value. It can be URL or const URL&, but const URL is not right.

> Source/WebCore/css/CSSPendingSubstitutionValue.h:64
> +    const URL m_baseURL;

Here, the type "const URL" is fine, good, appropriate.
Comment 7 Tyler Wilcock 2020-10-04 16:12:02 PDT
Created attachment 410486 [details]
Patch
Comment 8 Tyler Wilcock 2020-10-04 17:18:34 PDT
Thanks Darin.  I've fixed that and marked the new patch with cq?
Comment 9 EWS 2020-10-04 17:29:03 PDT
Committed r267951: <https://trac.webkit.org/changeset/267951>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 410486 [details].
Comment 10 Sam Sneddon [:gsnedders] 2021-04-02 03:54:18 PDT
*** Bug 190807 has been marked as a duplicate of this bug. ***