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

Unified Diff: Source/core/editing/markup.cpp

Issue 1163863005: Check documentElement conditions in parser* DOM mutation methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add the test again. Created 5 years, 7 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 | « Source/core/dom/ContainerNode.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/markup.cpp
diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp
index 379cd98169c98a6c25674d0f1ed21efdf9ad14f5..93ade68126b4c63b0067727d06c1763a66c73618 100644
--- a/Source/core/editing/markup.cpp
+++ b/Source/core/editing/markup.cpp
@@ -287,9 +287,9 @@ PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkup(Document& docu
static const char fragmentMarkerTag[] = "webkit-fragment-marker";
-static bool findNodesSurroundingContext(Document* document, RefPtrWillBeRawPtr<Comment>& nodeBeforeContext, RefPtrWillBeRawPtr<Comment>& nodeAfterContext)
+static bool findNodesSurroundingContext(DocumentFragment* fragment, RefPtrWillBeRawPtr<Comment>& nodeBeforeContext, RefPtrWillBeRawPtr<Comment>& nodeAfterContext)
{
- for (Node& node : NodeTraversal::startsAt(document->firstChild())) {
+ for (Node& node : NodeTraversal::startsAt(fragment->firstChild())) {
if (node.nodeType() == Node::COMMENT_NODE && toComment(node).data() == fragmentMarkerTag) {
if (!nodeBeforeContext)
nodeBeforeContext = &toComment(node);
@@ -337,18 +337,19 @@ PassRefPtrWillBeRawPtr<DocumentFragment> createFragmentFromMarkupWithContext(Doc
taggedMarkup.append(markup.substring(fragmentEnd));
RefPtrWillBeRawPtr<DocumentFragment> taggedFragment = createFragmentFromMarkup(document, taggedMarkup.toString(), baseURL, parserContentPolicy);
- RefPtrWillBeRawPtr<Document> taggedDocument = Document::create();
- taggedDocument->setContextFeatures(document.contextFeatures());
-
- // FIXME: It's not clear what this code is trying to do. It puts nodes as direct children of a
- // Document that are not normally allowed by using the parser machinery.
- taggedDocument->parserTakeAllChildrenFrom(*taggedFragment);
RefPtrWillBeRawPtr<Comment> nodeBeforeContext = nullptr;
RefPtrWillBeRawPtr<Comment> nodeAfterContext = nullptr;
- if (!findNodesSurroundingContext(taggedDocument.get(), nodeBeforeContext, nodeAfterContext))
+ if (!findNodesSurroundingContext(taggedFragment.get(), nodeBeforeContext, nodeAfterContext))
return nullptr;
+ RefPtrWillBeRawPtr<Document> taggedDocument = Document::create();
+ taggedDocument->setContextFeatures(document.contextFeatures());
+
+ RefPtrWillBeRawPtr<Element> root = Element::create(QualifiedName::null(), taggedDocument.get());
+ root->appendChild(taggedFragment.get());
+ taggedDocument->appendChild(root);
+
RefPtrWillBeRawPtr<Range> range = Range::create(*taggedDocument.get(),
positionAfterNode(nodeBeforeContext.get()).parentAnchoredEquivalent(),
positionBeforeNode(nodeAfterContext.get()).parentAnchoredEquivalent());
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698