Closed Bug 1874606 Opened 8 months ago Closed 8 months ago

Wrong background-position with min/max/clamp on percentages

Categories

(Core :: Layout, defect)

Firefox 121
Desktop
Windows 11
defect

Tracking

()

RESOLVED INVALID
Tracking Status
firefox-esr115 --- wontfix
firefox121 --- wontfix
firefox122 --- wontfix
firefox123 --- wontfix

People

(Reporter: eyalgruss, Assigned: emilio)

References

(Regression, )

Details

(Keywords: regression)

Attachments

(1 file)

When using CSS min/max/clamp on percentage values in background-position, the result is wrong in Firefox (works in Chrome).

e.g. min(10%, 100%) actually takes the larger value.

Code to reproduce:

body {
  background-image: url('https://img.freepik.com/free-vector/english-alphabets-many-colors_1308-4763.jpg');
  background-size: 200%;
  background-position-x: min(10%, 100%);
}

Firefox screenshot

Chrome screenshot

Set release status flags based on info from the regressing bug 1709018

:emilio, since you are the author of the regressor, bug 1709018, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

This is actually the correct behavior, afaict. https://drafts.csswg.org/css-backgrounds-3/#background-position says:

A percentage for the horizontal offset is relative to (width of background positioning area - width of background image).

Since the background-image (due to the background-size) is larger than the background positioning area, the percentage basis is negative. This is precisely the bug bug 1709018 was fixing.

In fact, Chrome and Safari behave like us if you use the background-position shorthand, but not if you use the background-position-x longhand for some reason.

Flags: needinfo?(emilio)

Will add a test, but the bug itself is invalid.

Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → INVALID

See https://bugzilla.mozilla.org/show_bug.cgi?id=1874606#c3 (and the
test is self-explanatory, it's just a copy of
background-position-negative-percentage-comparison.html but with the
longhand expanded).

Assignee: nobody → emilio

so it seems that instead of clamp(0%, var(--dx), 100%) one should write clamp(100%, var(--dx), 0%)

If the image is larger than the positioning area, sure.

Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c133f145c344
Add a test for a WebKit / Blink bug where they incorrectly simplify percentages inside calc() in background-position longhands. r=layout-reviewers,jfkthame
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/44397 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: