Index: Source/core/inspector/DOMPatchSupport.cpp |
diff --git a/Source/core/inspector/DOMPatchSupport.cpp b/Source/core/inspector/DOMPatchSupport.cpp |
index 9708d9671ef630af589c9776f11745de8b1ea04c..9ff59837de960c62edf96cd6a3481e017e9ee9e2 100644 |
--- a/Source/core/inspector/DOMPatchSupport.cpp |
+++ b/Source/core/inspector/DOMPatchSupport.cpp |
@@ -85,6 +85,8 @@ void DOMPatchSupport::patchDocument(const String& markup) |
RefPtrWillBeRawPtr<Document> newDocument = nullptr; |
if (document().isHTMLDocument()) |
newDocument = HTMLDocument::create(); |
+ else if (document().isSVGDocument()) |
+ newDocument = XMLDocument::createSVG(); |
else if (document().isXHTMLDocument()) |
newDocument = XMLDocument::createXHTML(); |
else if (document().isXMLDocument()) |
@@ -92,16 +94,18 @@ void DOMPatchSupport::patchDocument(const String& markup) |
ASSERT(newDocument); |
newDocument->setContextFeatures(document().contextFeatures()); |
aandrey
2014/11/17 15:47:53
if a new document type will be added, it will cras
apavlov
2014/11/17 16:04:39
That's what ASSERT() is for.
apavlov
2014/11/17 16:05:55
Eh, I see what you mean. I cannot think of a way t
|
- RefPtrWillBeRawPtr<DocumentParser> parser = nullptr; |
- if (document().isHTMLDocument()) |
- parser = HTMLDocumentParser::create(toHTMLDocument(*newDocument), false); |
- else |
- parser = XMLDocumentParser::create(*newDocument, 0); |
- parser->pinToMainThread(); |
- parser->insert(markup); // Use insert() so that the parser will not yield. |
- parser->finish(); |
- parser->detach(); |
- |
+ if (!document().isHTMLDocument()) { |
+ RefPtrWillBeRawPtr<DocumentParser> parser = XMLDocumentParser::create(*newDocument, nullptr); |
+ parser->pinToMainThread(); |
+ parser->append(markup.impl()); |
+ parser->finish(); |
+ parser->detach(); |
+ |
+ // Avoid breakage on non-well-formed documents. |
+ if (!static_cast<XMLDocumentParser*>(parser.get())->wellFormed()) |
aandrey
2014/11/17 15:47:53
you can remove this static_cast with proper type f
apavlov
2014/11/17 16:04:39
With a proper type for parser, I cannot call appen
|
+ return; |
+ } |
+ newDocument->setContent(markup); |
OwnPtr<Digest> oldInfo = createDigest(document().documentElement(), 0); |
OwnPtr<Digest> newInfo = createDigest(newDocument->documentElement(), &m_unusedNodesMap); |