Ignore:
Timestamp:
May 3, 2012, 8:11:27 AM (13 years ago)
Author:
[email protected]
Message:

Remove extra checks for empty string when parsing CSS value
https://bugs.webkit.org/show_bug.cgi?id=85480

Reviewed by Alexis Menard.

Source/WebCore:

Each parse value helper function was checking whether the value string was empty. For the
common case this check is already done by StylePropertySet::setProperty(). So this patch
make CSSParser::parseValue() assume the value string is not empty, and fix the other two
clients.

Test: fast/html/font-face-empty-should-not-crash.html

  • css/CSSParser.cpp:

(WebCore::parseColorValue): Replace the string empty check by an ASSERT() to document
function's expectations.
(WebCore::parseSimpleLengthValue): Ditto.
(WebCore::parseKeywordValue): Ditto.
(WebCore::CSSParser::parseFontFaceValue): This will be covered by the added test.
(WebCore::CSSParser::parseValue):

  • css/WebKitCSSMatrix.cpp:

(WebCore::WebKitCSSMatrix::setMatrixValue): This is already covered by
transforms/cssmatrix-2d-interface.xhtml.

LayoutTests:

  • fast/html/font-face-empty-should-not-crash-expected.txt: Added.
  • fast/html/font-face-empty-should-not-crash.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/WebKitCSSMatrix.cpp

    r115215 r115972  
    5353void WebKitCSSMatrix::setMatrixValue(const String& string, ExceptionCode& ec)
    5454{
     55    if (string.isEmpty())
     56        return;
     57
    5558    RefPtr<StylePropertySet> styleDeclaration = StylePropertySet::create();
    5659    if (CSSParser::parseValue(styleDeclaration.get(), CSSPropertyWebkitTransform, string, true, CSSStrictMode, 0)) {
     
    8184        // set the matrix
    8285        m_matrix = t;
    83     } else if (!string.isEmpty()) // There is something there but parsing failed
     86    } else // There is something there but parsing failed.
    8487        ec = SYNTAX_ERR;
    8588}
Note: See TracChangeset for help on using the changeset viewer.