Bug 1455055 part 7. Clean up remaining HandleEvent implementations. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 00:49:30 -0400
changeset 468266 966c8536f1bda8ea929e552ee3a3e79331a33bdf
parent 468265 491b4ebcc48a57315d0e19b31e99d8a62f911f5e
child 468267 8b18a3c2beafed5be581528fb3d8a04713d6ced3
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1455055
milestone61.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 1455055 part 7. Clean up remaining HandleEvent implementations. r=masayuki MozReview-Commit-ID: LezJYKK74H5
browser/components/sessionstore/nsSessionStoreUtils.cpp
docshell/base/nsDocShellTreeOwner.cpp
editor/libeditor/EditorEventListener.cpp
editor/libeditor/HTMLEditorObjectResizer.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
extensions/spellcheck/src/mozInlineSpellChecker.h
toolkit/components/satchel/nsFormFillController.cpp
toolkit/components/satchel/nsFormFillController.h
widget/tests/TestAppShellSteadyState.cpp
--- a/browser/components/sessionstore/nsSessionStoreUtils.cpp
+++ b/browser/components/sessionstore/nsSessionStoreUtils.cpp
@@ -23,28 +23,28 @@ public:
 
   explicit DynamicFrameEventFilter(EventListener* aListener)
     : mListener(aListener)
   { }
 
   NS_IMETHODIMP HandleEvent(Event* aEvent) override
   {
     if (mListener && TargetInNonDynamicDocShell(aEvent)) {
-      mListener->HandleEvent(*aEvent->InternalDOMEvent());
+      mListener->HandleEvent(*aEvent);
     }
 
     return NS_OK;
   }
 
 private:
   ~DynamicFrameEventFilter() { }
 
