Bug 1178847 - Move the code from ChromeProcessController::InitializeRoot to APZCCallbackHelper so it can be reused in the child process. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 21 Jul 2015 10:51:22 -0400
changeset 287219 d6f86fab2822800ac645447309436830ae6694c8
parent 287218 49ae0961591e54fd5ff844fe946d111f95281b13
child 287220 b501e96201ef2a95005a2498226d724bd0880bac
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1178847
milestone42.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 1178847 - Move the code from ChromeProcessController::InitializeRoot to APZCCallbackHelper so it can be reused in the child process. r=botond
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/ChromeProcessController.cpp
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -261,16 +261,46 @@ APZCCallbackHelper::GetOrCreateScrollIde
     *aViewIdOut = nsLayoutUtils::FindOrCreateIDFor(aContent);
     if (nsCOMPtr<nsIPresShell> shell = GetPresShell(aContent)) {
       *aPresShellIdOut = shell->GetPresShellId();
       return true;
     }
     return false;
 }
 
+void
+APZCCallbackHelper::InitializeRootDisplayport(nsIPresShell* aPresShell)
+{
+  // Create a view-id and set a zero-margin displayport for the root element
+  // of the root document in the chrome process. This ensures that the scroll
+  // frame for this element gets an APZC, which in turn ensures that all content
+  // in the chrome processes is covered by an APZC.
+  // The displayport is zero-margin because this element is generally not
+  // actually scrollable (if it is, APZC will set proper margins when it's
+  // scrolled).
+  if (!aPresShell) {
+    return;
+  }
+
+  MOZ_ASSERT(aPresShell->GetDocument());
+  nsIContent* content = aPresShell->GetDocument()->GetDocumentElement();
+  if (!content) {
+    return;
+  }
+
+  uint32_t presShellId;
+  FrameMetrics::ViewID viewId;
+  if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(content, &presShellId, &viewId)) {
+    // Note that the base rect that goes with these margins is set in
+    // nsRootBoxFrame::BuildDisplayList.
+    nsLayoutUtils::SetDisplayPortMargins(content, aPresShell, ScreenMargin(), 0,
+        nsLayoutUtils::RepaintMode::DoNotRepaint);
+  }
+}
+
 class FlingSnapEvent : public nsRunnable
 {
     typedef mozilla::layers::FrameMetrics::ViewID ViewID;
 
 public:
     FlingSnapEvent(const ViewID& aScrollId,
                    const mozilla::CSSPoint& aDestination)
         : mScrollId(aScrollId)
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -63,16 +63,20 @@ public:
     /* Get the presShellId and view ID for the given content element.
      * If the view ID does not exist, one is created.
      * The pres shell ID should generally already exist; if it doesn't for some
      * reason, false is returned. */
     static bool GetOrCreateScrollIdentifiers(nsIContent* aContent,
                                              uint32_t* aPresShellIdOut,
                                              FrameMetrics::ViewID* aViewIdOut);
 
+    /* Initialize a zero-margin displayport on the root document element of the
+       given presShell. */
+    static void InitializeRootDisplayport(nsIPresShell* aPresShell);
+
     /* Tell layout to perform scroll snapping for the scrollable frame with the
      * given scroll id. aDestination specifies the expected landing position of
      * a current fling or scrolling animation that should be used to select
      * the scroll snap point.
      */
     static void RequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
                                  const mozilla::CSSPoint& aDestination);
 
--- a/gfx/layers/apz/util/ChromeProcessController.cpp
+++ b/gfx/layers/apz/util/ChromeProcessController.cpp
@@ -33,42 +33,17 @@ ChromeProcessController::ChromeProcessCo
   mUILoop->PostTask(
       FROM_HERE,
       NewRunnableMethod(this, &ChromeProcessController::InitializeRoot));
 }
 
 void
 ChromeProcessController::InitializeRoot()
 {
-  // Create a view-id and set a zero-margin displayport for the root element
-  // of the root document in the chrome process. This ensures that the scroll
-  // frame for this element gets an APZC, which in turn ensures that all content
-  // in the chrome processes is covered by an APZC.
-  // The displayport is zero-margin because this element is generally not
-  // actually scrollable (if it is, APZC will set proper margins when it's
-  // scrolled).
-  nsIPresShell* presShell = GetPresShell();
-  if (!presShell) {
-    return;
-  }
-
-  MOZ_ASSERT(presShell->GetDocument());
-  nsIContent* content = presShell->GetDocument()->GetDocumentElement();
-  if (!content) {
-    return;
-  }
-
-  uint32_t presShellId;
-  FrameMetrics::ViewID viewId;
-  if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(content, &presShellId, &viewId)) {
-    // Note that the base rect that goes with these margins is set in
-    // nsRootBoxFrame::BuildDisplayList.
-    nsLayoutUtils::SetDisplayPortMargins(content, presShell, ScreenMargin(), 0,
-        nsLayoutUtils::RepaintMode::DoNotRepaint);
-  }
+  APZCCallbackHelper::InitializeRootDisplayport(GetPresShell());
 }
 
 void
 ChromeProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   FrameMetrics metrics = aFrameMetrics;