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

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

Issue 115693010: Fix Range.createContextualFragment for non-Element contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed 2nd round of feedback. Created 6 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
« Source/core/dom/Range.cpp ('K') | « Source/core/editing/markup.h ('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 c58d828319b0af89fd79888ccd56782f36902319..7477a73e0c0aa7ff3b8e403ec8df3e2e554fa2cf 100644
--- a/Source/core/editing/markup.cpp
+++ b/Source/core/editing/markup.cpp
@@ -975,11 +975,23 @@ static inline void removeElementPreservingChildren(PassRefPtrWillBeRawPtr<Docume
fragment->removeChild(element);
}
-PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const String& markup, HTMLElement* element, ParserContentPolicy parserContentPolicy, ExceptionState& exceptionState)
+static inline bool isSupportedContainer(Element* element)
{
ASSERT(element);
- if (element->ieForbidsInsertHTML() || element->hasLocalName(colTag) || element->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag)
+ if (!element->isHTMLElement())
+ return true;
+
+ if (element->hasLocalName(colTag) || element->hasLocalName(colgroupTag) || element->hasLocalName(framesetTag)
|| element->hasLocalName(headTag) || element->hasLocalName(styleTag) || element->hasLocalName(titleTag)) {
+ return false;
+ }
+ return !toHTMLElement(element)->ieForbidsInsertHTML();
+}
+
+PassRefPtrWillBeRawPtr<DocumentFragment> createContextualFragment(const String& markup, Element* element, ParserContentPolicy parserContentPolicy, ExceptionState& exceptionState)
+{
+ ASSERT(element);
+ if (!isSupportedContainer(element)) {
exceptionState.throwDOMException(NotSupportedError, "The range's container is '" + element->localName() + "', which is not supported.");
return nullptr;
}
« Source/core/dom/Range.cpp ('K') | « Source/core/editing/markup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698