changeset 1803:19bdbf3b30ee

Automated merge with ssh://javafxsrc.us.oracle.com//javafx/8.0/scrum//graphics/jfx/rt
author David Hill
date Fri, 12 Oct 2012 11:01:33 -0400
parents ea00b638cdd6 408ee6a41174
children bae4dedcad85
files
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Oct 09 13:07:14 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualFlow.java	Fri Oct 12 11:01:33 2012 -0400
@@ -757,6 +757,7 @@
             maxPrefBreadth = -1;
             lastWidth = -1;
             lastHeight = -1;
+            numCellsVisibleOnScreen = -1;
             releaseCell(accumCell);
 //            accumCell = null;
 //            accumCellParent.getChildren().clear();
@@ -769,6 +770,7 @@
             maxPrefBreadth = -1;
             lastWidth = -1;
             lastHeight = -1;
+            numCellsVisibleOnScreen = -1;
             needsReconfigureCells = false;
         }
         
@@ -1261,19 +1263,21 @@
         // Toggle visibility on the corner
         corner.setVisible(breadthBar.isVisible() && lengthBar.isVisible());
 
-        numCellsVisibleOnScreen = 0;
         double sumCellLength = 0;
         double flowLength = (isVertical ? getHeight() : getWidth()) -
             (breadthBar.isVisible() ? breadthBar.prefHeight(-1) : 0);
-        for (int i = 0, max = cells.size(); i < max; i++) {
-            IndexedCell cell = cells.get(i);
-            if (cell != null && ! cell.isEmpty()) {
-                sumCellLength += (isVertical ? cell.getHeight() : cell.getWidth());
-                if (sumCellLength > flowLength) {
-                    break;
+        if (numCellsVisibleOnScreen == -1) {
+            numCellsVisibleOnScreen = 0;
+            for (int i = 0, max = cells.size(); i < max; i++) {
+                IndexedCell cell = cells.get(i);
+                if (cell != null && ! cell.isEmpty()) {
+                    sumCellLength += (isVertical ? cell.getHeight() : cell.getWidth());
+                    if (sumCellLength > flowLength) {
+                        break;
+                    }
+
+                    numCellsVisibleOnScreen++;
                 }
-
-                numCellsVisibleOnScreen++;
             }
         }
 
@@ -1315,7 +1319,7 @@
                 // only a single row and it is bigger than the viewport
                 lengthBar.setVisibleAmount(flowLength / sumCellLength);
             } else {
-                lengthBar.setVisibleAmount(cellCount / viewportLength);
+                lengthBar.setVisibleAmount(numCellsVisibleOnScreen / (float) cellCount);
             }
 
             // Fix for RT-11873. If this isn't here, we can have a situation where