Bug 1260651 part.55 Rename nsEditorEventListeners to mozilla::EditorEventListener (and their file names) r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 07 Jul 2016 19:40:51 +0900
changeset 385887 dfee7368ac6a9a5ecf5afd56605f8da850e83291
parent 385886 204158de432126d4a98f51c470c89e404711fdd7
child 385888 51addd3c3e4791ff30cabb2860df401f2cd51b09
push id22587
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 06:59:31 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.55 Rename nsEditorEventListeners to mozilla::EditorEventListener (and their file names) r=mccr8 MozReview-Commit-ID: HqUUCZkaFTT
editor/libeditor/EditorEventListener.cpp
editor/libeditor/EditorEventListener.h
editor/libeditor/HTMLEditorEventListener.cpp
editor/libeditor/HTMLEditorEventListener.h
editor/libeditor/moz.build
editor/libeditor/nsEditor.cpp
editor/libeditor/nsEditor.h
editor/libeditor/nsEditorEventListener.cpp
editor/libeditor/nsEditorEventListener.h
layout/build/nsLayoutStatics.cpp
rename from editor/libeditor/nsEditorEventListener.cpp
rename to editor/libeditor/EditorEventListener.cpp
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=4 sw=2 et tw=78: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsEditorEventListener.h"
+#include "EditorEventListener.h"
 
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/EventListenerManager.h" // for EventListenerManager
 #include "mozilla/IMEStateManager.h"    // for IMEStateManager
 #include "mozilla/Preferences.h"        // for Preferences
 #include "mozilla/TextEvents.h"         // for WidgetCompositionEvent
 #include "mozilla/dom/Element.h"        // for Element
 #include "mozilla/dom/Event.h"          // for Event
@@ -59,18 +59,19 @@
 #include "nsContentUtils.h"             // for nsContentUtils, etc
 #include "nsIBidiKeyboard.h"            // for nsIBidiKeyboard
 #endif
 
 #include "mozilla/dom/TabParent.h"
 
 class nsPresContext;
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+
+using namespace dom;
 
 static void
 DoCommandCallback(Command aCommand, void* aData)
 {
   nsIDocument* doc = static_cast<nsIDocument*>(aData);
   nsPIDOMWindowOuter* win = doc->GetWindow();
   if (!win) {
     return;
@@ -91,39 +92,39 @@ DoCommandCallback(Command aCommand, void
   bool commandEnabled;
   nsresult rv = controller->IsCommandEnabled(commandStr, &commandEnabled);
   NS_ENSURE_SUCCESS_VOID(rv);
   if (commandEnabled) {
     controller->DoCommand(commandStr);
   }
 }
 
-nsEditorEventListener::nsEditorEventListener()
+EditorEventListener::EditorEventListener()
   : mEditor(nullptr)
   , mCommitText(false)
   , mInTransaction(false)
   , mMouseDownOrUpConsumedByIME(false)
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   , mHaveBidiKeyboards(false)
   , mShouldSwitchTextDirection(false)
   , mSwitchToRTL(false)
 #endif
 {
 }
 
-nsEditorEventListener::~nsEditorEventListener()
+EditorEventListener::~EditorEventListener()
 {
   if (mEditor) {
     NS_WARNING("We're not uninstalled");
     Disconnect();
   }
 }
 
 nsresult
-nsEditorEventListener::Connect(nsEditor* aEditor)
+EditorEventListener::Connect(nsEditor* aEditor)
 {
   NS_ENSURE_ARG(aEditor);
 
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();
   if (bidiKeyboard) {
     bool haveBidiKeyboards = false;
     bidiKeyboard->GetHaveBidiKeyboards(&haveBidiKeyboards);
@@ -136,17 +137,17 @@ nsEditorEventListener::Connect(nsEditor*
   nsresult rv = InstallToEditor();
   if (NS_FAILED(rv)) {
     Disconnect();
   }
   return rv;
 }
 
 nsresult
-nsEditorEventListener::InstallToEditor()
+EditorEventListener::InstallToEditor()
 {
   NS_PRECONDITION(mEditor, "The caller must set mEditor");
 
   nsCOMPtr<EventTarget> piTarget = mEditor->GetDOMEventTarget();
   NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
 
   // register the event listeners with the listener manager
   EventListenerManager* elmP = piTarget->GetOrCreateListenerManager();
@@ -206,17 +207,17 @@ nsEditorEventListener::InstallToEditor()
   elmP->AddEventListenerByType(this,
                                NS_LITERAL_STRING("compositionend"),
                                TrustedEventsAtSystemGroupBubble());
 
   return NS_OK;
 }
 
 void
-nsEditorEventListener::Disconnect()
+EditorEventListener::Disconnect()
 {
   if (!mEditor) {
     return;
   }
   UninstallFromEditor();
 
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm) {
@@ -231,17 +232,17 @@ nsEditorEventListener::Disconnect()
       mEditor->FinalizeSelection();
     }
   }
 
   mEditor = nullptr;
 }
 
 void
-nsEditorEventListener::UninstallFromEditor()
+EditorEventListener::UninstallFromEditor()
 {
   nsCOMPtr<EventTarget> piTarget = mEditor->GetDOMEventTarget();
   if (!piTarget) {
     return;
   }
 
   EventListenerManager* elmP = piTarget->GetOrCreateListenerManager();
   if (!elmP) {
@@ -293,32 +294,32 @@ nsEditorEventListener::UninstallFromEdit
                                   NS_LITERAL_STRING("compositionstart"),
                                   TrustedEventsAtSystemGroupBubble());
   elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("compositionend"),
                                   TrustedEventsAtSystemGroupBubble());
 }
 
 already_AddRefed<nsIPresShell>
-nsEditorEventListener::GetPresShell()
+EditorEventListener::GetPresShell()
 {
   NS_PRECONDITION(mEditor,
     "The caller must check whether this is connected to an editor");
   return mEditor->GetPresShell();
 }
 
 nsPresContext*
-nsEditorEventListener::GetPresContext()
+EditorEventListener::GetPresContext()
 {
   nsCOMPtr<nsIPresShell> presShell = GetPresShell();
   return presShell ? presShell->GetPresContext() : nullptr;
 }
 
 nsIContent*
-nsEditorEventListener::GetFocusedRootContent()
+EditorEventListener::GetFocusedRootContent()
 {
   NS_ENSURE_TRUE(mEditor, nullptr);
 
   nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContent();
   if (!focusedContent) {
     return nullptr;
   }
 
@@ -328,40 +329,32 @@ nsEditorEventListener::GetFocusedRootCon
   if (composedDoc->HasFlag(NODE_IS_EDITABLE)) {
     return nullptr;
   }
 
   return focusedContent;
 }
 
 bool
-nsEditorEventListener::EditorHasFocus()
+EditorEventListener::EditorHasFocus()
 {
   NS_PRECONDITION(mEditor,
     "The caller must check whether this is connected to an editor");
   nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContent();
   if (!focusedContent) {
     return false;
   }
   nsIDocument* composedDoc = focusedContent->GetComposedDoc();
   return !!composedDoc;
 }
 
-/**
- *  nsISupports implementation
- */
-
-NS_IMPL_ISUPPORTS(nsEditorEventListener, nsIDOMEventListener)
-
-/**
- *  nsIDOMEventListener implementation
- */
+NS_IMPL_ISUPPORTS(EditorEventListener, nsIDOMEventListener)
 
 NS_IMETHODIMP
-nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
+EditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIEditor> kungFuDeathGrip = mEditor;
 
   WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
 
   // Let's handle each event with the message of the internal event of the
@@ -411,34 +404,34 @@ nsEditorEventListener::HandleEvent(nsIDO
     case eKeyPress: {
       nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
       return KeyPress(keyEvent);
     }
     // mousedown
     case eMouseDown: {
       nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
       NS_ENSURE_TRUE(mouseEvent, NS_OK);
-      // nsEditorEventListener may receive (1) all mousedown, mouseup and click
+      // EditorEventListener may receive (1) all mousedown, mouseup and click
       // events, (2) only mousedown event or (3) only mouseup event.
       // mMouseDownOrUpConsumedByIME is used only for ignoring click event if
       // preceding mousedown and/or mouseup event is consumed by IME.
       // Therefore, even if case #2 or case #3 occurs,
       // mMouseDownOrUpConsumedByIME is true here.  Therefore, we should always
       // overwrite it here.
       mMouseDownOrUpConsumedByIME = NotifyIMEOfMouseButtonEvent(mouseEvent);
       return mMouseDownOrUpConsumedByIME ? NS_OK : MouseDown(mouseEvent);
     }
     // mouseup
     case eMouseUp: {
       nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent);
       NS_ENSURE_TRUE(mouseEvent, NS_OK);
       // See above comment in the eMouseDown case, first.
       // This code assumes that case #1 is occuring.  However, if case #3 may
       // occurs after case #2 and the mousedown is consumed,
-      // mMouseDownOrUpConsumedByIME is true even though nsEditorEventListener
+      // mMouseDownOrUpConsumedByIME is true even though EditorEventListener
       // has not received the preceding mousedown event of this mouseup event.
       // So, mMouseDownOrUpConsumedByIME may be invalid here.  However,
       // this is not a matter because mMouseDownOrUpConsumedByIME is referred
       // only by eMouseClick case but click event is fired only in case #1.
       // So, before a click event is fired, mMouseDownOrUpConsumedByIME is
       // always initialized in the eMouseDown case if it's referred.
       if (NotifyIMEOfMouseButtonEvent(mouseEvent)) {
         mMouseDownOrUpConsumedByIME = true;
@@ -540,17 +533,17 @@ bool IsCtrlShiftPressed(nsIDOMKeyEvent* 
 }
 
 }
 
 // This logic is mostly borrowed from Chromium's
 // RenderWidgetHostViewWin::OnKeyEvent.
 
 nsresult
-nsEditorEventListener::KeyUp(nsIDOMKeyEvent* aKeyEvent)
+EditorEventListener::KeyUp(nsIDOMKeyEvent* aKeyEvent)
 {
   NS_ENSURE_TRUE(aKeyEvent, NS_OK);
 
   if (!mHaveBidiKeyboards) {
     return NS_OK;
   }
 
   uint32_t keyCode = 0;
@@ -562,17 +555,17 @@ nsEditorEventListener::KeyUp(nsIDOMKeyEv
       nsIPlaintextEditor::eEditorRightToLeft :
       nsIPlaintextEditor::eEditorLeftToRight);
     mShouldSwitchTextDirection = false;
   }
   return NS_OK;
 }
 
 nsresult
-nsEditorEventListener::KeyDown(nsIDOMKeyEvent* aKeyEvent)
+EditorEventListener::KeyDown(nsIDOMKeyEvent* aKeyEvent)
 {
   NS_ENSURE_TRUE(aKeyEvent, NS_OK);
 
   if (!mHaveBidiKeyboards) {
     return NS_OK;
   }
 
   uint32_t keyCode = 0;
@@ -587,17 +580,17 @@ nsEditorEventListener::KeyDown(nsIDOMKey
     // In case the user presses any other key besides Ctrl and Shift
     mShouldSwitchTextDirection = false;
   }
   return NS_OK;
 }
 #endif
 
 nsresult
-nsEditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
+EditorEventListener::KeyPress(nsIDOMKeyEvent* aKeyEvent)
 {
   NS_ENSURE_TRUE(aKeyEvent, NS_OK);
 
   if (!mEditor->IsAcceptableInputEvent(aKeyEvent->AsEvent())) {
     return NS_OK;
   }
 
   // DOM event handling happens in two passes, the client pass and the system
@@ -644,17 +637,17 @@ nsEditorEventListener::KeyPress(nsIDOMKe
                            *keyEvent, DoCommandCallback, doc);
   if (handled) {
     aKeyEvent->AsEvent()->PreventDefault();
   }
   return NS_OK;
 }
 
 nsresult
-nsEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
+EditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
 {
   // nothing to do if editor isn't editable or clicked on out of the editor.
   if (mEditor->IsReadonly() || mEditor->IsDisabled() ||
       !mEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
     return NS_OK;
   }
 
   // Notifies clicking on editor to IMEStateManager even when the event was
@@ -682,17 +675,17 @@ nsEditorEventListener::MouseClick(nsIDOM
   aMouseEvent->GetButton(&button);
   if (button == 1) {
     return HandleMiddleClickPaste(aMouseEvent);
   }
   return NS_OK;
 }
 
 nsresult
-nsEditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
+EditorEventListener::HandleMiddleClickPaste(nsIDOMMouseEvent* aMouseEvent)
 {
   if (!Preferences::GetBool("middlemouse.paste", false)) {
     // Middle click paste isn't enabled.
     return NS_OK;
   }
 
   // Set the selection to the point under the mouse cursor:
   nsCOMPtr<nsIDOMNode> parent;
@@ -742,18 +735,18 @@ nsEditorEventListener::HandleMiddleClick
   aMouseEvent->AsEvent()->StopPropagation();
   aMouseEvent->AsEvent()->PreventDefault();
 
   // We processed the event, whether drop/paste succeeded or not
   return NS_OK;
 }
 
 bool
-nsEditorEventListener::NotifyIMEOfMouseButtonEvent(
-                         nsIDOMMouseEvent* aMouseEvent)
+EditorEventListener::NotifyIMEOfMouseButtonEvent(
+                       nsIDOMMouseEvent* aMouseEvent)
 {
   if (!EditorHasFocus()) {
     return false;
   }
 
   bool defaultPrevented;
   nsresult rv = aMouseEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
   NS_ENSURE_SUCCESS(rv, false);
@@ -763,26 +756,26 @@ nsEditorEventListener::NotifyIMEOfMouseB
   nsPresContext* presContext = GetPresContext();
   NS_ENSURE_TRUE(presContext, false);
   return IMEStateManager::OnMouseButtonEventInEditor(presContext,
                                                      GetFocusedRootContent(),
                                                      aMouseEvent);
 }
 
 nsresult
-nsEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
+EditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
 {
   // FYI: This may be called by HTMLEditorEventListener::MouseDown() even
   //      when the event is not acceptable for committing composition.
   mEditor->ForceCompositionEnd();
   return NS_OK;
 }
 
 nsresult
-nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
+EditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
 {
   if (!mEditor->IsAcceptableInputEvent(aTextEvent)) {
     return NS_OK;
   }
 
   // if we are readonly or disabled, then do nothing.
   if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
     return NS_OK;
@@ -791,17 +784,17 @@ nsEditorEventListener::HandleText(nsIDOM
   return mEditor->UpdateIMEComposition(aTextEvent);
 }
 
 /**
  * Drag event implementation
  */
 
 nsresult
-nsEditorEventListener::DragEnter(nsIDOMDragEvent* aDragEvent)
+EditorEventListener::DragEnter(nsIDOMDragEvent* aDragEvent)
 {
   NS_ENSURE_TRUE(aDragEvent, NS_OK);
 
   nsCOMPtr<nsIPresShell> presShell = GetPresShell();
   NS_ENSURE_TRUE(presShell, NS_OK);
 
   if (!mCaret) {
     mCaret = new nsCaret();
@@ -814,17 +807,17 @@ nsEditorEventListener::DragEnter(nsIDOMD
   }
 
   presShell->SetCaret(mCaret);
 
   return DragOver(aDragEvent);
 }
 
 nsresult
-nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
+EditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
 {
   NS_ENSURE_TRUE(aDragEvent, NS_OK);
 
   nsCOMPtr<nsIDOMNode> parent;
   bool defaultPrevented;
   aDragEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
   if (defaultPrevented) {
     return NS_OK;
@@ -859,17 +852,17 @@ nsEditorEventListener::DragOver(nsIDOMDr
 
   if (mCaret) {
     mCaret->SetVisible(false);
   }
   return NS_OK;
 }
 
 void
-nsEditorEventListener::CleanupDragDropCaret()
+EditorEventListener::CleanupDragDropCaret()
 {
   if (!mCaret) {
     return;
   }
 
   mCaret->SetVisible(false);    // hide it, so that it turns off its timer
 
   nsCOMPtr<nsIPresShell> presShell = GetPresShell();
@@ -877,27 +870,27 @@ nsEditorEventListener::CleanupDragDropCa
     presShell->RestoreCaret();
   }
 
   mCaret->Terminate();
   mCaret = nullptr;
 }
 
 nsresult
-nsEditorEventListener::DragExit(nsIDOMDragEvent* aDragEvent)
+EditorEventListener::DragExit(nsIDOMDragEvent* aDragEvent)
 {
   NS_ENSURE_TRUE(aDragEvent, NS_OK);
 
   CleanupDragDropCaret();
 
   return NS_OK;
 }
 
 nsresult
-nsEditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
+EditorEventListener::Drop(nsIDOMDragEvent* aDragEvent)
 {
   NS_ENSURE_TRUE(aDragEvent, NS_OK);
 
   CleanupDragDropCaret();
 
   bool defaultPrevented;
   aDragEvent->AsEvent()->GetDefaultPrevented(&defaultPrevented);
   if (defaultPrevented) {
@@ -923,17 +916,17 @@ nsEditorEventListener::Drop(nsIDOMDragEv
   }
 
   aDragEvent->AsEvent()->StopPropagation();
   aDragEvent->AsEvent()->PreventDefault();
   return mEditor->InsertFromDrop(aDragEvent->AsEvent());
 }
 
 bool
-nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
+EditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
 {
   // if the target doc is read-only, we can't drop
   if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
     return false;
   }
 
   nsCOMPtr<nsIDOMDataTransfer> domDataTransfer;
   aEvent->GetDataTransfer(getter_AddRefs(domDataTransfer));
@@ -1025,38 +1018,38 @@ nsEditorEventListener::CanDrop(nsIDOMDra
       // Okay, now you can bail, we are over the orginal selection
       return false;
     }
   }
   return true;
 }
 
 nsresult
-nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
+EditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
 {
   if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
     return NS_OK;
   }
   WidgetCompositionEvent* compositionStart =
     aCompositionEvent->WidgetEventPtr()->AsCompositionEvent();
   return mEditor->BeginIMEComposition(compositionStart);
 }
 
 void
-nsEditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
+EditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent)
 {
   if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
     return;
   }
 
   mEditor->EndIMEComposition();
 }
 
 nsresult
-nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
+EditorEventListener::Focus(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(aEvent, NS_OK);
 
   // Don't turn on selection and caret when the editor is disabled.
   if (mEditor->IsDisabled()) {
     return NS_OK;
   }
 
@@ -1110,17 +1103,17 @@ nsEditorEventListener::Focus(nsIDOMEvent
   nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContentForIME();
   IMEStateManager::OnFocusInEditor(ps->GetPresContext(), focusedContent,
                                    mEditor);
 
   return NS_OK;
 }
 
 nsresult
-nsEditorEventListener::Blur(nsIDOMEvent* aEvent)
+EditorEventListener::Blur(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(aEvent, NS_OK);
 
   // check if something else is focused. If another element is focused, then
   // we should not change the selection.
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   NS_ENSURE_TRUE(fm, NS_OK);
 
@@ -1128,45 +1121,45 @@ nsEditorEventListener::Blur(nsIDOMEvent*
   fm->GetFocusedElement(getter_AddRefs(element));
   if (!element) {
     mEditor->FinalizeSelection();
   }
   return NS_OK;
 }
 
 void
-nsEditorEventListener::SpellCheckIfNeeded()
+EditorEventListener::SpellCheckIfNeeded()
 {
   // If the spell check skip flag is still enabled from creation time,
   // disable it because focused editors are allowed to spell check.
   uint32_t currentFlags = 0;
   mEditor->GetFlags(&currentFlags);
   if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck) {
     currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck;
     mEditor->SetFlags(currentFlags);
   }
 }
 
 bool
-nsEditorEventListener::IsFileControlTextBox()
+EditorEventListener::IsFileControlTextBox()
 {
   dom::Element* root = mEditor->GetRoot();
   if (!root || !root->ChromeOnlyAccess()) {
     return false;
   }
   nsIContent* parent = root->FindFirstNonChromeOnlyAccessContent();
   if (!parent || !parent->IsHTMLElement(nsGkAtoms::input)) {
     return false;
   }
   nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(parent);
   return formControl->GetType() == NS_FORM_INPUT_FILE;
 }
 
 bool
-nsEditorEventListener::ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent)
+EditorEventListener::ShouldHandleNativeKeyBindings(nsIDOMKeyEvent* aKeyEvent)
 {
   // Only return true if the target of the event is a desendant of the active
   // editing host in order to match the similar decision made in
   // nsXBLWindowKeyHandler.
   // Note that IsAcceptableInputEvent doesn't check for the active editing
   // host for keyboard events, otherwise this check would have been
   // unnecessary.  IsAcceptableInputEvent currently makes a similar check for
   // mouse events.
@@ -1192,8 +1185,10 @@ nsEditorEventListener::ShouldHandleNativ
 
   nsIContent* editingHost = htmlEditor->GetActiveEditingHost();
   if (!editingHost) {
     return false;
   }
 
   return nsContentUtils::ContentIsDescendantOf(targetContent, editingHost);
 }
+
+} // namespace mozilla
rename from editor/libeditor/nsEditorEventListener.h
rename to editor/libeditor/EditorEventListener.h
--- a/editor/libeditor/nsEditorEventListener.h
+++ b/editor/libeditor/EditorEventListener.h
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsEditorEventListener_h__
-#define nsEditorEventListener_h__
+#ifndef EditorEventListener_h
+#define EditorEventListener_h
 
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsIDOMEventListener.h"
 #include "nsISupportsImpl.h"
 #include "nscore.h"
 
 class nsCaret;
@@ -27,32 +27,34 @@ class nsPresContext;
 #undef KeyPress
 #endif
 
 #ifdef XP_WIN
 // On Windows, we support switching the text direction by pressing Ctrl+Shift
 #define HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
 #endif
 
-class nsEditorEventListener : public nsIDOMEventListener
+namespace mozilla {
+
+class EditorEventListener : public nsIDOMEventListener
 {
 public:
-  nsEditorEventListener();
+  EditorEventListener();
 
   virtual nsresult Connect(nsEditor* aEditor);
 
   void Disconnect();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
   void SpellCheckIfNeeded();
 
 protected:
-  virtual ~nsEditorEventListener();
+  virtual ~EditorEventListener();
 
   nsresult InstallToEditor();
   void UninstallFromEditor();
 
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   nsresult KeyDown(nsIDOMKeyEvent* aKeyEvent);
   nsresult KeyUp(nsIDOMKeyEvent* aKeyEvent);
 #endif
@@ -90,9 +92,11 @@ protected:
   bool mMouseDownOrUpConsumedByIME;
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   bool mHaveBidiKeyboards;
   bool mShouldSwitchTextDirection;
   bool mSwitchToRTL;
 #endif
 };
 
-#endif // nsEditorEventListener_h__
+} // namespace mozilla
+
+#endif // #ifndef EditorEventListener_h
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -35,17 +35,17 @@ using namespace dom;
 nsresult
 HTMLEditorEventListener::Connect(nsEditor* aEditor)
 {
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryObject(aEditor);
   nsCOMPtr<nsIHTMLInlineTableEditor> htmlInlineTableEditor =
     do_QueryObject(aEditor);
   NS_PRECONDITION(htmlEditor && htmlInlineTableEditor,
                   "Set nsHTMLEditor or its sub class");
-  return nsEditorEventListener::Connect(aEditor);
+  return EditorEventListener::Connect(aEditor);
 }
 #endif
 
 nsHTMLEditor*
 HTMLEditorEventListener::GetHTMLEditor()
 {
   // mEditor must be nsHTMLEditor or its subclass.
   return static_cast<nsHTMLEditor*>(mEditor);
@@ -62,31 +62,31 @@ HTMLEditorEventListener::MouseUp(nsIDOMM
   NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
 
   int32_t clientX, clientY;
   aMouseEvent->GetClientX(&clientX);
   aMouseEvent->GetClientY(&clientY);
   htmlEditor->MouseUp(clientX, clientY, element);
 
-  return nsEditorEventListener::MouseUp(aMouseEvent);
+  return EditorEventListener::MouseUp(aMouseEvent);
 }
 
 nsresult
 HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
 {
   nsHTMLEditor* htmlEditor = GetHTMLEditor();
   // Contenteditable should disregard mousedowns outside it.
   // IsAcceptableInputEvent() checks it for a mouse event.
   if (!htmlEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
     // If it's not acceptable mousedown event (including when mousedown event
     // is fired outside of the active editing host), we need to commit
     // composition because it will be change the selection to the clicked
     // point.  Then, we won't be able to commit the composition.
-    return nsEditorEventListener::MouseDown(aMouseEvent);
+    return EditorEventListener::MouseDown(aMouseEvent);
   }
 
   // Detect only "context menu" click
   // XXX This should be easier to do!
   // But eDOMEvents_contextmenu and eContextMenu is not exposed in any event
   // interface :-(
   int16_t buttonNumber;
   nsresult rv = aMouseEvent->GetButton(&buttonNumber);
@@ -192,26 +192,26 @@ HTMLEditorEventListener::MouseDown(nsIDO
   } else if (!isContextClick && buttonNumber == 0 && clickCount == 1) {
     // if the target element is an image, we have to display resizers
     int32_t clientX, clientY;
     aMouseEvent->GetClientX(&clientX);
     aMouseEvent->GetClientY(&clientY);
     htmlEditor->MouseDown(clientX, clientY, element, aMouseEvent->AsEvent());
   }
 
-  return nsEditorEventListener::MouseDown(aMouseEvent);
+  return EditorEventListener::MouseDown(aMouseEvent);
 }
 
 nsresult
 HTMLEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
 {
   nsCOMPtr<nsIDOMEventTarget> target;
   nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
 
   GetHTMLEditor()->DoInlineTableEditingAction(element);
 
-  return nsEditorEventListener::MouseClick(aMouseEvent);
+  return EditorEventListener::MouseClick(aMouseEvent);
 }
 
 } // namespace mozilla
