Bug 1544218 - part 3: Make FocusTarget use mozilla::PresShell directly rather than via nsIPresShell r=kats
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 16 Apr 2019 04:33:55 +0000
changeset 469611 359c63f6aa5e
parent 469610 06908f47b337
child 469612 fe7c0d7c09e5
push id35876
push useropoprus@mozilla.com
push dateTue, 16 Apr 2019 09:47:48 +0000
treeherdermozilla-central@fe4a28a68cfc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1544218
milestone68.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 1544218 - part 3: Make FocusTarget use mozilla::PresShell directly rather than via nsIPresShell r=kats Differential Revision: https://phabricator.services.mozilla.com/D27473
gfx/layers/apz/src/FocusTarget.cpp
gfx/layers/apz/src/FocusTarget.h
--- a/gfx/layers/apz/src/FocusTarget.cpp
+++ b/gfx/layers/apz/src/FocusTarget.cpp
@@ -6,17 +6,17 @@
 
 #include "mozilla/layers/FocusTarget.h"
 
 #include "mozilla/dom/BrowserBridgeChild.h"  // for BrowserBridgeChild
 #include "mozilla/dom/EventTarget.h"         // for EventTarget
 #include "mozilla/dom/TabParent.h"           // for TabParent
 #include "mozilla/EventDispatcher.h"         // for EventDispatcher
 #include "mozilla/layout/RenderFrame.h"      // For RenderFrame
-#include "mozilla/PresShell.h"               // For PresShell and nsIPresShell
+#include "mozilla/PresShell.h"               // For PresShell
 #include "nsIContentInlines.h"               // for nsINode::IsEditable()
 #include "nsLayoutUtils.h"                   // for nsLayoutUtils
 
 #define ENABLE_FT_LOGGING 0
 // #define ENABLE_FT_LOGGING 1
 
 #if ENABLE_FT_LOGGING
 #  define FT_LOG(FMT, ...)         \
@@ -27,35 +27,33 @@
 #endif
 
 using namespace mozilla::dom;
 using namespace mozilla::layout;
 
 namespace mozilla {
 namespace layers {
 
-static already_AddRefed<nsIPresShell> GetRetargetEventPresShell(
-    nsIPresShell* aRootPresShell) {
+static PresShell* GetRetargetEventPresShell(PresShell* aRootPresShell) {
   MOZ_ASSERT(aRootPresShell);
 
   // Use the last focused window in this PresShell and its
   // associated PresShell
   nsCOMPtr<nsPIDOMWindowOuter> window =
       aRootPresShell->GetFocusedDOMWindowInOurWindow();
   if (!window) {
     return nullptr;
   }
 
   RefPtr<Document> retargetEventDoc = window->GetExtantDoc();
   if (!retargetEventDoc) {
     return nullptr;
   }
 
-  nsCOMPtr<nsIPresShell> presShell = retargetEventDoc->GetPresShell();
-  return presShell.forget();
+  return retargetEventDoc->GetPresShell();
 }
 
 static bool HasListenersForKeyEvents(nsIContent* aContent) {
   if (!aContent) {
     return false;
   }
 
   WidgetEvent event(true, eVoidEvent);
@@ -94,26 +92,26 @@ static bool IsEditableNode(nsINode* aNod
   return aNode && aNode->IsEditable();
 }
 
 FocusTarget::FocusTarget()
     : mSequenceNumber(0),
       mFocusHasKeyEventListeners(false),
       mData(AsVariant(NoFocusTarget())) {}
 
-FocusTarget::FocusTarget(nsIPresShell* aRootPresShell,
+FocusTarget::FocusTarget(PresShell* aRootPresShell,
                          uint64_t aFocusSequenceNumber)
     : mSequenceNumber(aFocusSequenceNumber),
       mFocusHasKeyEventListeners(false),
       mData(AsVariant(NoFocusTarget())) {
   MOZ_ASSERT(aRootPresShell);
   MOZ_ASSERT(NS_IsMainThread());
 
   // Key events can be retargeted to a child PresShell when there is an iframe
-  nsCOMPtr<nsIPresShell> presShell = GetRetargetEventPresShell(aRootPresShell);
+  RefPtr<PresShell> presShell = GetRetargetEventPresShell(aRootPresShell);
 
   if (!presShell) {
     FT_LOG("Creating nil target with seq=%" PRIu64
            " (can't find retargeted presshell)\n",
            aFocusSequenceNumber);
 
     return;
   }
--- a/gfx/layers/apz/src/FocusTarget.h
+++ b/gfx/layers/apz/src/FocusTarget.h
@@ -9,19 +9,20 @@
 
 #include <stdint.h>  // for int32_t, uint32_t
 
 #include "mozilla/DefineEnum.h"                  // for MOZ_DEFINE_ENUM
 #include "mozilla/layers/ScrollableLayerGuid.h"  // for ViewID
 #include "mozilla/webrender/WebRenderTypes.h"    // for RenderRoot
 #include "mozilla/Variant.h"                     // for Variant
 
-class nsIPresShell;
+namespace mozilla {
 
-namespace mozilla {
+class PresShell;
+
 namespace layers {
 
 /**
  * This class is used for communicating information about the currently focused
  * element of a document and the scrollable frames to use when keyboard
  * scrolling it. It is created on the main thread at paint-time, but is then
  * passed over IPC to the compositor/APZ code.
  */
@@ -53,17 +54,17 @@ class FocusTarget final {
     bool operator==(const NoFocusTarget& aRhs) const { return true; }
   };
 
   FocusTarget();
 
   /**
    * Construct a focus target for the specified top level PresShell
    */
-  FocusTarget(nsIPresShell* aRootPresShell, uint64_t aFocusSequenceNumber);
+  FocusTarget(PresShell* aRootPresShell, uint64_t aFocusSequenceNumber);
 
   bool operator==(const FocusTarget& aRhs) const;
 
   const char* Type() const;
 
  public:
   // The content sequence number recorded at the time of this class's creation
   uint64_t mSequenceNumber;