Bug 1056545 part.1 Make event handlers of ns*EditorEventListener protected and virtual as far as possible r=ehsan
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 26 Aug 2014 09:57:45 +0900
changeset 223230 ea2c4929d8d4a2e98e70faf99a8f8f9516d947a6
parent 223229 e1174da6b7078a99c67f439f178e8558ba5c8473
child 223231 c2c4c70d0be36493b7736d4981b47e3c3fb9bac4
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1056545
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1056545 part.1 Make event handlers of ns*EditorEventListener protected and virtual as far as possible r=ehsan
editor/libeditor/nsEditorEventListener.cpp
editor/libeditor/nsEditorEventListener.h
editor/libeditor/nsHTMLEditorEventListener.cpp
editor/libeditor/nsHTMLEditorEventListener.h
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -417,17 +417,17 @@ bool IsCtrlShiftPressed(bool& isRTL)
   return true;
 }
 
 }
 
 // This logic is mostly borrowed from Chromium's
 // RenderWidgetHostViewWin::OnKeyEvent.
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::KeyUp(nsIDOMEvent* aKeyEvent)
 {
   if (mHaveBidiKeyboards) {
     nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
     if (!keyEvent) {
       // non-key event passed to keyup.  bad things.
       return NS_OK;
     }
@@ -443,17 +443,17 @@ nsEditorEventListener::KeyUp(nsIDOMEvent
         mShouldSwitchTextDirection = false;
       }
     }
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::KeyDown(nsIDOMEvent* aKeyEvent)
 {
   if (mHaveBidiKeyboards) {
     nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
     if (!keyEvent) {
       // non-key event passed to keydown.  bad things.
       return NS_OK;
     }
@@ -471,17 +471,17 @@ nsEditorEventListener::KeyDown(nsIDOMEve
       mShouldSwitchTextDirection = false;
     }
   }
 
   return NS_OK;
 }
 #endif
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::KeyPress(nsIDOMEvent* aKeyEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   if (!mEditor->IsAcceptableInputEvent(aKeyEvent)) {
     return NS_OK;
   }
 
@@ -533,17 +533,17 @@ nsEditorEventListener::KeyPress(nsIDOMEv
     if (handled) {
       aKeyEvent->PreventDefault();
     }
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
   NS_ENSURE_TRUE(mouseEvent, NS_OK);
 
   // nothing to do if editor isn't editable or clicked on out of the editor.
@@ -629,25 +629,25 @@ nsEditorEventListener::MouseClick(nsIDOM
 
       // We processed the event, whether drop/paste succeeded or not
       return NS_OK;
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   mEditor->ForceCompositionEnd();
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   if (!mEditor->IsAcceptableInputEvent(aTextEvent)) {
     return NS_OK;
   }
 
@@ -863,17 +863,17 @@ nsEditorEventListener::CanDrop(nsIDOMDra
           return false;  //okay, now you can bail, we are over the orginal selection
       }
     }
   }
   
   return true;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
     return NS_OK;
   }
   WidgetCompositionEvent* compositionStart =
     aCompositionEvent->GetInternalNSEvent()->AsCompositionEvent();
@@ -886,17 +886,17 @@ nsEditorEventListener::HandleEndComposit
   MOZ_ASSERT(mEditor);
   if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
     return;
   }
 
   mEditor->EndIMEComposition();
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_ARG(aEvent);
 
   // Don't turn on selection and caret when the editor is disabled.
   if (mEditor->IsDisabled()) {
     return NS_OK;
@@ -944,17 +944,17 @@ nsEditorEventListener::Focus(nsIDOMEvent
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
   NS_ENSURE_TRUE(ps, NS_OK);
   nsCOMPtr<nsIContent> focusedContent = mEditor->GetFocusedContentForIME();
   IMEStateManager::OnFocusInEditor(ps->GetPresContext(), focusedContent);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 nsEditorEventListener::Blur(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_ARG(aEvent);
 
   // check if something else is focused. If another element is focused, then
   // we should not change the selection.
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
--- a/editor/libeditor/nsEditorEventListener.h
+++ b/editor/libeditor/nsEditorEventListener.h
@@ -37,50 +37,49 @@ public:
 
   virtual nsresult Connect(nsEditor* aEditor);
 
   void Disconnect();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
-#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
-  NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
-#endif
-  NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
-  NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
-  void       HandleEndComposition(nsIDOMEvent* aCompositionEvent);
-  NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }
-  NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD Focus(nsIDOMEvent* aEvent);
-  NS_IMETHOD Blur(nsIDOMEvent* aEvent);
-
   void SpellCheckIfNeeded();
 
 protected:
   virtual ~nsEditorEventListener();
 
   nsresult InstallToEditor();
   void UninstallFromEditor();
 
-  bool CanDrop(nsIDOMDragEvent* aEvent);
+#ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
+  nsresult KeyDown(nsIDOMEvent* aKeyEvent);
+  nsresult KeyUp(nsIDOMEvent* aKeyEvent);
+#endif
+  nsresult KeyPress(nsIDOMEvent* aKeyEvent);
+  nsresult HandleText(nsIDOMEvent* aTextEvent);
+  nsresult HandleStartComposition(nsIDOMEvent* aCompositionEvent);
+  void HandleEndComposition(nsIDOMEvent* aCompositionEvent);
+  virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
+  virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }
+  virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent);
+  nsresult Focus(nsIDOMEvent* aEvent);
+  nsresult Blur(nsIDOMEvent* aEvent);
   nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
   nsresult DragOver(nsIDOMDragEvent* aDragEvent);
   nsresult DragExit(nsIDOMDragEvent* aDragEvent);
   nsresult Drop(nsIDOMDragEvent* aDragEvent);
   nsresult DragGesture(nsIDOMDragEvent* aDragEvent);
