diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index b79a9971988e..6fb2ca6bbdf9 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -185,7 +185,7 @@ HTMLSlotElement* nsIContent::GetAssignedSlotByMode() const { } nsIContent::IMEState nsIContent::GetDesiredIMEState() { - if (!IsEditable()) { + if (!IsEditable() || !IsInComposedDoc()) { // Check for the special case where we're dealing with elements which don't // have the editable flag set, but are readwrite (such as text controls). if (!IsElement() || diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 431288b3ee6d..03990e9ed30f 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -591,46 +591,73 @@ nsIContent* nsINode::GetSelectionRootContent(PresShell* aPresShell, bool aAllowCrossShadowBoundary) { NS_ENSURE_TRUE(aPresShell, nullptr); - if (IsDocument()) return AsDocument()->GetRootElement(); - if (!IsContent()) return nullptr; + const bool isContent = IsContent(); - if (GetComposedDoc() != aPresShell->GetDocument()) { + if (!isContent && !IsDocument()) { return nullptr; } - if (AsContent()->HasIndependentSelection() || IsInNativeAnonymousSubtree()) { - // This node should be an inclusive descendant of input/textarea editor. - // In that case, the anonymous
for TextEditor should be always the - // selection root. - // FIXME: If Selection for the document is collapsed in or - //