Bug 1455052 part 7. Remove nsIDOMEvent use from layout. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 12:53:17 -0400
changeset 414722 f1ec3420bc84b682259c719846a2a998cb935f8f
parent 414721 45ca32f89afe5c4fcf2f7ef65eb868edd27fe2e2
child 414723 b35aad989a131db1435b0254724f31db025a0e7a
push id102409
push userbzbarsky@mozilla.com
push dateFri, 20 Apr 2018 16:56:05 +0000
treeherdermozilla-inbound@27df0b6428b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1455052
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 1455052 part 7. Remove nsIDOMEvent use from layout. r=masayuki MozReview-Commit-ID: 2OfAXBR8G5M
layout/base/nsLayoutUtils.cpp
layout/printing/nsPrintPreviewListener.cpp
layout/xul/MenuBoxObject.cpp
layout/xul/nsBoxFrame.cpp
layout/xul/nsDocElementBoxFrame.cpp
layout/xul/nsMenuBarListener.cpp
layout/xul/nsXULPopupManager.cpp
layout/xul/nsXULPopupManager.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -35,17 +35,16 @@
 #include "nsCSSPseudoElements.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSColorUtils.h"
 #include "nsView.h"
 #include "nsViewManager.h"
 #include "nsPlaceholderFrame.h"
 #include "nsIScrollableFrame.h"
 #include "nsSubDocumentFrame.h"
-#include "nsIDOMEvent.h"
 #include "nsDisplayList.h"
 #include "nsRegion.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsBlockFrame.h"
 #include "nsBidiPresUtils.h"
 #include "imgIContainer.h"
 #include "ImageOps.h"
 #include "ImageRegion.h"
--- a/layout/printing/nsPrintPreviewListener.cpp
+++ b/layout/printing/nsPrintPreviewListener.cpp
@@ -7,17 +7,16 @@
 #include "nsPrintPreviewListener.h"
 
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h" // for Event
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMElement.h"
-#include "nsIDOMEvent.h"
 #include "nsIDocument.h"
 #include "nsIDocShell.h"
 #include "nsPresContext.h"
 #include "nsFocusManager.h"
 #include "nsLiteralString.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
