Bug 231044

Summary: Allow NaN, infinity, and -infinity in calc
Product: WebKit Reporter: Nikos Mouchtaris <nmouchtaris>
Component: New BugsAssignee: Nikos Mouchtaris <nmouchtaris>
Status: RESOLVED FIXED    
Severity: Normal CC: clopez, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, jonlee, macpherson, menard, seokho, simon.fraser, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
simon.fraser: review+, ews-feeder: commit-queue-
infinity none

Description Nikos Mouchtaris 2021-09-30 16:24:39 PDT
Allow NaN, infinity, and -infinity in calc
Comment 1 Nikos Mouchtaris 2021-09-30 16:32:37 PDT
Created attachment 439792 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-10-01 10:32:32 PDT
<rdar://problem/83772269>
Comment 3 Nikos Mouchtaris 2021-10-01 14:13:17 PDT
Created attachment 439910 [details]
Patch
Comment 4 EWS Watchlist 2021-10-01 14:14:43 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 5 Nikos Mouchtaris 2021-10-01 14:56:42 PDT
Created attachment 439914 [details]
Patch
Comment 6 Nikos Mouchtaris 2021-10-01 15:02:57 PDT
Created attachment 439915 [details]
Patch
Comment 7 Simon Fraser (smfr) 2021-10-01 15:17:35 PDT
Comment on attachment 439915 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=439915&action=review

> Source/WebCore/css/CSSPrimitiveValue.cpp:955
> +    if (m_value.num == -1*std::numeric_limits<double>::infinity())

Spaces around *

> Source/WebCore/css/CSSValueKeywords.in:1369
> +INFINITY

Why is this capitalized?

> Source/WebCore/css/calc/CSSCalcExpressionNodeParser.cpp:100
> +    return { { CSSValuePi, CSSUnitType::CSS_NUMBER, piDouble }, { CSSValueE, CSSUnitType::CSS_NUMBER, std::exp(1.0) }, { CSSValueInfinity, CSSUnitType::CSS_NUMBER, -1*std::numeric_limits<double>::infinity() }, { CSSValueINFINITY, CSSUnitType::CSS_NUMBER, std::numeric_limits<double>::infinity() }, { CSSValueNaN, CSSUnitType::CSS_NUMBER, std::numeric_limits<double>::quiet_NaN() } };

This need wrapping. CSSValueINFINITY is ugly.
Comment 8 Simon Fraser (smfr) 2021-10-01 15:29:57 PDT
Comment on attachment 439915 [details]
Patch

r- for the -infinity confusion
Comment 9 Nikos Mouchtaris 2021-10-01 16:10:16 PDT
Created attachment 439924 [details]
Patch
Comment 10 Simon Fraser (smfr) 2021-10-01 16:14:43 PDT
Comment on attachment 439924 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=439924&action=review

> Source/WebCore/css/calc/CSSCalcExpressionNodeParser.cpp:103
> +    return { { CSSValuePi, CSSUnitType::CSS_NUMBER, piDouble }, { CSSValueE, CSSUnitType::CSS_NUMBER, std::exp(1.0) },
> +        { CSSValueNegativeInfinity, CSSUnitType::CSS_NUMBER, -1 * std::numeric_limits<double>::infinity() },
> +        { CSSValueInfinity, CSSUnitType::CSS_NUMBER, std::numeric_limits<double>::infinity() },
> +        { CSSValueNaN, CSSUnitType::CSS_NUMBER, std::numeric_limits<double>::quiet_NaN() } };

I would wrap this like:

return {
    { CSSValuePi, CSSUnitType::CSS_NUMBER, piDouble }, { CSSValueE, CSSUnitType::CSS_NUMBER, std::exp(1.0) },
    { CSSValueNegativeInfinity, CSSUnitType::CSS_NUMBER, -1 * std::numeric_limits<double>::infinity() },
    { CSSValueInfinity, CSSUnitType::CSS_NUMBER, std::numeric_limits<double>::infinity() },
    { CSSValueNaN, CSSUnitType::CSS_NUMBER, std::numeric_limits<double>::quiet_NaN() },
};
Comment 11 Nikos Mouchtaris 2021-10-01 18:54:01 PDT
Created attachment 439947 [details]
infinity
Comment 12 EWS 2021-10-01 23:23:04 PDT
Committed r283434 (242421@main): <https://commits.webkit.org/242421@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 439947 [details].
Comment 13 Tim Nguyen (:ntim) 2021-11-07 01:38:16 PST
*** Bug 219832 has been marked as a duplicate of this bug. ***