Skip to content

Commit

Permalink
[css-properties-values-api] Absolutize initial <url> values.
Browse files Browse the repository at this point in the history
The computed value would incorrectly remain relative for the initial value
of <url>-registered custom properties. This is because it did not undergo
the token-rewriting done for non-initial properties.

Since the token-rewriting function was implemented, circumstances have
changed a little: there is now a general absolutization mechanism (i.e.
StyleBuilderConverter::ConvertRegisteredPropertyVariableData). Therefore,
this CL performs the URL absolutization on the CSSValue-level rather than
the token level. This automatically also catches the initial-value case.

Note that CSSVariableDatas with var()-references would previously "forget"
their base URL and TextEncoding when resolved. This didn't matter in
practice, because we would already have rewritten the tokens at that point.
However, it matters now, since the URL is now made absolute _after_ the
CSSVariableData is resolved. Hence, CSSVariableData::CreateResolved has
gained the appropriate parameters.

R=futhark@chromium.org

Bug: 641877
Change-Id: I0fd80664adb49e60df24dcc0e91d23872f61fdb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1528188
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646218}
  • Loading branch information
andruud authored and chromium-wpt-export-bot committed Apr 1, 2019
1 parent f326d29 commit 2f2bf34
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -30,6 +30,10 @@
test_initial_value({ syntax: '<transform-function>', initialValue: 'rotate(42deg)' }, 'rotate(42deg)');
test_initial_value({ syntax: '<transform-list>', initialValue: 'scale(calc(2 + 2))' }, 'scale(4)');
test_initial_value({ syntax: '<transform-list>', initialValue: 'scale(calc(2 + 1)) translateX(calc(3px + 1px))' }, 'scale(3) translateX(4px)');
test_initial_value({ syntax: '<url>', initialValue: 'url(a)' },
`url("${new URL('a', document.baseURI)}")`);
test_initial_value({ syntax: '<url>+', initialValue: 'url(a) url(a)' },
`url("${new URL('a', document.baseURI)}") url("${new URL('a', document.baseURI)}")`);

// Test that the initial value of the custom property 'reg' is successfully
// substituted into 'property'.
Expand Down

0 comments on commit 2f2bf34

Please sign in to comment.