Bug 1423431 - Handle nsTreeBodyFrame row of null height in divisions - r=tnikkel
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 21 Dec 2017 12:33:06 +1100
changeset 449040 42d07ddce2241fbc4aa8d87bf2d15c6b25b8c224
parent 449039 7d9c675dabf5d63ff88582d2e5815a06ce9bb0ba
child 449041 5475206095b7b4ae1107d725ade1f37310aaf670
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1423431
milestone59.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 1423431 - Handle nsTreeBodyFrame row of null height in divisions - r=tnikkel MozReview-Commit-ID: KxDPVMq3pjV
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -421,17 +421,18 @@ nsTreeBodyFrame::ReflowFinished()
     EnsureView();
     NS_ENSURE_TRUE(weakFrame.IsAlive(), false);
   }
   if (mView) {
     CalcInnerBox();
     ScrollParts parts = GetScrollParts();
     mHorzWidth = CalcHorzWidth(parts);
     if (!mHasFixedRowCount) {
-      mPageLength = mInnerBox.height / mRowHeight;
+      mPageLength =
+        (mRowHeight > 0) ? (mInnerBox.height / mRowHeight) : mRowCount;
     }
 
     int32_t lastPageTopRow = std::max(0, mRowCount - mPageLength);
     if (mTopRowIndex > lastPageTopRow)
       ScrollToRowInternal(parts, lastPageTopRow);
 
     nsIContent *treeContent = GetBaseElement();
     if (treeContent &&
@@ -1283,16 +1284,19 @@ nsTreeBodyFrame::GetCoordsForCellItem(in
   *aHeight = nsPresContext::AppUnitsToIntCSSPixels(theRect.height);
 
   return NS_OK;
 }
 
 int32_t
 nsTreeBodyFrame::GetRowAt(int32_t aX, int32_t aY)
 {
+  if (mRowHeight <= 0)
+    return -1;
+
   // Now just mod by our total inner box height and add to our top row index.
   int32_t row = (aY/mRowHeight)+mTopRowIndex;
 
   // Check if the coordinates are below our visible space (or within our visible
   // space but below any row).
   if (row > mTopRowIndex + mPageLength || row >= mRowCount)
     return -1;
 
@@ -2910,17 +2914,17 @@ nsTreeBodyFrame::PaintTreeBody(gfxContex
   DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
 
   aRenderingContext.Save();
   aRenderingContext.Clip(
     NSRectToSnappedRect(mInnerBox + aPt, PresContext()->AppUnitsPerDevPixel(),
                         *drawTarget));
   int32_t oldPageCount = mPageLength;
   if (!mHasFixedRowCount)
-    mPageLength = mInnerBox.height/mRowHeight;
+    mPageLength = (mRowHeight > 0) ? (mInnerBox.height/mRowHeight) : mRowCount;
 
   if (oldPageCount != mPageLength || mHorzWidth != CalcHorzWidth(GetScrollParts())) {
     // Schedule a ResizeReflow that will update our info properly.
     PresShell()->FrameNeedsReflow(this, nsIPresShell::eResize,
                                   NS_FRAME_IS_DIRTY);
   }
 #ifdef DEBUG
   int32_t rowCount = mRowCount;
@@ -4447,17 +4451,17 @@ nsTreeBodyFrame::ThumbMoved(nsScrollbarF
     return;
 
   AutoWeakFrame weakFrame(this);
 
   // Vertical Scrollbar
   if (parts.mVScrollbar == aScrollbar) {
     nscoord rh = nsPresContext::AppUnitsToIntCSSPixels(mRowHeight);
     nscoord newIndex = nsPresContext::AppUnitsToIntCSSPixels(aNewPos);
-    nscoord newrow = newIndex/rh;
+    nscoord newrow = (rh > 0) ? (newIndex/rh) : 0;
     ScrollInternal(parts, newrow);
   // Horizontal Scrollbar
   } else if (parts.mHScrollbar == aScrollbar) {
     int32_t newIndex = nsPresContext::AppUnitsToIntCSSPixels(aNewPos);
     ScrollHorzInternal(parts, newIndex);
   }
   if (weakFrame.IsAlive()) {
     UpdateScrollbars(parts);