Ignore:
Timestamp:
11/19/10 04:54:11 (4 years ago)
Author:
zimmermann@webkit.org
Message:

2010-11-19 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Convert SVGPathSeg/SVGPathSegList to the new SVGPropertyTearOff concept
https://bugs.webkit.org/show_bug.cgi?id=49580

SVGPathElement.cloneNode loses generated pathSegList
https://bugs.webkit.org/show_bug.cgi?id=43388

SVG Path elements are not correctly updated through pathSegList manipulation on relative values
https://bugs.webkit.org/show_bug.cgi?id=30219

Changing an SVGPathSeg does not update a following Smooth Cubic Curveto
https://bugs.webkit.org/show_bug.cgi?id=19741

SVGPathElement should only build SVGPathSeg* list on demand
https://bugs.webkit.org/show_bug.cgi?id=10827

Tests: svg/W3C-SVG-1.1-SE/paths-dom-02-f.svg

svg/dom/SVGPathSegList-appendItem.xhtml
svg/dom/SVGPathSegList-clear-and-initialize.xhtml
svg/dom/SVGPathSegList-cloning.html
svg/dom/SVGPathSegList-insertItemBefore.xhtml
svg/dom/SVGPathSegList-removeItem.xhtml
svg/dom/SVGPathSegList-replaceItem.xhtml
svg/dom/SVGPathSegList-xml-dom-synchronization.xhtml
svg/dom/SVGPathSegList-xml-dom-synchronization2.xhtml
svg/dom/SVGPathSegList-segment-modification.svg

Convert SVGPathSeg*/SVGPathSegList to the new SVG(Animated)PropertyTearOff concept.
Unlike all other SVG* types that use the SVGPropertyTearOff concept, SVGPathSegs are already refcounted,
and don't need to be wrapped in SVGPropertyTearOff objects. The consequence is that SVGPathSegs need to track
themselves to which list and path element they belong. Introduce new SVGAnimatedPathSegListPropertyTearOff
and SVGPathSegListPropertyTearOff classes, that encapsulate the special needed for SVGPathSegList.

Each SVGPathSeg now needs to store a RefPtr<SVGPathElement> - this makes it impossible to use SVGPathSegList
to represent the 'd' attribute internally in SVGPathElement. SVGPathSegList is now only used in the SVG DOM bindings
if someone explicitely requests 'pathElement.pathSegList' (eg. via JS). Switch to use SVGPathByteStream to store
the 'd' attribute data in SVGPathElement, which is much more compact, and less memory intensive.
Dirk already prepared SVGPathParserFactory some months ago, which allows easy conversion between
String/Path/SVGPathSegList/SVGPathByteStream in all directions, including normalizing the lists, when requested.

