Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: src/xml/SkDOM.cpp

Issue 2142893006: Dust-off SkXMLParser (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: XML_STATIC for MSVC voodoo Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/xml/SkDOM.h ('k') | src/xml/SkXMLParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/xml/SkDOM.cpp
diff --git a/src/xml/SkDOM.cpp b/src/xml/SkDOM.cpp
index 15b458e4fbc3821edf3df69d11b6ff5c2eda331a..78cf6f07e9266d42fad174a82bfc589cd1d3152f 100644
--- a/src/xml/SkDOM.cpp
+++ b/src/xml/SkDOM.cpp
@@ -310,10 +310,9 @@ private:
int fLevel;
};
-const SkDOM::Node* SkDOM::build(const char doc[], size_t len)
-{
+const SkDOM::Node* SkDOM::build(SkStream& docStream) {
SkDOMParser parser(&fAlloc);
- if (!parser.parse(doc, len))
+ if (!parser.parse(docStream))
{
SkDEBUGCODE(SkDebugf("xml parse error, line %d\n", parser.fParserError.getLineNumber());)
fRoot = nullptr;
@@ -324,6 +323,11 @@ const SkDOM::Node* SkDOM::build(const char doc[], size_t len)
return fRoot;
}
+const SkDOM::Node* SkDOM::build(const char doc[], size_t len) {
+ SkMemoryStream docStream(doc, len);
+ return this->build(docStream);
+}
+
///////////////////////////////////////////////////////////////////////////
static void walk_dom(const SkDOM& dom, const SkDOM::Node* node, SkXMLParser* parser)
@@ -475,40 +479,4 @@ void SkDOM::dump(const Node* node, int level) const
xmlWriter.writeDOM(*this, node, false);
}
-void SkDOM::UnitTest()
-{
-#ifdef SK_SUPPORT_UNITTEST
- static const char gDoc[] =
- "<root a='1' b='2'>"
- "<elem1 c='3' />"
- "<elem2 d='4' />"
- "<elem3 e='5'>"
- "<subelem1/>"
- "<subelem2 f='6' g='7'/>"
- "</elem3>"
- "<elem4 h='8'/>"
- "</root>"
- ;
-
- SkDOM dom;
-
- SkASSERT(dom.getRootNode() == nullptr);
-
- const Node* root = dom.build(gDoc, sizeof(gDoc) - 1);
- SkASSERT(root && dom.getRootNode() == root);
-
- const char* v = dom.findAttr(root, "a");
- SkASSERT(v && !strcmp(v, "1"));
- v = dom.findAttr(root, "b");
- SkASSERT(v && !strcmp(v, "2"));
- v = dom.findAttr(root, "c");
- SkASSERT(v == nullptr);
-
- SkASSERT(dom.getFirstChild(root, "elem1"));
- SkASSERT(!dom.getFirstChild(root, "subelem1"));
-
- dom.dump();
-#endif
-}
-
#endif
« no previous file with comments | « include/xml/SkDOM.h ('k') | src/xml/SkXMLParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698