Bug 1346109. Set a displayport base in APZCCallbackHelper::InitializeRootDisplayport when we set displayport margins. r=botond
authorTimothy Nikkel <tnikkel@gmail.com>
Mon, 20 Mar 2017 00:14:57 -0500
changeset 348417 d899491bd624aa3e0c4cc22ef6a579f988f51509
parent 348416 2a9f685bbf0cbfbb1e2e061e4e48bb8a0f7413df
child 348418 4d632924b0c76c4fc2944f918736f3f911a42b1f
push id39156
push usercbook@mozilla.com
push dateMon, 20 Mar 2017 13:29:29 +0000
treeherderautoland@7c3e1b806e3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1346109
milestone55.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 1346109. Set a displayport base in APZCCallbackHelper::InitializeRootDisplayport when we set displayport margins. r=botond Since this is for a root document this isn't that hard.
gfx/layers/apz/util/APZCCallbackHelper.cpp
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -336,17 +336,32 @@ APZCCallbackHelper::InitializeRootDispla
   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
+    nsPresContext* pc = aPresShell->GetPresContext();
+    // This code is only correct for root content or toplevel documents.
+    MOZ_ASSERT(!pc || pc->IsRootContentDocument() || !pc->GetParentPresContext());
+    nsIFrame* frame = aPresShell->GetRootScrollFrame();
+    if (!frame) {
+      frame = aPresShell->GetRootFrame();
+    }
+    nsRect baseRect;
+    if (frame) {
+      baseRect =
+        nsRect(nsPoint(0, 0), nsLayoutUtils::CalculateCompositionSizeForFrame(frame));
+    } else if (pc) {
+      baseRect = nsRect(nsPoint(0, 0), pc->GetVisibleArea().Size());
+    }
+    nsLayoutUtils::SetDisplayPortBaseIfNotSet(content, baseRect);
+    // Note that we also set the base rect that goes with these margins in
     // nsRootBoxFrame::BuildDisplayList.
     nsLayoutUtils::SetDisplayPortMargins(content, aPresShell, ScreenMargin(), 0,
         nsLayoutUtils::RepaintMode::DoNotRepaint);
     nsLayoutUtils::SetZeroMarginDisplayPortOnAsyncScrollableAncestors(
         content->GetPrimaryFrame(), nsLayoutUtils::RepaintMode::DoNotRepaint);
   }
 }