Bug 1460940 - Remove nsIDOMDocument uses in widget/. r=bz
authorAdrian Wielgosik <adrian.wielgosik@gmail.com>
Fri, 11 May 2018 19:46:15 +0200
changeset 472394 72c6733416e041bf2109fe1d1ebd38521a99dac9
parent 472393 ea6301dd947a4a8663ea093482f023b021ea5d5e
child 472395 3c934aabc02f279f148454b0da81d967e98272aa
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1460940
milestone62.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 1460940 - Remove nsIDOMDocument uses in widget/. r=bz MozReview-Commit-ID: Rxvwm6zfrB
dom/base/nsContentUtils.cpp
widget/gtk/nsDragService.cpp
widget/nsBaseDragService.cpp
widget/nsBaseDragService.h
widget/nsClipboardHelper.cpp
widget/nsDragServiceProxy.cpp
widget/nsIClipboardHelper.idl
widget/nsIDragSession.idl
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5988,19 +5988,18 @@ nsContentUtils::CheckForSubFrameDrop(nsI
 
   // Always allow dropping onto chrome shells.
   if (tdsti->ItemType() == nsIDocShellTreeItem::typeChrome) {
     return false;
   }
 
   // If there is no source node, then this is a drag from another
   // application, which should be allowed.
-  nsCOMPtr<nsIDOMDocument> sourceDocument;
-  aDragSession->GetSourceDocument(getter_AddRefs(sourceDocument));
-  nsCOMPtr<nsIDocument> doc = do_QueryInterface(sourceDocument);
+  nsCOMPtr<nsIDocument> doc;
+  aDragSession->GetSourceDocument(getter_AddRefs(doc));
   if (doc) {
     // Get each successive parent of the source document and compare it to
     // the drop document. If they match, then this is a drag from a child frame.
     do {
       doc = doc->GetParentDocument();
       if (doc == targetDoc) {
         // The drag is from a child frame.
         return true;
--- a/widget/gtk/nsDragService.cpp
+++ b/widget/gtk/nsDragService.cpp
@@ -263,23 +263,22 @@ OnSourceGrabEventAfter(GtkWidget *widget
     // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#drag-and-drop-processing-model
     // recommends an interval of 350ms +/- 200ms.
     sMotionEventTimerID =
         g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 350,
                            DispatchMotionEventCopy, nullptr, nullptr);
 }
 
 static GtkWindow*
-GetGtkWindow(nsIDOMDocument *aDocument)
+GetGtkWindow(nsIDocument *aDocument)
 {
-    nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDocument);
-    if (!doc)
+    if (!aDocument)
         return nullptr;
 
-    nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
+    nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell();
     if (!presShell)
         return nullptr;
 
     RefPtr<nsViewManager> vm = presShell->GetViewManager();
     if (!vm)
         return nullptr;
 
     nsCOMPtr<nsIWidget> widget;
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -143,17 +143,17 @@ nsBaseDragService::GetNumDropItems(uint3
 
 //
 // GetSourceDocument
 //
 // Returns the DOM document where the drag was initiated. This will be
 // nullptr if the drag began outside of our application.
 //
 NS_IMETHODIMP
-nsBaseDragService::GetSourceDocument(nsIDOMDocument** aSourceDocument)
+nsBaseDragService::GetSourceDocument(nsIDocument** aSourceDocument)
 {
   *aSourceDocument = mSourceDocument.get();
   NS_IF_ADDREF(*aSourceDocument);
 
   return NS_OK;
 }
 
 //
@@ -242,17 +242,17 @@ nsBaseDragService::InvokeDragSession(nsI
 {
   AUTO_PROFILER_LABEL("nsBaseDragService::InvokeDragSession", OTHER);
 
   NS_ENSURE_TRUE(aDOMNode, NS_ERROR_INVALID_ARG);
   NS_ENSURE_TRUE(mSuppressLevel == 0, NS_ERROR_FAILURE);
 
   // stash the document of the dom node
   nsCOMPtr<nsINode> node = do_QueryInterface(aDOMNode);
-  mSourceDocument = do_QueryInterface(node->OwnerDoc());
+  mSourceDocument = node->OwnerDoc();
   mTriggeringPrincipalURISpec.Assign(aPrincipalURISpec);
   mSourceNode = aDOMNode;
   mContentPolicyType = aContentPolicyType;
   mEndDragPoint = LayoutDeviceIntPoint(0, 0);
 
   // When the mouse goes down, the selection code starts a mouse
   // capture. However, this gets in the way of determining drag
   // feedback for things like trees because the event coordinates
@@ -497,40 +497,37 @@ nsBaseDragService::DiscardInternalTransf
     }
   }
 }
 
 NS_IMETHODIMP
 nsBaseDragService::FireDragEventAtSource(EventMessage aEventMessage,
                                          uint32_t aKeyModifiers)
 {
-  if (mSourceNode && !mSuppressLevel) {
-    nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
-    if (doc) {
-      nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
-      if (presShell) {
-        nsEventStatus status = nsEventStatus_eIgnore;
-        WidgetDragEvent event(true, aEventMessage, nullptr);
-        event.inputSource = mInputSource;
-        if (aEventMessage == eDragEnd) {
-          event.mRefPoint = mEndDragPoint;
-          event.mUserCancelled = mUserCancelled;
+  if (mSourceNode && mSourceDocument && !mSuppressLevel) {
+    nsCOMPtr<nsIPresShell> presShell = mSourceDocument->GetShell();
+    if (presShell) {
+      nsEventStatus status = nsEventStatus_eIgnore;
+      WidgetDragEvent event(true, aEventMessage, nullptr);
+      event.inputSource = mInputSource;
+      if (aEventMessage == eDragEnd) {
+        event.mRefPoint = mEndDragPoint;
+        event.mUserCancelled = mUserCancelled;
+      }
+      event.mModifiers = aKeyModifiers;
+      // Send the drag event to APZ, which needs to know about them to be
+      // able to accurately detect the end of a drag gesture.
+      if (nsPresContext* presContext = presShell->GetPresContext()) {
+        if (nsCOMPtr<nsIWidget> widget = presContext->GetRootWidget()) {
+          widget->DispatchEventToAPZOnly(&event);
         }
-        event.mModifiers = aKeyModifiers;
-        // Send the drag event to APZ, which needs to know about them to be
-        // able to accurately detect the end of a drag gesture.
-        if (nsPresContext* presContext = presShell->GetPresContext()) {
-          if (nsCOMPtr<nsIWidget> widget = presContext->GetRootWidget()) {
-            widget->DispatchEventToAPZOnly(&event);
-          }
-        }
+      }
 
-        nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
-        return presShell->HandleDOMEventWithTarget(content, &event, &status);
-      }
+      nsCOMPtr<nsIContent> content = do_QueryInterface(mSourceNode);
+      return presShell->HandleDOMEventWithTarget(content, &event, &status);
     }
   }
 
   return NS_OK;
 }
 
 /* This is used by Windows and Mac to update the position of a popup being
  * used as a drag image during the drag. This isn't used on GTK as it manages
--- a/widget/nsBaseDragService.h
+++ b/widget/nsBaseDragService.h
@@ -4,32 +4,32 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsBaseDragService_h__
 #define nsBaseDragService_h__
 
 #include "nsIDragService.h"
 #include "nsIDragSession.h"
 #include "nsITransferable.h"
-#include "nsIDOMDocument.h"
 #include "nsCOMPtr.h"
 #include "nsRect.h"
 #include "nsPoint.h"
 #include "nsString.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsTArray.h"
 #include "Units.h"
 
 // translucency level for drag images
 #define DRAG_TRANSLUCENCY 0.65
 
 class nsIContent;
 class nsIDOMNode;
+class nsIDocument;
 class nsPresContext;
 class nsIImageLoadingContent;
 
 namespace mozilla {
 namespace gfx {
 class SourceSurface;
 } // namespace gfx
 
@@ -160,17 +160,17 @@ protected:
   bool mDragEventDispatchedToChildProcess;
 
   uint32_t mDragAction;
   uint32_t mDragActionFromChildProcess;
 
   nsSize mTargetSize;
   nsCOMPtr<nsIDOMNode> mSourceNode;
   nsCString mTriggeringPrincipalURISpec;
-  nsCOMPtr<nsIDOMDocument> mSourceDocument;       // the document at the drag source. will be null
+  nsCOMPtr<nsIDocument> mSourceDocument;          // the document at the drag source. will be null
                                                   //  if it came from outside the app.
   nsContentPolicyType mContentPolicyType;         // the contentpolicy type passed to the channel
                                                   // when initiating the drag session
   RefPtr<mozilla::dom::DataTransfer> mDataTransfer;
 
   // used to determine the image to appear on the cursor while dragging
   nsCOMPtr<nsIDOMNode> mImage;
   // offset of cursor within the image
--- a/widget/nsClipboardHelper.cpp
+++ b/widget/nsClipboardHelper.cpp
@@ -10,17 +10,16 @@
 #include "nsCOMPtr.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIServiceManager.h"
 
 // helpers
 #include "nsIClipboard.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsITransferable.h"
 #include "nsReadableUtils.h"
 
 NS_IMPL_ISUPPORTS(nsClipboardHelper, nsIClipboardHelper)
 
 /*****************************************************************************
  * nsClipboardHelper ctor / dtor
  *****************************************************************************/
--- a/widget/nsDragServiceProxy.cpp
+++ b/widget/nsDragServiceProxy.cpp
@@ -46,19 +46,18 @@ GetPrincipalURIFromNode(nsCOMPtr<nsIDOMN
   principalURI->GetSpec(aPrincipalURISpec);
 }
 
 nsresult
 nsDragServiceProxy::InvokeDragSessionImpl(nsIArray* aArrayTransferables,
                                           nsIScriptableRegion* aRegion,
                                           uint32_t aActionType)
 {
-  nsCOMPtr<nsIDocument> doc = do_QueryInterface(mSourceDocument);
-  NS_ENSURE_STATE(doc->GetDocShell());
-  TabChild* child = TabChild::GetFrom(doc->GetDocShell());
+  NS_ENSURE_STATE(mSourceDocument->GetDocShell());
+  TabChild* child = TabChild::GetFrom(mSourceDocument->GetDocShell());
   NS_ENSURE_STATE(child);
   nsTArray<mozilla::dom::IPCDataTransfer> dataTransfers;
   nsContentUtils::TransferablesToIPCTransferables(aArrayTransferables,
                                                   dataTransfers,
                                                   false,
                                                   child->Manager(),
                                                   nullptr);
 
--- a/widget/nsIClipboardHelper.idl
+++ b/widget/nsIClipboardHelper.idl
@@ -6,18 +6,16 @@
 
 #include "nsISupports.idl"
 #include "nsIClipboard.idl"
 
 %{ C++
 #include "nsString.h" // needed for AString -> nsAString, unfortunately
 %}
 
-interface nsIDOMDocument;
-
 /**
  * helper service for common uses of nsIClipboard.
  */
 
 [scriptable, uuid(438307fd-0c68-4d79-922a-f6cc9550cd02)]
 interface nsIClipboardHelper : nsISupports
 {
   /**
--- a/widget/nsIDragSession.idl
+++ b/widget/nsIDragSession.idl
@@ -9,20 +9,20 @@
 
 
 %{ C++
 #include "nsSize.h"
 %}
 
 native nsSize (nsSize);
 
-interface nsIDOMDocument;
 interface nsIDOMNode;
 
 webidl DataTransfer;
+webidl Document;
 
 [scriptable, builtinclass, uuid(25bce737-73f0-43c7-bc20-c71044a73c5a)]
 interface nsIDragSession : nsISupports
 {
   /**
     * Set the current state of the drag, whether it can be dropped or not.
     * usually the target "frame" sets this so the native system can render the correct feedback
     */
@@ -49,17 +49,17 @@ interface nsIDragSession : nsISupports
     */
   readonly attribute unsigned long numDropItems;
   
   /**
     * The document where the drag was started, which will be null if the
     * drag originated outside the application. Useful for determining if a drop
     * originated in the same document.
     */
-  readonly attribute nsIDOMDocument sourceDocument;
+  readonly attribute Document sourceDocument;
 
   /**
     * The dom node that was originally dragged to start the session, which will be null if the
     * drag originated outside the application.
     */
   readonly attribute nsIDOMNode sourceNode;
 
   /**