Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-backgrounds-4] default background-origin for border-area in shorthand #11167

Open
fantasai opened this issue Nov 7, 2024 · 2 comments
Open

Comments

@fantasai
Copy link
Collaborator

fantasai commented Nov 7, 2024

In #10907 (comment) @jsnkuhn wrote:

FYI, the other property reset i've used every time with border-area is background-origin: border-box;. Considering resetting border-box as an initial background-origin value might be of use as well since im my experience most devs are not familiar with that property.

https://codepen.io/jsnkuhn/pen/eYwoGgr?editors=1100
https://codepen.io/jsnkuhn/pen/LYKXGPo
https://codepen.io/jsnkuhn/pen/WNqaeOV
https://codepen.io/jsnkuhn/pen/OJeoapM

There's two relevant questions

  • should background-origin check background-clip to compute a smart default value
  • in the background shorthand, when one box keyword is specified it's applied to both background-clip and background-origin (spec); but border-area is not a valid keyword for background-origin, so should we default it to border-area.

I think we should definitely fix the latter. Unsure about the former, though it would certainly be helpful to authors.

@tabatkins
Copy link
Member

(I presume the end of your second bullet point means to say border-box.)

Yes, I definitely think that background: url(...) border-area; should default -origin to border-box. We already magically match up the two properties when you specify only one value (and while nothing special happens for text, the initial padding-box value for origin is likely what you expect anyway), and a border-box origin is clearly the similarly-intended partner to a border-area clip. (This would also apply to a border-area text value, I presume.)

I'm mildly against doing this with the initial value (rather than just via the shorthand); we don't match up the values today for any of the values; that is, if I set background-clip: border-box;, I'll confusingly still get a background-origin: padding-box; by default, and have to remember to correct it. I don't think border-area is meaningfully different from border-box here, so we shouldn't add novel magic for it.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-backgrounds-4] default background-origin for `border-area` in shorthand, and agreed to the following:

  • RESOLVED: Using 'border-area' in the background shorthand (and omitting origin) defaults the origin to border-box
The full IRC log of that discussion <TabAtkins> fantasai: in the bg shorthand if you specify a single keyword like 'border-box', it sets both clip and origin to that keyword
<TabAtkins> fantasai: but 'border-area' keyword is only valid for clip, not origin
<TabAtkins> fantasai: want to clarify that in that case, origin defaults to border-box
<TabAtkins> +1 to this from me
<kizu> +1, makes sense
<oriol> +1
<TabAtkins> Rossen0: objections?
<fantasai> background: ... border-area;
<emilio> A bit unfortunate that it's different from background: ...; background-clip: border-area
<emilio> But yeah
<TabAtkins> RESOLVED: Using 'border-area' in the background shorthand (and omitting origin) defaults the origin to border-box
<TabAtkins> fantasai: second, do we want some way to make things default if you specify the longhand?
<TabAtkins> fantasai: argument for, it's unfortuante/confusing to get it set to the "wrong" value
<TabAtkins> fantasai: argument against, it's not something we're currnetly doing
<TabAtkins> Rossen0: okay, will leave that part of the discussion
<fantasai> for other values of background-clip (though maybe we should have)
fantasai added a commit to fantasai/WebKit that referenced this issue Dec 7, 2024
…ified

https://bugs.webkit.org/show_bug.cgi?id=283308
rdar://140142957

Reviewed by NOBODY (OOPS!).

If the origin is not specified, but clip is given as border-area,
set origin to border-box.

See w3c/csswg-drafts#11167

* 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:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeBackgroundShorthand):
fantasai added a commit to fantasai/WebKit that referenced this issue Dec 7, 2024
…ified

https://bugs.webkit.org/show_bug.cgi?id=283308
rdar://140142957

Reviewed by NOBODY (OOPS!).

If the origin is not specified, but clip is given as border-area,
set origin to border-box.

See w3c/csswg-drafts#11167

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-shorthand-serialization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-shorthand-serialization.html:
* 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:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serializeLayered const):
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeBackgroundShorthand):
webkit-commit-queue pushed a commit to fantasai/WebKit that referenced this issue Dec 8, 2024
…ified

https://bugs.webkit.org/show_bug.cgi?id=283308
rdar://140142957

Reviewed by Tim Nguyen.

If the origin is not specified, but clip is given as border-area,
set origin to border-box.

See w3c/csswg-drafts#11167

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-shorthand-serialization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-shorthand-serialization.html:
* 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:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serializeLayered const):
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeBackgroundShorthand):

Canonical link: https://commits.webkit.org/287521@main
mnutt pushed a commit to movableink/webkit that referenced this issue Dec 8, 2024
…ified

https://bugs.webkit.org/show_bug.cgi?id=283308
rdar://140142957

Reviewed by Tim Nguyen.

If the origin is not specified, but clip is given as border-area,
set origin to border-box.

See w3c/csswg-drafts#11167

* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-shorthand-serialization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/background-shorthand-serialization.html:
* 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:
* Source/WebCore/css/ShorthandSerializer.cpp:
(WebCore::ShorthandSerializer::serializeLayered const):
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::consumeBackgroundShorthand):

Canonical link: https://commits.webkit.org/287521@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment