Closed Bug 2094419 Opened 12 days ago Closed 8 days ago

[wpt-sync] Sync PR 64930 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=329410

Categories

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

task

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox163 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

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

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

Ahmad Saleem <ahmad.saleem792+github@gmail.com> wrote:

WebKit export of https://bugs.webkit.org/show_bug.cgi?id=329410

WebKit export from bug: A lone negative calc(<!---->)<!----> as a ratio makes (<!---->aspect-<!---->ratio ><!----> calc(<!---->-<!---->1)<!---->)<!----> unknown,<!----> though calc(<!---->-<!---->1)<!---->/<!---->2 is clamped to 0/<!---->2

<pre>
[CSS Values] A lone negative calc() as a ratio makes (aspect-ratio > calc(-1)) unknown

A <ratio> written as one number is that number over 1 [1], and each number
of a <ratio> is a <number [0,∞]> [1]. A calculation below 0 where such a
number is taken is valid and clamps to 0: "the value resulting from a
top-level calculation must be clamped to the range allowed in the target
context" [2]. So (aspect-ratio > calc(-1)) is (aspect-ratio > 0), and
calc(-1)/2 is 0/2.

GenericMediaQueryParser consumes a ratio feature's value as two numbers
first, which already clamps a calc() in either position. A lone number
instead falls through to an unbounded <integer> or <number>, and the Ratio
case of validateFeatureAgainstSchema() returned false whenever it resolved
below 0. That is right for a literal such as -1, which is out of range and
invalid [2], but not for a calc(). (aspect-ratio > calc(-1)) and
not (aspect-ratio < calc(-1)) were therefore both unknown, in @media and in
@container, while (min-aspect-ratio: calc(-1)/2) matched.

Clamp a calc() result to 0 for the lone integer and number cases, and keep
rejecting negative literals.

[1] <a href="https://www.w3.org/TR/css-values-4/#ratios">https://www.w3.org/TR/css-values-4/#ratios</a>
[2] <a href="https://www.w3.org/TR/css-values-4/#calc-range">https://www.w3.org/TR/css-values-4/#calc-range</a>

WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=329410">https://bugs.webkit.org/show_bug.cgi?id=329410</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/326111@main">https://commits.webkit.org/326111@main</a>
</pre>

Component: web-platform-tests → CSS Parsing and Computation
Product: Testing → Core

CI Results

Ran 0 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 1 tests and 18 subtests

Status Summary

Firefox

OK : 1
PASS: 18

Chrome

OK : 1
PASS: 10
FAIL: 8

Safari

OK : 1
PASS: 14
FAIL: 4

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Status: NEW → RESOLVED
Closed: 8 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch
You need to log in before you can comment on or make changes to this bug.