diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
index c84f7a93365..8e59a31eaa7 100644
--- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp
@@ -3782,7 +3782,7 @@ nsGenericHTMLElement::IsEditableRoot() const
}
if (document->HasFlag(NODE_IS_EDITABLE)) {
- return PR_FALSE;
+ return this == document->GetRootContent();
}
if (GetContentEditableValue() != eTrue) {
diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp
index 55e3fdf5f10..522e6c5b191 100644
--- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp
@@ -1065,8 +1065,11 @@ FindSelectionRoot(nsIEditor *aEditor, nsIContent *aContent)
CallQueryInterface(rootElement, &root);
- if (!root && document) {
- NS_IF_ADDREF(root = document->GetRootContent());
+ if (!root) {
+ nsIDocument *document = aContent->GetCurrentDoc();
+ if (document) {
+ NS_IF_ADDREF(root = document->GetRootContent());
+ }
}
return root;
@@ -1116,33 +1119,26 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
{ // only enable caret and selection if the editor is not disabled
nsCOMPtr content = do_QueryInterface(target);
- PRBool targetIsEditableDoc = PR_FALSE;
- nsCOMPtr editableRoot;
- if (content) {
- editableRoot = FindSelectionRoot(mEditor, content);
- }
- else {
- nsCOMPtr document = do_QueryInterface(target);
- targetIsEditableDoc = document && document->HasFlag(NODE_IS_EDITABLE);
- }
+ nsCOMPtr editableRoot =
+ content ? FindSelectionRoot(mEditor, content) : nsnull;
nsCOMPtr selCon;
mEditor->GetSelectionController(getter_AddRefs(selCon));
- if (selCon && (targetIsEditableDoc || editableRoot))
+ if (selCon)
{
nsCOMPtr selection;
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(selection));
nsCOMPtr presShell = do_QueryReferent(mPresShell);
- if (presShell) {
- nsCOMPtr caret;
- presShell->GetCaret(getter_AddRefs(caret));
- if (caret) {
- caret->SetIgnoreUserModify(PR_FALSE);
- if (selection) {
- caret->SetCaretDOMSelection(selection);
- }
+ if (presShell) {
+ nsCOMPtr caret;
+ presShell->GetCaret(getter_AddRefs(caret));
+ if (caret) {
+ caret->SetIgnoreUserModify(PR_FALSE);
+ if (selection) {
+ caret->SetCaretDOMSelection(selection);
+ }
}
}
@@ -1206,16 +1202,6 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
selectionPrivate->SetAncestorLimiter(nsnull);
}
- if (selection) {
- nsCOMPtr target;
- aEvent->GetTarget(getter_AddRefs(target));
- nsCOMPtr node = do_QueryInterface(target);
- nsIDocument* doc = node ? node->GetOwnerDoc() : nsnull;
- if (doc && !doc->HasFlag(NODE_IS_EDITABLE)) {
- selection->RemoveAllRanges();
- }
- }
-
nsCOMPtr presShell = do_QueryReferent(mPresShell);
if (presShell) {
nsCOMPtr caret;