Bug 1455055 part 3. Clean up HandleEvent implementations in layout. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 00:49:29 -0400
changeset 468262 21dc0a5895332067a6ff6e7dba21569c18ea4b55
parent 468261 ee04ee4104b6264c8c28aa33bd2cf01ca01f9c25
child 468263 a8a18e514b3d582939adb8173b540eedabbc06d6
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 3. Clean up HandleEvent implementations in layout. r=masayuki MozReview-Commit-ID: 7Irm8aAmeIt
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/forms/nsFileControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/forms/nsListControlFrame.h
layout/generic/ScrollbarActivity.cpp
layout/generic/nsImageMap.cpp
layout/printing/nsPrintPreviewListener.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -2216,17 +2216,17 @@ nsLayoutUtils::HasPseudoStyle(nsIContent
     pseudoContext = aPresContext->StyleSet()->
       ProbePseudoElementStyle(aContent->AsElement(), aPseudoElement,
                               aComputedStyle);
   }
   return pseudoContext != nullptr;
 }
 
 nsPoint
-nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(nsIDOMEvent* aDOMEvent, nsIFrame* aFrame)
+nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(Event* aDOMEvent, nsIFrame* aFrame)
 {
   if (!aDOMEvent)
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   WidgetEvent* event = aDOMEvent->WidgetEventPtr();
   if (!event)
     return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
   return GetEventCoordinatesRelativeTo(event, aFrame);
 }
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -39,17 +39,16 @@
 #include "gfxPoint.h"
 #include "nsClassHashtable.h"
 
 class gfxContext;
 class nsPresContext;
 class nsIContent;
 class nsAtom;
 class nsIScrollableFrame;
-class nsIDOMEvent;
 class nsRegion;
 class nsDisplayListBuilder;
 enum class nsDisplayListBuilderMode : uint8_t;
 class nsDisplayItem;
 class nsFontMetrics;
 class nsFontFaceList;
 class nsIImageLoadingContent;
 class nsBlockFrame;