As consequence SVGPathSegList is now only built on demand, when explicitely requested. Using the SVGAnimatedProperty
concept gives us 'd' attribute <-> SVGPathSegList synchronization for free, fixing several bugs, listed above.

  • Android.mk: Remove obsolete SVGPathSeg*.cpp files and SVGAnimatedPathData.cpp from build.
  • CMakeLists.txt: Ditto.
  • DerivedSources.make: Remove SVGAnimatedPathData IDL generation.
  • GNUmakefile.am: Remove obsolete SVGPathSeg*.cpp files and SVGAnimatedPathData.cpp from build.
  • WebCore.gyp/WebCore.gyp: Remove SVGAnimatedPathData IDL generation.
  • WebCore.gypi: Remove obsolete SVGPathSeg*.cpp files and SVGAnimatedPathData.cpp from build.
  • WebCore.order: Remove no-longer existant SVGAnimatedPathData symbols.
  • WebCore.pro: Remove obsolete SVGPathSeg*.cpp files and SVGAnimatedPathData.cpp / JSSVGPathSegCustom.* from build.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • bindings/js/JSBindingsAllInOne.cpp: Remove JSSVGPathSegCustom.cpp from build.
  • bindings/js/JSDOMBinding.cpp: Adapt to toJS() changes, remove context parameter. (WebCore::setDOMException):
  • bindings/js/JSDOMBinding.h: Remove obsolete CREATE_SVG_OBJECT_WRAPPER macro, the context parameter is not existant anymore.
  • bindings/js/JSSVGPathSegCustom.cpp: Replace CREATE_SVG_OBJECT_WRAPPER by CREATE_DOM_OBJECT_WRAPPER. Remove context parameter/handling. (WebCore::toJS):
  • bindings/js/JSSVGPathSegListCustom.cpp: Removed.
  • bindings/scripts/CodeGenerator.pm: Map 'SVGPathSegList' IDL type to SVG 'SVGPathSegListPropertyTearOff' native type.
  • bindings/scripts/CodeGeneratorJS.pm: Remove IsSVGTypeNeedingContextParameter() methods and usages. Handle SVGPathSegListPropertyTearOff.
  • bindings/scripts/CodeGeneratorObjC.pm: Handle SVGPathSegListPropertyTearOff.
  • bindings/scripts/CodeGeneratorV8.pm: Remove IsSVGTypeNeedingContextParameter() methods and usages.
  • rendering/SVGRenderTreeAsText.cpp: Build path string from byte stream, not path segment list. (WebCore::operator<<):
  • svg/SVGAllInOne.cpp: Remove obsolete cpp files.
  • svg/SVGAnimatedPathData.cpp: Removed.
  • svg/SVGAnimatedPathData.h: Removed.
  • svg/SVGAnimatedPathData.idl: Removed.
  • svg/SVGPathElement.cpp: Build SVGPathList on demand. Use SVGPathByteStream to parse/store the 'd' attribute content. (WebCore::SVGPathElement::SVGPathElement): (WebCore::SVGPathElement::getPathSegAtLength): Use SVGPathByteStream, not SVGPathSegList to determine the getPathSegAtLength() information. (WebCore::SVGPathElement::createSVGPathSegClosePath): Pass SVGPathElement to SVGPathSeg and a SVGPathSegRole parameter and store it to track the list origin. (WebCore::SVGPathElement::createSVGPathSegMovetoAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegMovetoRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegLinetoAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegLinetoRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoCubicAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoCubicRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoQuadraticAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoQuadraticRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegArcAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegArcRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegLinetoHorizontalAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegLinetoHorizontalRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegLinetoVerticalAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegLinetoVerticalRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoCubicSmoothAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoCubicSmoothRel): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothAbs): Ditto. (WebCore::SVGPathElement::createSVGPathSegCurvetoQuadraticSmoothRel): Ditto. (WebCore::SVGPathElement::parseMappedAttribute): Build SVGPathByteStream from 'd' attribute, not a SVGPathSegList. (WebCore::SVGPathElement::svgAttributeChanged): If a SVGPathSegList object has been built, synchronize it with the 'd' attribute. (WebCore::SVGPathElement::synchronizeProperty): Synchronize 'd' attribute with the SVGPathSegList, if needed. (WebCore::SVGPathElement::synchronizeD): Added. (WebCore::SVGPathElement::pathSegList): Use same trick as in SVGPolyElement to expose the 'pathSegList' / 'animatedPathSegList' object to the SVG DOM bindings. (WebCore::SVGPathElement::normalizedPathSegList): Ditto. (WebCore::SVGPathElement::animatedPathSegList): Ditto. (WebCore::SVGPathElement::animatedNormalizedPathSegList): Ditto. (WebCore::SVGPathElement::toPathData): Build 'Path' object from SVGPathByteStream, not from SVGPathSegList. (WebCore::SVGPathElement::pathSegListChanged): Used to synchronize the SVGPathSegLists and the d attribute, as well as any changes from any SVGPathSeg associated with this SVGPathElement.
  • svg/SVGPathElement.h: Add new accessors... (WebCore::SVGPathElement::pathByteStream): ... needed by SVGRenderTreeAsText. (WebCore::SVGPathElement::animatablePathSegList): ... needed by SVGPathSegListPropertyTearOff.
  • svg/SVGPathElement.idl: Merge SVGAnimatedPathData interface into SVGPathElement.
  • svg/SVGPathParserFactory.cpp: Cleanup SVGPathParserFactory, remove obsolete methods, now that SVGPathElement switched to using SVGPathByteStream internally. (WebCore::globalSVGPathSegListBuilder): (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromSVGPathSegList): (WebCore::SVGPathParserFactory::buildPathFromByteStream): (WebCore::SVGPathParserFactory::buildSVGPathSegListFromByteStream): (WebCore::SVGPathParserFactory::buildStringFromSVGPathSegList): (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromString): (WebCore::SVGPathParserFactory::buildAnimatedSVGPathByteStream): (WebCore::SVGPathParserFactory::getSVGPathSegAtLengthFromSVGPathByteStream):
  • svg/SVGPathParserFactory.h:
  • svg/SVGPathSeg.cpp: Removed.
  • svg/SVGPathSeg.h: Add new SVGPathSegRole enum, identifying to which list a path segment belongs. (WebCore::SVGPathSeg::SVGPathSeg):
  • svg/SVGPathSeg.idl: Reindented.
  • svg/SVGPathSegArc.cpp: Removed.
  • svg/SVGPathSegArc.h: All setters now call the commitChange() method.
  • svg/SVGPathSegArcAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegArcRel.idl: Ditto.
  • svg/SVGPathSegClosePath.cpp: Removed.
  • svg/SVGPathSegClosePath.h:
  • svg/SVGPathSegCurvetoCubic.cpp: Removed.
  • svg/SVGPathSegCurvetoCubic.h: All setters now call the commitChange() method.
  • svg/SVGPathSegCurvetoCubicAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegCurvetoCubicRel.idl: Ditto.
  • svg/SVGPathSegCurvetoCubicSmooth.cpp: Removed.
  • svg/SVGPathSegCurvetoCubicSmooth.h: All setters now call the commitChange() method.
  • svg/SVGPathSegCurvetoCubicSmoothAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegCurvetoCubicSmoothRel.idl: Ditto.
  • svg/SVGPathSegCurvetoQuadratic.cpp: Removed.
  • svg/SVGPathSegCurvetoQuadratic.h: All setters now call the commitChange() method.
  • svg/SVGPathSegCurvetoQuadraticAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegCurvetoQuadraticRel.idl: Ditto.
  • svg/SVGPathSegCurvetoQuadraticSmooth.cpp: Removed.
  • svg/SVGPathSegCurvetoQuadraticSmooth.h: All setters now call the commitChange() method.
  • svg/SVGPathSegCurvetoQuadraticSmoothAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegCurvetoQuadraticSmoothRel.idl: Ditto.
  • svg/SVGPathSegLineto.cpp: Removed.
  • svg/SVGPathSegLineto.h: All setters now call the commitChange() method.
  • svg/SVGPathSegLinetoAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegLinetoHorizontal.cpp: Removed.
  • svg/SVGPathSegLinetoHorizontal.h: All setters now call the commitChange() method.
  • svg/SVGPathSegLinetoHorizontalAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegLinetoHorizontalRel.idl: Ditto.
  • svg/SVGPathSegLinetoRel.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegLinetoVertical.cpp: Removed.
  • svg/SVGPathSegLinetoVertical.h: All setters now call the commitChange() method.
  • svg/SVGPathSegLinetoVerticalAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegLinetoVerticalRel.idl: Ditto.
  • svg/SVGPathSegList.cpp: Switch from SVGList<RefPtr<SVGPathSeg> > to a plain Vector<RefPtr<SVGPathSeg> >. (WebCore::SVGPathSegList::valueAsString): Utilize SVGPathParserFactory to build a String from a SVGPathSegList. (WebCore::SVGPathSegList::commitChange): Call SVGPathElement::pathSegListChanged().
  • svg/SVGPathSegList.h: (WebCore::SVGPathSegList::SVGPathSegList):
  • svg/SVGPathSegList.idl: Remove [JSCCustom] flags, no longer needed.
  • svg/SVGPathSegListBuilder.cpp: Adapt to SVGPathSegList API changes. (WebCore::SVGPathSegListBuilder::SVGPathSegListBuilder): (WebCore::SVGPathSegListBuilder::moveTo): (WebCore::SVGPathSegListBuilder::lineTo): (WebCore::SVGPathSegListBuilder::lineToHorizontal): (WebCore::SVGPathSegListBuilder::lineToVertical): (WebCore::SVGPathSegListBuilder::curveToCubic): (WebCore::SVGPathSegListBuilder::curveToCubicSmooth): (WebCore::SVGPathSegListBuilder::curveToQuadratic): (WebCore::SVGPathSegListBuilder::curveToQuadraticSmooth): (WebCore::SVGPathSegListBuilder::arcTo): (WebCore::SVGPathSegListBuilder::closePath):
  • svg/SVGPathSegListBuilder.h: Ditto. (WebCore::SVGPathSegListBuilder::setCurrentSVGPathElement): (WebCore::SVGPathSegListBuilder::setCurrentSVGPathSegList): (WebCore::SVGPathSegListBuilder::setCurrentSVGPathSegRole): (WebCore::SVGPathSegListBuilder::cleanup):
  • svg/SVGPathSegListSource.cpp: Ditto. (WebCore::SVGPathSegListSource::SVGPathSegListSource): (WebCore::SVGPathSegListSource::parseSVGSegmentType): (WebCore::SVGPathSegListSource::nextCommand): (WebCore::SVGPathSegListSource::parseMoveToSegment): (WebCore::SVGPathSegListSource::parseLineToSegment): (WebCore::SVGPathSegListSource::parseCurveToQuadraticSmoothSegment):
  • svg/SVGPathSegListSource.h: Ditto. (WebCore::SVGPathSegListSource::create):
  • svg/SVGPathSegMoveto.cpp: Removed.
  • svg/SVGPathSegMoveto.h: All setters now call the commitChange() method.
  • svg/SVGPathSegMovetoAbs.idl: Enable StrictTypeChecking.
  • svg/SVGPathSegMovetoRel.idl: Ditto.
  • svg/SVGPathSegWithContext.h: Added. This is the new base class for all SVGPathSeg derived types, that's associated with a SVGPathElement and a 'role' (normalized/unaltered segment list). (WebCore::SVGPathSegWithContext::SVGPathSegWithContext): (WebCore::SVGPathSegWithContext::animatedProperty): (WebCore::SVGPathSegWithContext::setContextAndRole): (WebCore::SVGPathSegWithContext::commitChange): (WebCore::SVGPathSegSingleCoordinate::x): (WebCore::SVGPathSegSingleCoordinate::setX): (WebCore::SVGPathSegSingleCoordinate::y): (WebCore::SVGPathSegSingleCoordinate::setY): (WebCore::SVGPathSegSingleCoordinate::SVGPathSegSingleCoordinate):
  • svg/properties/SVGAnimatedPathSegListPropertyTearOff.h: Added. (WebCore::SVGAnimatedPathSegListPropertyTearOff::baseVal): (WebCore::SVGAnimatedPathSegListPropertyTearOff::animVal): (WebCore::SVGAnimatedPathSegListPropertyTearOff::removeItemFromList): (WebCore::SVGAnimatedPathSegListPropertyTearOff::create): (WebCore::SVGAnimatedPathSegListPropertyTearOff::SVGAnimatedPathSegListPropertyTearOff):
  • svg/properties/SVGPathSegListPropertyTearOff.cpp: Added. (WebCore::SVGPathSegListPropertyTearOff::clear): Added in the cpp file, not in the header, as it needs access to SVGPathSegWithContext, which we can't include from the header. (WebCore::SVGPathSegListPropertyTearOff::getItem): Ditto. (WebCore::SVGPathSegListPropertyTearOff::removeItem): Ditto. (WebCore::SVGPathSegListPropertyTearOff::contextElement): Needs access to SVGPathElement, that's why it lives in the cpp file. (WebCore::SVGPathSegListPropertyTearOff::processIncomingListItemValue): Needs access to SVGPathSegWithContext.
  • svg/properties/SVGPathSegListPropertyTearOff.h: Added. (WebCore::SVGPathSegListPropertyTearOff::create): (WebCore::SVGPathSegListPropertyTearOff::removeItemFromList): (WebCore::SVGPathSegListPropertyTearOff::numberOfItems): (WebCore::SVGPathSegListPropertyTearOff::initialize): (WebCore::SVGPathSegListPropertyTearOff::insertItemBefore): (WebCore::SVGPathSegListPropertyTearOff::replaceItem): (WebCore::SVGPathSegListPropertyTearOff::appendItem): (WebCore::SVGPathSegListPropertyTearOff::SVGPathSegListPropertyTearOff): (WebCore::SVGPathSegListPropertyTearOff::commitChange): (WebCore::SVGPathSegListPropertyTearOff::processIncomingListItemWrapper):

