PassRefPtr<SVGPathSeg> SVGPathSegList::appendItem(PassRefPtr<SVGPathSeg> passItem) { updateListFromByteStream(); RefPtr<SVGPathSeg> item = Base::appendItem(passItem); if (m_byteStream) { SVGPathByteStreamBuilder builder; builder.setCurrentByteStream(m_byteStream.get()); SVGPathSegListSource source(lastAppended(), end()); SVGPathParser parser; parser.setCurrentConsumer(&builder); parser.setCurrentSource(&source); parser.parsePathDataFromSource(UnalteredParsing, false); } return item.release(); }
const SVGPathByteStream* SVGPathSegList::byteStream() const { if (!m_byteStream) { m_byteStream = SVGPathByteStream::create(); if (!Base::isEmpty()) { SVGPathByteStreamBuilder builder; builder.setCurrentByteStream(m_byteStream.get()); SVGPathSegListSource source(begin(), end()); SVGPathParser parser; parser.setCurrentConsumer(&builder); parser.setCurrentSource(&source); parser.parsePathDataFromSource(UnalteredParsing); } } return m_byteStream.get(); }
void SVGPathSegList::updateListFromByteStream() { if (m_listSyncedToByteStream) return; Base::clear(); if (m_byteStream && !m_byteStream->isEmpty()) { SVGPathSegListBuilder builder; builder.setCurrentSVGPathElement(m_contextElement); builder.setCurrentSVGPathSegList(this); builder.setCurrentSVGPathSegRole(PathSegUnalteredRole); SVGPathByteStreamSource source(m_byteStream.get()); SVGPathParser parser; parser.setCurrentConsumer(&builder); parser.setCurrentSource(&source); parser.parsePathDataFromSource(UnalteredParsing); } m_listSyncedToByteStream = true; }
bool SVGPathParserFactory::buildPathFromString(const CStdString& d, KdPath& result) { if (d.IsEmpty()) return false; SVGPathBuilder* builder = new SVGPathBuilder(); builder->setCurrentPath(&result); //OwnPtr<SVGPathStringSource> source = SVGPathStringSource::create(d); SVGPathStringSource* source = new SVGPathStringSource(d); //SVGPathParser* parser = globalSVGPathParser(source.get(), builder); SVGPathParser* parser = new SVGPathParser(); parser->setCurrentSource(source); parser->setCurrentConsumer(builder); bool ok = parser->parsePathDataFromSource(NormalizedParsing); parser->cleanup(); delete parser; delete source; delete builder; return ok; }