@@ -75,16 +74,17 @@ struct ContainerLayerParameters;
 class WritingMode;
 class DisplayItemClip;
 class EffectSet;
 struct ActiveScrolledRoot;
 namespace dom {
 class CanvasRenderingContext2D;
 class DOMRectList;
 class Element;
+class Event;
 class HTMLImageElement;
 class HTMLCanvasElement;
 class HTMLVideoElement;
 class InspectorFontFace;
 class OffscreenCanvas;
 class Selection;
 } // namespace dom
 namespace gfx {
@@ -704,17 +704,17 @@ public:
    * Get the coordinates of a given DOM mouse event, relative to a given
    * frame. Works only for DOM events generated by WidgetGUIEvents.
    * @param aDOMEvent the event
    * @param aFrame the frame to make coordinates relative to
    * @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
    * for some reason the coordinates for the mouse are not known (e.g.,
    * the event is not a GUI event).
    */
-  static nsPoint GetDOMEventCoordinatesRelativeTo(nsIDOMEvent* aDOMEvent,
+  static nsPoint GetDOMEventCoordinatesRelativeTo(mozilla::dom::Event* aDOMEvent,
                                                   nsIFrame* aFrame);
 
   /**
    * Get the coordinates of a given native mouse event, relative to a given
    * frame.
    * @param aEvent the event
    * @param aFrame the frame to make coordinates relative to
    * @return the point, or (NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE) if
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -233,22 +233,21 @@ AppendBlobImplAsDirectory(nsTArray<Ownin
 /**
  * This is called when we receive a drop or a dragover.
  */
 NS_IMETHODIMP
 nsFileControlFrame::DnDListener::HandleEvent(Event* aEvent)
 {
   NS_ASSERTION(mFrame, "We should have been unregistered");
 
-  Event* event = aEvent->InternalDOMEvent();
-  if (event->DefaultPrevented()) {
+  if (aEvent->DefaultPrevented()) {
     return NS_OK;
   }
 
-  DragEvent* dragEvent = event->AsDragEvent();
+  DragEvent* dragEvent = aEvent->AsDragEvent();
   if (!dragEvent) {
     return NS_OK;
   }
 
   RefPtr<DataTransfer> dataTransfer = dragEvent->GetDataTransfer();
   if (!IsValidDropData(dataTransfer)) {
     return NS_OK;
   }
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -839,20 +839,20 @@ nsListControlFrame::PerformSelection(int
     wasChanged = SingleSelection(aClickedIndex, false); // might destroy us
   }
 
   return wasChanged;
 }
 
 //---------------------------------------------------------
 bool
-nsListControlFrame::HandleListSelection(nsIDOMEvent* aEvent,
+nsListControlFrame::HandleListSelection(dom::Event* aEvent,
                                         int32_t aClickedIndex)
 {
-  MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aEvent->AsMouseEvent();
   bool isControl;
 #ifdef XP_MACOSX
   isControl = mouseEvent->MetaKey();
 #else
   isControl = mouseEvent->CtrlKey();
 #endif
   bool isShift = mouseEvent->ShiftKey();
   return PerformSelection(aClickedIndex, isShift, isControl); // might destroy us
@@ -1557,20 +1557,20 @@ nsListControlFrame::IsOptionDisabled(int
   }
   return NS_ERROR_FAILURE;
 }
 
 //----------------------------------------------------------------------
 // helper
 //----------------------------------------------------------------------
 bool
-nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent)
+nsListControlFrame::IsLeftButton(dom::Event* aMouseEvent)
 {
   // only allow selection with the left button
-  MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
   return mouseEvent && mouseEvent->Button() == 0;
 }
 
 nscoord
 nsListControlFrame::CalcFallbackRowBSize(float aFontSizeInflation)
 {
   RefPtr<nsFontMetrics> fontMet =
     nsLayoutUtils::GetFontMetricsForFrame(this, aFontSizeInflation);
@@ -1598,21 +1598,21 @@ nsListControlFrame::CalcIntrinsicBSize(n
 
   return mNumDisplayRows * aBSizeOfARow;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMMouseListener
 //----------------------------------------------------------------------
 nsresult
-nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
+nsListControlFrame::MouseUp(dom::Event* aMouseEvent)
 {
   NS_ASSERTION(aMouseEvent != nullptr, "aMouseEvent is null.");
 
-  MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
   NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE);
 
   UpdateInListState(aMouseEvent);
 
   mButtonDown = false;
 
   EventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
@@ -1697,29 +1697,29 @@ nsListControlFrame::MouseUp(nsIDOMEvent*
       FireOnInputAndOnChange();
     }
   }
 
   return NS_OK;
 }
 
 void
-nsListControlFrame::UpdateInListState(nsIDOMEvent* aEvent)
+nsListControlFrame::UpdateInListState(dom::Event* aEvent)
 {
   if (!mComboboxFrame || !mComboboxFrame->IsDroppedDown())
     return;
 
   nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(aEvent, this);
   nsRect borderInnerEdge = GetScrollPortRect();
   if (pt.y >= borderInnerEdge.y && pt.y < borderInnerEdge.YMost()) {
     mItemSelectionStarted = true;
   }
 }
 
-bool nsListControlFrame::IgnoreMouseEventForSelection(nsIDOMEvent* aEvent)
+bool nsListControlFrame::IgnoreMouseEventForSelection(dom::Event* aEvent)
 {
   if (!mComboboxFrame)
     return false;
 
   // Our DOM listener does get called when the dropdown is not
   // showing, because it listens to events on the SELECT element
   if (!mComboboxFrame->IsDroppedDown())
     return true;
@@ -1740,18 +1740,18 @@ nsListControlFrame::FireMenuItemActiveEv
     return;
   }
 
   FireDOMEvent(NS_LITERAL_STRING("DOMMenuItemActive"), optionContent);
 }
 #endif
 
 nsresult
-nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
-                                         int32_t&     aCurIndex)
+nsListControlFrame::GetIndexFromDOMEvent(dom::Event* aMouseEvent,
+                                         int32_t&    aCurIndex)
 {
   if (IgnoreMouseEventForSelection(aMouseEvent))
     return NS_ERROR_FAILURE;
 
   if (nsIPresShell::GetCapturingContent() != mContent) {
     // If we're not capturing, then ignore movement in the border
     nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(aMouseEvent, this);
     nsRect borderInnerEdge = GetScrollPortRect();
@@ -1792,21 +1792,21 @@ FireShowDropDownEvent(nsIContent* aConte
                                         eventName, true, false);
     return true;
   }
 
   return false;
 }
 
 nsresult
-nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent)
+nsListControlFrame::MouseDown(dom::Event* aMouseEvent)
 {
   NS_ASSERTION(aMouseEvent != nullptr, "aMouseEvent is null.");
 
-  MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
   NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE);
 
   UpdateInListState(aMouseEvent);
 
   EventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return NS_OK;
   }