2010-11-19 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Convert SVGPathSeg/SVGPathSegList to the new SVGPropertyTearOff concept
https://bugs.webkit.org/show_bug.cgi?id=49580

Add several new tests covering SVGPathSegList usage.

  • platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.checksum: Added.
  • platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.png: Added.
  • platform/mac/svg/W3C-SVG-1.1-SE/paths-dom-02-f-expected.txt: Added.
  • platform/mac/svg/custom/svg-curve-with-relative-cordinates-expected.txt:
  • platform/mac/svg/dom/SVGPathSegList-appendItem-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-appendItem-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-clear-and-initialize-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-clear-and-initialize-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-cloning-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-cloning-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-cloning-expected.txt: Added.
  • platform/mac/svg/dom/SVGPathSegList-insertItemBefore-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-insertItemBefore-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-removeItem-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-removeItem-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-replaceItem-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-replaceItem-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-segment-modification-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-segment-modification-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-segment-modification-expected.txt: Added.
  • platform/mac/svg/dom/SVGPathSegList-xml-dom-synchronization-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-xml-dom-synchronization-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-xml-dom-synchronization2-expected.checksum: Added.
  • platform/mac/svg/dom/SVGPathSegList-xml-dom-synchronization2-expected.png: Added.
  • platform/mac/svg/dom/SVGPathSegList-xml-dom-synchronization2-expected.txt: Added.
  • svg/W3C-SVG-1.1-SE/paths-dom-02-f.svg: Added.
  • svg/dom/SVGPathSegList-appendItem-expected.txt: Added.
  • svg/dom/SVGPathSegList-appendItem.xhtml: Added.
  • svg/dom/SVGPathSegList-clear-and-initialize-expected.txt: Added.
  • svg/dom/SVGPathSegList-clear-and-initialize.xhtml: Added.
  • svg/dom/SVGPathSegList-cloning.html: Added.
  • svg/dom/SVGPathSegList-insertItemBefore-expected.txt: Added.
  • svg/dom/SVGPathSegList-insertItemBefore.xhtml: Added.
  • svg/dom/SVGPathSegList-removeItem-expected.txt: Added.
  • svg/dom/SVGPathSegList-removeItem.xhtml: Added.
  • svg/dom/SVGPathSegList-replaceItem-expected.txt: Added.
  • svg/dom/SVGPathSegList-replaceItem.xhtml: Added.
  • svg/dom/SVGPathSegList-segment-modification.svg: Added.
  • svg/dom/SVGPathSegList-xml-dom-synchronization-expected.txt: Added.
  • svg/dom/SVGPathSegList-xml-dom-synchronization.xhtml: Added.
  • svg/dom/SVGPathSegList-xml-dom-synchronization2.xhtml: Added.
  • svg/dom/fuzz-path-parser-expected.txt:
  • svg/dom/path-parser-expected.txt:
  • svg/dom/script-tests/path-parser.js: ():
  • svg/dom/svglist-exception-on-out-bounds-error-expected.txt:
  • svg/dom/svglist-exception-on-out-bounds-error.html:
  • svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/svg/SVGPathParserFactory.cpp

    r72294 r72381  
    2828#include "SVGPathByteStreamBuilder.h" 
    2929#include "SVGPathByteStreamSource.h" 
     30#include "SVGPathElement.h" 
    3031#include "SVGPathParser.h" 
    3132#include "SVGPathSegListBuilder.h" 
     
    4748} 
    4849 
    49 static SVGPathSegListBuilder* globalSVGPathSegListBuilder(SVGPathSegList* result) 
     50static SVGPathSegListBuilder* globalSVGPathSegListBuilder(SVGPathElement* element, SVGPathSegRole role, SVGPathSegList& result) 
    5051{ 
    5152    static SVGPathSegListBuilder* s_builder = 0; 
     
    5354        s_builder = new SVGPathSegListBuilder; 
    5455 
     56    s_builder->setCurrentSVGPathElement(element); 
    5557    s_builder->setCurrentSVGPathSegList(result); 
     58    s_builder->setCurrentSVGPathSegRole(role); 
    5659    return s_builder; 
    5760} 
     
    138141} 
    139142 
     143bool SVGPathParserFactory::buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList& list, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode) 
     144{ 
     145    result = SVGPathByteStream::create(); 
     146    if (list.isEmpty()) 
     147        return false; 
     148 
     149    SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result.get()); 
     150 
     151    OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(list); 
     152    SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
     153    bool ok = parser->parsePathDataFromSource(parsingMode); 
     154    parser->cleanup(); 
     155    return ok; 
     156} 
     157 
    140158bool SVGPathParserFactory::buildPathFromByteStream(SVGPathByteStream* stream, Path& result) 
    141159{ 
     
    153171} 
    154172 
    155 bool SVGPathParserFactory::buildPathFromSVGPathSegList(SVGPathSegList* pathSegList, Path& result) 
    156 { 
    157     ASSERT(pathSegList); 
    158     if (!pathSegList->numberOfItems()) 
    159         return false; 
    160  
    161     SVGPathBuilder* builder = globalSVGPathBuilder(result); 
    162  
    163     OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); 
    164     SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    165     bool ok = parser->parsePathDataFromSource(NormalizedParsing); 
    166     parser->cleanup(); 
    167     return ok; 
    168 } 
    169  
    170 bool SVGPathParserFactory::buildSVGPathSegListFromString(const String& d, SVGPathSegList* result, PathParsingMode parsingMode) 
    171 { 
    172     ASSERT(result); 
     173bool SVGPathParserFactory::buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathElement* element, SVGPathSegList& result, PathParsingMode parsingMode) 
     174{ 
     175    ASSERT(stream); 
     176    if (stream->isEmpty()) 
     177        return false;  
     178 
     179    SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(element, parsingMode == NormalizedParsing ? PathSegNormalizedRole : PathSegUnalteredRole, result); 
     180 
     181    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); 
     182    SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
     183    bool ok = parser->parsePathDataFromSource(parsingMode); 
     184    parser->cleanup(); 
     185    return ok; 
     186} 
     187 
     188bool SVGPathParserFactory::buildStringFromByteStream(SVGPathByteStream* stream, String& result, PathParsingMode parsingMode) 
     189{ 
     190    ASSERT(stream); 
     191    if (stream->isEmpty()) 
     192        return false;  
     193 
     194    SVGPathStringBuilder* builder = globalSVGPathStringBuilder(); 
     195 
     196    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); 
     197    SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
     198    bool ok = parser->parsePathDataFromSource(parsingMode); 
     199    result = builder->result(); 
     200    parser->cleanup(); 
     201    return ok; 
     202} 
     203 
     204bool SVGPathParserFactory::buildStringFromSVGPathSegList(const SVGPathSegList& list, String& result, PathParsingMode parsingMode) 
     205{ 
     206    result = String(); 
     207    if (list.isEmpty()) 
     208        return false; 
     209 
     210    SVGPathStringBuilder* builder = globalSVGPathStringBuilder(); 
     211 
     212    OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(list); 
     213    SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
     214    bool ok = parser->parsePathDataFromSource(parsingMode); 
     215    result = builder->result(); 
     216    parser->cleanup(); 
     217    return ok; 
     218} 
     219 
     220bool SVGPathParserFactory::buildSVGPathByteStreamFromString(const String& d, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode) 
     221{ 
     222    result = SVGPathByteStream::create(); 
    173223    if (d.isEmpty()) 
    174224        return false; 
    175225 
    176     SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(result); 
     226    SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result.get()); 
    177227 
    178228    OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d); 
    179229    SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    180230    bool ok = parser->parsePathDataFromSource(parsingMode); 
    181     parser->cleanup(); 
    182     return ok; 
    183 } 
    184  
    185 bool SVGPathParserFactory::buildSVGPathSegListFromByteStream(SVGPathByteStream* stream, SVGPathSegList* result, PathParsingMode parsingMode) 
    186 { 
    187     ASSERT(stream); 
    188     ASSERT(result); 
    189     if (stream->isEmpty()) 
    190         return false;  
    191  
    192     SVGPathSegListBuilder* builder = globalSVGPathSegListBuilder(result); 
    193  
    194     OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); 
    195     SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    196     bool ok = parser->parsePathDataFromSource(parsingMode); 
    197     parser->cleanup(); 
    198     return ok; 
    199 } 
    200  
    201 bool SVGPathParserFactory::buildStringFromByteStream(SVGPathByteStream* stream, String& result, PathParsingMode parsingMode) 
    202 { 
    203     ASSERT(stream); 
    204     if (stream->isEmpty()) 
    205         return false;  
    206  
    207     SVGPathStringBuilder* builder = globalSVGPathStringBuilder(); 
    208  
    209     OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); 
    210     SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    211     bool ok = parser->parsePathDataFromSource(parsingMode); 
    212     result = builder->result(); 
    213     parser->cleanup(); 
    214     return ok; 
    215 } 
    216  
    217 bool SVGPathParserFactory::buildStringFromSVGPathSegList(SVGPathSegList* pathSegList, String& result, PathParsingMode parsingMode) 
    218 { 
    219     ASSERT(pathSegList); 
    220     if (!pathSegList->numberOfItems()) 
    221         return false;  
    222  
    223     SVGPathStringBuilder* builder = globalSVGPathStringBuilder(); 
    224  
    225     OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); 
    226     SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    227     bool ok = parser->parsePathDataFromSource(parsingMode); 
    228     result = builder->result(); 
    229     parser->cleanup(); 
    230     return ok; 
    231 } 
    232  
    233 bool SVGPathParserFactory::buildSVGPathByteStreamFromString(const String& d, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode) 
    234 { 
    235     if (d.isEmpty()) 
    236         return false; 
    237  
    238     OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create(); 
    239     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(stream.get()); 
    240  
    241     OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d); 
    242     SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    243     bool ok = parser->parsePathDataFromSource(parsingMode); 
    244     result = stream.release(); 
    245231    parser->cleanup(); 
    246232    return ok; 
     
    251237    ASSERT(fromStream); 
    252238    ASSERT(toStream); 
     239    result = SVGPathByteStream::create(); 
    253240    if (fromStream->isEmpty() || toStream->isEmpty()) 
    254241        return false; 
    255242 
    256     OwnPtr<SVGPathByteStream> stream = SVGPathByteStream::create(); 
    257     SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(stream.get()); 
     243    SVGPathByteStreamBuilder* builder = globalSVGPathByteStreamBuilder(result.get()); 
    258244 
    259245    OwnPtr<SVGPathByteStreamSource> fromSource = SVGPathByteStreamSource::create(fromStream); 
     
    261247    SVGPathBlender* blender = globalSVGPathBlender(); 
    262248    bool ok = blender->blendAnimatedPath(progress, fromSource.get(), toSource.get(), builder); 
    263     result = stream.release(); 
    264249    blender->cleanup(); 
    265250    return ok; 
    266251} 
    267252 
    268 bool SVGPathParserFactory::getSVGPathSegAtLengthFromSVGPathSegList(SVGPathSegList* pathSegList, float length, unsigned long& pathSeg) 
    269 { 
    270     ASSERT(pathSegList); 
    271     if (!pathSegList->numberOfItems()) 
    272         return false;  
     253bool SVGPathParserFactory::getSVGPathSegAtLengthFromSVGPathByteStream(SVGPathByteStream* stream, float length, unsigned long& pathSeg) 
     254{ 
     255    ASSERT(stream); 
     256    if (stream->isEmpty()) 
     257        return false; 
    273258 
    274259    PathTraversalState traversalState(PathTraversalState::TraversalSegmentAtLength); 
    275260    SVGPathTraversalStateBuilder* builder = globalSVGPathTraversalStateBuilder(traversalState, length); 
    276261 
    277     OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); 
     262    OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); 
    278263    SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 
    279264    bool ok = parser->parsePathDataFromSource(NormalizedParsing); 
Note: See TracChangeset for help on using the changeset viewer.