⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 276262 in webkit


Ignore:
Timestamp:
Apr 19, 2021, 10:51:46 AM (5 years ago)
Author:
Darin Adler
Message:

Nullptr crash in CSSCalcValue::category() via HTMLConverterCaches::floatPropertyValueForNode
​https://bugs.webkit.org/show_bug.cgi?id=221392

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-values/minmax-length-percent-serialize-expected.txt:

Updated to reflect 8 tests passing that were failing before.

Source/WebCore:

  • css/CSSCalculationValue.cpp:

(WebCore::CSSCalcOperationNode::createCalcExpression const): Pass in a destination category
when creating a CalcExpressionOperation.
(WebCore::createCSS): Pass the destination category from the CalcExpressionOperation when
creating a CSSCalcOperationNode.

  • css/CSSCalculationValue.h: Moved the CalculationCategory enumeration from here to

CalculationValue.h.

  • platform/CalculationValue.cpp:

(WebCore::operator==): Include destination category when comparing.

  • platform/CalculationValue.h: Moved CalculationCategory here. Added a destination

category constructor argument, data members, and getter function to the
CalcExpressionOperation class.

LayoutTests:

  • fast/css/calc-parsing-expected.txt: Updated for change below.
  • fast/css/calc-parsing.html: Added more test cases so this covers the affected cases of computed

