Bug 1506439 part 2. Stop creating a useless nsCOMPtr in DispatchInputEvent. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 13 Mar 2019 02:34:48 +0000
changeset 521643 fcaf6f3d0497
parent 521642 9b6190dc000d
child 521644 e2cb9629e540
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1506439
milestone67.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 1506439 part 2. Stop creating a useless nsCOMPtr in DispatchInputEvent. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D23068
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/html/nsTextEditorState.cpp
editor/libeditor/TextEditorDataTransfer.cpp
layout/base/PresShell.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4088,23 +4088,16 @@ nsresult nsContentUtils::DispatchEvent(D
   nsresult rv = EventDispatcher::DispatchDOMEvent(target, &aEvent, nullptr,
                                                   nullptr, &status);
   if (aDefaultAction) {
     *aDefaultAction = (status != nsEventStatus_eConsumeNoDefault);
   }
   return rv;
 }
 
-// static
-nsresult nsContentUtils::DispatchInputEvent(Element* aEventTargetElement) {
-  RefPtr<TextEditor> textEditor;  // See bug 1506439
-  return DispatchInputEvent(aEventTargetElement, EditorInputType::eUnknown,
-                            textEditor, InputEventOptions());
-}
-
 nsContentUtils::InputEventOptions::InputEventOptions(
     DataTransfer* aDataTransfer)
     : mDataTransfer(aDataTransfer) {
   MOZ_ASSERT(mDataTransfer);
   MOZ_ASSERT(mDataTransfer->IsReadOnly());
 }
 
 // static
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1421,17 +1421,20 @@ class nsContentUtils {
    * @param aTextEditor         Optional.  If this is called by editor,
    *                            editor should set this.  Otherwise, leave
    *                            nullptr.
    * @param aOptions            Optional.  If aEditorInputType value requires
    *                            some additional data, they should be properly
    *                            set with this argument.
    */
   MOZ_CAN_RUN_SCRIPT
-  static nsresult DispatchInputEvent(Element* aEventTarget);
+  static nsresult DispatchInputEvent(Element* aEventTarget) {
+    return DispatchInputEvent(aEventTarget, mozilla::EditorInputType::eUnknown,
+                              nullptr, InputEventOptions());
+  }
   struct MOZ_STACK_CLASS InputEventOptions final {
     InputEventOptions() = default;
     explicit InputEventOptions(const nsAString& aData)
         : mData(aData), mDataTransfer(nullptr) {}
     explicit InputEventOptions(mozilla::dom::DataTransfer* aDataTransfer);
 
     nsString mData;
     mozilla::dom::DataTransfer* mDataTransfer;
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -2433,19 +2433,18 @@ bool nsTextEditorState::SetValue(const n
       // If this is called as part of user input, we need to dispatch "input"
       // event with "insertReplacementText" since web apps may want to know
       // the user operation which changes editor value with a built-in function
       // like autocomplete, password manager, session restore, etc.
       if (aFlags & eSetValue_BySetUserInput) {
         nsCOMPtr<Element> element = do_QueryInterface(textControlElement);
         MOZ_ASSERT(element);
         MOZ_ASSERT(!newValue.IsVoid());
-        RefPtr<TextEditor> textEditor;  // See bug 1506439
         DebugOnly<nsresult> rvIgnored = nsContentUtils::DispatchInputEvent(
-            element, EditorInputType::eInsertReplacementText, textEditor,
+            element, EditorInputType::eInsertReplacementText, nullptr,
             nsContentUtils::InputEventOptions(newValue));
         NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
                              "Failed to dispatch input event");
       }
     } else {
       // Even if our value is not actually changing, apparently we need to mark
       // our SelectionProperties dirty to make accessibility tests happy.
       // Probably because they depend on the SetSelectionRange() call we make on
--- a/editor/libeditor/TextEditorDataTransfer.cpp
+++ b/editor/libeditor/TextEditorDataTransfer.cpp
@@ -283,18 +283,17 @@ nsresult TextEditor::OnDrop(DragEvent* a
     }
     droppedAt = SelectionRefPtr()->FocusRef();
     if (NS_WARN_IF(!droppedAt.IsSet())) {
       return NS_ERROR_FAILURE;
     }
 
     // Let's fire "input" event for the deletion now.
     if (mDispatchInputEvent) {
-      RefPtr<DataTransfer> dataTransfer;  // Required due to bug 1506439
-      FireInputEvent(EditAction::eDeleteByDrag, VoidString(), dataTransfer);
+      FireInputEvent(EditAction::eDeleteByDrag, VoidString(), nullptr);
       if (NS_WARN_IF(Destroyed())) {
         return NS_OK;
       }
     }
 
     // XXX Now, Selection may be changed by input event listeners.  If so,
     //     should we update |droppedAt|?
   }
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6520,21 +6520,19 @@ nsresult PresShell::EventHandler::Handle
                                        aDontRetargetEvents);
   }
 
   // Activation events need to be dispatched even if no frame was found, since
   // we don't want the focus to be out of sync.
   if (!aFrame) {
     if (!NS_EVENT_NEEDS_FRAME(aGUIEvent)) {
       mPresShell->mCurrentEventFrame = nullptr;
-      nsCOMPtr<nsIContent> overrideClickTarget;  // Required due to bug  1506439
       // XXX Shouldn't we create AutoCurrentEventInfoSetter instance for this
       //     call even if we set the target to nullptr.
-      return HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
-                                             overrideClickTarget);
+      return HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr);
     }
 
     if (aGUIEvent->HasKeyEventMessage()) {
       // Keypress events in new blank tabs should not be completely thrown away.
       // Retarget them -- the parent chrome shell might make use of them.
       return RetargetEventToParent(aGUIEvent, aEventStatus);
     }
 
@@ -7447,19 +7445,17 @@ nsresult PresShell::EventHandler::Handle
   // with parent PresShell.
   mPresShell->mCurrentEventContent = eventTargetElement;
   if (!mPresShell->GetCurrentEventContent() ||
       !mPresShell->GetCurrentEventFrame() ||
       InZombieDocument(mPresShell->mCurrentEventContent)) {
     return RetargetEventToParent(aGUIEvent, aEventStatus);
   }
 
-  nsCOMPtr<nsIContent> overrideClickTarget;  // Required due to bug  1506439
-  nsresult rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
-                                                overrideClickTarget);
+  nsresult rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr);
 
 #ifdef DEBUG
   mPresShell->ShowEventTargetDebug();
 #endif
 
   return rv;
 }
 
@@ -7553,19 +7549,17 @@ nsresult PresShell::EventHandler::Handle
   MOZ_ASSERT(!aGUIEvent->IsTargetedAtFocusedContent());
   MOZ_ASSERT(aEventStatus);
 
   AutoCurrentEventInfoSetter eventInfoSetter(*this, aFrameForPresShell,
                                              nullptr);
 
   nsresult rv = NS_OK;
   if (mPresShell->GetCurrentEventFrame()) {
-    nsCOMPtr<nsIContent> overrideClickTarget;  // Required due to bug  1506439
-    rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true,
-                                         overrideClickTarget);
+    rv = HandleEventWithCurrentEventInfo(aGUIEvent, aEventStatus, true, nullptr);
   }
 
 #ifdef DEBUG
   mPresShell->ShowEventTargetDebug();
 #endif
 
   return rv;
 }