+
+  bool CanDrop(nsIDOMDragEvent* aEvent);
   void CleanupDragDropCaret();
   already_AddRefed<nsIPresShell> GetPresShell();
   bool IsFileControlTextBox();
   bool ShouldHandleNativeKeyBindings(nsIDOMEvent* aKeyEvent);
 
-protected:
   nsEditor* mEditor; // weak
   nsRefPtr<nsCaret> mCaret;
   bool mCommitText;
   bool mInTransaction;
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
   bool mHaveBidiKeyboards;
   bool mShouldSwitchTextDirection;
   bool mSwitchToRTL;
--- a/editor/libeditor/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/nsHTMLEditorEventListener.cpp
@@ -43,17 +43,17 @@ nsHTMLEditorEventListener::Connect(nsEdi
 
 nsHTMLEditor*
 nsHTMLEditorEventListener::GetHTMLEditor()
 {
   // mEditor must be nsHTMLEditor or its subclass.
   return static_cast<nsHTMLEditor*>(mEditor);
 }
 
-NS_IMETHODIMP
+nsresult
 nsHTMLEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
@@ -70,17 +70,17 @@ nsHTMLEditorEventListener::MouseUp(nsIDO
   int32_t clientX, clientY;
   mouseEvent->GetClientX(&clientX);
   mouseEvent->GetClientY(&clientY);
   htmlEditor->MouseUp(clientX, clientY, element);
 
   return nsEditorEventListener::MouseUp(aMouseEvent);
 }
 
-NS_IMETHODIMP
+nsresult
 nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
@@ -215,17 +215,17 @@ nsHTMLEditorEventListener::MouseDown(nsI
     mouseEvent->GetClientX(&clientX);
     mouseEvent->GetClientY(&clientY);
     htmlEditor->MouseDown(clientX, clientY, element, aMouseEvent);
   }
 
   return nsEditorEventListener::MouseDown(aMouseEvent);
 }
 
-NS_IMETHODIMP
+nsresult
 nsHTMLEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
--- a/editor/libeditor/nsHTMLEditorEventListener.h
+++ b/editor/libeditor/nsHTMLEditorEventListener.h
@@ -25,18 +25,18 @@ public:
   {
   }
 
 #ifdef DEBUG
   // WARNING: You must be use nsHTMLEditor or its sub class for this class.
   virtual nsresult Connect(nsEditor* aEditor);
 #endif
 
-  NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
+protected:
+  virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent) MOZ_OVERRIDE;
+  virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent) MOZ_OVERRIDE;
+  virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent) MOZ_OVERRIDE;
 
-protected:
   inline nsHTMLEditor* GetHTMLEditor();
 };
 
 #endif // nsHTMLEditorEventListener_h__