Bug 1290823 - Introduce a helper APZCCallbackHelper::GetPresContextForContent(). r=rbarker
authorBotond Ballo <botond@mozilla.com>
Mon, 08 Aug 2016 15:19:24 -0400
changeset 308609 7faf4ab858f35ba51a9020000a71952301b586a6
parent 308608 6ee3b3be309baa1a40ed3c036cab4671359a3bed
child 308610 511617938a502998b3e690f69ffe99b8ce38320a
push idunknown
push userunknown
push dateunknown
reviewersrbarker
bugs1290823
milestone51.0a1
Bug 1290823 - Introduce a helper APZCCallbackHelper::GetPresContextForContent(). r=rbarker And use it in APZCCallbackHelper::GetRootContentDocumentPresShellForContent(). MozReview-Commit-ID: 9Gm8kgbqlHm
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZCCallbackHelper.h
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -333,28 +333,34 @@ APZCCallbackHelper::InitializeRootDispla
     // nsRootBoxFrame::BuildDisplayList.
     nsLayoutUtils::SetDisplayPortMargins(content, aPresShell, ScreenMargin(), 0,
         nsLayoutUtils::RepaintMode::DoNotRepaint);
     nsLayoutUtils::SetZeroMarginDisplayPortOnAsyncScrollableAncestors(
         content->GetPrimaryFrame(), nsLayoutUtils::RepaintMode::DoNotRepaint);
   }
 }
 
+nsPresContext*
+APZCCallbackHelper::GetPresContextForContent(nsIContent* aContent)
+{
+  nsIDocument* doc = aContent->GetComposedDoc();
+  if (!doc) {
+      return nullptr;
+  }
+  nsIPresShell* shell = doc->GetShell();
+  if (!shell) {
+      return nullptr;
+  }
+  return shell->GetPresContext();
+}
+
 nsIPresShell*
 APZCCallbackHelper::GetRootContentDocumentPresShellForContent(nsIContent* aContent)
 {
-    nsIDocument* doc = aContent->GetComposedDoc();
-    if (!doc) {
-        return nullptr;
-    }
-    nsIPresShell* shell = doc->GetShell();
-    if (!shell) {
-        return nullptr;
-    }
-    nsPresContext* context = shell->GetPresContext();
+    nsPresContext* context = GetPresContextForContent(aContent);
     if (!context) {
         return nullptr;
     }
     context = context->GetToplevelContentDocumentPresContext();
     if (!context) {
         return nullptr;
     }
     return context->PresShell();
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -61,16 +61,19 @@ public:
     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);
 
+    /* Get the pres context associated with the document enclosing |aContent|. */
+    static nsPresContext* GetPresContextForContent(nsIContent* aContent);
+
     /* Get the pres shell associated with the root content document enclosing |aContent|. */
     static nsIPresShell* GetRootContentDocumentPresShellForContent(nsIContent* aContent);
 
     /* Apply an "input transform" to the given |aInput| and return the transformed value.
        The input transform applied is the one for the content element corresponding to
        |aGuid|; this is populated in a previous call to UpdateCallbackTransform. See that
        method's documentations for details.
        This method additionally adjusts |aInput| by inversely scaling by the provided