From 63489b425b973bfe25e5a8e2c8840f462f4c33f1 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Tue, 26 Aug 2014 09:57:45 +0900 Subject: [PATCH] Bug 1056545 part.1 Make event handlers of ns*EditorEventListener protected and virtual as far as possible r=ehsan --- editor/libeditor/nsEditorEventListener.cpp | 18 +++++------ editor/libeditor/nsEditorEventListener.h | 31 +++++++++---------- .../libeditor/nsHTMLEditorEventListener.cpp | 6 ++-- editor/libeditor/nsHTMLEditorEventListener.h | 8 ++--- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/editor/libeditor/nsEditorEventListener.cpp b/editor/libeditor/nsEditorEventListener.cpp index f009467ddf0..dc08c816aca 100644 --- a/editor/libeditor/nsEditorEventListener.cpp +++ b/editor/libeditor/nsEditorEventListener.cpp @@ -422,7 +422,7 @@ bool IsCtrlShiftPressed(bool& isRTL) // This logic is mostly borrowed from Chromium's // RenderWidgetHostViewWin::OnKeyEvent. -NS_IMETHODIMP +nsresult nsEditorEventListener::KeyUp(nsIDOMEvent* aKeyEvent) { if (mHaveBidiKeyboards) { @@ -448,7 +448,7 @@ nsEditorEventListener::KeyUp(nsIDOMEvent* aKeyEvent) return NS_OK; } -NS_IMETHODIMP +nsresult nsEditorEventListener::KeyDown(nsIDOMEvent* aKeyEvent) { if (mHaveBidiKeyboards) { @@ -476,7 +476,7 @@ nsEditorEventListener::KeyDown(nsIDOMEvent* aKeyEvent) } #endif -NS_IMETHODIMP +nsresult nsEditorEventListener::KeyPress(nsIDOMEvent* aKeyEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -538,7 +538,7 @@ nsEditorEventListener::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; } -NS_IMETHODIMP +nsresult nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -634,7 +634,7 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent) return NS_OK; } -NS_IMETHODIMP +nsresult nsEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -642,7 +642,7 @@ nsEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent) return NS_OK; } -NS_IMETHODIMP +nsresult nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -868,7 +868,7 @@ nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent) return true; } -NS_IMETHODIMP +nsresult nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -891,7 +891,7 @@ nsEditorEventListener::HandleEndComposition(nsIDOMEvent* aCompositionEvent) mEditor->EndIMEComposition(); } -NS_IMETHODIMP +nsresult nsEditorEventListener::Focus(nsIDOMEvent* aEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -949,7 +949,7 @@ nsEditorEventListener::Focus(nsIDOMEvent* aEvent) return NS_OK; } -NS_IMETHODIMP +nsresult nsEditorEventListener::Blur(nsIDOMEvent* aEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); diff --git a/editor/libeditor/nsEditorEventListener.h b/editor/libeditor/nsEditorEventListener.h index 2b80e23bae4..4a35edbdf04 100644 --- a/editor/libeditor/nsEditorEventListener.h +++ b/editor/libeditor/nsEditorEventListener.h @@ -42,20 +42,6 @@ public: 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: @@ -64,18 +50,31 @@ protected: 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 GetPresShell(); bool IsFileControlTextBox(); bool ShouldHandleNativeKeyBindings(nsIDOMEvent* aKeyEvent); -protected: nsEditor* mEditor; // weak nsRefPtr mCaret; bool mCommitText; diff --git a/editor/libeditor/nsHTMLEditorEventListener.cpp b/editor/libeditor/nsHTMLEditorEventListener.cpp index 7188472a0b6..4cec4cc1097 100644 --- a/editor/libeditor/nsHTMLEditorEventListener.cpp +++ b/editor/libeditor/nsHTMLEditorEventListener.cpp @@ -48,7 +48,7 @@ nsHTMLEditorEventListener::GetHTMLEditor() return static_cast(mEditor); } -NS_IMETHODIMP +nsresult nsHTMLEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -75,7 +75,7 @@ nsHTMLEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent) return nsEditorEventListener::MouseUp(aMouseEvent); } -NS_IMETHODIMP +nsresult nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); @@ -220,7 +220,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent) return nsEditorEventListener::MouseDown(aMouseEvent); } -NS_IMETHODIMP +nsresult nsHTMLEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent) { NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE); diff --git a/editor/libeditor/nsHTMLEditorEventListener.h b/editor/libeditor/nsHTMLEditorEventListener.h index 9546c3d0734..2850d86d52a 100644 --- a/editor/libeditor/nsHTMLEditorEventListener.h +++ b/editor/libeditor/nsHTMLEditorEventListener.h @@ -30,11 +30,11 @@ public: 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; + inline nsHTMLEditor* GetHTMLEditor(); };