Bug 231044 - Allow NaN, infinity, and -infinity in calc
Summary: Allow NaN, infinity, and -infinity in calc
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nikos Mouchtaris
URL:
Keywords: InRadar
: 219832 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-09-30 16:24 PDT by Nikos Mouchtaris
Modified: 2021-11-07 01:38 PST (History)
12 users (show)

See Also:


Attachments
Patch (21.50 KB, patch)
2021-09-30 16:32 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (24.32 KB, patch)
2021-10-01 14:13 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (27.00 KB, patch)
2021-10-01 14:56 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (29.85 KB, patch)
2021-10-01 15:02 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff
Patch (30.56 KB, patch)
2021-10-01 16:10 PDT, Nikos Mouchtaris
simon.fraser: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
infinity (39.09 KB, patch)
2021-10-01 18:54 PDT, Nikos Mouchtaris
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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. ***