@@ -1841,19 +1841,18 @@ nsListControlFrame::MouseDown(nsIDOMEven
     }
     mChangesSinceDragStart = change;
   } else {
     // NOTE: the combo box is responsible for dropping it down
     if (mComboboxFrame) {
       // Ignore the click that occurs on the option element when one is
       // selected from the parent process popup.
       if (mComboboxFrame->IsOpenInParentProcess()) {
-        nsCOMPtr<nsIDOMEventTarget> etarget;
-        aMouseEvent->GetTarget(getter_AddRefs(etarget));
-        nsCOMPtr<nsIContent> econtent = do_QueryInterface(etarget);
+        nsCOMPtr<nsIContent> econtent =
+          do_QueryInterface(aMouseEvent->GetTarget());
         HTMLOptionElement* option = HTMLOptionElement::FromNodeOrNull(econtent);
         if (option) {
           return NS_OK;
         }
       }
 
       uint16_t inputSource = mouseEvent->MozInputSource();
       bool isSourceTouchEvent = inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH;
@@ -1879,24 +1878,21 @@ nsListControlFrame::MouseDown(nsIDOMEven
         }
       }
     }
   }
 
   return NS_OK;
 }
 
-//----------------------------------------------------------------------
-// nsIDOMMouseMotionListener
-//----------------------------------------------------------------------
 nsresult
-nsListControlFrame::MouseMove(nsIDOMEvent* aMouseEvent)
+nsListControlFrame::MouseMove(dom::Event* aMouseEvent)
 {
   NS_ASSERTION(aMouseEvent, "aMouseEvent is null.");
-  MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
   NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE);
 
   UpdateInListState(aMouseEvent);
 
   if (IsInDropDownMode()) {
     if (mComboboxFrame->IsDroppedDown()) {
       int32_t selectedIndex;
       if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, selectedIndex))) {
@@ -1907,30 +1903,30 @@ nsListControlFrame::MouseMove(nsIDOMEven
     if (mButtonDown) {
       return DragMove(aMouseEvent); // might destroy us
     }
   }
   return NS_OK;
 }
 
 nsresult
