Closed Bug 1689244 Opened 3 years ago Closed 3 years ago

Don't eagerly resolve min() expressions that have a percent value (at least not if the percent value could be resolved against a negative percent basis)

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox-esr78 --- wontfix
firefox87 --- wontfix

People

(Reporter: dholbert, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(1 file)

spinning this off from https://github.com/w3c/csswg-drafts/issues/4227 , where it's pointed out that you can't trivially resolve min(10%,20%) without knowing whether the percent basis is positive or negative.

It looks like we do eagerly resolve it right now, at least based on the jsfiddle testcase in that github issue. We need to stop doing that.

I'll attach a version of that jsfiddle testcase that shows how our current behavior isn't internally consistent right now.

Attached file testcase 1

Here's a testcase. We place the image (a star) at the bottom of the element for the first two lines, but we place it at the top for the third one.

Chrome places it at the top for all three, which is the EXPECTED RESULTS.

The only difference in the third one is that it's got a negligible-but-nonzero pixel-valued length component to the arithmetic in the min() expression, which means it can't be resolved eagerly. This negligible addition in the third line shouldn't affect our behavior, but it does, which is a hint that we're not being consistent.

As described in comment 0 and in the github issue, really none of the expressions can be resolved eagerly, because the percent value could be resolved against a negative percent-basis (as is true in this case).

Severity: -- → S3

Boris or emilio, maybe you have cycles to take a look?

It looks like we need to revise bug 1609428's code so that we treat <percentage> the same way that we treat <length-percentage> (i.e. decline to simplify the expression in the style system), for min/max/clamp expressions.

Depends on: 1609428
Flags: needinfo?(boris.chiou)

The only negative percent basis is for a <length-percentage> anyhow right? So we could just not simplify percentages in background-position.

Returning None from here might do it.

Keywords: testcase
OS: Unspecified → All
Hardware: Unspecified → All
Version: unspecified → Trunk

I get expected results with Firefox 92.0a1 buildID=20210717093616 in tests in #c2, #c3 and #c4 .

Resolving as WORKSFORME

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
Flags: needinfo?(boris.chiou)

Web Platform Test pull request:
PR 27716: Added 4 background-position tests with min() max() functions with %tages
https://github.com/web-platform-tests/wpt/pull/27716

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: