Bug 43682

Summary: Add missing String builder for SVGPathParser
Product: WebKit Reporter: Dirk Schulze <krit>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
Patch zimmermann: review+

Description Dirk Schulze 2010-08-07 14:59:25 PDT
Add missing String builder (inheriting from SVGCustomer) for SVGPathParser.
Comment 1 Dirk Schulze 2010-08-07 15:16:15 PDT
Created attachment 63832 [details]
Patch
Comment 2 Nikolas Zimmermann 2010-08-08 04:46:35 PDT
Comment on attachment 63832 [details]
Patch

WebCore/svg/SVGPathParserFactory.cpp:80
 +      s_parser->setCurrentSource(source);
For consistency, add a newline before this statement and remove the one before return s_parser :-)

WebCore/svg/SVGPathParserFactory.cpp:181
 +      ASSERT(stream);
Ok you misunderstood the suggestion I gave.

The passed in OwnPtr should not be initialized, this is the task of this function.
The function should be used like this:

OwnPtr<SVGPathByteStream> stream; // stream pointer is null here!
if (!factory->buildSVGPathByteStreamFromString(d, stream, NormalizedParsing))
    return false;
// stream pointer is now set.

That means, the ASSERT(stream) should go away. The function should be used like this:

bool SVGPathParserFactory::buildSVGPathByteStreamFromString(const String& d, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode)
{
    if (d.isEmpty())
        return false;

    OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create();
    SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(stream.get());

    OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d);
    SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
    bool ok = parser->parsePathDataFromSource(parsingMode);
    parser->cleanup();
    result = stream.release(); // this is the important step
    return ok;
}

r=me, with those fixes.
Comment 3 Dirk Schulze 2010-08-08 09:11:15 PDT
Committed r64949: <http://trac.webkit.org/changeset/64949>