Open Bug 1695097 Opened 5 years ago Updated 5 years ago

[wpt-sync] Sync PR 27794 - Ensure roundtrip for parsing & serialization of custom properties and var()

Categories

(Core :: CSS Parsing and Computation, task, P4)

task

Tracking

()

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 27794 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/27794
Details from upstream follow.

b'Xiaocheng Hu <xiaochengh@chromium.org>' wrote:

Ensure roundtrip for parsing & serialization of custom properties and var()

When tokenizing a style sheet, currently all comment tokens are
discarded. This patch adds a flag is_after_comment_ to CSSParserToken
to indicate removed comment tokens, so that we can add them back
in serialization, so that parsing & serialization of custom properties
can round-trip for cases like '--foo: 1/**/px'.

Using this mechanism, when resolving consecutive var() functions, we can
also insert a comment between them, so that the resolved token
sequence can be serialized with an empty comment in between. In this way,
parsing & serialization of consecutive var() functions can round-trip
for cases like '--a: 1; --b: px; --foo: var(a)var(b)'.

Bug: 1180294
Change-Id: I96e5958f1479b052eba12aff31fc18a6265b08b4

Reviewed-on: https://chromium-review.googlesource.com/2708609
WPT-Export-Revision: 51af0c053b56b6cbd86045e2eef6d2a31cd4efab

Component: web-platform-tests → CSS Parsing and Computation
Product: Testing → Core
You need to log in before you can comment on or make changes to this bug.