Bug 602892. Part 1: Refactor so that mScrollingActive is always true for scrollframes that are always active. r=tnikkel,a=blocking
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 04 Jan 2011 21:46:56 +1300
changeset 59827 e870951c916747c5b724e108705a880201c50c3d
parent 59826 c3825c079c0051dc199e6dc960567385e46755a2
child 59828 2a0d0ed04874772ed05106229c999493944d12c9
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewerstnikkel, blocking
bugs602892
milestone2.0b9pre
Bug 602892. Part 1: Refactor so that mScrollingActive is always true for scrollframes that are always active. r=tnikkel,a=blocking
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1342,25 +1342,25 @@ nsGfxScrollFrameInner::nsGfxScrollFrameI
     mIsXUL(aIsXUL),
     mSupppressScrollbarUpdate(PR_FALSE),
     mSkippedScrollbarLayout(PR_FALSE),
     mHadNonInitialReflow(PR_FALSE),
     mHorizontalOverflow(PR_FALSE),
     mVerticalOverflow(PR_FALSE),
     mPostedReflowCallback(PR_FALSE),
     mMayHaveDirtyFixedChildren(PR_FALSE),
-    mUpdateScrollbarAttributes(PR_FALSE),
-    mScrollingActive(PR_FALSE)
+    mUpdateScrollbarAttributes(PR_FALSE)
 {
   // lookup if we're allowed to overlap the content from the look&feel object
   PRBool canOverlap;
   nsPresContext* presContext = mOuter->PresContext();
   presContext->LookAndFeel()->
     GetMetric(nsILookAndFeel::eMetric_ScrollbarsCanOverlapContent, canOverlap);
   mScrollbarsCanOverlapContent = canOverlap;
+  mScrollingActive = IsAlwaysActive();
 }
 
 nsGfxScrollFrameInner::~nsGfxScrollFrameInner()
 {
   if (mActivityExpirationState.IsTracked()) {
     gScrollFrameActivityTracker->RemoveObject(this);
   }
   if (gScrollFrameActivityTracker &&
@@ -1525,30 +1525,30 @@ static void AdjustViews(nsIFrame* aFrame
     // views for popups are not scrolled.
     do {
       childListName = aFrame->GetAdditionalChildListName(childListIndex++);
     } while (childListName == nsGkAtoms::popupList);
   } while (childListName);
 }
 
 static PRBool
-CanScrollWithBlitting(nsIFrame* aFrame, nsIFrame* aDisplayRoot)
+CanScrollWithBlitting(nsIFrame* aFrame)
 {
   for (nsIFrame* f = aFrame; f;
        f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
     if (f->GetStyleDisplay()->HasTransform()) {
       return PR_FALSE;
     }
 #ifdef MOZ_SVG
     if (nsSVGIntegrationUtils::UsingEffectsForFrame(f) ||
         f->IsFrameOfType(nsIFrame::eSVG)) {
       return PR_FALSE;
     }
 #endif
-    if (f == aDisplayRoot)
+    if (nsLayoutUtils::IsPopup(f))
       break;
   }
   return PR_TRUE;
 }
 
 static void
 InvalidateFixedBackgroundFramesFromList(nsDisplayListBuilder* aBuilder,
                                         nsIFrame* aMovingFrame,
@@ -1604,21 +1604,16 @@ PRBool nsGfxScrollFrameInner::IsAlwaysAc
 {
   // The root scrollframe for a non-chrome document which is the direct
   // child of a chrome document is always treated as "active".
   // XXX maybe we should extend this so that IFRAMEs which are fill the
   // entire viewport (like GMail!) are always active
   return mIsRoot && mOuter->PresContext()->IsRootContentDocument();
 }
 
-PRBool nsGfxScrollFrameInner::IsScrollingActive() const
-{
-  return mScrollingActive || IsAlwaysActive();
-}
-
 void nsGfxScrollFrameInner::MarkActive()
 {
   if (IsAlwaysActive())
     return;
 
   mScrollingActive = PR_TRUE;
   if (mActivityExpirationState.IsTracked()) {
     gScrollFrameActivityTracker->MarkUsed(this);
@@ -1638,24 +1633,24 @@ void nsGfxScrollFrameInner::ScrollVisual
   }
 
   rootPresContext->RequestUpdatePluginGeometry(mOuter);
 
   AdjustViews(mScrolledFrame);
   // We need to call this after fixing up the view positions
   // to be consistent with the frame hierarchy.
   PRUint32 flags = nsIFrame::INVALIDATE_REASON_SCROLL_REPAINT;
-  nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(mOuter);
-  if (IsScrollingActive() && CanScrollWithBlitting(mOuter, displayRoot)) {
+  if (IsScrollingActive() && CanScrollWithBlitting(mOuter)) {
     flags |= nsIFrame::INVALIDATE_NO_THEBES_LAYERS;
   }
   MarkActive();
   mOuter->InvalidateWithFlags(mScrollPort, flags);
 
   if (flags & nsIFrame::INVALIDATE_NO_THEBES_LAYERS) {
+    nsIFrame* displayRoot = nsLayoutUtils::GetDisplayRootFrame(mOuter);
     nsRect update =
       GetScrollPortRect() + mOuter->GetOffsetToCrossDoc(displayRoot);
     update = update.ConvertAppUnitsRoundOut(
       mOuter->PresContext()->AppUnitsPerDevPixel(),
       displayRoot->PresContext()->AppUnitsPerDevPixel());
     InvalidateFixedBackgroundFrames(displayRoot, mScrolledFrame, update);
   }
 }
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -218,17 +218,17 @@ public:
   PRUint32 GetScrollbarVisibility() const {
     return (mHasVerticalScrollbar ? nsIScrollableFrame::VERTICAL : 0) |
            (mHasHorizontalScrollbar ? nsIScrollableFrame::HORIZONTAL : 0);
   }
   nsMargin GetActualScrollbarSizes() const;
   nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState);
   PRBool IsLTR() const;
   PRBool IsScrollbarOnRight() const;
-  PRBool IsScrollingActive() const;
+  PRBool IsScrollingActive() const { return mScrollingActive; }
   // adjust the scrollbar rectangle aRect to account for any visible resizer.
   // aHasResizer specifies if there is a content resizer, however this method
   // will also check if a widget resizer is present as well.
   void AdjustScrollbarRectForResizer(nsIFrame* aFrame, nsPresContext* aPresContext,
                                      nsRect& aRect, PRBool aHasResizer, PRBool aVertical);
   // returns true if a resizer should be visible
   PRBool HasResizer() {
       return mScrollCornerContent && mScrollCornerContent->Tag() == nsGkAtoms::resizer;