Bug 1387406 - part3: nsFocusManager should treat editor as HTMLEditor r?smaug
Editor treated by nsFocusManager is always HTMLEditor. So, it should treat the editor as is.
MozReview-Commit-ID: Di1k2dlLodV
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -10,17 +10,16 @@
#include "AccessibleCaretEventHub.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsGkAtoms.h"
#include "nsGlobalWindow.h"
#include "nsContentUtils.h"
#include "nsIContentParent.h"
#include "nsIDocument.h"
-#include "nsIEditor.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDOMRange.h"
#include "nsIHTMLDocument.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
@@ -49,16 +48,17 @@
#include "nsNetUtil.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/EventStates.h"
+#include "mozilla/HTMLEditor.h"
#include "mozilla/IMEStateManager.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/Unused.h"
#include <algorithm>
#ifdef MOZ_XUL
@@ -852,28 +852,22 @@ nsFocusManager::ContentRemoved(nsIDocume
}
}
}
// Notify the editor in case we removed its ancestor limiter.
if (content->IsEditable()) {
nsCOMPtr<nsIDocShell> docShell = aDocument->GetDocShell();
if (docShell) {
- nsCOMPtr<nsIEditor> editor;
- docShell->GetEditor(getter_AddRefs(editor));
- if (editor) {
- nsCOMPtr<nsISelection> s;
- editor->GetSelection(getter_AddRefs(s));
- nsCOMPtr<nsISelectionPrivate> selection = do_QueryInterface(s);
- if (selection) {
- nsCOMPtr<nsIContent> limiter;
- selection->GetAncestorLimiter(getter_AddRefs(limiter));
- if (limiter == content) {
- editor->FinalizeSelection();
- }
+ RefPtr<HTMLEditor> htmlEditor = docShell->GetHTMLEditor();
+ if (htmlEditor) {
+ RefPtr<Selection> selection = htmlEditor->GetSelection();
+ if (selection && selection->GetFrameSelection() &&
+ content == selection->GetFrameSelection()->GetAncestorLimiter()) {
+ htmlEditor->FinalizeSelection();
}
}
}
}
NotifyFocusStateChange(content, nullptr, shouldShowFocusRing, false);
}