UNDO: Fix for Bug 503
authorcharlie <charlie@ibex.org>
Wed, 24 Mar 2004 15:29:53 +0000 (15:29 +0000)
committercharlie <charlie@ibex.org>
Wed, 24 Mar 2004 15:29:53 +0000 (15:29 +0000)
Fixes the loop that assigns colMaxWidth[] values to find the largest
(instead of the smallest) to stop ibex from clipping boxes.  To make
this possible, the patch induces colMaxWidth[1..n] to 0 instead of
MAX_LENGTH (as max(MAX_LENGTH,any_width) will always be MAX_LENGTH).

darcs-hash:20040324152953-e3a7d-6b220e3ab11a2c4b5aa8f5b0b9ad1215c2e1a432.gz

src/org/ibex/Box.java

index 180a652..2109cb9 100644 (file)
@@ -218,7 +218,7 @@ public final class Box extends JSScope implements Scheduler.Task {
     private static LENGTH[] colMaxWidth = new LENGTH[65535];
     private static LENGTH[] rowHeight = new LENGTH[65535];
     private static LENGTH[] rowMaxHeight = new LENGTH[65535];
-    static { for(int i=0; i<rowMaxHeight.length; i++) { rowMaxHeight[i] = 0; colMaxWidth[i] = 0; } }
+    static { for(int i=0; i<rowMaxHeight.length; i++) { rowMaxHeight[i] = MAX_LENGTH; colMaxWidth[i] = MAX_LENGTH; } }
 
     Box nextPackedSibling() { Box b = nextSibling(); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
     Box firstPackedChild() { Box b = getChild(0); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
@@ -302,7 +302,7 @@ public final class Box extends JSScope implements Scheduler.Task {
                 x_slack += colWidth[i];
                 colWidth[i] = max(colWidth[i], child.contentwidth / child.colspan);
                 x_slack -= colWidth[i];
-                colMaxWidth[i] = max(colMaxWidth[i], (child.test(HSHRINK) ? child.contentwidth : child.maxwidth) / child.colspan);
+                colMaxWidth[i] = min(colMaxWidth[i], child.test(HSHRINK) ? child.contentwidth : child.maxwidth) / child.colspan;
             }
         
         // PHASE 2: hand out slack
@@ -348,8 +348,8 @@ public final class Box extends JSScope implements Scheduler.Task {
         }
 
         // cleanup
-        for(int i=0; i<cols; i++) { colWidth[i] = 0; colMaxWidth[i] = 0; }
-        for(int i=0; i<rows; i++) { rowHeight[i] = 0; rowMaxHeight[i] = 0; }
+        for(int i=0; i<cols; i++) { colWidth[i] = 0; colMaxWidth[i] = MAX_LENGTH; }
+        for(int i=0; i<rows; i++) { rowHeight[i] = 0; rowMaxHeight[i] = MAX_LENGTH; }
 
         for(Box child = getChild(0); child != null; child = child.nextSibling())
             if (test(VISIBLE))