--- a/editor/libeditor/HTMLEditorEventListener.h
+++ b/editor/libeditor/HTMLEditorEventListener.h
@@ -1,25 +1,25 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef HTMLEditorEventListener_h
 #define HTMLEditorEventListener_h
 
-#include "nsEditorEventListener.h"
+#include "EditorEventListener.h"
 #include "nscore.h"
 
 class nsEditor;
 class nsHTMLEditor;
 
 namespace mozilla {
 
-class HTMLEditorEventListener final : public nsEditorEventListener
+class HTMLEditorEventListener final : public EditorEventListener
 {
 public:
   HTMLEditorEventListener()
   {
   }
 
   virtual ~HTMLEditorEventListener()
   {
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -31,28 +31,28 @@ UNIFIED_SOURCES += [
     'CreateElementTransaction.cpp',
     'CSSEditUtils.cpp',
     'DeleteNodeTransaction.cpp',
     'DeleteRangeTransaction.cpp',
     'DeleteTextTransaction.cpp',
     'EditAggregateTransaction.cpp',
     'EditorCommands.cpp',
     'EditorController.cpp',
+    'EditorEventListener.cpp',
     'EditorUtils.cpp',
     'EditTransactionBase.cpp',
     'HTMLEditorEventListener.cpp',
     'HTMLEditRules.cpp',
     'HTMLEditUtils.cpp',
     'HTMLURIRefObject.cpp',
     'InsertNodeTransaction.cpp',
     'InsertTextTransaction.cpp',
     'InternetCiter.cpp',
     'JoinNodeTransaction.cpp',
     'nsEditor.cpp',
-    'nsEditorEventListener.cpp',
     'nsHTMLAbsPosition.cpp',
     'nsHTMLAnonymousUtils.cpp',
     'nsHTMLDataTransfer.cpp',
     'nsHTMLEditor.cpp',
     'nsHTMLEditorStyle.cpp',
     'nsHTMLInlineTableEditor.cpp',
     'nsHTMLObjectResizer.cpp',
     'nsPlaintextDataTransfer.cpp',
--- a/editor/libeditor/nsEditor.cpp
+++ b/editor/libeditor/nsEditor.cpp
@@ -12,16 +12,17 @@
 
 #include "ChangeAttributeTransaction.h" // for ChangeAttributeTransaction
 #include "CompositionTransaction.h"     // for CompositionTransaction
 #include "CreateElementTransaction.h"   // for CreateElementTransaction
 #include "DeleteNodeTransaction.h"      // for DeleteNodeTransaction
 #include "DeleteRangeTransaction.h"     // for DeleteRangeTransaction
 #include "DeleteTextTransaction.h"      // for DeleteTextTransaction
 #include "EditAggregateTransaction.h"   // for EditAggregateTransaction
+#include "EditorEventListener.h"        // for EditorEventListener
 #include "EditorUtils.h"                // for AutoRules, etc
 #include "EditTransactionBase.h"        // for EditTransactionBase
 #include "InsertNodeTransaction.h"      // for InsertNodeTransaction
 #include "InsertTextTransaction.h"      // for InsertTextTransaction
 #include "JoinNodeTransaction.h"        // for JoinNodeTransaction
 #include "PlaceholderTransaction.h"     // for PlaceholderTransaction
 #include "SplitNodeTransaction.h"       // for SplitNodeTransaction
 #include "StyleSheetTransactions.h"     // for AddStyleSheetTransaction, etc
@@ -44,17 +45,16 @@
 #include "nsCaret.h"                    // for nsCaret
 #include "nsCaseTreatment.h"
 #include "nsCharTraits.h"               // for NS_IS_HIGH_SURROGATE, etc
 #include "nsComponentManagerUtils.h"    // for do_CreateInstance
 #include "nsComputedDOMStyle.h"         // for nsComputedDOMStyle
 #include "nsContentUtils.h"             // for nsContentUtils
 #include "nsDOMString.h"                // for DOMStringIsNull
 #include "nsDebug.h"                    // for NS_ENSURE_TRUE, etc
-#include "nsEditorEventListener.h"      // for nsEditorEventListener
 #include "nsError.h"                    // for NS_OK, etc
 #include "nsFocusManager.h"             // for nsFocusManager
 #include "nsFrameSelection.h"           // for nsFrameSelection
 #include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::dir
 #include "nsIAbsorbingTransaction.h"    // for nsIAbsorbingTransaction
 #include "nsIAtom.h"                    // for nsIAtom
 #include "nsIContent.h"                 // for nsIContent
 #include "nsIDOMAttr.h"                 // for nsIDOMAttr
@@ -313,18 +313,18 @@ nsEditor::PostCreate()
     nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(focusedContent);
     if (target) {
       InitializeSelection(target);
     }
 
     // If the text control gets reframed during focus, Focus() would not be
     // called, so take a chance here to see if we need to spell check the text
     // control.
-    nsEditorEventListener* listener =
-      reinterpret_cast<nsEditorEventListener*> (mEventListener.get());
+    EditorEventListener* listener =
+      reinterpret_cast<EditorEventListener*>(mEventListener.get());
     listener->SpellCheckIfNeeded();
 
     IMEState newState;
     rv = GetPreferredIMEState(&newState);
     NS_ENSURE_SUCCESS(rv, NS_OK);
     nsCOMPtr<nsIContent> content = GetFocusedContentForIME();
     IMEStateManager::UpdateIMEState(newState, content, this);
   }
@@ -336,49 +336,49 @@ nsEditor::PostCreate()
 }
 
 /* virtual */
 void
 nsEditor::CreateEventListeners()
 {
   // Don't create the handler twice
   if (!mEventListener) {
-    mEventListener = new nsEditorEventListener();
+    mEventListener = new EditorEventListener();
   }
 }
 
 nsresult
 nsEditor::InstallEventListeners()
 {
   NS_ENSURE_TRUE(mDocWeak && mEventListener,
                  NS_ERROR_NOT_INITIALIZED);
 
   // Initialize the event target.
   nsCOMPtr<nsIContent> rootContent = GetRoot();
   NS_ENSURE_TRUE(rootContent, NS_ERROR_NOT_AVAILABLE);
   mEventTarget = do_QueryInterface(rootContent->GetParent());
   NS_ENSURE_TRUE(mEventTarget, NS_ERROR_NOT_AVAILABLE);
 
-  nsEditorEventListener* listener =
-    reinterpret_cast<nsEditorEventListener*>(mEventListener.get());
+  EditorEventListener* listener =
+    reinterpret_cast<EditorEventListener*>(mEventListener.get());
   nsresult rv = listener->Connect(this);
   if (mComposition) {
     // Restart to handle composition with new editor contents.
     mComposition->StartHandlingComposition(this);
   }
   return rv;
 }
 
 void
 nsEditor::RemoveEventListeners()
 {
   if (!mDocWeak || !mEventListener) {
     return;
   }
-  reinterpret_cast<nsEditorEventListener*>(mEventListener.get())->Disconnect();
+  reinterpret_cast<EditorEventListener*>(mEventListener.get())->Disconnect();
   if (mComposition) {
     // Even if this is called, don't release mComposition because this is
     // may be reused after reframing.
     mComposition->EndHandlingComposition(this);
   }
   mEventTarget = nullptr;
 }
 
--- a/editor/libeditor/nsEditor.h
+++ b/editor/libeditor/nsEditor.h
@@ -786,17 +786,17 @@ public:
   // element in the document has focus.
   virtual already_AddRefed<nsIContent> FindSelectionRoot(nsINode* aNode);
 
   // Initializes selection and caret for the editor.  If aEventTarget isn't
   // a host of the editor, i.e., the editor doesn't get focus, this does
   // nothing.
   nsresult InitializeSelection(nsIDOMEventTarget* aFocusEventTarget);
 
-  // This method has to be called by nsEditorEventListener::Focus.
+  // This method has to be called by EditorEventListener::Focus.
   // All actions that have to be done when the editor is focused needs to be
   // added here.
   void OnFocus(nsIDOMEventTarget* aFocusEventTarget);
 
   // Used to insert content from a data transfer into the editable area.
   // This is called for each item in the data transfer, with the index of
   // each item passed as aIndex.
   virtual nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -18,17 +18,16 @@
 #include "nsCSSKeywords.h"
 #include "nsCSSParser.h"
 #include "nsCSSProps.h"
 #include "nsCSSPseudoClasses.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSRendering.h"
 #include "mozilla/dom/Attr.h"
 #include "nsDOMClassInfo.h"
-#include "nsEditorEventListener.h"
 #include "mozilla/EventListenerManager.h"
 #include "nsFrame.h"
 #include "nsGlobalWindow.h"
 #include "nsGkAtoms.h"
 #include "nsImageFrame.h"
 #include "nsLayoutStylesheetCache.h"
 #include "mozilla/RuleProcessorCache.h"
 #include "nsPrincipal.h"