Changeset 214507 in webkit


Ignore:
Timestamp:
Mar 28, 2017 4:53:28 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

Ranges for variation font properties are not enforced
https://bugs.webkit.org/show_bug.cgi?id=169979

Reviewed by David Hyatt.

Source/WebCore:

The spec specifies that:

  • Font weights less than or equal to 0, or greater than or equal to 1000 are parse errors
  • Font stretch values less than or equal to 0% are parse errors
  • Font style values less than or equal to -90deg or greater than or equal to 90deg are parse errors

Test: fast/text/variations/out-of-bounds-selection-properties.html

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeFontWeightRange):
(WebCore::fontStretchIsWithinRange):
(WebCore::consumeFontStretch):
(WebCore::consumeFontStretchRange):
(WebCore::fontStyleIsWithinRange):
(WebCore::consumeFontStyle):
(WebCore::consumeFontStyleRange):

LayoutTests:

  • fast/text/font-selection-font-face-parse-expected.txt:
  • fast/text/font-selection-font-face-parse.html:
  • fast/text/font-selection-font-loading-api-parse-expected.txt:
  • fast/text/font-selection-font-loading-api-parse.html:
  • fast/text/font-style-parse-expected.txt:
  • fast/text/font-style-parse.html:
  • fast/text/variations/font-loading-api-parse-ranges-expected.txt:
  • fast/text/variations/font-loading-api-parse-ranges.html:
  • fast/text/variations/out-of-bounds-selection-properties-expected.txt: Added.
  • fast/text/variations/out-of-bounds-selection-properties.html: Added.
  • platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214506 r214507  
     12017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Ranges for variation font properties are not enforced
     4        https://bugs.webkit.org/show_bug.cgi?id=169979
     5
     6        Reviewed by David Hyatt.
     7
     8        * fast/text/font-selection-font-face-parse-expected.txt:
     9        * fast/text/font-selection-font-face-parse.html:
     10        * fast/text/font-selection-font-loading-api-parse-expected.txt:
     11        * fast/text/font-selection-font-loading-api-parse.html:
     12        * fast/text/font-style-parse-expected.txt:
     13        * fast/text/font-style-parse.html:
     14        * fast/text/variations/font-loading-api-parse-ranges-expected.txt:
     15        * fast/text/variations/font-loading-api-parse-ranges.html:
     16        * fast/text/variations/out-of-bounds-selection-properties-expected.txt: Added.
     17        * fast/text/variations/out-of-bounds-selection-properties.html: Added.
     18        * platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
     19
    1202017-03-28  Andy Estes  <aestes@apple.com>
    221
  • trunk/LayoutTests/fast/text/font-selection-font-face-parse-expected.txt

    r214419 r214507  
    2626PASS weightTestSheet.cssRules[25].style.fontWeight is ""
    2727PASS weightTestSheet.cssRules[26].style.fontWeight is "1 2"
    28 PASS weightTestSheet.cssRules[27].style.fontWeight is "-2 -1"
     28PASS weightTestSheet.cssRules[27].style.fontWeight is ""
    2929PASS weightTestSheet.cssRules[28].style.fontWeight is ""
    3030PASS weightTestSheet.cssRules[29].style.fontWeight is "7 8"
     
    6464PASS stretchTestSheet.cssRules[32].style.fontStretch is ""
    6565PASS stretchTestSheet.cssRules[33].style.fontStretch is "1% 2%"
    66 PASS stretchTestSheet.cssRules[34].style.fontStretch is "-2% -1%"
     66PASS stretchTestSheet.cssRules[34].style.fontStretch is ""
    6767PASS stretchTestSheet.cssRules[35].style.fontStretch is ""
    6868PASS stretchTestSheet.cssRules[36].style.fontStretch is ""
     
    7373PASS stretchTestSheet.cssRules[41].style.fontStretch is "2% calc(7%)"
    7474PASS styleTestSheet.cssRules[0].style.fontStyle is "oblique 1deg"
    75 PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 200grad"
    76 PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 6.28318rad"
    77 PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 4turn"
     75PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 20grad"
     76PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 0.28318rad"
     77PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 0.04turn"
    7878PASS styleTestSheet.cssRules[4].style.fontStyle is ""
    7979PASS styleTestSheet.cssRules[5].style.fontStyle is ""
     
    8484PASS styleTestSheet.cssRules[10].style.fontStyle is ""
    8585PASS styleTestSheet.cssRules[11].style.fontStyle is ""
    86 PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(1441deg)"
     86PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(15.4deg)"
    8787PASS styleTestSheet.cssRules[13].style.fontStyle is ""
    8888PASS styleTestSheet.cssRules[14].style.fontStyle is ""
     
    9696PASS styleTestSheet.cssRules[22].style.fontStyle is ""
    9797PASS styleTestSheet.cssRules[23].style.fontStyle is ""
    98 PASS styleTestSheet.cssRules[24].style.fontStyle is "oblique 100deg 200deg"
    99 PASS styleTestSheet.cssRules[25].style.fontStyle is "oblique 100deg 200deg"
     98PASS styleTestSheet.cssRules[24].style.fontStyle is "oblique 10deg 20deg"
     99PASS styleTestSheet.cssRules[25].style.fontStyle is "oblique 10deg 20deg"
    100100PASS styleTestSheet.cssRules[26].style.fontStyle is ""
    101101PASS styleTestSheet.cssRules[27].style.fontStyle is ""
     
    109109PASS styleTestSheet.cssRules[35].style.fontStyle is ""
    110110PASS styleTestSheet.cssRules[36].style.fontStyle is ""
    111 PASS styleTestSheet.cssRules[37].style.fontStyle is "oblique 2deg 1turn"
     111PASS styleTestSheet.cssRules[37].style.fontStyle is "oblique 2deg 4grad"
    112112PASS styleTestSheet.cssRules[38].style.fontStyle is ""
    113113PASS styleTestSheet.cssRules[39].style.fontStyle is ""
  • trunk/LayoutTests/fast/text/font-selection-font-face-parse.html

    r214419 r214507  
    232232}
    233233@font-face {
    234     font-style: oblique 200grad;
    235 }
    236 @font-face {
    237     font-style: oblique 6.28318rad;
    238 }
    239 @font-face {
    240     font-style: oblique 4turn;
     234    font-style: oblique 20grad;
     235}
     236@font-face {
     237    font-style: oblique 0.28318rad;
     238}
     239@font-face {
     240    font-style: oblique 0.04turn;
    241241}
    242242@font-face {
     
    265265}
    266266@font-face {
    267     font-style: oblique calc(4turn + 1deg);
    268 }
    269 @font-face {
    270     font-style: oblique 100 200;
    271 }
    272 @font-face {
    273     font-style: oblique 100  200;
    274 }
    275 @font-face {
    276     font-style: oblique a 100 200;
    277 }
    278 @font-face {
    279     font-style: oblique 100 200 a;
    280 }
    281 @font-face {
    282     font-style: oblique 100 a 200;
    283 }
    284 @font-face {
    285     font-style: oblique 100 a200;
    286 }
    287 @font-face {
    288     font-style: oblique 100a 200;
    289 }
    290 @font-face {
    291     font-style: oblique 100  a200;
     267    font-style: oblique calc(0.04turn + 1deg);
     268}
     269@font-face {
     270    font-style: oblique 10 20;
     271}
     272@font-face {
     273    font-style: oblique 10  20;
     274}
     275@font-face {
     276    font-style: oblique a 10 20;
     277}
     278@font-face {
     279    font-style: oblique 10 20 a;
     280}
     281@font-face {
     282    font-style: oblique 10 a 20;
     283}
     284@font-face {
     285    font-style: oblique 10 a20;
     286}
     287@font-face {
     288    font-style: oblique 10a 20;
     289}
     290@font-face {
     291    font-style: oblique 10  a20;
    292292}
    293293@font-face {
     
    301301}
    302302@font-face {
    303     font-style: oblique 100deg 200deg;
    304 }
    305 @font-face {
    306     font-style: oblique 100deg   200deg;
    307 }
    308 @font-face {
    309     font-style: oblique a 100deg 200deg;
    310 }
    311 @font-face {
    312     font-style: oblique 100deg 200deg a;
    313 }
    314 @font-face {
    315     font-style: oblique 100deg a 200deg;
    316 }
    317 @font-face {
    318     font-style: oblique 100deg a200deg;
    319 }
    320 @font-face {
    321     font-style: oblique 100dega 200deg;
    322 }
    323 @font-face {
    324     font-style: oblique 100deg  a200deg;
     303    font-style: oblique 10deg 20deg;
     304}
     305@font-face {
     306    font-style: oblique 10deg   20deg;
     307}
     308@font-face {
     309    font-style: oblique a 10deg 20deg;
     310}
     311@font-face {
     312    font-style: oblique 10deg 20deg a;
     313}
     314@font-face {
     315    font-style: oblique 10deg a 20deg;
     316}
     317@font-face {
     318    font-style: oblique 10deg a20deg;
     319}
     320@font-face {
     321    font-style: oblique 10dega 20deg;
     322}
     323@font-face {
     324    font-style: oblique 10deg  a20deg;
    325325}
    326326@font-face {
     
    340340}
    341341@font-face {
    342     font-style: oblique 2deg 1turn;
     342    font-style: oblique 2deg 4grad;
    343343}
    344344@font-face {
     
    386386shouldBeEqualToString("weightTestSheet.cssRules[25].style.fontWeight", "");
    387387shouldBeEqualToString("weightTestSheet.cssRules[26].style.fontWeight", "1 2");
    388 shouldBeEqualToString("weightTestSheet.cssRules[27].style.fontWeight", "-2 -1");
     388shouldBeEqualToString("weightTestSheet.cssRules[27].style.fontWeight", "");
    389389shouldBeEqualToString("weightTestSheet.cssRules[28].style.fontWeight", "");
    390390shouldBeEqualToString("weightTestSheet.cssRules[29].style.fontWeight", "7 8");
     
    426426shouldBeEqualToString("stretchTestSheet.cssRules[32].style.fontStretch", "");
    427427shouldBeEqualToString("stretchTestSheet.cssRules[33].style.fontStretch", "1% 2%");
    428 shouldBeEqualToString("stretchTestSheet.cssRules[34].style.fontStretch", "-2% -1%");
     428shouldBeEqualToString("stretchTestSheet.cssRules[34].style.fontStretch", "");
    429429shouldBeEqualToString("stretchTestSheet.cssRules[35].style.fontStretch", "");
    430430shouldBeEqualToString("stretchTestSheet.cssRules[36].style.fontStretch", "");
     
    437437var styleTestSheet = document.getElementById("styleTest").sheet;
    438438shouldBeEqualToString("styleTestSheet.cssRules[0].style.fontStyle", "oblique 1deg");
    439 shouldBeEqualToString("styleTestSheet.cssRules[1].style.fontStyle", "oblique 200grad");
    440 shouldBeEqualToString("styleTestSheet.cssRules[2].style.fontStyle", "oblique 6.28318rad");
    441 shouldBeEqualToString("styleTestSheet.cssRules[3].style.fontStyle", "oblique 4turn");
     439shouldBeEqualToString("styleTestSheet.cssRules[1].style.fontStyle", "oblique 20grad");
     440shouldBeEqualToString("styleTestSheet.cssRules[2].style.fontStyle", "oblique 0.28318rad");
     441shouldBeEqualToString("styleTestSheet.cssRules[3].style.fontStyle", "oblique 0.04turn");
    442442shouldBeEqualToString("styleTestSheet.cssRules[4].style.fontStyle", "");
    443443shouldBeEqualToString("styleTestSheet.cssRules[5].style.fontStyle", "");
     
    448448shouldBeEqualToString("styleTestSheet.cssRules[10].style.fontStyle", "");
    449449shouldBeEqualToString("styleTestSheet.cssRules[11].style.fontStyle", "");
    450 shouldBeEqualToString("styleTestSheet.cssRules[12].style.fontStyle", "oblique calc(1441deg)");
     450shouldBeEqualToString("styleTestSheet.cssRules[12].style.fontStyle", "oblique calc(15.4deg)");
    451451
    452452shouldBeEqualToString("styleTestSheet.cssRules[13].style.fontStyle", "");
     
    461461shouldBeEqualToString("styleTestSheet.cssRules[22].style.fontStyle", "");
    462462shouldBeEqualToString("styleTestSheet.cssRules[23].style.fontStyle", "");
    463 shouldBeEqualToString("styleTestSheet.cssRules[24].style.fontStyle", "oblique 100deg 200deg");
    464 shouldBeEqualToString("styleTestSheet.cssRules[25].style.fontStyle", "oblique 100deg 200deg");
     463shouldBeEqualToString("styleTestSheet.cssRules[24].style.fontStyle", "oblique 10deg 20deg");
     464shouldBeEqualToString("styleTestSheet.cssRules[25].style.fontStyle", "oblique 10deg 20deg");
    465465shouldBeEqualToString("styleTestSheet.cssRules[26].style.fontStyle", "");
    466466shouldBeEqualToString("styleTestSheet.cssRules[27].style.fontStyle", "");
     
    474474shouldBeEqualToString("styleTestSheet.cssRules[35].style.fontStyle", "");
    475475shouldBeEqualToString("styleTestSheet.cssRules[36].style.fontStyle", "");
    476 shouldBeEqualToString("styleTestSheet.cssRules[37].style.fontStyle", "oblique 2deg 1turn");
     476shouldBeEqualToString("styleTestSheet.cssRules[37].style.fontStyle", "oblique 2deg 4grad");
    477477shouldBeEqualToString("styleTestSheet.cssRules[38].style.fontStyle", "");
    478478shouldBeEqualToString("styleTestSheet.cssRules[39].style.fontStyle", "");
  • trunk/LayoutTests/fast/text/font-selection-font-loading-api-parse-expected.txt

    r214419 r214507  
    3232PASS setFontFaceStretch(fontFace, 'calc(3% + 4%)') is "7%"
    3333PASS setFontFaceStyle(fontFace, 'oblique 1deg') is "oblique 1deg"
    34 PASS setFontFaceStyle(fontFace, 'oblique 200grad') is "oblique 180deg"
    35 PASS setFontFaceStyle(fontFace, 'oblique 6.28318rad') is "oblique 359.75deg"
    36 PASS setFontFaceStyle(fontFace, 'oblique 4turn') is "oblique 1440deg"
     34PASS setFontFaceStyle(fontFace, 'oblique 20grad') is "oblique 18deg"
     35PASS setFontFaceStyle(fontFace, 'oblique 0.28318rad') is "oblique 16deg"
     36PASS setFontFaceStyle(fontFace, 'oblique 0.04turn') is "oblique 14.25deg"
    3737PASS setFontFaceStyle(fontFace, 'oblique 5') threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    3838PASS setFontFaceStyle(fontFace, 'oblique 20') threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
     
    4343PASS setFontFaceStyle(fontFace, 'initial') threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    4444PASS setFontFaceStyle(fontFace, 'oblique calc(3 + 4)') threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    45 PASS setFontFaceStyle(fontFace, 'oblique calc(4turn + 1deg)') is "oblique 1441deg"
     45PASS setFontFaceStyle(fontFace, 'oblique calc(0.04turn + 1deg)') is "oblique 15.25deg"
    4646PASS successfullyParsed is true
    4747
  • trunk/LayoutTests/fast/text/font-selection-font-loading-api-parse.html

    r214419 r214507  
    5757
    5858shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 1deg')", "oblique 1deg");
    59 shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 200grad')", "oblique 180deg");
    60 shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 6.28318rad')", "oblique 359.75deg");
    61 shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 4turn')", "oblique 1440deg");
     59shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 20grad')", "oblique 18deg");
     60shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 0.28318rad')", "oblique 16deg");
     61shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique 0.04turn')", "oblique 14.25deg");
    6262shouldThrow("setFontFaceStyle(fontFace, 'oblique 5')");
    6363shouldThrow("setFontFaceStyle(fontFace, 'oblique 20')");
     
    6868shouldThrow("setFontFaceStyle(fontFace, 'initial')");
    6969shouldThrow("setFontFaceStyle(fontFace, 'oblique calc(3 + 4)')");
    70 shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique calc(4turn + 1deg)')", "oblique 1441deg");
     70shouldBeEqualToString("setFontFaceStyle(fontFace, 'oblique calc(0.04turn + 1deg)')", "oblique 15.25deg");
    7171</script>
    7272<script src="../../resources/js-test-post.js"></script>
  • trunk/LayoutTests/fast/text/font-style-parse-expected.txt

    r214419 r214507  
    11PASS window.getComputedStyle(document.getElementById('test1')).fontStyle is "normal"
    22PASS window.getComputedStyle(document.getElementById('test2')).fontStyle is "oblique 1deg"
    3 PASS window.getComputedStyle(document.getElementById('test3')).fontStyle is "oblique 180deg"
    4 PASS window.getComputedStyle(document.getElementById('test4')).fontStyle is "oblique 359.75deg"
    5 PASS window.getComputedStyle(document.getElementById('test5')).fontStyle is "oblique 1440deg"
     3PASS window.getComputedStyle(document.getElementById('test3')).fontStyle is "oblique 18deg"
     4PASS window.getComputedStyle(document.getElementById('test4')).fontStyle is "oblique 16deg"
     5PASS window.getComputedStyle(document.getElementById('test5')).fontStyle is "oblique 14.25deg"
    66PASS window.getComputedStyle(document.getElementById('test6')).fontStyle is "normal"
    77PASS window.getComputedStyle(document.getElementById('test7')).fontStyle is "normal"
     
    1212PASS window.getComputedStyle(document.getElementById('test12')).fontStyle is "normal"
    1313PASS window.getComputedStyle(document.getElementById('test13')).fontStyle is "normal"
    14 PASS window.getComputedStyle(document.getElementById('test14')).fontStyle is "oblique 1441deg"
     14PASS window.getComputedStyle(document.getElementById('test14')).fontStyle is "oblique 15.25deg"
    1515PASS window.getComputedStyle(document.getElementById('test15')).fontStyle is "italic"
    1616PASS window.getComputedStyle(document.getElementById('test16')).fontStyle is "italic"
  • trunk/LayoutTests/fast/text/font-style-parse.html

    r214419 r214507  
    88<div id="test1"></div>
    99<div id="test2" style="font-style: oblique 1deg;"></div>
    10 <div id="test3" style="font-style: oblique 200grad;"></div>
    11 <div id="test4" style="font-style: oblique 6.28318rad;"></div>
    12 <div id="test5" style="font-style: oblique 4turn;"></div>
     10<div id="test3" style="font-style: oblique 20grad;"></div>
     11<div id="test4" style="font-style: oblique 0.28318rad;"></div>
     12<div id="test5" style="font-style: oblique 0.04turn;"></div>
    1313<div id="test6" style="font-style: oblique 5;"></div>
    1414<div id="test7" style="font-style: oblique 20;"></div>
     
    1919<div id="test12" style="font-style: initial;"></div>
    2020<div id="test13" style="font-style: oblique calc(3 + 4);"></div>
    21 <div id="test14" style="font-style: oblique calc(4turn + 1deg);"></div>
     21<div id="test14" style="font-style: oblique calc(0.04turn + 1deg);"></div>
    2222<div id="test15" style="font: 100 italic 48px/49px 'Helvetica Neue';"></div>
    2323<div id="test16" style="font: italic 100 48px/49px 'Helvetica Neue';"></div>
     
    3131shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).fontStyle", "normal");
    3232shouldBeEqualToString("window.getComputedStyle(document.getElementById('test2')).fontStyle", "oblique 1deg");
    33 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test3')).fontStyle", "oblique 180deg");
    34 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test4')).fontStyle", "oblique 359.75deg");
    35 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test5')).fontStyle", "oblique 1440deg");
     33shouldBeEqualToString("window.getComputedStyle(document.getElementById('test3')).fontStyle", "oblique 18deg");
     34shouldBeEqualToString("window.getComputedStyle(document.getElementById('test4')).fontStyle", "oblique 16deg");
     35shouldBeEqualToString("window.getComputedStyle(document.getElementById('test5')).fontStyle", "oblique 14.25deg");
    3636shouldBeEqualToString("window.getComputedStyle(document.getElementById('test6')).fontStyle", "normal");
    3737shouldBeEqualToString("window.getComputedStyle(document.getElementById('test7')).fontStyle", "normal");
     
    4242shouldBeEqualToString("window.getComputedStyle(document.getElementById('test12')).fontStyle", "normal");
    4343shouldBeEqualToString("window.getComputedStyle(document.getElementById('test13')).fontStyle", "normal");
    44 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test14')).fontStyle", "oblique 1441deg");
     44shouldBeEqualToString("window.getComputedStyle(document.getElementById('test14')).fontStyle", "oblique 15.25deg");
    4545shouldBeEqualToString("window.getComputedStyle(document.getElementById('test15')).fontStyle", "italic");
    4646shouldBeEqualToString("window.getComputedStyle(document.getElementById('test16')).fontStyle", "italic");
  • trunk/LayoutTests/fast/text/variations/font-loading-api-parse-ranges-expected.txt

    r214433 r214507  
    88PASS (new FontFace('asdf', 'url(notreal)', { weight: '50 150' })).weight is "50 150"
    99PASS (new FontFace('asdf', 'url(notreal)', { weight: '2 3' })).weight is "2 3"
    10 PASS (new FontFace('asdf', 'url(notreal)', { weight: '-3 -2' })).weight is "-3 -2"
     10PASS (new FontFace('asdf', 'url(notreal)', { weight: '-3 -2' })).weight threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    1111PASS (new FontFace('asdf', 'url(notreal)', { weight: '5 4' })).weight threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    1212PASS (new FontFace('asdf', 'url(notreal)', { weight: '100 200 3' })).weight threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    1313PASS (new FontFace('asdf', 'url(notreal)', { weight: '100 200 a' })).weight threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    14 PASS (new FontFace('asdf', 'url(notreal)', { weight: '-3' })).weight is "-3"
     14PASS (new FontFace('asdf', 'url(notreal)', { weight: '-3' })).weight threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    1515PASS (new FontFace('asdf', 'url(notreal)', { stretch: 'semi-expanded expanded' })).stretch threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    1616PASS (new FontFace('asdf', 'url(notreal)', { stretch: '100% 200%' })).stretch is "100% 200%"
     
    2323PASS (new FontFace('asdf', 'url(notreal)', { stretch: '50% 60%' })).stretch is "50% 60%"
    2424PASS (new FontFace('asdf', 'url(notreal)', { stretch: '2% 3%' })).stretch is "2% 3%"
    25 PASS (new FontFace('asdf', 'url(notreal)', { stretch: '-3% -2%' })).stretch is "-3% -2%"
     25PASS (new FontFace('asdf', 'url(notreal)', { stretch: '-3% -2%' })).stretch threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    2626PASS (new FontFace('asdf', 'url(notreal)', { stretch: '5% 4%' })).stretch threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    2727PASS (new FontFace('asdf', 'url(notreal)', { stretch: '100% 200% 3%' })).stretch threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    2828PASS (new FontFace('asdf', 'url(notreal)', { stretch: '100% 200% a' })).stretch threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    29 PASS (new FontFace('asdf', 'url(notreal)', { stretch: '-3%' })).stretch is "-3%"
     29PASS (new FontFace('asdf', 'url(notreal)', { stretch: '-3%' })).stretch threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
    3030PASS (new FontFace('asdf', 'url(notreal)', { style: 'oblique 10deg 20deg' })).style is "oblique 10deg 20deg"
    3131PASS (new FontFace('asdf', 'url(notreal)', { style: 'oblique a10deg 20deg' })).style threw exception SyntaxError (DOM Exception 12): The string did not match the expected pattern..
  • trunk/LayoutTests/fast/text/variations/font-loading-api-parse-ranges.html

    r214433 r214507  
    1515shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { weight: '50 150' })).weight", "50 150");
    1616shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { weight: '2 3' })).weight", "2 3");
    17 shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { weight: '-3 -2' })).weight", "-3 -2");
     17shouldThrow("(new FontFace('asdf', 'url(notreal)', { weight: '-3 -2' })).weight");
    1818shouldThrow("(new FontFace('asdf', 'url(notreal)', { weight: '5 4' })).weight");
    1919shouldThrow("(new FontFace('asdf', 'url(notreal)', { weight: '100 200 3' })).weight");
    2020shouldThrow("(new FontFace('asdf', 'url(notreal)', { weight: '100 200 a' })).weight");
    21 shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { weight: '-3' })).weight", "-3");
     21shouldThrow("(new FontFace('asdf', 'url(notreal)', { weight: '-3' })).weight");
    2222
    2323shouldThrow("(new FontFace('asdf', 'url(notreal)', { stretch: 'semi-expanded expanded' })).stretch");
     
    3131shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { stretch: '50% 60%' })).stretch", "50% 60%");
    3232shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { stretch: '2% 3%' })).stretch", "2% 3%");
    33 shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { stretch: '-3% -2%' })).stretch", "-3% -2%");
     33shouldThrow("(new FontFace('asdf', 'url(notreal)', { stretch: '-3% -2%' })).stretch");
    3434shouldThrow("(new FontFace('asdf', 'url(notreal)', { stretch: '5% 4%' })).stretch");
    3535shouldThrow("(new FontFace('asdf', 'url(notreal)', { stretch: '100% 200% 3%' })).stretch");
    3636shouldThrow("(new FontFace('asdf', 'url(notreal)', { stretch: '100% 200% a' })).stretch");
    37 shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { stretch: '-3%' })).stretch", "-3%");
     37shouldThrow("(new FontFace('asdf', 'url(notreal)', { stretch: '-3%' })).stretch");
    3838
    3939shouldBeEqualToString("(new FontFace('asdf', 'url(notreal)', { style: 'oblique 10deg 20deg' })).style", "oblique 10deg 20deg");
  • trunk/LayoutTests/platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt

    r214419 r214507  
    2626PASS weightTestSheet.cssRules[25].style.fontWeight is ""
    2727FAIL weightTestSheet.cssRules[26].style.fontWeight should be 1 2. Was .
    28 FAIL weightTestSheet.cssRules[27].style.fontWeight should be -2 -1. Was .
     28PASS weightTestSheet.cssRules[27].style.fontWeight is ""
    2929PASS weightTestSheet.cssRules[28].style.fontWeight is ""
    3030FAIL weightTestSheet.cssRules[29].style.fontWeight should be 7 8. Was .
     
    6464PASS stretchTestSheet.cssRules[32].style.fontStretch is ""
    6565FAIL stretchTestSheet.cssRules[33].style.fontStretch should be 1% 2%. Was .
    66 FAIL stretchTestSheet.cssRules[34].style.fontStretch should be -2% -1%. Was .
     66PASS stretchTestSheet.cssRules[34].style.fontStretch is ""
    6767PASS stretchTestSheet.cssRules[35].style.fontStretch is ""
    6868PASS stretchTestSheet.cssRules[36].style.fontStretch is ""
     
    7373FAIL stretchTestSheet.cssRules[41].style.fontStretch should be 2% calc(7%). Was .
    7474PASS styleTestSheet.cssRules[0].style.fontStyle is "oblique 1deg"
    75 PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 200grad"
    76 PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 6.28318rad"
    77 PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 4turn"
     75PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 20grad"
     76PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 0.28318rad"
     77PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 0.04turn"
    7878PASS styleTestSheet.cssRules[4].style.fontStyle is ""
    7979PASS styleTestSheet.cssRules[5].style.fontStyle is ""
     
    8484PASS styleTestSheet.cssRules[10].style.fontStyle is ""
    8585PASS styleTestSheet.cssRules[11].style.fontStyle is ""
    86 PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(1441deg)"
     86PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(15.4deg)"
    8787PASS styleTestSheet.cssRules[13].style.fontStyle is ""
    8888PASS styleTestSheet.cssRules[14].style.fontStyle is ""
     
    9696PASS styleTestSheet.cssRules[22].style.fontStyle is ""
    9797PASS styleTestSheet.cssRules[23].style.fontStyle is ""
    98 FAIL styleTestSheet.cssRules[24].style.fontStyle should be oblique 100deg 200deg. Was .
    99 FAIL styleTestSheet.cssRules[25].style.fontStyle should be oblique 100deg 200deg. Was .
     98FAIL styleTestSheet.cssRules[24].style.fontStyle should be oblique 10deg 20deg. Was .
     99FAIL styleTestSheet.cssRules[25].style.fontStyle should be oblique 10deg 20deg. Was .
    100100PASS styleTestSheet.cssRules[26].style.fontStyle is ""
    101101PASS styleTestSheet.cssRules[27].style.fontStyle is ""
     
    109109PASS styleTestSheet.cssRules[35].style.fontStyle is ""
    110110PASS styleTestSheet.cssRules[36].style.fontStyle is ""
    111 FAIL styleTestSheet.cssRules[37].style.fontStyle should be oblique 2deg 1turn. Was .
     111FAIL styleTestSheet.cssRules[37].style.fontStyle should be oblique 2deg 4grad. Was .
    112112PASS styleTestSheet.cssRules[38].style.fontStyle is ""
    113113PASS styleTestSheet.cssRules[39].style.fontStyle is ""
  • trunk/Source/WebCore/ChangeLog

    r214506 r214507  
     12017-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Ranges for variation font properties are not enforced
     4        https://bugs.webkit.org/show_bug.cgi?id=169979
     5
     6        Reviewed by David Hyatt.
     7
     8        The spec specifies that:
     9        - Font weights less than or equal to 0, or greater than or equal to 1000 are parse errors
     10        - Font stretch values less than or equal to 0% are parse errors
     11        - Font style values less than or equal to -90deg or greater than or equal to 90deg are parse errors
     12
     13        Test: fast/text/variations/out-of-bounds-selection-properties.html
     14
     15        * css/parser/CSSPropertyParser.cpp:
     16        (WebCore::consumeFontWeightRange):
     17        (WebCore::fontStretchIsWithinRange):
     18        (WebCore::consumeFontStretch):
     19        (WebCore::consumeFontStretchRange):
     20        (WebCore::fontStyleIsWithinRange):
     21        (WebCore::consumeFontStyle):
     22        (WebCore::consumeFontStyleRange):
     23
    1242017-03-28  Andy Estes  <aestes@apple.com>
    225
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r214419 r214507  
    884884    if (auto result = consumeFontWeightKeywordValue(range))
    885885        return result;
    886     auto firstNumber = consumeNumber(range, ValueRangeAll);
     886    auto firstNumber = consumeFontWeightNumber(range);
    887887    if (!firstNumber)
    888888        return nullptr;
    889889    if (range.atEnd())
    890890        return firstNumber;
    891     auto secondNumber = consumeNumber(range, ValueRangeAll);
    892     if (!secondNumber)
    893         return nullptr;
    894     if (firstNumber->floatValue() > secondNumber->floatValue())
     891    auto secondNumber = consumeFontWeightNumber(range);
     892    if (!secondNumber || firstNumber->floatValue() > secondNumber->floatValue())
    895893        return nullptr;
    896894    auto result = CSSValueList::createSpaceSeparated();
     
    906904}
    907905
     906static bool fontStretchIsWithinRange(float stretch)
     907{
     908    return stretch > 0;
     909}
     910
    908911static RefPtr<CSSPrimitiveValue> consumeFontStretch(CSSParserTokenRange& range)
    909912{
    910913    if (auto result = consumeFontStretchKeywordValue(range))
    911914        return result;
    912     return consumePercent(range, ValueRangeAll);
     915    if (auto percent = consumePercent(range, ValueRangeNonNegative))
     916        return fontStretchIsWithinRange(percent->value<float>()) ? percent : nullptr;
     917    return nullptr;
    913918}
    914919
     
    918923    if (auto result = consumeFontStretchKeywordValue(range))
    919924        return result;
    920     auto firstPercent = consumePercent(range, ValueRangeAll);
    921     if (!firstPercent)
     925    auto firstPercent = consumePercent(range, ValueRangeNonNegative);
     926    if (!firstPercent || !fontStretchIsWithinRange(firstPercent->value<float>()))
    922927        return nullptr;
    923928    if (range.atEnd())
    924929        return firstPercent;
    925     auto secondPercent = consumePercent(range, ValueRangeAll);
    926     if (!secondPercent)
    927         return nullptr;
    928     if (firstPercent->floatValue() > secondPercent->floatValue())
     930    auto secondPercent = consumePercent(range, ValueRangeNonNegative);
     931    if (!secondPercent || !fontStretchIsWithinRange(secondPercent->value<float>()) || firstPercent->floatValue() > secondPercent->floatValue())
    929932        return nullptr;
    930933    auto result = CSSValueList::createSpaceSeparated();
     
    938941{
    939942    return consumeIdent<CSSValueNormal, CSSValueItalic, CSSValueOblique>(range);
     943}
     944
     945static bool fontStyleIsWithinRange(float oblique)
     946{
     947    return oblique > -90 && oblique < 90;
    940948}
    941949
     
    953961    if (range.atEnd())
    954962        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique));
    955     if (auto angle = consumeAngle(range, cssParserMode))
    956         return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), WTFMove(angle));
     963    if (auto angle = consumeAngle(range, cssParserMode)) {
     964        if (fontStyleIsWithinRange(angle->value<float>(CSSPrimitiveValue::CSS_DEG)))
     965            return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), WTFMove(angle));
     966        return nullptr;
     967    }
    957968    return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique));
    958969}
     
    969980
    970981    if (auto firstAngle = consumeAngle(range, cssParserMode)) {
     982        if (!fontStyleIsWithinRange(firstAngle->value<float>(CSSPrimitiveValue::CSS_DEG)))
     983            return nullptr;
    971984        if (range.atEnd()) {
    972985            auto result = CSSValueList::createSpaceSeparated();
     
    975988        }
    976989        auto secondAngle = consumeAngle(range, cssParserMode);
    977         if (!secondAngle)
    978             return nullptr;
    979         if (firstAngle->floatValue(CSSPrimitiveValue::CSS_DEG) > secondAngle->floatValue(CSSPrimitiveValue::CSS_DEG))
     990        if (!secondAngle || !fontStyleIsWithinRange(secondAngle->value<float>(CSSPrimitiveValue::CSS_DEG)) || firstAngle->floatValue(CSSPrimitiveValue::CSS_DEG) > secondAngle->floatValue(CSSPrimitiveValue::CSS_DEG))
    980991            return nullptr;
    981992        auto result = CSSValueList::createSpaceSeparated();
Note: See TracChangeset for help on using the changeset viewer.