-nsListControlFrame::DragMove(nsIDOMEvent* aMouseEvent)
+nsListControlFrame::DragMove(dom::Event* aMouseEvent)
 {
   NS_ASSERTION(aMouseEvent, "aMouseEvent is null.");
 
   UpdateInListState(aMouseEvent);
 
   if (!IsInDropDownMode()) {
     int32_t selectedIndex;
     if (NS_SUCCEEDED(GetIndexFromDOMEvent(aMouseEvent, selectedIndex))) {
       // Don't waste cycles if we already dragged over this item
       if (selectedIndex == mEndSelectionIndex) {
         return NS_OK;
       }
-      MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
+      MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
       NS_ASSERTION(mouseEvent, "aMouseEvent is not a MouseEvent!");
       bool isControl;
 #ifdef XP_MACOSX
       isControl = mouseEvent->MetaKey();
 #else
       isControl = mouseEvent->CtrlKey();
 #endif
       AutoWeakFrame weakFrame(this);
@@ -2089,17 +2085,17 @@ nsListControlFrame::GetIncrementalString
 void
 nsListControlFrame::Shutdown()
 {
   delete sIncrementalString;
   sIncrementalString = nullptr;
 }
 
 void
-nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent)
+nsListControlFrame::DropDownToggleKey(dom::Event* aKeyEvent)
 {
   // Cocoa widgets do native popups, so don't try to show
   // dropdowns there.
   if (IsInDropDownMode() && !nsComboboxControlFrame::ToolkitHasNativePopup()) {
     aKeyEvent->PreventDefault();
     if (!mComboboxFrame->IsDroppedDown()) {
       if (!FireShowDropDownEvent(mContent, true, false)) {
         mComboboxFrame->ShowDropDown(true);
@@ -2111,17 +2107,17 @@ nsListControlFrame::DropDownToggleKey(ns
       if (weakFrame.IsAlive()) {
         FireOnInputAndOnChange();
       }
     }
   }
 }
 
 nsresult
-nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
+nsListControlFrame::KeyDown(dom::Event* aKeyEvent)
 {
   MOZ_ASSERT(aKeyEvent, "aKeyEvent is null.");
 
   EventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return NS_OK;
   }
 
@@ -2302,17 +2298,17 @@ nsListControlFrame::KeyDown(nsIDOMEvent*
 
   // Actually process the new index and let the selection code
   // do the scrolling for us
   PostHandleKeyEvent(newIndex, 0, keyEvent->IsShift(), isControlOrMeta);
   return NS_OK;
 }
 
 nsresult
-nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
+nsListControlFrame::KeyPress(dom::Event* aKeyEvent)
 {
   MOZ_ASSERT(aKeyEvent, "aKeyEvent is null.");
 
   EventStates eventStates = mContent->AsElement()->State();
   if (eventStates.HasState(NS_EVENT_STATE_DISABLED)) {
     return NS_OK;
   }
 
@@ -2533,19 +2529,17 @@ nsListEventListener::HandleEvent(dom::Ev
   aEvent->GetType(eventType);
   if (eventType.EqualsLiteral("keydown")) {
     return mFrame->nsListControlFrame::KeyDown(aEvent);
   }
   if (eventType.EqualsLiteral("keypress")) {
     return mFrame->nsListControlFrame::KeyPress(aEvent);
   }
   if (eventType.EqualsLiteral("mousedown")) {
-    bool defaultPrevented = false;
-    aEvent->GetDefaultPrevented(&defaultPrevented);
-    if (defaultPrevented) {
+    if (aEvent->DefaultPrevented()) {
       return NS_OK;
     }
     return mFrame->nsListControlFrame::MouseDown(aEvent);
   }
   if (eventType.EqualsLiteral("mouseup")) {
     // Don't try to honor defaultPrevented here - it's not web compatible.
     // (bug 1194733)
     return mFrame->nsListControlFrame::MouseUp(aEvent);
--- a/layout/forms/nsListControlFrame.h
+++ b/layout/forms/nsListControlFrame.h
@@ -30,16 +30,17 @@
 #endif
 
 class nsIComboboxControlFrame;
 class nsPresContext;
 class nsListEventListener;
 
 namespace mozilla {
 namespace dom {
+class Event;
 class HTMLOptionElement;
 class HTMLOptionsCollection;
 } // namespace dom
 } // namespace mozilla
 
 /**
  * Frame-based listbox.
  */
@@ -155,22 +156,22 @@ public:
    */
   NS_IMETHOD OnOptionSelected(int32_t aIndex, bool aSelected) override;
   NS_IMETHOD OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex) override;
 
   /**
    * Mouse event listeners.
    * @note These methods might destroy the frame, pres shell and other objects.
    */
-  nsresult MouseDown(nsIDOMEvent* aMouseEvent);
-  nsresult MouseUp(nsIDOMEvent* aMouseEvent);
-  nsresult MouseMove(nsIDOMEvent* aMouseEvent);
-  nsresult DragMove(nsIDOMEvent* aMouseEvent);
-  nsresult KeyDown(nsIDOMEvent* aKeyEvent);
-  nsresult KeyPress(nsIDOMEvent* aKeyEvent);
+  nsresult MouseDown(mozilla::dom::Event* aMouseEvent);
+  nsresult MouseUp(mozilla::dom::Event* aMouseEvent);
+  nsresult MouseMove(mozilla::dom::Event* aMouseEvent);
+  nsresult DragMove(mozilla::dom::Event* aMouseEvent);
+  nsresult KeyDown(mozilla::dom::Event* aKeyEvent);
+  nsresult KeyPress(mozilla::dom::Event* aKeyEvent);
 
   /**
    * Returns the options collection for mContent, if any.
    */
   mozilla::dom::HTMLOptionsCollection* GetOptions() const;
   /**
    * Returns the HTMLOptionElement for a given index in mContent's collection.
    */
@@ -267,17 +268,17 @@ protected:
     return mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::multiple);
   }
 
 
   /**
    * Toggles (show/hide) the combobox dropdown menu.
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void DropDownToggleKey(nsIDOMEvent* aKeyEvent);
+  void DropDownToggleKey(mozilla::dom::Event* aKeyEvent);
 
   nsresult   IsOptionDisabled(int32_t anIndex, bool &aIsDisabled);
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
   void ScrollToFrame(HTMLOptionElement& aOptElement);
   /**
    * @note This method might destroy the frame, pres shell and other objects.
@@ -289,23 +290,23 @@ protected:
    * listbox, they then have to move the mouse into the list. We don't
    * want to process those mouse events as selection events (i.e., to
    * scroll list items into view). So we ignore the events until
    * the mouse moves below our border-inner-edge, when
    * mItemSelectionStarted is set.
    *
    * @param aPoint relative to this frame
    */
-  bool       IgnoreMouseEventForSelection(nsIDOMEvent* aEvent);
+  bool       IgnoreMouseEventForSelection(mozilla::dom::Event* aEvent);
 
   /**
    * If the dropdown is showing and the mouse has moved below our
    * border-inner-edge, then set mItemSelectionStarted.
    */
-  void       UpdateInListState(nsIDOMEvent* aEvent);
+  void       UpdateInListState(mozilla::dom::Event* aEvent);
   void       AdjustIndexForDisabledOpt(int32_t aStartIndex, int32_t &anNewIndex,
                                        int32_t aNumOptions, int32_t aDoAdjustInc, int32_t aDoAdjustIncNext);
 
   /**
    * Resets the select back to it's original default values;
    * those values as determined by the original HTML
    */
   virtual void ResetList(bool aAllowScrolling);
@@ -314,20 +315,21 @@ protected:
   virtual ~nsListControlFrame();
 
   /**
    * Sets the mSelectedIndex and mOldSelectedIndex from figuring out what
    * item was selected using content
    * @param aPoint the event point, in listcontrolframe coordinates
    * @return NS_OK if it successfully found the selection
    */
-  nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, int32_t& aCurIndex);
+  nsresult GetIndexFromDOMEvent(mozilla::dom::Event* aMouseEvent,
+                                int32_t& aCurIndex);
 
   bool     CheckIfAllFramesHere();
-  bool     IsLeftButton(nsIDOMEvent* aMouseEvent);
+  bool     IsLeftButton(mozilla::dom::Event* aMouseEvent);
 
   // guess at a row block size based on our own style.
   nscoord  CalcFallbackRowBSize(float aFontSizeInflation);
 
   // CalcIntrinsicBSize computes our intrinsic block size (taking the
   // "size" attribute into account).  This should only be called in
   // non-dropdown mode.
   nscoord CalcIntrinsicBSize(nscoord aBSizeOfARow, int32_t aNumberOfOptions);
@@ -360,17 +362,18 @@ protected:
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
   bool     PerformSelection(int32_t aClickedIndex, bool aIsShift,
                             bool aIsControl);
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  bool     HandleListSelection(nsIDOMEvent * aDOMEvent, int32_t selectedIndex);
+  bool     HandleListSelection(mozilla::dom::Event * aDOMEvent,
+                               int32_t selectedIndex);
   void     InitSelectionRange(int32_t aClickedIndex);
   void     PostHandleKeyEvent(int32_t aNewIndex, uint32_t aCharCode,
                               bool aIsShift, bool aIsControlOrMeta);
 
 public:
   nsSelectsAreaFrame* GetOptionsContainer() const {
     return static_cast<nsSelectsAreaFrame*>(GetScrolledFrame());
   }
--- a/layout/generic/ScrollbarActivity.cpp
+++ b/layout/generic/ScrollbarActivity.cpp
@@ -117,19 +117,18 @@ ScrollbarActivity::HandleEvent(dom::Even
 
   if (type.EqualsLiteral("mousemove")) {
     // Mouse motions anywhere in the scrollable frame should keep the
     // scrollbars visible.
     ActivityOccurred();
     return NS_OK;
   }
 
-  nsCOMPtr<nsIDOMEventTarget> target;
-  aEvent->GetOriginalTarget(getter_AddRefs(target));
-  nsCOMPtr<nsIContent> targetContent = do_QueryInterface(target);
+  nsCOMPtr<nsIContent> targetContent =
+    do_QueryInterface(aEvent->GetOriginalTarget());
 
   HandleEventForScrollbar(type, targetContent, GetHorizontalScrollbar(),
                           &mHScrollbarHovered);
   HandleEventForScrollbar(type, targetContent, GetVerticalScrollbar(),
                           &mVScrollbarHovered);
 
   return NS_OK;
 }
--- a/layout/generic/nsImageMap.cpp
+++ b/layout/generic/nsImageMap.cpp
@@ -981,18 +981,17 @@ nsImageMap::HandleEvent(Event* aEvent)
 {
   nsAutoString eventType;
   aEvent->GetType(eventType);
   bool focus = eventType.EqualsLiteral("focus");
   MOZ_ASSERT(focus == !eventType.EqualsLiteral("blur"),
              "Unexpected event type");
 
   //Set which one of our areas changed focus
-  nsCOMPtr<nsIContent> targetContent = do_QueryInterface(
-    aEvent->InternalDOMEvent()->GetTarget());
+  nsCOMPtr<nsIContent> targetContent = do_QueryInterface(aEvent->GetTarget());
   if (!targetContent) {
     return NS_OK;
   }
 
   for (auto& area : mAreas) {
     if (area->mArea == targetContent) {
       //Set or Remove internal focus
       area->HasFocus(focus);
--- a/layout/printing/nsPrintPreviewListener.cpp
+++ b/layout/printing/nsPrintPreviewListener.cpp
@@ -103,17 +103,17 @@ nsPrintPreviewListener::RemoveListeners(
 //
 enum eEventAction {
   eEventAction_Tab,       eEventAction_ShiftTab,
   eEventAction_Propagate, eEventAction_Suppress,
   eEventAction_StopPropagation
 };
 
 static eEventAction
-GetActionForEvent(nsIDOMEvent* aEvent)
+GetActionForEvent(Event* aEvent)
 {
   WidgetKeyboardEvent* keyEvent =
     aEvent->WidgetEventPtr()->AsKeyboardEvent();
   if (!keyEvent) {
     return eEventAction_Suppress;
   }
 
   if (keyEvent->mFlags.mInSystemGroup) {
@@ -155,17 +155,17 @@ GetActionForEvent(nsIDOMEvent* aEvent)
 
   return eEventAction_Suppress;
 }
 
 NS_IMETHODIMP
 nsPrintPreviewListener::HandleEvent(Event* aEvent)
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(
-    aEvent ? aEvent->InternalDOMEvent()->GetOriginalTarget() : nullptr);
+    aEvent ? aEvent->GetOriginalTarget() : nullptr);
   if (content && !content->IsXULElement()) {
     eEventAction action = ::GetActionForEvent(aEvent);
     switch (action) {
       case eEventAction_Tab:
       case eEventAction_ShiftTab:
       {
         nsAutoString eventString;
         aEvent->GetType(eventString);