style for calc expressions that mix percentages and numbers. Alternatively, we could remove this
entire test case because the web platform tests also cover this pretty well.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276261 r276262  
     12021-04-19  Darin Adler  <darin@apple.com>
     2
     3        Nullptr crash in CSSCalcValue::category() via HTMLConverterCaches::floatPropertyValueForNode
     4        https://bugs.webkit.org/show_bug.cgi?id=221392
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/css/calc-parsing-expected.txt: Updated for change below.
     9        * fast/css/calc-parsing.html: Added more test cases so this covers the affected cases of computed
     10        style for calc expressions that mix percentages and numbers. Alternatively, we could remove this
     11        entire test case because the web platform tests also cover this pretty well.
     12
    1132021-04-19  Chris Gambrell  <cgambrell@apple.com>
    214
  • trunk/LayoutTests/fast/css/calc-parsing-expected.txt

    r253105 r276262  
    1 Tests parsing of various valid and invalid calc expressions.
     1Tests parsing and re-serializing of various valid and invalid calc expressions.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    … …  
    55
    66
    7 testDiv.style["width"] = "calc(100px)"
    8 PASS testDiv.style['width'] is "calc(100px)"
    9 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "100px"
    10 
    11 testDiv.style["width"] = "max(100px + 200px)"
    12 PASS testDiv.style['width'] is "max(300px)"
    13 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "300px"
    14 
    15 testDiv.style["width"] = "max(100px , 200px)"
    16 PASS testDiv.style['width'] is "max(200px)"
    17 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "200px"
    18 
    19 testDiv.style["width"] = "max(100px,200px)"
    20 PASS testDiv.style['width'] is "max(200px)"
    21 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "200px"
    22 
    23 testDiv.style["width"] = "clamp(100px,123px,200px)"
    24 PASS testDiv.style['width'] is "clamp(100px, 123px, 200px)"
    25 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "123px"
    26 
    27 testDiv.style["width"] = "clamp(100px,300px,200px)"
    28 PASS testDiv.style['width'] is "clamp(100px, 300px, 200px)"
    29 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "200px"
    30 
    31 testDiv.style["width"] = "clamp(200px,300px,100px)"
    32 PASS testDiv.style['width'] is "clamp(200px, 300px, 100px)"
    33 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "200px"
    34 
    35 testDiv.style["width"] = "clamp((50px + 50px),40px,200px)"
    36 PASS testDiv.style['width'] is "clamp(100px, 40px, 200px)"
    37 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "100px"
    38 
    39 testDiv.style["width"] = "clamp(50px + 50px,40px,200px)"
    40 PASS testDiv.style['width'] is "clamp(100px, 40px, 200px)"
    41 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "100px"
    42 
    43 testDiv.style["width"] = "calc(100px, 200px)"
    44 PASS testDiv.style['width'] is "999px"
    45 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    46 
    47 testDiv.style["width"] = "calc(100px  200px)"
    48 PASS testDiv.style['width'] is "999px"
    49 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    50 
    51 testDiv.style["width"] = "calc(100px ( 200px)"
    52 PASS testDiv.style['width'] is "999px"
    53 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    54 
    55 testDiv.style["width"] = "min(100px 200px)"
    56 PASS testDiv.style['width'] is "999px"
    57 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    58 
    59 testDiv.style["width"] = "max(100px 200px)"
    60 PASS testDiv.style['width'] is "999px"
    61 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    62 
    63 testDiv.style["width"] = "max(100px,, 200px)"
    64 PASS testDiv.style['width'] is "999px"
    65 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    66 
    67 testDiv.style["width"] = "max(100px, , 200px)"
    68 PASS testDiv.style['width'] is "999px"
    69 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    70 
    71 testDiv.style["width"] = "max(100px, 200px,)"
    72 PASS testDiv.style['width'] is "999px"
    73 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    74 
    75 testDiv.style["width"] = "clamp(200px,300px)"
    76 PASS testDiv.style['width'] is "999px"
    77 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    78 
    79 testDiv.style["width"] = "clamp(200px,300px,)"
    80 PASS testDiv.style['width'] is "999px"
    81 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    82 
    83 testDiv.style["width"] = "clamp(200px,,300px)"
    84 PASS testDiv.style['width'] is "999px"
    85 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    86 
    87 testDiv.style["width"] = "clamp((),,300px)"
    88 PASS testDiv.style['width'] is "999px"
    89 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
    90 
    91 testDiv.style["width"] = "clamp(1px,2px,2px,4px)"
    92 PASS testDiv.style['width'] is "999px"
    93 PASS window.getComputedStyle(testDiv).getPropertyValue('width') is "999px"
     7element.style["width"] = "calc(100px)"
     8PASS element.style['width'] is "calc(100px)"
     9PASS getComputedStyle(element).getPropertyValue('width') is "100px"
     10
     11element.style["width"] = "max(100px + 200px)"
     12PASS element.style['width'] is "max(300px)"
     13PASS getComputedStyle(element).getPropertyValue('width') is "300px"
     14
     15element.style["width"] = "max(100px , 200px)"
     16PASS element.style['width'] is "max(200px)"
     17PASS getComputedStyle(element).getPropertyValue('width') is "200px"
     18
     19element.style["width"] = "max(100px,200px)"
     20PASS element.style['width'] is "max(200px)"
     21PASS getComputedStyle(element).getPropertyValue('width') is "200px"
     22
     23element.style["width"] = "clamp(100px,123px,200px)"
     24PASS element.style['width'] is "clamp(100px, 123px, 200px)"
     25PASS getComputedStyle(element).getPropertyValue('width') is "123px"
     26
     27element.style["width"] = "clamp(100px,300px,200px)"
     28PASS element.style['width'] is "clamp(100px, 300px, 200px)"
     29PASS getComputedStyle(element).getPropertyValue('width') is "200px"
     30
     31element.style["width"] = "clamp(200px,300px,100px)"
     32PASS element.style['width'] is "clamp(200px, 300px, 100px)"
     33PASS getComputedStyle(element).getPropertyValue('width') is "200px"
     34
     35element.style["width"] = "clamp((50px + 50px),40px,200px)"
     36PASS element.style['width'] is "clamp(100px, 40px, 200px)"
     37PASS getComputedStyle(element).getPropertyValue('width') is "100px"
     38
     39element.style["width"] = "clamp(50px + 50px,40px,200px)"
     40PASS element.style['width'] is "clamp(100px, 40px, 200px)"
     41PASS getComputedStyle(element).getPropertyValue('width') is "100px"
     42
     43element.style["width"] = "min(100px,0%)"
     44PASS element.style['width'] is "min(100px, 0%)"
     45PASS getComputedStyle(element).getPropertyValue('width') is "0px"
     46
     47element.style["width"] = "max(100px,0%)"
     48PASS element.style['width'] is "max(100px, 0%)"
     49PASS getComputedStyle(element).getPropertyValue('width') is "100px"
     50
     51element.style["width"] = "clamp(100px,0%,1%)"
     52PASS element.style['width'] is "clamp(100px, 0%, 1%)"
     53PASS getComputedStyle(element).getPropertyValue('width') is "100px"
     54
     55element.style["width"] = "calc(100px, 200px)"
     56PASS element.style['width'] is "999px"
     57PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     58
     59element.style["width"] = "calc(100px  200px)"
     60PASS element.style['width'] is "999px"
     61PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     62
     63element.style["width"] = "calc(100px ( 200px)"
     64PASS element.style['width'] is "999px"
     65PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     66
     67element.style["width"] = "min(100px 200px)"
     68PASS element.style['width'] is "999px"
     69PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     70
     71element.style["width"] = "max(100px 200px)"
     72PASS element.style['width'] is "999px"
     73PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     74
     75element.style["width"] = "max(100px,, 200px)"
     76PASS element.style['width'] is "999px"
     77PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     78
     79element.style["width"] = "max(100px, , 200px)"
     80PASS element.style['width'] is "999px"
     81PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     82
     83element.style["width"] = "max(100px, 200px,)"
     84PASS element.style['width'] is "999px"
     85PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     86
     87element.style["width"] = "clamp(200px,300px)"
     88PASS element.style['width'] is "999px"
     89PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     90
     91element.style["width"] = "clamp(200px,300px,)"
     92PASS element.style['width'] is "999px"
     93PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     94
     95element.style["width"] = "clamp(200px,,300px)"
     96PASS element.style['width'] is "999px"
     97PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     98
     99element.style["width"] = "clamp((),,300px)"
     100PASS element.style['width'] is "999px"
     101PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     102
     103element.style["width"] = "clamp(1px,2px,2px,4px)"
     104PASS element.style['width'] is "999px"
     105PASS getComputedStyle(element).getPropertyValue('width') is "999px"
     106
     107element.style["min-width"] = "calc(100px)"
     108PASS element.style['min-width'] is "calc(100px)"
     109PASS getComputedStyle(element).getPropertyValue('min-width') is "100px"
     110
     111element.style["min-width"] = "max(100px + 200px)"
     112PASS element.style['min-width'] is "max(300px)"
     113PASS getComputedStyle(element).getPropertyValue('min-width') is "300px"
     114
     115element.style["min-width"] = "max(100px , 200px)"
     116PASS element.style['min-width'] is "max(200px)"
     117PASS getComputedStyle(element).getPropertyValue('min-width') is "200px"
     118
     119element.style["min-width"] = "max(100px,200px)"
     120PASS element.style['min-width'] is "max(200px)"
     121PASS getComputedStyle(element).getPropertyValue('min-width') is "200px"
     122
     123element.style["min-width"] = "clamp(100px,123px,200px)"
     124PASS element.style['min-width'] is "clamp(100px, 123px, 200px)"
     125PASS getComputedStyle(element).getPropertyValue('min-width') is "123px"
     126
     127element.style["min-width"] = "clamp(100px,300px,200px)"
     128PASS element.style['min-width'] is "clamp(100px, 300px, 200px)"
     129PASS getComputedStyle(element).getPropertyValue('min-width') is "200px"
     130
     131element.style["min-width"] = "clamp(200px,300px,100px)"
     132PASS element.style['min-width'] is "clamp(200px, 300px, 100px)"
     133PASS getComputedStyle(element).getPropertyValue('min-width') is "200px"
     134
     135element.style["min-width"] = "clamp((50px + 50px),40px,200px)"
     136PASS element.style['min-width'] is "clamp(100px, 40px, 200px)"
     137PASS getComputedStyle(element).getPropertyValue('min-width') is "100px"
     138
     139element.style["min-width"] = "clamp(50px + 50px,40px,200px)"
     140PASS element.style['min-width'] is "clamp(100px, 40px, 200px)"
     141PASS getComputedStyle(element).getPropertyValue('min-width') is "100px"
     142
     143element.style["min-width"] = "min(100px,0%)"
     144PASS element.style['min-width'] is "min(100px, 0%)"
     145PASS getComputedStyle(element).getPropertyValue('min-width') is "min(100px, 0%)"
     146
     147element.style["min-width"] = "max(100px,0%)"
     148PASS element.style['min-width'] is "max(100px, 0%)"
     149PASS getComputedStyle(element).getPropertyValue('min-width') is "max(100px, 0%)"
     150
     151element.style["min-width"] = "clamp(100px,0%,1%)"
     152PASS element.style['min-width'] is "clamp(100px, 0%, 1%)"
     153PASS getComputedStyle(element).getPropertyValue('min-width') is "clamp(100px, 0%, 1%)"
     154
     155element.style["min-width"] = "calc(100px, 200px)"
     156PASS element.style['min-width'] is "999px"
     157PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     158
     159element.style["min-width"] = "calc(100px  200px)"
     160PASS element.style['min-width'] is "999px"
     161PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     162
     163element.style["min-width"] = "calc(100px ( 200px)"
     164PASS element.style['min-width'] is "999px"
     165PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     166
     167element.style["min-width"] = "min(100px 200px)"
     168PASS element.style['min-width'] is "999px"
     169PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     170
     171element.style["min-width"] = "max(100px 200px)"
     172PASS element.style['min-width'] is "999px"
     173PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     174
     175element.style["min-width"] = "max(100px,, 200px)"
     176PASS element.style['min-width'] is "999px"
     177PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     178
     179element.style["min-width"] = "max(100px, , 200px)"
     180PASS element.style['min-width'] is "999px"
     181PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     182
     183element.style["min-width"] = "max(100px, 200px,)"
     184PASS element.style['min-width'] is "999px"
     185PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     186
     187element.style["min-width"] = "clamp(200px,300px)"
     188PASS element.style['min-width'] is "999px"
     189PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     190
     191element.style["min-width"] = "clamp(200px,300px,)"
     192PASS element.style['min-width'] is "999px"
     193PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     194
     195element.style["min-width"] = "clamp(200px,,300px)"
     196PASS element.style['min-width'] is "999px"
     197PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     198
     199element.style["min-width"] = "clamp((),,300px)"
     200PASS element.style['min-width'] is "999px"
     201PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
     202
     203element.style["min-width"] = "clamp(1px,2px,2px,4px)"
     204PASS element.style['min-width'] is "999px"
     205PASS getComputedStyle(element).getPropertyValue('min-width') is "999px"
    94206PASS successfullyParsed is true
    95207
  • trunk/LayoutTests/fast/css/calc-parsing.html

    r253105 r276262  
    55        <div id="testDiv"></div>
    66        <script>
    7             description("Tests parsing of various valid and invalid calc expressions.");
     7            description("Tests parsing and re-serializing of various valid and invalid calc expressions.");
    88
    9             var testDiv = document.getElementById("testDiv");
     9            var element = document.getElementById("testDiv");
    1010           
    11             function testExpression(expression, specifiedValue, computedValue)
     11            function testProperty(propertyName)
    1212            {
    13                 debug('');
    14                 testDiv.style["width"] = '999px';
     13                function testExpression(expression, specifiedValue, computedValue)
     14                {
     15                    debug('');
     16                    element.style[propertyName] = '999px';
    1517
    16                 evalAndLog(`testDiv.style["width"] = "${expression}"`);
    17                 shouldBeEqualToString("testDiv.style['width']", `${specifiedValue}`);
    18                 shouldBeEqualToString("window.getComputedStyle(testDiv).getPropertyValue('width')", `${computedValue}`);
     18                    evalAndLog(`element.style["${propertyName}"] = "${expression}"`);
     19                    shouldBeEqualToString(`element.style['${propertyName}']`, `${specifiedValue}`);
     20                    shouldBeEqualToString(`getComputedStyle(element).getPropertyValue('${propertyName}')`, `${computedValue}`);
     21                }
     22
     23                // Valid expressions.
     24                testExpression('calc(100px)', 'calc(100px)', '100px');
     25                testExpression('max(100px + 200px)', 'max(300px)', '300px');
     26                testExpression('max(100px , 200px)', 'max(200px)', '200px');
     27                testExpression('max(100px,200px)', 'max(200px)', '200px');
     28                testExpression('clamp(100px,123px,200px)', 'clamp(100px, 123px, 200px)', '123px');
     29                testExpression('clamp(100px,300px,200px)', 'clamp(100px, 300px, 200px)', '200px');
     30                testExpression('clamp(200px,300px,100px)', 'clamp(200px, 300px, 100px)', '200px');
     31                testExpression('clamp((50px + 50px),40px,200px)', 'clamp(100px, 40px, 200px)', '100px');
     32                testExpression('clamp(50px + 50px,40px,200px)', 'clamp(100px, 40px, 200px)', '100px');
     33                testExpression('min(100px,0%)', 'min(100px, 0%)', propertyName == 'width' ? '0px' : "min(100px, 0%)");
     34                testExpression('max(100px,0%)', 'max(100px, 0%)', propertyName == 'width' ? '100px' : "max(100px, 0%)");
     35                testExpression('clamp(100px,0%,1%)', 'clamp(100px, 0%, 1%)', propertyName == 'width' ? '100px' : "clamp(100px, 0%, 1%)");
     36
     37                // Non-parsing expressions.
     38                testExpression('calc(100px, 200px)', '999px', '999px');
     39                testExpression('calc(100px  200px)', '999px', '999px');
     40                testExpression('calc(100px ( 200px)', '999px', '999px');
     41                testExpression('min(100px 200px)', '999px', '999px');
     42                testExpression('max(100px 200px)', '999px', '999px');
     43                testExpression('max(100px,, 200px)', '999px', '999px');
     44                testExpression('max(100px, , 200px)', '999px', '999px');
     45                testExpression('max(100px, 200px,)', '999px', '999px');
     46                testExpression('clamp(200px,300px)', '999px', '999px');
     47                testExpression('clamp(200px,300px,)', '999px', '999px');
     48                testExpression('clamp(200px,,300px)', '999px', '999px');
     49                testExpression('clamp((),,300px)', '999px', '999px');
     50                testExpression('clamp(1px,2px,2px,4px)', '999px', '999px');
    1951            }
    2052
    21             // Valid expressions.
    22             testExpression('calc(100px)', 'calc(100px)', '100px');
    23             testExpression('max(100px + 200px)', 'max(300px)', '300px');
    24             testExpression('max(100px , 200px)', 'max(200px)', '200px');
    25             testExpression('max(100px,200px)', 'max(200px)', '200px');
    26             testExpression('clamp(100px,123px,200px)', 'clamp(100px, 123px, 200px)', '123px');
    27             testExpression('clamp(100px,300px,200px)', 'clamp(100px, 300px, 200px)', '200px');
    28             testExpression('clamp(200px,300px,100px)', 'clamp(200px, 300px, 100px)', '200px');
    29             testExpression('clamp((50px + 50px),40px,200px)', 'clamp(100px, 40px, 200px)', '100px');
    30             testExpression('clamp(50px + 50px,40px,200px)', 'clamp(100px, 40px, 200px)', '100px');
    31 
    32             // Non-parsing expression.
    33             testExpression('calc(100px, 200px)', '999px', '999px');
    34             testExpression('calc(100px  200px)', '999px', '999px');
    35 
    36             testExpression('calc(100px ( 200px)', '999px', '999px');
    37 
    38             testExpression('min(100px 200px)', '999px', '999px');
    39             testExpression('max(100px 200px)', '999px', '999px');
    40             testExpression('max(100px,, 200px)', '999px', '999px');
    41             testExpression('max(100px, , 200px)', '999px', '999px');
    42             testExpression('max(100px, 200px,)', '999px', '999px');
    43 
    44             testExpression('clamp(200px,300px)', '999px', '999px');
    45             testExpression('clamp(200px,300px,)', '999px', '999px');
    46             testExpression('clamp(200px,,300px)', '999px', '999px');
    47             testExpression('clamp((),,300px)', '999px', '999px');
    48             testExpression('clamp(1px,2px,2px,4px)', '999px', '999px');
     53            testProperty("width");
     54            testProperty("min-width");
    4955        </script>
    5056        <script src="../../resources/js-test-post.js"></script>
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r276242 r276262  
     12021-04-19  Darin Adler  <darin@apple.com>
     2
     3        Nullptr crash in CSSCalcValue::category() via HTMLConverterCaches::floatPropertyValueForNode
     4        https://bugs.webkit.org/show_bug.cgi?id=221392
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/css-values/minmax-length-percent-serialize-expected.txt:
     9        Updated to reflect 8 tests passing that were failing before.
     10
    1112021-04-19  Youenn Fablet  <youenn@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-values/minmax-length-percent-serialize-expected.txt

    r267650 r276262  
    1616PASS 'max(1px + 1%)' as a used value should serialize as '2px'.
    1717PASS 'min(20px, 10%)' as a specified value should serialize as 'min(20px, 10%)'.
    18 FAIL 'min(20px, 10%)' as a computed value should serialize as 'min(20px, 10%)'. assert_not_equals: 'min(20px, 10%)' should be valid in text-indent. got disallowed value ""
     18PASS 'min(20px, 10%)' as a computed value should serialize as 'min(20px, 10%)'.
    1919PASS 'min(20px, 10%)' as a used value should serialize as '10px'.
    2020PASS 'min(1em, 10%)' as a specified value should serialize as 'min(1em, 10%)'.
    21 FAIL 'min(1em, 10%)' as a computed value should serialize as 'min(16px, 10%)'. assert_not_equals: 'min(1em, 10%)' should be valid in text-indent. got disallowed value ""
     21PASS 'min(1em, 10%)' as a computed value should serialize as 'min(16px, 10%)'.
    2222PASS 'min(1em, 10%)' as a used value should serialize as '10px'.
    2323PASS 'min(10%, 20px)' as a specified value should serialize as 'min(10%, 20px)'.
    24 FAIL 'min(10%, 20px)' as a computed value should serialize as 'min(10%, 20px)'. assert_not_equals: 'min(10%, 20px)' should be valid in text-indent. got disallowed value ""
     24PASS 'min(10%, 20px)' as a computed value should serialize as 'min(10%, 20px)'.
    2525PASS 'min(10%, 20px)' as a used value should serialize as '10px'.
    2626PASS 'min(10%, 1em)' as a specified value should serialize as 'min(10%, 1em)'.
    27 FAIL 'min(10%, 1em)' as a computed value should serialize as 'min(10%, 16px)'. assert_not_equals: 'min(10%, 1em)' should be valid in text-indent. got disallowed value ""
     27PASS 'min(10%, 1em)' as a computed value should serialize as 'min(10%, 16px)'.
    2828PASS 'min(10%, 1em)' as a used value should serialize as '10px'.
    2929PASS 'max(20px, 10%)' as a specified value should serialize as 'max(20px, 10%)'.
    30 FAIL 'max(20px, 10%)' as a computed value should serialize as 'max(20px, 10%)'. assert_not_equals: 'max(20px, 10%)' should be valid in text-indent. got disallowed value ""
     30PASS 'max(20px, 10%)' as a computed value should serialize as 'max(20px, 10%)'.
    3131PASS 'max(20px, 10%)' as a used value should serialize as '20px'.
    3232PASS 'max(1em, 10%)' as a specified value should serialize as 'max(1em, 10%)'.
    33 FAIL 'max(1em, 10%)' as a computed value should serialize as 'max(16px, 10%)'. assert_not_equals: 'max(1em, 10%)' should be valid in text-indent. got disallowed value ""
     33PASS 'max(1em, 10%)' as a computed value should serialize as 'max(16px, 10%)'.
    3434PASS 'max(1em, 10%)' as a used value should serialize as '16px'.
    3535PASS 'max(10%, 20px)' as a specified value should serialize as 'max(10%, 20px)'.
    36 FAIL 'max(10%, 20px)' as a computed value should serialize as 'max(10%, 20px)'. assert_not_equals: 'max(10%, 20px)' should be valid in text-indent. got disallowed value ""
     36PASS 'max(10%, 20px)' as a computed value should serialize as 'max(10%, 20px)'.
    3737PASS 'max(10%, 20px)' as a used value should serialize as '20px'.
    3838PASS 'max(10%, 1em)' as a specified value should serialize as 'max(10%, 1em)'.
    39 FAIL 'max(10%, 1em)' as a computed value should serialize as 'max(10%, 16px)'. assert_not_equals: 'max(10%, 1em)' should be valid in text-indent. got disallowed value ""
     39PASS 'max(10%, 1em)' as a computed value should serialize as 'max(10%, 16px)'.
    4040PASS 'max(10%, 1em)' as a used value should serialize as '16px'.
    4141PASS 'min(10% + 30px, 5em + 5%)' as a specified value should serialize as 'min(10% + 30px, 5% + 5em)'.
  • trunk/Source/WebCore/ChangeLog

    r276260 r276262  
     12021-04-19  Darin Adler  <darin@apple.com>
     2
     3        Nullptr crash in CSSCalcValue::category() via HTMLConverterCaches::floatPropertyValueForNode
     4        https://bugs.webkit.org/show_bug.cgi?id=221392
     5
     6        Reviewed by Simon Fraser.
     7
     8        * css/CSSCalculationValue.cpp:
     9        (WebCore::CSSCalcOperationNode::createCalcExpression const): Pass in a destination category
     10        when creating a CalcExpressionOperation.
     11        (WebCore::createCSS): Pass the destination category from the CalcExpressionOperation when
     12        creating a CSSCalcOperationNode.
     13
     14        * css/CSSCalculationValue.h: Moved the CalculationCategory enumeration from here to
     15        CalculationValue.h.
     16
     17        * platform/CalculationValue.cpp:
     18        (WebCore::operator==): Include destination category when comparing.
     19
     20        * platform/CalculationValue.h: Moved CalculationCategory here. Added a destination
     21        category constructor argument, data members, and getter function to the
     22        CalcExpressionOperation class.
     23
    1242021-04-19  Antti Koivisto  <antti@apple.com>
    225
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r276052 r276262  
    13681368        nodes.uncheckedAppend(WTFMove(node));
    13691369    }
    1370     return makeUnique<CalcExpressionOperation>(WTFMove(nodes), m_operator);
     1370
     1371    // Reverse the operation we did when creating this node, recovering a suitable destination category for otherwise-ambiguous min/max/clamp nodes.
     1372    // Note that this category is really only good enough for that purpose and is not accurate for other node types; we could use a boolean instead.
     1373    auto destinationCategory = CalculationCategory::Other;
     1374    if (category() == CalculationCategory::PercentLength)
     1375        destinationCategory = CalculationCategory::Length;
     1376    else if (category() == CalculationCategory::PercentNumber)
     1377        destinationCategory = CalculationCategory::Number;
     1378
     1379    return makeUnique<CalcExpressionOperation>(WTFMove(nodes), m_operator, destinationCategory);
    13711380}
    13721381
    … …  
    20372046            if (children.isEmpty())
    20382047                return nullptr;
    2039             return CSSCalcOperationNode::createMinOrMaxOrClamp(op, WTFMove(children), CalculationCategory::Other);
     2048            return CSSCalcOperationNode::createMinOrMaxOrClamp(op, WTFMove(children), operationNode.destinationCategory());
    20402049        }
    20412050        }
  • trunk/Source/WebCore/css/CSSCalculationValue.h

    r253079 r276262  
    4444class CSSToLengthConversionData;
    4545class RenderStyle;
    46 
    47 // FIXME: Unify with CSSPrimitiveValue::UnitCategory.
    48 enum class CalculationCategory : uint8_t {
    49     Number = 0,
    50     Length,
    51     Percent,
    52     PercentNumber,
    53     PercentLength,
    54     Angle,
    55     Time,
    56     Frequency,
    57     // TODO:
    58     // Flex,
    59     // Resolution
    60     Other
    61 };
    6246
    6347class CSSCalcExpressionNode : public RefCounted<CSSCalcExpressionNode> {
  • trunk/Source/WebCore/platform/CalculationValue.cpp

    r253105 r276262  
    181181bool operator==(const CalcExpressionOperation& a, const CalcExpressionOperation& b)
    182182{
    183     if (a.getOperator() != b.getOperator())
     183    if (a.getOperator() != b.getOperator() || a.destinationCategory() != b.destinationCategory())
    184184        return false;
    185     // Maybe Vectors of unique_ptrs should always do deep compare?
     185    // FIXME: Would be nice to have a helper function for doing a deep compare on a vector of pointers.
    186186    if (a.children().size() != b.children().size())
    187187        return false;
  • trunk/Source/WebCore/platform/CalculationValue.h

    r253105 r276262  
    4343namespace WebCore {
    4444
     45// FIXME: Find a way to unify this with CSSPrimitiveValue::UnitCategory?
     46enum class CalculationCategory : uint8_t {
     47    Number,
     48    Length,
     49    Percent,
     50    PercentNumber,
     51    PercentLength,
     52    Angle,
     53    Time,
     54    Frequency,
     55    Other
     56};
     57
    4558// Don't change these values; parsing uses them.
    4659enum class CalcOperator : uint8_t {
    … …  
    152165class CalcExpressionOperation final : public CalcExpressionNode {
    153166public:
    154     CalcExpressionOperation(Vector<std::unique_ptr<CalcExpressionNode>>&& children, CalcOperator);
     167    CalcExpressionOperation(Vector<std::unique_ptr<CalcExpressionNode>>&& children, CalcOperator, CalculationCategory destinationCategory = CalculationCategory::Other);
    155168
    156169    CalcOperator getOperator() const { return m_operator; }
     170    CalculationCategory destinationCategory() const { return m_destinationCategory; }
    157171
    158172    const Vector<std::unique_ptr<CalcExpressionNode>>& children() const { return m_children; }
    … …  
    165179    Vector<std::unique_ptr<CalcExpressionNode>> m_children;
    166180    CalcOperator m_operator;
     181    CalculationCategory m_destinationCategory { CalculationCategory::Other };
    167182};
    168183
    … …  
    238253}
    239254
    240 inline CalcExpressionOperation::CalcExpressionOperation(Vector<std::unique_ptr<CalcExpressionNode>>&& children, CalcOperator op)
     255inline CalcExpressionOperation::CalcExpressionOperation(Vector<std::unique_ptr<CalcExpressionNode>>&& children, CalcOperator op, CalculationCategory destinationCategory)
    241256    : CalcExpressionNode(CalcExpressionNodeType::Operation)
    242257    , m_children(WTFMove(children))
    243258    , m_operator(op)
     259    , m_destinationCategory(destinationCategory)
    244260{
    245261}
Note: See TracChangeset for help on using the changeset viewer.