-  bool TargetInNonDynamicDocShell(nsIDOMEvent* aEvent)
+  bool TargetInNonDynamicDocShell(Event* aEvent)
   {
-    EventTarget* target = aEvent->InternalDOMEvent()->GetTarget();
+    EventTarget* target = aEvent->GetTarget();
     if (!target) {
       return false;
     }
 
     nsPIDOMWindowOuter* outer = target->GetOwnerGlobalForBindings();
     if (!outer) {
       return false;
     }
--- a/docshell/base/nsDocShellTreeOwner.cpp
+++ b/docshell/base/nsDocShellTreeOwner.cpp
@@ -921,18 +921,17 @@ nsDocShellTreeOwner::RemoveChromeListene
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShellTreeOwner::HandleEvent(Event* aEvent)
 {
-  DragEvent* dragEvent =
-    aEvent ? aEvent->InternalDOMEvent()->AsDragEvent() : nullptr;
+  DragEvent* dragEvent = aEvent ? aEvent->AsDragEvent() : nullptr;
   if (NS_WARN_IF(!dragEvent)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (dragEvent->DefaultPrevented()) {
     return NS_OK;
   }
 
--- a/editor/libeditor/EditorEventListener.cpp
+++ b/editor/libeditor/EditorEventListener.cpp
@@ -376,29 +376,29 @@ EditorEventListener::HandleEvent(Event* 
   // NOTE: Each event handler may require specific event interface.  Before
   //       calling it, this queries the specific interface.  If it would fail,
   //       each event handler would just ignore the event.  So, in this method,
   //       you don't need to check if the QI succeeded before each call.
   WidgetEvent* internalEvent = aEvent->WidgetEventPtr();
   switch (internalEvent->mMessage) {
     // dragenter
     case eDragEnter: {
-      return DragEnter(aEvent->InternalDOMEvent()->AsDragEvent());
+      return DragEnter(aEvent->AsDragEvent());
     }
     // dragover
     case eDragOver: {
-      return DragOver(aEvent->InternalDOMEvent()->AsDragEvent());
+      return DragOver(aEvent->AsDragEvent());
     }
     // dragexit
     case eDragExit: {
-      return DragExit(aEvent->InternalDOMEvent()->AsDragEvent());
+      return DragExit(aEvent->AsDragEvent());
     }
     // drop
     case eDrop: {
-      return Drop(aEvent->InternalDOMEvent()->AsDragEvent());
+      return Drop(aEvent->AsDragEvent());
     }
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
     // keydown
     case eKeyDown: {
       return KeyDown(internalEvent->AsKeyboardEvent());
     }
     // keyup
     case eKeyUp:
@@ -416,17 +416,17 @@ EditorEventListener::HandleEvent(Event* 
       // Therefore, even if case #2 or case #3 occurs,
       // mMouseDownOrUpConsumedByIME is true here.  Therefore, we should always
       // overwrite it here.
       mMouseDownOrUpConsumedByIME =
         NotifyIMEOfMouseButtonEvent(internalEvent->AsMouseEvent());
       if (mMouseDownOrUpConsumedByIME) {
         return NS_OK;
       }
-      MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+      MouseEvent* mouseEvent = aEvent->AsMouseEvent();
       return NS_WARN_IF(!mouseEvent) ? NS_OK : MouseDown(mouseEvent);
     }
     // mouseup
     case eMouseUp: {
       // 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 EditorEventListener
@@ -437,22 +437,22 @@ EditorEventListener::HandleEvent(Event* 
       // So, before a click event is fired, mMouseDownOrUpConsumedByIME is
       // always initialized in the eMouseDown case if it's referred.
       if (NotifyIMEOfMouseButtonEvent(internalEvent->AsMouseEvent())) {
         mMouseDownOrUpConsumedByIME = true;
       }
       if (mMouseDownOrUpConsumedByIME) {
         return NS_OK;
       }
-      MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+      MouseEvent* mouseEvent = aEvent->AsMouseEvent();
       return NS_WARN_IF(!mouseEvent) ? NS_OK : MouseUp(mouseEvent);
     }
     // click
     case eMouseClick: {
-      MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+      MouseEvent* mouseEvent = aEvent->AsMouseEvent();
       NS_ENSURE_TRUE(mouseEvent, NS_OK);
       // If the preceding mousedown event or mouseup event was consumed,
       // editor shouldn't handle this click event.
       if (mMouseDownOrUpConsumedByIME) {
         mMouseDownOrUpConsumedByIME = false;
         mouseEvent->PreventDefault();
         return NS_OK;
       }
--- a/editor/libeditor/HTMLEditorObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -73,17 +73,17 @@ NS_IMPL_ISUPPORTS(ResizerMouseMotionList
 ResizerMouseMotionListener::ResizerMouseMotionListener(HTMLEditor& aHTMLEditor)
   : mHTMLEditorWeak(&aHTMLEditor)
 {
 }
 
 NS_IMETHODIMP
 ResizerMouseMotionListener::HandleEvent(Event* aMouseEvent)
 {
-  MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
   }
 
   // Don't do anything special if not an HTML object resizer editor
   RefPtr<HTMLEditor> htmlEditor = mHTMLEditorWeak.get();
   if (htmlEditor) {
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1848,40 +1848,39 @@ mozInlineSpellChecker::HandleEvent(Event
   if (eventType.EqualsLiteral("keypress")) {
     return OnKeyPress(aEvent);
   }
 
   return NS_OK;
 }
 
 nsresult
-mozInlineSpellChecker::OnBlur(nsIDOMEvent* aEvent)
+mozInlineSpellChecker::OnBlur(Event* aEvent)
 {
   // force spellcheck on blur, for instance when tabbing out of a textbox
   HandleNavigationEvent(true);
   return NS_OK;
 }
 
 nsresult
-mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent)
+mozInlineSpellChecker::OnMouseClick(Event *aMouseEvent)
 {
-  MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
   NS_ENSURE_TRUE(mouseEvent, NS_OK);
 
   // ignore any errors from HandleNavigationEvent as we don't want to prevent
   // anyone else from seeing this event.
   HandleNavigationEvent(mouseEvent->Button() != 0);
   return NS_OK;
 }
 
 nsresult
-mozInlineSpellChecker::OnKeyPress(nsIDOMEvent* aKeyEvent)
+mozInlineSpellChecker::OnKeyPress(Event* aKeyEvent)
 {
-  RefPtr<KeyboardEvent> keyEvent =
-    aKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
+  RefPtr<KeyboardEvent> keyEvent = aKeyEvent->AsKeyboardEvent();
   NS_ENSURE_TRUE(keyEvent, NS_OK);
 
   uint32_t keyCode = keyEvent->KeyCode();
 
   // we only care about navigation keys that moved selection
   switch (keyCode)
   {
     case KeyboardEventBinding::DOM_VK_RIGHT:
--- a/extensions/spellcheck/src/mozInlineSpellChecker.h
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.h
@@ -19,16 +19,20 @@ class mozInlineSpellChecker;
 class mozISpellI18NUtil;
 class mozInlineSpellResume;
 class UpdateCurrentDictionaryCallback;
 
 namespace mozilla {
 class EditorSpellCheck;
 class TextEditor;
 enum class EditAction : int32_t;
+
+namespace dom {
+class Event;
+} // namespace dom
 } // namespace mozilla
 
 class mozInlineSpellStatus
 {
 public:
   explicit mozInlineSpellStatus(mozInlineSpellChecker* aSpellChecker);
 
   nsresult InitForEditorChange(mozilla::EditAction aAction,
@@ -185,19 +189,19 @@ public:
 
   mozilla::EditorSpellCheck* GetEditorSpellCheck();
 
   // returns true if there are any spell checking dictionaries available
   static bool CanEnableInlineSpellChecking();
   // update the cached value whenever the list of available dictionaries changes
   static void UpdateCanEnableInlineSpellChecking();
 
-  nsresult OnBlur(nsIDOMEvent* aEvent);
-  nsresult OnMouseClick(nsIDOMEvent* aMouseEvent);
-  nsresult OnKeyPress(nsIDOMEvent* aKeyEvent);
+  nsresult OnBlur(mozilla::dom::Event* aEvent);
+  nsresult OnMouseClick(mozilla::dom::Event* aMouseEvent);
+  nsresult OnKeyPress(mozilla::dom::Event* aKeyEvent);
 
   mozInlineSpellChecker();
 
   // spell checks all of the words between two nodes
   nsresult SpellCheckBetweenNodes(nsIDOMNode *aStartNode,
                                   int32_t aStartOffset,
                                   nsIDOMNode *aEndNode,
                                   int32_t aEndOffset);
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -876,18 +876,17 @@ nsFormFillController::HandleEvent(Event*
   case eFocus:
     return Focus(aEvent);
   case eMouseDown:
     return MouseDown(aEvent);
   case eKeyPress:
     return KeyPress(aEvent);
   case eEditorInput:
     {
-      nsCOMPtr<nsINode> input = do_QueryInterface(
-        aEvent->InternalDOMEvent()->GetTarget());
+      nsCOMPtr<nsINode> input = do_QueryInterface(aEvent->GetTarget());
       if (!IsTextControl(input)) {
         return NS_OK;
       }
 
       bool unused = false;
       return (!mSuppressOnInput && mController && mFocusedInput) ?
              mController->HandleText(&unused) : NS_OK;
     }
@@ -910,32 +909,31 @@ nsFormFillController::HandleEvent(Event*
     return NS_OK;
   case eContextMenu:
     if (mFocusedPopup) {
       mFocusedPopup->ClosePopup();
     }
     return NS_OK;
   case ePageHide:
     {
-      nsCOMPtr<nsIDocument> doc = do_QueryInterface(
-        aEvent->InternalDOMEvent()->GetTarget());
+      nsCOMPtr<nsIDocument> doc = do_QueryInterface(aEvent->GetTarget());
       if (!doc) {
         return NS_OK;
       }
 
       if (mFocusedInput) {
         if (doc == mFocusedInput->OwnerDoc()) {
           StopControllingInput();
         }
       }
 
       // Only remove the observer notifications and marked autofill and password
       // manager fields if the page isn't going to be persisted (i.e. it's being
       // unloaded) so that appropriate autocomplete handling works with bfcache.
-      bool persisted = aEvent->InternalDOMEvent()->AsPageTransitionEvent()->Persisted();
+      bool persisted = aEvent->AsPageTransitionEvent()->Persisted();
       if (!persisted) {
         RemoveForDocument(doc);
       }
     }
     break;
   default:
     // Handling the default case to shut up stupid -Wswitch warnings.
     // One day compilers will be smarter...
@@ -1023,20 +1021,19 @@ nsFormFillController::MaybeStartControll
   if (aInput->ControlType() == NS_FORM_INPUT_PASSWORD) {
     StartQueryLoginReputation(aInput);
   }
 #endif
 
 }
 
 nsresult
-nsFormFillController::Focus(nsIDOMEvent* aEvent)
+nsFormFillController::Focus(Event* aEvent)
 {
-  nsCOMPtr<nsIContent> input = do_QueryInterface(
-    aEvent->InternalDOMEvent()->GetTarget());
+  nsCOMPtr<nsIContent> input = do_QueryInterface(aEvent->GetTarget());
   MaybeStartControllingInput(HTMLInputElement::FromNodeOrNull(input));
 
   // Bail if we didn't start controlling the input.
   if (!mFocusedInput) {
     return NS_OK;
   }
 
 #ifndef ANDROID
@@ -1063,25 +1060,24 @@ nsFormFillController::Focus(nsIDOMEvent*
     ShowPopup();
   }
 #endif
 
   return NS_OK;
 }
 
 nsresult
-nsFormFillController::KeyPress(nsIDOMEvent* aEvent)
+nsFormFillController::KeyPress(Event* aEvent)
 {
   NS_ASSERTION(mController, "should have a controller!");
   if (!mFocusedInput || !mController) {
     return NS_OK;
   }
 
-  RefPtr<KeyboardEvent> keyEvent =
-    aEvent->InternalDOMEvent()->AsKeyboardEvent();
+  RefPtr<KeyboardEvent> keyEvent = aEvent->AsKeyboardEvent();
   if (!keyEvent) {
     return NS_ERROR_FAILURE;
   }
 
   bool cancel = false;
   bool unused = false;
 
   uint32_t k = keyEvent->KeyCode();
@@ -1172,25 +1168,25 @@ nsFormFillController::KeyPress(nsIDOMEve
       aEvent->StopPropagation();
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
+nsFormFillController::MouseDown(Event* aEvent)
 {
-  MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aEvent->AsMouseEvent();
   if (!mouseEvent) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsIDOMHTMLInputElement> targetInput = do_QueryInterface(
-    aEvent->InternalDOMEvent()->GetTarget());
+  nsCOMPtr<nsIDOMHTMLInputElement> targetInput =
+    do_QueryInterface(aEvent->GetTarget());
   if (!targetInput) {
     return NS_OK;
   }
 
   int16_t button = mouseEvent->Button();
 
   // In case of a right click we set a timestamp that
   // will be checked in Focus() to avoid showing
--- a/toolkit/components/satchel/nsFormFillController.h
+++ b/toolkit/components/satchel/nsFormFillController.h
@@ -50,19 +50,19 @@ public:
   NS_DECL_NSIAUTOCOMPLETESEARCH
   NS_DECL_NSIAUTOCOMPLETEINPUT
   NS_DECL_NSIFORMAUTOCOMPLETEOBSERVER
   NS_DECL_NSIDOMEVENTLISTENER
   NS_DECL_NSIMUTATIONOBSERVER
 
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFormFillController, nsIFormFillController)
 
-  nsresult Focus(nsIDOMEvent* aEvent);
-  nsresult KeyPress(nsIDOMEvent* aKeyEvent);
-  nsresult MouseDown(nsIDOMEvent* aMouseEvent);
+  nsresult Focus(mozilla::dom::Event* aEvent);
+  nsresult KeyPress(mozilla::dom::Event* aKeyEvent);
+  nsresult MouseDown(mozilla::dom::Event* aMouseEvent);
 
   nsFormFillController();
 
 protected:
   virtual ~nsFormFillController();
 
   void AddWindowListeners(nsPIDOMWindowOuter* aWindow);
   void RemoveWindowListeners(nsPIDOMWindowOuter* aWindow);
@@ -86,17 +86,16 @@ protected:
 
   inline nsIDocShell *GetDocShellForInput(mozilla::dom::HTMLInputElement *aInput);
   inline nsPIDOMWindowOuter *GetWindowForDocShell(nsIDocShell *aDocShell);
   inline int32_t GetIndexOfDocShell(nsIDocShell *aDocShell);
 
   void MaybeRemoveMutationObserver(nsINode* aNode);
 
   void RemoveForDocument(nsIDocument* aDoc);
-  bool IsEventTrusted(nsIDOMEvent *aEvent);
 
   bool IsTextControl(nsINode* aNode);
 
   nsresult StartQueryLoginReputation(mozilla::dom::HTMLInputElement *aInput);
 
   // members //////////////////////////////////////////
 
   nsCOMPtr<nsIAutoCompleteController> mController;
--- a/widget/tests/TestAppShellSteadyState.cpp
+++ b/widget/tests/TestAppShellSteadyState.cpp
@@ -183,23 +183,17 @@ public:
     if (NS_FAILED(aEvent->GetType(type))) {
       fail("Failed to get event type");
       return NS_ERROR_FAILURE;
     }
 
     if (type.EqualsLiteral("load")) {
       passed("Got load event");
 
-      nsCOMPtr<nsIDOMEventTarget> target;
-      if (NS_FAILED(aEvent->GetTarget(getter_AddRefs(target)))) {
-        fail("Failed to get event type");
-        return NS_ERROR_FAILURE;
-      }
-
-      nsCOMPtr<nsIDocument> document = do_QueryInterface(target);
+      nsCOMPtr<nsIDocument> document = do_QueryInterface(aEvent->GetTarget());
       if (!document) {
         fail("Failed to QI to nsIDocument!");
         return NS_ERROR_FAILURE;
       }
 
       nsCOMPtr<nsPIDOMWindow> window = document->GetWindow();
       if (!window) {
         fail("Failed to get window from document!");