Bug 1382682 - Move ViewIDForASR into nsLayoutUtils for reuse. r=mstange
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 20 Jul 2017 12:33:09 -0400
changeset 418871 a2bfff6c59b16b7c999c7620fdc3b596291b1970
parent 418870 ed9a8d8a28969ffa461d14fd5febfe437408141c
child 418872 7b1329006eda9e9532af32fac208eae3979fbee4
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1382682
milestone56.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 1382682 - Move ViewIDForASR into nsLayoutUtils for reuse. r=mstange MozReview-Commit-ID: IcYqDO1D2SB
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/painting/FrameLayerBuilder.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -830,16 +830,23 @@ nsLayoutUtils::FindContentFor(ViewID aId
 
   if (exists) {
     return content;
   } else {
     return nullptr;
   }
 }
 
+ViewID
+nsLayoutUtils::ViewIDForASR(const mozilla::ActiveScrolledRoot* aASR)
+{
+  nsIContent* content = aASR->mScrollableFrame->GetScrolledFrame()->GetContent();
+  return nsLayoutUtils::FindOrCreateIDFor(content);
+}
+
 nsIFrame*
 GetScrollFrameFromContent(nsIContent* aContent)
 {
   nsIFrame* frame = aContent->GetPrimaryFrame();
   if (aContent->OwnerDoc()->GetRootElement() == aContent) {
     nsIPresShell* presShell = frame ? frame->PresContext()->PresShell() : nullptr;
     if (!presShell) {
       presShell = aContent->OwnerDoc()->GetShell();
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -67,16 +67,17 @@ namespace mozilla {
 enum class CSSPseudoElementType : uint8_t;
 class EventListenerManager;
 enum class LayoutFrameType : uint8_t;
 struct IntrinsicSize;
 struct ContainerLayerParameters;
 class WritingMode;
 class DisplayItemClip;
 class EffectSet;
+struct ActiveScrolledRoot;
 namespace dom {
 class CanvasRenderingContext2D;
 class DOMRectList;
 class Element;
 class HTMLImageElement;
 class HTMLCanvasElement;
 class HTMLVideoElement;
 class OffscreenCanvas;
@@ -179,16 +180,22 @@ public:
   static ViewID FindOrCreateIDFor(nsIContent* aContent);
 
   /**
    * Find content for given ID.
    */
   static nsIContent* FindContentFor(ViewID aId);
 
   /**
+   * Find the view ID (or generate a new one) for the content element
+   * corresponding to the ASR.
+   */
+  static ViewID ViewIDForASR(const mozilla::ActiveScrolledRoot* aASR);
+
+  /**
    * Find the scrollable frame for a given ID.
    */
   static nsIScrollableFrame* FindScrollableFrameFor(ViewID aId);
 
   /**
    * Find the ID for a given scrollable frame.
    */
   static ViewID FindIDForScrollableFrame(nsIScrollableFrame* aScrollable);
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -4991,23 +4991,16 @@ FindDirectChildASR(const ActiveScrolledR
   const ActiveScrolledRoot* directChild = aDescendant;
   while (directChild->mParent != aParent) {
     directChild = directChild->mParent;
     MOZ_RELEASE_ASSERT(directChild, "this must not be null");
   }
   return directChild;
 }
 
-static FrameMetrics::ViewID
-ViewIDForASR(const ActiveScrolledRoot* aASR)
-{
-  nsIContent* content = aASR->mScrollableFrame->GetScrolledFrame()->GetContent();
-  return nsLayoutUtils::FindOrCreateIDFor(content);
-}
-
 static void
 FixUpFixedPositionLayer(Layer* aLayer,
                         const ActiveScrolledRoot* aTargetASR,
                         const ActiveScrolledRoot* aLeafScrollMetadataASR,
                         const ActiveScrolledRoot* aContainerScrollMetadataASR,
                         const ActiveScrolledRoot* aContainerCompositorASR,
                         bool aIsFixedToRootScrollFrame)
 {
@@ -5046,17 +5039,17 @@ FixUpFixedPositionLayer(Layer* aLayer,
     aLeafScrollMetadataASR == aContainerScrollMetadataASR
       ? aContainerCompositorASR
       : aLeafScrollMetadataASR;
 
   // The goal of the annotation is to have the layer move with aTargetASR.
   if (compositorASR && aTargetASR != compositorASR) {
     // Mark this layer as fixed with respect to the child scroll frame of aTargetASR.
     aLayer->SetFixedPositionData(
-      ViewIDForASR(FindDirectChildASR(aTargetASR, compositorASR)),
+      nsLayoutUtils::ViewIDForASR(FindDirectChildASR(aTargetASR, compositorASR)),
       aLayer->GetFixedPositionAnchor(),
       aLayer->GetFixedPositionSides());
   } else {
     // Remove the fixed annotation from the layer, unless this layers is fixed
     // to the document's root scroll frame - in that case, the annotation is
     // needed for hit testing, because fixed layers in iframes should scroll
     // the iframe, even though their position is not affected by scrolling in
     // the iframe. (The APZ hit testing code has a special case for this.)