Changeset 57473 in webkit


Ignore:
Timestamp:
Apr 12, 2010 8:49:53 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-12 Jeff Schiller <codedread@gmail.com>

Reviewed by Dirk Schulze.

Add tests to handle that comma/whitespace around arc flags are optional
and that arc flags can only be 0 or 1 in SVG path syntax:
https://bugs.webkit.org/show_bug.cgi?id=37431

  • svg/dom/fuzz-path-parser-expected.txt: One test now fails due to flags not 0 or 1
  • svg/dom/path-parser-expected.txt: Add test results for missing whitespace and flags not 0 or 1
  • svg/dom/script-tests/path-parser.js: Add 6 tests to check that whitespace is optional after flags and flags must be 0 or 1

2010-04-12 Jeff Schiller <codedread@gmail.com>

Reviewed by Dirk Schulze.

Make comma/whitespace around arc flags optional in SVG path syntax and ensure flags are
either 0 or 1: https://bugs.webkit.org/show_bug.cgi?id=37431

  • svg/SVGParserUtilities.cpp: (WebCore::parseArcFlag): function to read in a 0 or 1 for largeArcFlag and sweepFlag (WebCore::SVGPathParser::parseSVG): modify/simplify arc parsing by using parseArcFlag()
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57465 r57473  
     12010-04-12  Jeff Schiller  <codedread@gmail.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        Add tests to handle that comma/whitespace around arc flags are optional
     6        and that arc flags can only be 0 or 1 in SVG path syntax:
     7        https://bugs.webkit.org/show_bug.cgi?id=37431
     8
     9        * svg/dom/fuzz-path-parser-expected.txt: One test now fails due to flags not 0 or 1
     10        * svg/dom/path-parser-expected.txt: Add test results for missing whitespace and flags not 0 or 1
     11        * svg/dom/script-tests/path-parser.js: Add 6 tests to check that whitespace is optional after flags and flags must be 0 or 1
     12
    1132010-04-11  Tony Chang  <tony@chromium.org>
    214
  • trunk/LayoutTests/svg/dom/fuzz-path-parser-expected.txt

    r39819 r57473  
    44CONSOLE MESSAGE: line 97: Error: Problem parsing d="M1,1s6 3,8,h9 q5,5 1 4,4,h0 T5 t3,6 s8 5 8 2 zS0 7,7,s6,3,1,"
    55CONSOLE MESSAGE: line 97: Error: Problem parsing d="M1,1t4 4 l6 6 a4 2,3,0,1,2 1,Q1,1,0,3,H8 C7,9 8 4,0 t5,2,H9,zHq1 5,9,T6 8,"
     6CONSOLE MESSAGE: line 97: Error: Problem parsing d="M1,1t1 0 Zc3,8,8 7 3,4 zzQ5,3 4,4 H0 v8,v1,C0,1,6,2,5,4 q2 7 5 3 a7,4 7 9,7,2 9,ZL6 6,"
    67CONSOLE MESSAGE: line 97: Error: Problem parsing d="M1,1L5,9,t3 7 Q6 1 1,1 T3,0 s4 6 8 1,s8 3,8 9,a5 4 3 2,4,2 3,6 "
    78CONSOLE MESSAGE: line 97: Error: Problem parsing d="M1,1a9,2 6 1 2 2 2,za9 0 2 8,2,3,3 s5,8,8 1,HC5 8 5,8,4 2 c8 4 5 2 5 9,l3 9,H7 s6 2,0 0 a4 9,1 6,3,7,0,M6,"
     
    213214Could not parse: M1,1t4 4 l6 6 a4 2,3,0,1,2 1,Q1,1,0,3,H8 C7,9 8 4,0 t5,2,H9,zHq1 5,9,T6 8,
    214215Parsed as 1 command(s) [M]: M1,1
    215 Parsed as 16 command(s) [MCZCZZCLLLCCCCZL]: M1,1t1 0 Zc3,8,8 7 3,4 zzQ5,3 4,4 H0 v8,v1,C0,1,6,2,5,4 q2 7 5 3 a7,4 7 9,7,2 9,ZL6 6,
     216Could not parse: M1,1t1 0 Zc3,8,8 7 3,4 zzQ5,3 4,4 H0 v8,v1,C0,1,6,2,5,4 q2 7 5 3 a7,4 7 9,7,2 9,ZL6 6,
    216217Could not parse: M1,1L5,9,t3 7 Q6 1 1,1 T3,0 s4 6 8 1,s8 3,8 9,a5 4 3 2,4,2 3,6
    217218Parsed as 6 command(s) [MCLLCC]: M1,1t8 9,l3 5 l9,5 s6,9,2 9,T1 9
  • trunk/LayoutTests/svg/dom/path-parser-expected.txt

    r48393 r57473  
     1CONSOLE MESSAGE: line 9: Error: Problem parsing d="M100,200 a3,4,5,2,1,6,7"
     2CONSOLE MESSAGE: line 9: Error: Problem parsing d="M100,200 a3,4,5,1,2,6,7"
    13CONSOLE MESSAGE: line 9: Error: Problem parsing d="
    24M1,2"
     
    4042PASS parsePath('M100,200 a3,4,5,1,0,6,7') is 'M100,200 C98.5,202.3,98.6,205.7,100.2,207.7 C101.9,209.6,104.5,209.3,106,207'
    4143PASS parsePath('M100,200 a3,4,5,1,1,6,7') is 'M100,200 C101.5,197.7,104.1,197.4,105.8,199.3 C107.4,201.3,107.5,204.7,106,207'
     44PASS parsePath('M100,200 a3,4,5,006,7') is 'M100,200 C98.5,202.3,98.6,205.7,100.2,207.7 C101.9,209.6,104.5,209.3,106,207'
     45PASS parsePath('M100,200 a3,4,5,016,7') is 'M100,200 C101.5,197.7,104.1,197.4,105.8,199.3 C107.4,201.3,107.5,204.7,106,207'
     46PASS parsePath('M100,200 a3,4,5,106,7') is 'M100,200 C98.5,202.3,98.6,205.7,100.2,207.7 C101.9,209.6,104.5,209.3,106,207'
     47PASS parsePath('M100,200 a3,4,5,116,7') is 'M100,200 C101.5,197.7,104.1,197.4,105.8,199.3 C107.4,201.3,107.5,204.7,106,207'
     48PASS parsePath('M100,200 a3,4,5,2,1,6,7') is ''
     49PASS parsePath('M100,200 a3,4,5,1,2,6,7') is ''
    4250PASS parsePath('M1,2,3,4') is 'M1,2 L3,4'
    4351PASS parsePath('m100,200,3,4') is 'M100,200 L103,204'
  • trunk/LayoutTests/svg/dom/script-tests/path-parser.js

    r48554 r57473  
    8484shouldBe("parsePath('M100,200 a3,4,5,1,0,6,7')", "'M100,200 C98.5,202.3,98.6,205.7,100.2,207.7 C101.9,209.6,104.5,209.3,106,207'");
    8585shouldBe("parsePath('M100,200 a3,4,5,1,1,6,7')", "'M100,200 C101.5,197.7,104.1,197.4,105.8,199.3 C107.4,201.3,107.5,204.7,106,207'");
     86shouldBe("parsePath('M100,200 a3,4,5,006,7')", "'M100,200 C98.5,202.3,98.6,205.7,100.2,207.7 C101.9,209.6,104.5,209.3,106,207'");
     87shouldBe("parsePath('M100,200 a3,4,5,016,7')", "'M100,200 C101.5,197.7,104.1,197.4,105.8,199.3 C107.4,201.3,107.5,204.7,106,207'");
     88shouldBe("parsePath('M100,200 a3,4,5,106,7')", "'M100,200 C98.5,202.3,98.6,205.7,100.2,207.7 C101.9,209.6,104.5,209.3,106,207'");
     89shouldBe("parsePath('M100,200 a3,4,5,116,7')", "'M100,200 C101.5,197.7,104.1,197.4,105.8,199.3 C107.4,201.3,107.5,204.7,106,207'");
     90shouldBe("parsePath('M100,200 a3,4,5,2,1,6,7')", "''");
     91shouldBe("parsePath('M100,200 a3,4,5,1,2,6,7')", "''");
    8692
    8793shouldBe("parsePath('M1,2,3,4')", "'M1,2 L3,4'");
  • trunk/WebCore/ChangeLog

    r57469 r57473  
     12010-04-12  Jeff Schiller  <codedread@gmail.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        Make comma/whitespace around arc flags optional in SVG path syntax and ensure flags are
     6        either 0 or 1: https://bugs.webkit.org/show_bug.cgi?id=37431
     7
     8        * svg/SVGParserUtilities.cpp:
     9        (WebCore::parseArcFlag): function to read in a 0 or 1 for largeArcFlag and sweepFlag
     10        (WebCore::SVGPathParser::parseSVG): modify/simplify arc parsing by using parseArcFlag()
     11
    1122010-04-11  Sheriff Bot  <webkit.review.bot@gmail.com>
    213
  • trunk/WebCore/svg/SVGParserUtilities.cpp

    r48393 r57473  
    141141}
    142142
     143// only used to parse largeArcFlag and sweepFlag which must be a "0" or "1"
     144// and might not have any whitespace/comma after it
     145bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag)
     146{
     147    const UChar flagChar = *ptr++;
     148    if (flagChar == '0')
     149        flag = false;
     150    else if (flagChar == '1')
     151        flag = true;
     152    else
     153        return false;
     154   
     155    skipOptionalSpacesOrDelimiter(ptr, end);
     156   
     157    return true;
     158}
     159
    143160bool parseNumberOptionalNumber(const String& s, float& x, float& y)
    144161{
     
    479496                bool largeArc, sweep;
    480497                double angle, rx, ry;
    481                 if (!parseNumber(ptr, end, rx)    || !parseNumber(ptr, end, ry) ||
    482                     !parseNumber(ptr, end, angle) || !parseNumber(ptr, end, tox))
    483                     return false;
    484                 largeArc = tox == 1;
    485                 if (!parseNumber(ptr, end, tox))
    486                     return false;
    487                 sweep = tox == 1;
    488                 if (!parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
     498                if (!parseNumber(ptr, end, rx)    || !parseNumber(ptr, end, ry)
     499                    || !parseNumber(ptr, end, angle)
     500                    || !parseArcFlag(ptr, end, largeArc) || !parseArcFlag(ptr, end, sweep)
     501                    || !parseNumber(ptr, end, tox) || !parseNumber(ptr, end, toy))
    489502                    return false;
    490503
Note: See TracChangeset for help on using the changeset viewer.