Changeset 57140 in webkit


Ignore:
Timestamp:
Apr 6, 2010 3:37:25 AM (14 years ago)
Author:
krit@webkit.org
Message:

2010-04-06 Dirk Schulze <krit@webkit.org>

Reviewed by Oliver Hunt.

SVG/SMIL parse failure on attribute keySplines
https://bugs.webkit.org/show_bug.cgi?id=37071

Test: svg/animations/animate-keySplines.html

The String in 'keySplines' can have multiple spaces between numbers
and delimiters. The parsing code is inspired by SVGParserUtilities
and respects this.

  • svg/SVGAnimationElement.cpp: (WebCore::parseKeySplines):

2010-04-06 Dirk Schulze <krit@webkit.org>

Reviewed by Oliver Hunt.

SVG/SMIL parse failure on attribute keySplines
https://bugs.webkit.org/show_bug.cgi?id=37071

Test correct parsing of keySplines.

  • svg/animations/animate-keySplines-expected.txt: Added.
  • svg/animations/animate-keySplines.html: Added.
  • svg/animations/script-tests/animate-keySplines.js: Added. (sample1): (sample2): (sample3): (executeTest):
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57136 r57140  
     12010-04-06  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        SVG/SMIL parse failure on attribute keySplines
     6        https://bugs.webkit.org/show_bug.cgi?id=37071
     7
     8        Test correct parsing of keySplines.
     9
     10        * svg/animations/animate-keySplines-expected.txt: Added.
     11        * svg/animations/animate-keySplines.html: Added.
     12        * svg/animations/script-tests/animate-keySplines.js: Added.
     13        (sample1):
     14        (sample2):
     15        (sample3):
     16        (executeTest):
     17
    1182010-04-06  Pavel Feldman  <pfeldman@chromium.org>
    219
  • trunk/WebCore/ChangeLog

    r57134 r57140  
     12010-04-06  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        SVG/SMIL parse failure on attribute keySplines
     6        https://bugs.webkit.org/show_bug.cgi?id=37071
     7
     8        Test: svg/animations/animate-keySplines.html
     9
     10        The String in 'keySplines' can have multiple spaces between numbers
     11        and delimiters. The parsing code is inspired by SVGParserUtilities
     12        and respects this.
     13
     14        * svg/SVGAnimationElement.cpp:
     15        (WebCore::parseKeySplines):
     16
    1172010-04-06  Yury Semikhatsky  <yurys@chromium.org>
    218
  • trunk/WebCore/svg/SVGAnimationElement.cpp

    r56775 r57140  
    55    Copyright (C) 2008 Apple Inc. All rights reserved.
    66    Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
     7    Copyright (C) Research In Motion Limited 2010. All rights reserved.
    78
    89    This library is free software; you can redistribute it and/or
     
    3738#include "HTMLNames.h"
    3839#include "MappedAttribute.h"
     40#include "PlatformString.h"
    3941#include "RenderObject.h"
    4042#include "SVGElementInstance.h"
    4143#include "SVGNames.h"
     44#include "SVGParserUtilities.h"
    4245#include "SVGURIReference.h"
    4346#include "SVGUseElement.h"
     
    9093{
    9194    result.clear();
    92     Vector<String> parseList;
    93     parse.split(';', parseList);
    94     for (unsigned n = 0; n < parseList.size(); ++n) {
    95         Vector<String> parseSpline;
    96         parseList[n].split(',', parseSpline);
    97         // The spec says the sepator is a space, all tests use commas. Weird.
    98         if (parseSpline.size() == 1)
    99             parseList[n].split(' ', parseSpline);
    100         if (parseSpline.size() != 4)
    101             goto fail;
    102         double curveValues[4];
    103         for (unsigned i = 0; i < 4; ++i) {
    104             String parseNumber = parseSpline[i];
    105             bool ok;
    106             curveValues[i] = parseNumber.toDouble(&ok);
    107             if (!ok || curveValues[i] < 0.0 || curveValues[i] > 1.0)
    108                 goto fail;
    109         }
    110         result.append(UnitBezier(curveValues[0], curveValues[1], curveValues[2], curveValues[3]));
    111     }
    112     return;
    113 fail:
    114     result.clear();
     95    if (parse.isEmpty())
     96        return;
     97    const UChar* cur = parse.characters();
     98    const UChar* end = cur + parse.length();
     99
     100    skipOptionalSpaces(cur, end);
     101
     102    bool delimParsed = false;
     103    while (cur < end) {
     104        delimParsed = false;
     105        float posA = 0.0f;
     106        if (!parseNumber(cur, end, posA)) {
     107            result.clear();
     108            return;
     109        }
     110
     111        float posB = 0.0f;
     112        if (!parseNumber(cur, end, posB)) {
     113            result.clear();
     114            return;
     115        }
     116
     117        float posC = 0.0f;
     118        if (!parseNumber(cur, end, posC)) {
     119            result.clear();
     120            return;
     121        }
     122
     123        float posD = 0.0f;
     124        if (!parseNumber(cur, end, posD, false)) {
     125            result.clear();
     126            return;
     127        }
     128
     129        skipOptionalSpaces(cur, end);
     130
     131        if (cur < end && *cur == ';') {
     132            delimParsed = true;
     133            cur++;
     134        }
     135        skipOptionalSpaces(cur, end);
     136
     137        result.append(UnitBezier(posA, posB, posC, posD));
     138    }
     139    if (!(cur == end && !delimParsed))
     140        result.clear();
    115141}
    116142
Note: See TracChangeset for help on using the changeset viewer.