Bug 1383780 - Avoid adding anonymous editor element into non-HTML element. r?masayuki
It is mainly for avoiding other anonymous element being inserted into
<svg:use>, but in general we probably don't want to insert some random
HTML anonymous element into a non-HTML element.
MozReview-Commit-ID: J5kCUzA7K90
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -171,16 +171,24 @@ HTMLEditor::CreateAnonymousElement(nsIAt
return nullptr;
}
nsCOMPtr<nsIContent> parentContent = do_QueryInterface(aParentNode);
if (NS_WARN_IF(!parentContent)) {
return nullptr;
}
+ // Don't put anonymous editor element into non-HTML element.
+ // It is mainly for avoiding other anonymous element being inserted
+ // into <svg:use>, but in general we probably don't want to insert
+ // some random HTML anonymous element into a non-HTML element.
+ if (!parentContent->IsHTMLElement()) {
+ return nullptr;
+ }
+
nsCOMPtr<nsIDocument> doc = GetDocument();
if (NS_WARN_IF(!doc)) {
return nullptr;
}
// Get the pres shell
nsCOMPtr<nsIPresShell> ps = GetPresShell();
if (NS_WARN_IF(!ps)) {