Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Values set by mask and background shorthands should not serialize as "initial" - #9849

Merged
webkit-early-warning-system merged 1 commit into
WebKit:mainfrom
darinadler:eng/Values-set-by-mask-and-background-shorthands-should-not-serialize-as-initial
Feb 11, 2023
Merged

webkit-early-warning-system merged 1 commit into
WebKit:mainfrom
darinadler:eng/Values-set-by-mask-and-background-shorthands-should-not-serialize-as-initial

Conversation

@darinadler

@darinadler darinadler commented Feb 9, 2023 •

Copy link
Copy Markdown
Member

5d2cf87

Values set by mask and background shorthands should not serialize as "initial"
https://bugs.webkit.org/show_bug.cgi?id=251838
rdar://problem/105114588

Reviewed by Tim Nguyen.

Needed to expand the function that serializes longhands to cover this case.
Also fixed serialization of the background shorthand to more closely match
the specification and a mistake in the parser that allowed invalid background
shorthand values involving sizes without positions.

* LayoutTests/editing/deleting/paste-with-transparent-background-color-expected.txt:
* LayoutTests/editing/deleting/paste-with-transparent-background-color-live-range-expected.txt:
Updated for progression where we no longer add "background-image: none" as a side effect.

* LayoutTests/fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* LayoutTests/fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* LayoutTests/fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* LayoutTests/fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* LayoutTests/fast/css/remove-shorthand-expected.txt:
* LayoutTests/fast/dom/background-shorthand-csstext-expected.txt:
* LayoutTests/fast/dom/background-shorthand-csstext.html:
Updated to assume background-color will be serialized first, as specified.

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-invalid-expected.txt:
Updated to expect PASS for the test of parsing a size without a position.

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-valid.html:
Added tests of the longhand values. Removed result that allowed WebKit's old
incorrect serialization.

* LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub.html:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:
Added tests of the longhand values.

* Source/WebCore/css/CSSProperties.json: Moved background-color to the start
of the background shorthand so serialization matches the specification.

* Source/WebCore/css/StyleProperties.cpp:
(WebCore::serializeLonghandValue): Added special case for the lists that are
used for the mask and background longhands, because the parser puts
placeholders in there when parsing the shorthands.

* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeBackgroundShorthand): Only parse size
immediately after a position. The old code required that it be after a
position, but not immediately after. Removed comment saying this makes
"invalid longhands". They are now valid, and the serializeLonghandValue
function above makes them serialize correctly.

Canonical link: https://commits.webkit.org/260157@main

9e49d81

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🛠 gtk
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 gtk-wk2
✅ 🧪 api-ios   🧪 mac-wk1 ✅ 🧪 api-gtk
✅ 🛠 tv ✅ 🧪 mac-wk2
✅ 🛠 tv-sim ✅ 🧪 mac-AS-debug-wk2
✅ 🛠 watch ✅ 🧪 mac-wk2-stress
✅ 🛠 🧪 merge ✅ 🛠 watch-sim

@darinadler darinadler self-assigned this Feb 9, 2023
@darinadler darinadler added the CSS Cascading Style Sheets implementation label Feb 9, 2023
@webkit-early-warning-system

webkit-early-warning-system commented Feb 9, 2023 •

Copy link
Copy Markdown
Collaborator

@darinadler
darinadler marked this pull request as draft February 9, 2023 16:51
@darinadler
darinadler force-pushed the eng/Values-set-by-mask-and-background-shorthands-should-not-serialize-as-initial branch from 620a5ab to babcc53 Compare February 11, 2023 02:14
@webkit-early-warning-system

webkit-early-warning-system commented Feb 11, 2023 •

Copy link
Copy Markdown
Collaborator

@darinadler
darinadler marked this pull request as ready for review February 11, 2023 06:46
@darinadler
darinadler requested a review from rniwa as a code owner February 11, 2023 06:46

@nt1m nt1m left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you export the WPT changes and check the cross browser results in the checks tab on the WPT PR?

@darinadler
darinadler force-pushed the eng/Values-set-by-mask-and-background-shorthands-should-not-serialize-as-initial branch from babcc53 to 9e49d81 Compare February 11, 2023 16:56
@darinadler

Copy link
Copy Markdown
Member Author

Looks good! Can you export the WPT changes and check the cross browser results in the checks tab on the WPT PR?

I exported the changes in web-platform-tests/wpt#38456 but I don’t really know how to check the results for other browsers; need someone to show me how, I guess.

@Loirooriol

Copy link
Copy Markdown
Contributor

It's in the Checks tab: Chrome, Firefox, Safari.

@nt1m

nt1m commented Feb 11, 2023

Copy link
Copy Markdown
Member

