New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 618165 link

Starred by 18 users

Issue metadata

Status: Fixed
Owner:
Not working on Chrome any more
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Relative urls don't work in var() references and @apply rules

Reported by cgalv...@gmail.com, Jun 8 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0

Example URL:

Steps to reproduce the problem:
Happy day and excuse my bad English.

in a html file I have the following:

<Button class = "botonAgregar"> Crear periodo </ button>

html file in that have linked a CSS file with the following properties:

.botonAgregar{
    font-family: fuenteNegrita;
    font-size: 20px;
    text-align: center;
    border-radius: 15px;
    border-color: transparent;
    color: white;
    padding: 7px 20px 7px 50px;
    margin: 5px;
    text-decoration: none;
    background: var(--colorOscuro) url("../img/icons/plusWhite.png") no-repeat scroll 15px 7px / 25px 25px;
}

("--colorOscuro" Is a global variable with the value css "#2DAFE5")

What is the expected behavior?
The previous code displays a button with an icon on the left side.

What went wrong?
In Firefox it works correctly, but Chrome does not show the "plusWhite.png" icon.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes 

Chrome version: 50.0.2661.102  Channel: stable
OS Version: Ubuntu 16.04 (64-bit)
Flash Version: 

A temporary solution to this is to change the css configuration with the following:

background: url("../img/icons/plusWhite.png") no-repeat scroll 15px 7px / 25px 25px;
background-color: var(--colorOscuro);

However, I consider it something to be solved.
 
firefox.png
3.0 KB View Download
chrome.png
2.5 KB View Download

Comment 1 by tkent@chromium.org, Jun 8 2016

Components: -Blink Blink>CSS
Labels: Needs-Feedback
Could you provide a standalone test case that reproduces this issue (for example on jsbin.com/jsfiddle.net, or upload a html file)? I can't manage to repro this on 50.0.2661.104.

Also if possible, could you test newer Chrome versions? The current stable version of Chrome is now M51.

Thanks!

Comment 3 by cgalv...@gmail.com, Jun 10 2016

good day.

I have already made a simple example jsFiddle reproducing the same error:

https://jsfiddle.net/cgalvist/emmcbwzn/15/

I tried to add an icon with an absolute url, but if it works in Chrome. It seems that the problem is with a relative url.

Right now I am using Chromium. 50.0.2661.102 version in Ubuntu 16.04 64 bits.

As already mentioned, if it works in Firefox 46.0.1 on Ubuntu 16.04 64 bits.

Right now I can not update chromium, but later performed the same test with the updated browser.

Comment 4 by timloh@chromium.org, Jun 11 2016

Labels: -OS-Linux -Needs-Feedback Hotlist-Interop OS-All
Status: Available (was: Unconfirmed)
Summary: Background image doesn't work when var() used in background (was: background image does not work in chrome)
Thanks, I can repro this on M51.

Comment 5 by timloh@chromium.org, Jun 15 2016

Summary: Relative urls don't work in var() references (was: Background image doesn't work when var() used in background)
The CSSVariableResolver just creates a new CSSParserContext so it can't resolve URLs.

https://jsfiddle.net/suj05a9z/1/

Comment 6 by timloh@chromium.org, Jun 27 2016

Owner: timloh@chromium.org
Status: Assigned (was: Available)
tentatively assigning to myself

Comment 7 by cgalv...@gmail.com, Jun 27 2016

ok, thanks for your attention

Comment 8 by timloh@chromium.org, Aug 15 2016

 Issue 637072  has been merged into this issue.

Comment 9 by timloh@chromium.org, Aug 15 2016

Summary: Relative urls don't work in var() references and @apply rules (was: Relative urls don't work in var() references)
As per the duped bug, this also applies to @apply rules and protocol-relative urls (i.e. without the http(s)).
Cc: tabatkins@chromium.org
Tab, if we have --a:url(a.png) and background-image:var(--a) in separate sheets, which sheet should we use the base URL from?
The behavior that falls out most obviously is to use the "background-image" sheet - the url() isn't interpreted as a url until it's substituted.

This might change if the custom property was declared to have a <url> type, as we'd then be able to resolve it as a url immediately in the custom property.

I'm unsure which behavior is better, but I suspect it would be best to have a consistent behavior between the two cases.
(Just lurking on this issue, apologies for the intrusion.)

Resolving URL types relative to the declaration stylesheet seems preferable.

a.css
--a:a.png /* just a string at this point */

b.css
--b:url(b.png) /* resolve relative to b.css */