--- a/layout/xul/MenuBoxObject.cpp
+++ b/layout/xul/MenuBoxObject.cpp
@@ -79,19 +79,17 @@ void MenuBoxObject::SetActiveChild(Eleme
 bool MenuBoxObject::HandleKeyPress(KeyboardEvent& keyEvent)
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (!pm) {
     return false;
   }
 
   // if event has already been handled, bail
-  bool eventHandled = false;
-  keyEvent.GetDefaultPrevented(&eventHandled);
-  if (eventHandled) {
+  if (keyEvent.DefaultPrevented()) {
     return false;
   }
 
   if (nsMenuBarListener::IsAccessKeyPressed(&keyEvent))
     return false;
 
   nsMenuFrame* menu = do_QueryFrame(GetFrame(false));
   if (!menu) {
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -56,17 +56,16 @@
 #include "nsIScrollableFrame.h"
 #include "nsWidgetsCID.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsContainerFrame.h"
 #include "nsIDOMElement.h"
 #include "nsITheme.h"
 #include "nsTransform2D.h"
 #include "mozilla/EventStateManager.h"
-#include "nsIDOMEvent.h"
 #include "nsDisplayList.h"
 #include "mozilla/Preferences.h"
 #include "nsThemeConstants.h"
 #include "nsLayoutUtils.h"
 #include "nsSliderFrame.h"
 #include <algorithm>
 
 // Needed for Print Preview
--- a/layout/xul/nsDocElementBoxFrame.cpp
+++ b/layout/xul/nsDocElementBoxFrame.cpp
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "nsHTMLParts.h"
 #include "nsContainerFrame.h"
 #include "nsCSSRendering.h"
 #include "nsIDocument.h"
 #include "nsPageFrame.h"
-#include "nsIDOMEvent.h"
 #include "nsStyleConsts.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsBoxFrame.h"
 #include "nsStackLayout.h"
 #include "nsIAnonymousContentCreator.h"
 #include "mozilla/dom/NodeInfo.h"
 #include "nsIServiceManager.h"
--- a/layout/xul/nsMenuBarListener.cpp
+++ b/layout/xul/nsMenuBarListener.cpp
@@ -17,16 +17,17 @@
 #include "nsIDOMNode.h"
 #include "nsIDOMElement.h"
 
 #include "nsContentUtils.h"
 #include "mozilla/BasicEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/dom/Event.h"
+#include "mozilla/dom/EventBinding.h"
 #include "mozilla/dom/KeyboardEvent.h"
 #include "mozilla/dom/KeyboardEventBinding.h"
 
 using namespace mozilla;
 using mozilla::dom::Event;
 using mozilla::dom::KeyboardEvent;
 
 /*
@@ -431,17 +432,17 @@ nsMenuBarListener::KeyDown(Event* aKeyEv
   RefPtr<KeyboardEvent> keyEvent = aKeyEvent->AsKeyboardEvent();
   if (!keyEvent) {
     return NS_OK;
   }
 
   uint32_t theChar = keyEvent->KeyCode();
 
   uint16_t eventPhase = keyEvent->EventPhase();
-  bool capturing = (eventPhase == nsIDOMEvent::CAPTURING_PHASE);
+  bool capturing = (eventPhase == dom::EventBinding::CAPTURING_PHASE);
 
 #ifndef XP_MACOSX
   if (capturing && !mAccessKeyDown && theChar == NS_VK_F10 &&
       (GetModifiersForAccessKey(keyEvent) & ~MODIFIER_CONTROL) == 0) {
     ReserveKeyIfNeeded(aKeyEvent);
   }
 #endif
 
@@ -525,17 +526,17 @@ nsMenuBarListener::MouseDown(Event* aMou
   // Even if the mousedown event is canceled, it means the user don't want
   // to activate the menu.  Therefore, we need to record it at capturing (or
   // target) phase.
   if (mAccessKeyDown) {
     mAccessKeyDownCanceled = true;
   }
 
   // Don't do anything at capturing phase, any behavior should be cancelable.
-  if (aMouseEvent->EventPhase() == nsIDOMEvent::CAPTURING_PHASE) {
+  if (aMouseEvent->EventPhase() == dom::EventBinding::CAPTURING_PHASE) {
     return NS_OK;
   }
 
   if (!mMenuBarFrame->IsMenuOpen() && mMenuBarFrame->IsActive())
     ToggleMenuActiveState();
 
   return NS_OK; // means I am NOT consuming event
 }
--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -612,34 +612,33 @@ nsXULPopupManager::GetMouseLocationParen
 
 int32_t
 nsXULPopupManager::MouseLocationOffset()
 {
   return mRangeOffset;
 }
 
 void
-nsXULPopupManager::InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup,
+nsXULPopupManager::InitTriggerEvent(Event* aEvent, nsIContent* aPopup,
                                     nsIContent** aTriggerContent)
 {
   mCachedMousePoint = LayoutDeviceIntPoint(0, 0);
 
   if (aTriggerContent) {
     *aTriggerContent = nullptr;
     if (aEvent) {
       // get the trigger content from the event
-      nsCOMPtr<nsIContent> target = do_QueryInterface(
-        aEvent->InternalDOMEvent()->GetTarget());
+      nsCOMPtr<nsIContent> target = do_QueryInterface(aEvent->GetTarget());
       target.forget(aTriggerContent);
     }
   }
 
   mCachedModifiers = 0;
 
-  UIEvent* uiEvent = aEvent ? aEvent->InternalDOMEvent()->AsUIEvent() : nullptr;
+  UIEvent* uiEvent = aEvent ? aEvent->AsUIEvent() : nullptr;
   if (uiEvent) {
     mRangeParent = uiEvent->GetRangeParent();
     mRangeOffset = uiEvent->RangeOffset();
 
     // get the event coordinates relative to the root frame of the document
     // containing the popup.
     NS_ASSERTION(aPopup, "Expected a popup node");
     WidgetEvent* event = aEvent->WidgetEventPtr();
@@ -659,17 +658,17 @@ nsXULPopupManager::InitTriggerEvent(nsID
             return;
           nsIFrame* rootDocumentRootFrame = rootDocPresContext->
               PresShell()->GetRootFrame();
           if ((event->mClass == eMouseEventClass ||
                event->mClass == eMouseScrollEventClass ||
                event->mClass == eWheelEventClass) &&
                !event->AsGUIEvent()->mWidget) {
             // no widget, so just use the client point if available
-            MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+            MouseEvent* mouseEvent = aEvent->AsMouseEvent();
             nsIntPoint clientPt(mouseEvent->ClientX(), mouseEvent->ClientY());
 
             // XXX this doesn't handle IFRAMEs in transforms
             nsPoint thisDocToRootDocOffset = presShell->
               GetRootFrame()->GetOffsetToCrossDoc(rootDocumentRootFrame);
             // convert to device pixels
             mCachedMousePoint.x = presContext->AppUnitsToDevPixels(
                 nsPresContext::CSSPixelsToAppUnits(clientPt.x) + thisDocToRootDocOffset.x);
@@ -769,17 +768,17 @@ nsXULPopupManager::ShowMenu(nsIContent *
 void
 nsXULPopupManager::ShowPopup(nsIContent* aPopup,
                              nsIContent* aAnchorContent,
                              const nsAString& aPosition,
                              int32_t aXPos, int32_t aYPos,
                              bool aIsContextMenu,
                              bool aAttributesOverride,
                              bool aSelectFirstItem,
-                             nsIDOMEvent* aTriggerEvent)
+                             Event* aTriggerEvent)
 {
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
   if (!popupFrame || !MayShowPopup(popupFrame))
     return;
 
   nsCOMPtr<nsIContent> triggerContent;
   InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
 
@@ -788,17 +787,17 @@ nsXULPopupManager::ShowPopup(nsIContent*
 
   FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem, aTriggerEvent);
 }
 
 void
 nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup,
                                      int32_t aXPos, int32_t aYPos,
                                      bool aIsContextMenu,
-                                     nsIDOMEvent* aTriggerEvent)
+                                     Event* aTriggerEvent)
 {
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
   if (!popupFrame || !MayShowPopup(popupFrame))
     return;
 
   nsCOMPtr<nsIContent> triggerContent;
   InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
 
@@ -807,17 +806,17 @@ nsXULPopupManager::ShowPopupAtScreen(nsI
 }
 
 void
 nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup,
                                          const nsAString& aPosition,
                                          const nsIntRect& aRect,
                                          bool aIsContextMenu,
                                          bool aAttributesOverride,
-                                         nsIDOMEvent* aTriggerEvent)
+                                         Event* aTriggerEvent)
 {
   nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
   if (!popupFrame || !MayShowPopup(popupFrame))
     return;
 
   nsCOMPtr<nsIContent> triggerContent;
   InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
 
@@ -1421,17 +1420,17 @@ nsXULPopupManager::ExecuteMenu(nsIConten
   aMenu->OwnerDoc()->Dispatch(TaskCategory::Other,
                               event.forget());
 }
 
 void
 nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
                                          bool aIsContextMenu,
                                          bool aSelectFirstItem,
-                                         nsIDOMEvent* aTriggerEvent)
+                                         Event* aTriggerEvent)
 {
   nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup
 
   nsMenuPopupFrame* popupFrame = do_QueryFrame(aPopup->GetPrimaryFrame());
   if (!popupFrame)
     return;
 
   nsPresContext *presContext = popupFrame->PresContext();
--- a/layout/xul/nsXULPopupManager.h
+++ b/layout/xul/nsXULPopupManager.h
@@ -53,16 +53,17 @@ class nsMenuPopupFrame;
 class nsMenuBarFrame;
 class nsMenuParent;
 class nsIDocShellTreeItem;
 class nsPIDOMWindowOuter;
 class nsRefreshDriver;
 
 namespace mozilla {
 namespace dom {
+class Event;
 class KeyboardEvent;
 } // namespace dom
 } // namespace mozilla
 
 // when a menu command is executed, the closemenu attribute may be used
 // to define how the menu should be closed up
 enum CloseMenuMode {
   CloseMenuMode_Auto, // close up the chain of menus, default value
@@ -453,42 +454,42 @@ public:
    */
   void ShowPopup(nsIContent* aPopup,
                  nsIContent* aAnchorContent,
                  const nsAString& aPosition,
                  int32_t aXPos, int32_t aYPos,
                  bool aIsContextMenu,
                  bool aAttributesOverride,
                  bool aSelectFirstItem,
-                 nsIDOMEvent* aTriggerEvent);
+                 mozilla::dom::Event* aTriggerEvent);
 
   /**
    * Open a popup at a specific screen position specified by aXPos and aYPos,
    * measured in CSS pixels.
    *
    * This fires the popupshowing event synchronously.
    *
    * If aIsContextMenu is true, the popup is positioned at a slight
    * offset from aXPos/aYPos to ensure that it is not under the mouse
    * cursor.
    */
   void ShowPopupAtScreen(nsIContent* aPopup,
                          int32_t aXPos, int32_t aYPos,
                          bool aIsContextMenu,
-                         nsIDOMEvent* aTriggerEvent);
+                         mozilla::dom::Event* aTriggerEvent);
 
   /* Open a popup anchored at a screen rectangle specified by aRect.
    * The remaining arguments are similar to ShowPopup.
    */
   void ShowPopupAtScreenRect(nsIContent* aPopup,
                              const nsAString& aPosition,
                              const nsIntRect& aRect,
                              bool aIsContextMenu,
                              bool aAttributesOverride,
-                             nsIDOMEvent* aTriggerEvent);
+                             mozilla::dom::Event* aTriggerEvent);
 
   /**
    * Open a tooltip at a specific screen position specified by aXPos and aYPos,
    * measured in CSS pixels.
    *
    * This fires the popupshowing event synchronously.
    */
   void ShowTooltipAtScreen(nsIContent* aPopup,
@@ -720,17 +721,17 @@ protected:
   nsMenuChainItem* GetTopVisibleMenu();
 
   // Hide all of the visible popups from the given list. This function can
   // cause style changes and frame destruction.
   void HidePopupsInList(const nsTArray<nsMenuPopupFrame *> &aFrames);
 
   // set the event that was used to trigger the popup, or null to clear the
   // event details. aTriggerContent will be set to the target of the event.
-  void InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup, nsIContent** aTriggerContent);
+  void InitTriggerEvent(mozilla::dom::Event* aEvent, nsIContent* aPopup, nsIContent** aTriggerContent);
 
   // callbacks for ShowPopup and HidePopup as events may be done asynchronously
   void ShowPopupCallback(nsIContent* aPopup,
                          nsMenuPopupFrame* aPopupFrame,
                          bool aIsContextMenu,
                          bool aSelectFirstItem);
   void HidePopupCallback(nsIContent* aPopup,
                          nsMenuPopupFrame* aPopupFrame,
@@ -747,17 +748,17 @@ protected:
    * aSelectFirstItem - true to select the first item in the menu
    * aTriggerEvent - the event that triggered the showing event.
    *                 This is currently used to propagate the
    *                 inputSource attribute. May be null.
    */
   void FirePopupShowingEvent(nsIContent* aPopup,
                              bool aIsContextMenu,
                              bool aSelectFirstItem,
-                             nsIDOMEvent* aTriggerEvent);
+                             mozilla::dom::Event* aTriggerEvent);
 
   /**
    * Fire a popuphiding event and then hide the popup. This will be called
    * recursively if aNextPopup and aLastPopup are set in order to hide a chain
    * of open menus. If these are not set, only one popup is closed. However,
    * if the popup type indicates a menu, yet the next popup is not a menu,
    * then this ends the closing of popups. This allows a menulist inside a
    * non-menu to close up the menu but not close up the panel it is contained