From bc9b8f0f01333e2947828decc47a2b098269c10f Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 7 Aug 2017 14:55:58 +0900 Subject: [PATCH] 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 --HG-- extra : rebase_source : 49abc56f0a271cdf559adde468d8460ab1ba7aac --- dom/base/nsFocusManager.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 63ed26d8b728..644cdf509bbe 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -15,7 +15,6 @@ #include "nsContentUtils.h" #include "nsIContentParent.h" #include "nsIDocument.h" -#include "nsIEditor.h" #include "nsPIDOMWindow.h" #include "nsIDOMChromeWindow.h" #include "nsIDOMElement.h" @@ -54,6 +53,7 @@ #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" @@ -857,18 +857,12 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent) if (content->IsEditable()) { nsCOMPtr docShell = aDocument->GetDocShell(); if (docShell) { - nsCOMPtr editor; - docShell->GetEditor(getter_AddRefs(editor)); - if (editor) { - nsCOMPtr s; - editor->GetSelection(getter_AddRefs(s)); - nsCOMPtr selection = do_QueryInterface(s); - if (selection) { - nsCOMPtr limiter; - selection->GetAncestorLimiter(getter_AddRefs(limiter)); - if (limiter == content) { - editor->FinalizeSelection(); - } + RefPtr htmlEditor = docShell->GetHTMLEditor(); + if (htmlEditor) { + RefPtr selection = htmlEditor->GetSelection(); + if (selection && selection->GetFrameSelection() && + content == selection->GetFrameSelection()->GetAncestorLimiter()) { + htmlEditor->FinalizeSelection(); } } }