Bug 705106 - Use the correct scroll port size when trying to scroll to an area. r=roc
authorKartikaya Gupta <kgupta@mozilla.com>
Sat, 09 Jun 2012 12:14:39 -0400
changeset 101064 12ec56310403d6609687df6299b424c67f4ddbb9
parent 101063 ee3d46a285e637d7efb470e1f32df7b9449b0d44
child 101065 c88602e44a5bb7a214c1b4a089c7044b701ce14e
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs705106
milestone16.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 705106 - Use the correct scroll port size when trying to scroll to an area. r=roc
layout/base/nsPresShell.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
layout/generic/nsIScrollableFrame.h
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3091,17 +3091,19 @@ ComputeWhereToScroll(PRInt16 aWhereToScr
  */
 static void ScrollToShowRect(nsIScrollableFrame*      aScrollFrame,
                              const nsRect&            aRect,
                              nsIPresShell::ScrollAxis aVertical,
                              nsIPresShell::ScrollAxis aHorizontal,
                              PRUint32                 aFlags)
 {
   nsPoint scrollPt = aScrollFrame->GetScrollPosition();
-  nsRect visibleRect(scrollPt, aScrollFrame->GetScrollPortRect().Size());
+  nsRect visibleRect(scrollPt,
+                     aScrollFrame->GetScrollPositionClampingScrollPortSize());
+
   nsSize lineSize;
   // Don't call GetLineScrollAmount unless we actually need it. Not only
   // does this save time, but it's not safe to call GetLineScrollAmount
   // during reflow (because it depends on font size inflation and doesn't
   // use the in-reflow-safe font-size inflation path). If we did call it,
   // it would assert and possible give the wrong result.
   if (aVertical.mWhenToScroll == nsIPresShell::SCROLL_IF_NOT_VISIBLE ||
       aHorizontal.mWhenToScroll == nsIPresShell::SCROLL_IF_NOT_VISIBLE) {
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2408,22 +2408,28 @@ nsGfxScrollFrameInner::GetScrollRange(ns
 
 nsRect
 nsGfxScrollFrameInner::GetScrollRangeForClamping() const
 {
   if (!ShouldClampScrollPosition()) {
     return nsRect(nscoord_MIN/2, nscoord_MIN/2,
                   nscoord_MAX - nscoord_MIN/2, nscoord_MAX - nscoord_MIN/2);
   }
+  nsSize scrollPortSize = GetScrollPositionClampingScrollPortSize();
+  return GetScrollRange(scrollPortSize.width, scrollPortSize.height);
+}
+
+nsSize
+nsGfxScrollFrameInner::GetScrollPositionClampingScrollPortSize() const
+{
   nsIPresShell* presShell = mOuter->PresContext()->PresShell();
   if (mIsRoot && presShell->IsScrollPositionClampingScrollPortSizeSet()) {
-    nsSize size = presShell->GetScrollPositionClampingScrollPortSize();
-    return GetScrollRange(size.width, size.height);
+    return presShell->GetScrollPositionClampingScrollPortSize();
   }
-  return GetScrollRange();
+  return mScrollPort.Size();
 }
 
 static void
 AdjustForWholeDelta(PRInt32 aDelta, nscoord* aCoord)
 {
   if (aDelta < 0) {
     *aCoord = nscoord_MIN;
   } else if (aDelta > 0) {
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -144,16 +144,17 @@ public:
       mScrollPort.x - mScrolledFrame->GetPosition().x :
       mScrollPort.XMost() - mScrolledFrame->GetRect().XMost();
     pt.y = mScrollPort.y - mScrolledFrame->GetPosition().y;
     return pt;
   }
   nsRect GetScrollRange() const;
   // Get the scroll range assuming the scrollport has size (aWidth, aHeight).
   nsRect GetScrollRange(nscoord aWidth, nscoord aHeight) const;
+  nsSize GetScrollPositionClampingScrollPortSize() const;
 protected:
   nsRect GetScrollRangeForClamping() const;
 
 public:
   static void AsyncScrollCallback(void* anInstance, mozilla::TimeStamp aTime);
   /**
    * aRange is the range of allowable scroll positions around the desired
    * aScrollPosition. Null means only aScrollPosition is allowed.
@@ -459,16 +460,19 @@ public:
     return mInner.GetScrollPortRect();
   }
   virtual nsPoint GetScrollPosition() const {
     return mInner.GetScrollPosition();
   }
   virtual nsRect GetScrollRange() const {
     return mInner.GetScrollRange();
   }
+  virtual nsSize GetScrollPositionClampingScrollPortSize() const {
+    return mInner.GetScrollPositionClampingScrollPortSize();
+  }
   virtual nsSize GetLineScrollAmount() const {
     return mInner.GetLineScrollAmount();
   }
   virtual nsSize GetPageScrollAmount() const {
     return mInner.GetPageScrollAmount();
   }
   virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
                         const nsRect* aRange = nsnull) {
@@ -704,16 +708,19 @@ public:
     return mInner.GetScrollPortRect();
   }
   virtual nsPoint GetScrollPosition() const {
     return mInner.GetScrollPosition();
   }
   virtual nsRect GetScrollRange() const {
     return mInner.GetScrollRange();
   }
+  virtual nsSize GetScrollPositionClampingScrollPortSize() const {
+    return mInner.GetScrollPositionClampingScrollPortSize();
+  }
   virtual nsSize GetLineScrollAmount() const {
     return mInner.GetLineScrollAmount();
   }
   virtual nsSize GetPageScrollAmount() const {
     return mInner.GetPageScrollAmount();
   }
   virtual void ScrollTo(nsPoint aScrollPosition, ScrollMode aMode,
                         const nsRect* aRange = nsnull) {
--- a/layout/generic/nsIScrollableFrame.h
+++ b/layout/generic/nsIScrollableFrame.h
@@ -88,16 +88,21 @@ public:
    * Get the area that must contain the scroll position. Typically
    * (but not always, e.g. for RTL content) x and y will be 0, and
    * width or height will be nonzero if the content can be scrolled in
    * that direction. Since scroll positions must be a multiple of
    * device pixels, the range extrema will also be a multiple of
    * device pixels.
    */
   virtual nsRect GetScrollRange() const = 0;
+  /**
+   * Get the size of the scroll port to use when clamping the scroll
+   * position.
+   */
+  virtual nsSize GetScrollPositionClampingScrollPortSize() const = 0;
 
   /**
    * Return how much we would try to scroll by in each direction if
    * asked to scroll by one "line" vertically and horizontally.
    */
   virtual nsSize GetLineScrollAmount() const = 0;
   /**
    * Return how much we would try to scroll by in each direction if