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

Unified Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 2356373002: Update createContextualFragment behavior to latest spec (Closed)
Patch Set: V6 Created 4 years, 3 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 | « third_party/WebKit/LayoutTests/fast/dom/Range/create-contextual-fragment-from-xml-element-range.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Range.cpp
diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
index 67305ca845e14dbc2158b87095a59debea84cda7..57aa306557bd686de6e6c0a73f0040cdaa89915c 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -884,29 +884,20 @@ DocumentFragment* Range::createContextualFragment(const String& markup, Exceptio
if (!element || isHTMLHtmlElement(element)) {
Document& document = node->document();
- if (document.isHTMLDocument() || document.isXHTMLDocument()) {
+ if (document.isSVGDocument()) {
+ element = document.documentElement();
+ if (!element)
+ element = SVGSVGElement::create(document);
+ } else {
// Optimization over spec: try to reuse the existing <body> element, if it is available.
element = document.body();
if (!element)
element = HTMLBodyElement::create(document);
- } else if (document.isSVGDocument()) {
- element = document.documentElement();
- if (!element)
- element = SVGSVGElement::create(document);
}
}
- if (!element || (!element->isHTMLElement() && !element->isSVGElement())) {
- exceptionState.throwDOMException(NotSupportedError, "The range's container must be an HTML or SVG Element, Document, or DocumentFragment.");
- return nullptr;
- }
-
// Steps 3, 4, 5.
- DocumentFragment* fragment = blink::createContextualFragment(markup, element, AllowScriptingContentAndDoNotMarkAlreadyStarted, exceptionState);
- if (!fragment)
- return nullptr;
-
- return fragment;
+ return blink::createContextualFragment(markup, element, AllowScriptingContentAndDoNotMarkAlreadyStarted, exceptionState);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/Range/create-contextual-fragment-from-xml-element-range.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698