c.css
--background-image:url(var(--a)) /* now resolve relative to c.css */
--background-image:var(--b) /* already resolved relative to b.css */

$0.02 as a user/fan of this feature :)
Yeah, I agree that's probably the best choice, it just means having to actually look for urls and carry around side-channel information about them.  We can't *actually* resolve the url at declaration time, because we have no idea if it's going to be used in a CSS property at all; we'd have to instead just annotate the url() function we parsed with a hidden "resolved url", and use that *if* it ends up being put into a CSS property that expects a URL.

That's a lot more complicated than what the spec mandates currently, which is that the value of a custom property is just an uninterpreted token stream, which only gains meaning after substitution into a real property.

Also, more complex case:

a.css
--a: "a.png";

b.css
--b: url(var(--a));

c.css
background-image: var(--b); /* resolved according to a, b, or c? */
 Issue 645309  has been merged into this issue.
 Issue 652044  has been merged into this issue.
 Issue 660664  has been merged into this issue.
 Issue 668364  has been merged into this issue.

Comment 18 by leave...@gmail.com, Dec 14 2016

We resolved in today's CSS call [1] that URLs in custom properties are not treated specially, and resolve when substituted in a non-custom property, with the origin of that stylesheet (c.css in Tab's example in Comment 13). Perhaps this bug can be fixed now?

[1]: https://github.com/w3c/csswg-drafts/issues/757
Cc: meade@chromium.org f...@opera.com
Owner: ----
Status: Available (was: Assigned)
Unassigning because I'm not working on this right now, but yes we should fix it :-)
I think this will be easy to implement after https://codereview.chromium.org/2616093003/ lands, we'd just need to add a pointer to the parser context in probably the CSSVariableData (since registered properties might need these for <image>/<url> types too).
Project Member

Comment 21 by bugdroid1@chromium.org, Jan 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9f693fb8bdcda52ef30230ff57592a9736707dff

commit 9f693fb8bdcda52ef30230ff57592a9736707dff
Author: fs <fs@opera.com>
Date: Mon Jan 16 13:22:07 2017

Provide a CSSParserContext to CSSSyntaxDescriptor

Add a CSSParserContext* argument to CSSSyntaxDescriptor::parse to allow
CSSValues to be resolve against a proper parser context, and resolve
relative URLs and other sourcing sensitive data.
Provide parser contexts as available on call-sites, or use the
strictCSSParserContext() if none is available. Move the TODO up the
callstack as needed.

BUG= 618165 

Review-Url: https://codereview.chromium.org/2632083002
Cr-Commit-Position: refs/heads/master@{#443882}

[modify] https://crrev.com/9f693fb8bdcda52ef30230ff57592a9736707dff/third_party/WebKit/Source/core/css/CSSSyntaxDescriptor.cpp
[modify] https://crrev.com/9f693fb8bdcda52ef30230ff57592a9736707dff/third_party/WebKit/Source/core/css/CSSSyntaxDescriptor.h
[modify] https://crrev.com/9f693fb8bdcda52ef30230ff57592a9736707dff/third_party/WebKit/Source/core/css/CSSVariableData.cpp
[modify] https://crrev.com/9f693fb8bdcda52ef30230ff57592a9736707dff/third_party/WebKit/Source/core/css/PropertyRegistration.cpp
[modify] https://crrev.com/9f693fb8bdcda52ef30230ff57592a9736707dff/third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp

Labels: Update-Quarterly
As far as I see, css variable urls are properly resolved on tip-of-tree. Should this be closed?

Comment 24 by meade@chromium.org, Mar 10 2017

Cc: -f...@opera.com
Owner: f...@opera.com
Hey fs@, does your CL completely fix this? If so, could you please close this bug? Thanks!

Comment 25 by f...@opera.com, Mar 10 2017

It was just a very small step in the general direction of a fix (I think), while working on a somewhat related issue.

Comment 26 by f...@opera.com, Mar 10 2017

My guess would be that https://codereview.chromium.org/2718273002 (for  issue 270059 ) may have made some cases here appear fixed (it most certainly will not be correct for all cases IIUC.)

Comment 27 by meade@chromium.org, Mar 13 2017

Cc: f...@opera.com
Owner: meade@chromium.org
Thanks for the response, fs! 

Comment 28 by f...@opera.com, Mar 16 2017

 Issue 702121  has been merged into this issue.
Status: Fixed (was: Available)
Fixed by https://crrev.com/a3079e2f1ea9974caebcdebd00c1c33dbaa662e0.
is there any workaround for those of us who cannot update browsers yet?

Sign in to add a comment