Closed Bug 1846625 Opened 1 year ago Closed 10 months ago

[css-properties-values-api] Compute <url>

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: zrhoffman, Assigned: emilio)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

For "<url>" values, the computed value is one of the following:

  • if the URL is a relative URL, the computed value is the resolved absolute URL as described in [css3-values].

  • otherwise, the computed value is as specified.

WPTs that should pass: https://wpt.fyi/results/css/css-properties-values-api/url-resolution.html

Depends on: 1846628
Blocks: 1864818
Assignee: nobody → zsun

I guess that I need to get the stylesheet URI and re-compose the relative URL against the BaseURI for this case. The stylesheet URI corresponds to
the originaluri in referrer in URLExtraData? However, I'm struggling to find a way to get the stylesheet pointer. For example, in Document.cpp, in mDocument->DefaultStyleAttrURLData(), ReferrerInfoForInternalCSSAndSVGResources() is called. While in our case we might need to use external CSS, which needs a pointer to the stylesheet. Or maybe there is a way to fetch stylesheet uri from rust side?

@emilio - any suggestions/thoughts would be much appreciated!

Flags: needinfo?(emilio)

So I'm confused. We are already using the specified::Url and computed::Url values here, which keeps around the extra_data which they were parsed with here.

I think the only issue is that we're using the property registration's URL data here, while instead we should probably use the value url data.

Let me take a look since I've already debugged this.

Flags: needinfo?(emilio)

There are two issues here:

  • The first one is that we were serializing the specified url value,
    which arguably should include the whole expanded URI, but for reasons
    (mainly not copying urls around) doesn't. That means that
    ToComputedValue::from_computed_value(cv).to_css() is not equivalent
    to cv.to_css(). In order to fix that, teach the custom properties
    code to serialize computed values as well. This saves an extra
    conversion too.

  • The second one is that we were using the property registration's url
    data in order to resolve URIs against. That is not correct. Instead,
    use the value's URL data (introduced in bug 1863620) to do this.

With those two bugs fixed, we can resolve registered custom property
urls correctly. Use generics to avoid repetitive code.

Ah, I see. The patch explained very well. Thank you!

Assignee: zsun → nobody
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0bc1a6cfd186 Fix custom properties url resolution. r=zsun,zrhoffman,firefox-style-system-reviewers
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: