Bug 800041 - Set the correct reference frame for nsDisplayScrollLayer when the frame is transformed. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 25 Oct 2012 12:04:41 +1300
changeset 111299 bbfa842d5f5e0f3307b193dd080fadd1c7fa5d4b
parent 111298 c0c98a83180465a13114dbd9678a3c7968a1fc42
child 111300 1a97b903917f16b93a258990f6940ef005924330
push id23740
push userryanvm@gmail.com
push dateThu, 25 Oct 2012 12:13:42 +0000
treeherdermozilla-central@5374fb480634 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs800041
milestone19.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 800041 - Set the correct reference frame for nsDisplayScrollLayer when the frame is transformed. r=roc
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -2775,16 +2775,21 @@ nsDisplayScrollLayer::nsDisplayScrollLay
   , mScrolledFrame(aScrolledFrame)
 {
 #ifdef NS_BUILD_REFCNT_LOGGING
   MOZ_COUNT_CTOR(nsDisplayScrollLayer);
 #endif
 
   NS_ASSERTION(mScrolledFrame && mScrolledFrame->GetContent(),
                "Need a child frame with content");
+  nsIFrame *parent = nsLayoutUtils::GetCrossDocParentFrame(aForFrame);
+  NS_ASSERTION(parent, "Must have a parent!");
+  mReferenceFrame = 
+    aBuilder->FindReferenceFrameFor(parent);
+  mToReferenceFrame = aForFrame->GetOffsetToCrossDoc(mReferenceFrame);
 }
 
 nsDisplayScrollLayer::nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder,
                                            nsDisplayItem* aItem,
                                            nsIFrame* aForFrame,
                                            nsIFrame* aScrolledFrame,
                                            nsIFrame* aScrollFrame)
   : nsDisplayWrapList(aBuilder, aForFrame, aItem)
@@ -2792,32 +2797,42 @@ nsDisplayScrollLayer::nsDisplayScrollLay
   , mScrolledFrame(aScrolledFrame)
 {
 #ifdef NS_BUILD_REFCNT_LOGGING
   MOZ_COUNT_CTOR(nsDisplayScrollLayer);
 #endif
 
   NS_ASSERTION(mScrolledFrame && mScrolledFrame->GetContent(),
                "Need a child frame with content");
+  nsIFrame *parent = nsLayoutUtils::GetCrossDocParentFrame(aForFrame);
+  NS_ASSERTION(parent, "Must have a parent!");
+  mReferenceFrame = 
+    aBuilder->FindReferenceFrameFor(parent);
+  mToReferenceFrame = aForFrame->GetOffsetToCrossDoc(mReferenceFrame);
 }
 
 nsDisplayScrollLayer::nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder,
                                            nsIFrame* aForFrame,
                                            nsIFrame* aScrolledFrame,
                                            nsIFrame* aScrollFrame)
   : nsDisplayWrapList(aBuilder, aForFrame)
   , mScrollFrame(aScrollFrame)
   , mScrolledFrame(aScrolledFrame)
 {
 #ifdef NS_BUILD_REFCNT_LOGGING
   MOZ_COUNT_CTOR(nsDisplayScrollLayer);
 #endif
 
   NS_ASSERTION(mScrolledFrame && mScrolledFrame->GetContent(),
                "Need a child frame with content");
+  nsIFrame *parent = nsLayoutUtils::GetCrossDocParentFrame(aForFrame);
+  NS_ASSERTION(parent, "Must have a parent!");
+  mReferenceFrame = 
+    aBuilder->FindReferenceFrameFor(parent);
+  mToReferenceFrame = aForFrame->GetOffsetToCrossDoc(mReferenceFrame);
 }
 
 #ifdef NS_BUILD_REFCNT_LOGGING
 nsDisplayScrollLayer::~nsDisplayScrollLayer()
 {
   MOZ_COUNT_DTOR(nsDisplayScrollLayer);
 }
 #endif
@@ -2897,16 +2912,19 @@ nsDisplayScrollLayer::TryMerge(nsDisplay
     return false;
   }
 
   nsDisplayScrollLayer* other = static_cast<nsDisplayScrollLayer*>(aItem);
   if (other->mScrolledFrame != this->mScrolledFrame) {
     return false;
   }
 
+  NS_ASSERTION(other->mReferenceFrame == mReferenceFrame,
+               "Must have the same reference frame!");
+
   FrameProperties props = mScrolledFrame->Properties();
   props.Set(nsIFrame::ScrollLayerCount(),
     reinterpret_cast<void*>(GetScrollLayerCount() - 1));
 
   // Swap frames with the other item before doing MergeFrom.
   // XXX - This ensures that the frame associated with a scroll layer after
   // merging is the first, rather than the last. This tends to change less,
   // ensuring we're more likely to retain the associated gfx layer.