Interesting, Firefox serializes background-color: transparent to background-color: rgba(0, 0, 0, 0) and doesn't obey the shortest serialization rule for mask-position / background-position (0% 0% vs. 0%). Worth filing an CSSWG issue on the color part.

Chrome seems to keep serializing with initial which is wrong.

Here's the Firefox diff: https://wpt.fyi/results/css/css-backgrounds/parsing/background-valid.html?diff&filter=ADC&run_id=5146658350825472&run_id=6193847596482560

Chrome diff: https://wpt.fyi/results/css/css-backgrounds/parsing/background-valid.html?diff&filter=ADC&run_id=6280005059870720&run_id=6266588706111488

Seems good to go!

@darinadler darinadler added the merge-queue Applied to send a pull request to merge-queue label Feb 11, 2023
…"initial"

https://bugs.webkit.org/show_bug.cgi?id=251838
rdar://problem/105114588

Reviewed by Tim Nguyen.

Needed to expand the function that serializes longhands to cover this case.
Also fixed serialization of the background shorthand to more closely match
the specification and a mistake in the parser that allowed invalid background
shorthand values involving sizes without positions.

* LayoutTests/editing/deleting/paste-with-transparent-background-color-expected.txt:
* LayoutTests/editing/deleting/paste-with-transparent-background-color-live-range-expected.txt:
Updated for progression where we no longer add "background-image: none" as a side effect.

* LayoutTests/fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* LayoutTests/fast/backgrounds/background-shorthand-after-set-backgroundSize.html:
* LayoutTests/fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* LayoutTests/fast/backgrounds/background-shorthand-with-backgroundSize-style.html:
* LayoutTests/fast/css/remove-shorthand-expected.txt:
* LayoutTests/fast/dom/background-shorthand-csstext-expected.txt:
* LayoutTests/fast/dom/background-shorthand-csstext.html:
Updated to assume background-color will be serialized first, as specified.

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-invalid-expected.txt:
Updated to expect PASS for the test of parsing a size without a position.

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-valid.html:
Added tests of the longhand values. Removed result that allowed WebKit's old
incorrect serialization.

* LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub.html:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:
Added tests of the longhand values.

* Source/WebCore/css/CSSProperties.json: Moved background-color to the start
of the background shorthand so serialization matches the specification.

* Source/WebCore/css/StyleProperties.cpp:
(WebCore::serializeLonghandValue): Added special case for the lists that are
used for the mask and background longhands, because the parser puts
placeholders in there when parsing the shorthands.

* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeBackgroundShorthand): Only parse size
immediately after a position. The old code required that it be after a
position, but not immediately after. Removed comment saying this makes
"invalid longhands". They are now valid, and the serializeLonghandValue
function above makes them serialize correctly.

Canonical link: https://commits.webkit.org/260157@main
@webkit-early-warning-system
webkit-early-warning-system force-pushed the eng/Values-set-by-mask-and-background-shorthands-should-not-serialize-as-initial branch from 9e49d81 to 5d2cf87 Compare February 11, 2023 19:14
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 260157@main (5d2cf87): https://commits.webkit.org/260157@main

Reviewed commits have been landed. Closing PR #9849 and removing active labels.

@webkit-early-warning-system
webkit-early-warning-system merged commit 5d2cf87 into WebKit:main Feb 11, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 11, 2023
"background": {
"codegen-properties": {
"longhands": [
"background-color",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this? The spec says "canonical order: per grammar", and backgrfound-color only appears at the end in the <final-bg-layer>.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's only one background-image, then background-color does appear first. The spec is just saying you can't mention multiple background-colors in the shorthand (which makes sense).

I think this deserves some clarification?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, even if there is only a single layer, <bg-layer> will be omitted but it's still in the grammar, so background-color appears last. I agree that "canonical order: per grammar" may not be much clear in these complex cases, but I don't see what backs this:

Moved background-color to the start of the background shorthand so serialization matches the specification.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.w3.org/TR/css-backgrounds-3/#typedef-final-bg-layer lists the color first. That is where I got the idea from. Maybe I am looking in the wrong place.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point now.

I’d be happy to move background-color back to the end. I suggest we try to resolve this in w3c/csswg-drafts#418 and then change to match at that time. Whoever wrote the WPT test apparently read the specification the same way I did.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the WebKit parser does not parse a trailing color as a separate final background layer, nor should it. So while the grammar states something like that, it’s not at all consistent with how the values are interpreted. Anyway, I’m willing to change back.

@darinadler
darinadler deleted the eng/Values-set-by-mask-and-background-shorthands-should-not-serialize-as-initial branch February 12, 2023 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Cascading Style Sheets implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants