From d892b1ff73b696e37812afd7d78c2eaae3342a0b Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 11 Apr 2004 20:23:39 +0000 Subject: [PATCH] reflow on demand when JS reads width/height darcs-hash:20040411202339-5007d-f5f141a44138f32fc3f5e0c78e207c7a97c3ecea.gz --- src/org/ibex/Box.java | 13 +++++-------- src/org/ibex/Surface.java | 3 +-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/org/ibex/Box.java b/src/org/ibex/Box.java index 1f0da15..b2608fb 100644 --- a/src/org/ibex/Box.java +++ b/src/org/ibex/Box.java @@ -2,13 +2,7 @@ // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.ibex; -// FEATURE: reflow before allowing js to read from width/height -// FEATURE: fastpath for rows=1/cols=1 // FEATURE: mark to reflow starting with a certain child -// FEATURE: separate mark_for_reflow and mark_for_resize -// FEATURE: make all methods final -// FEATURE: use a linked list for the "frontier" when packing -// FEATURE: or else have a way to mark a column "same as last one"? // FEATURE: reintroduce surface.abort import java.util.*; @@ -199,6 +193,9 @@ public final class Box extends JSScope implements Scheduler.Task { // Reflow //////////////////////////////////////////////////////////////////////////////////////// + /** should only be invoked on the root box */ + void reflow() { pack(); resize(x, y, maxwidth, maxheight); place(); } + private static Box[] frontier = new Box[65535]; /** pack the boxes into rows and columns, compute contentwidth */ void pack() { @@ -518,8 +515,8 @@ public final class Box extends JSScope implements Scheduler.Task { case "rows": return test(FIXED) == ROWS ? N(rows) : N(0); case "colspan": return N(colspan); case "rowspan": return N(rowspan); - case "width": return N(width); - case "height": return N(height); + case "width": getRoot().reflow(); return N(width); + case "height": getRoot().reflow(); return N(height); case "minwidth": return N(minwidth); case "maxwidth": return N(maxwidth); case "minheight": return N(minheight); diff --git a/src/org/ibex/Surface.java b/src/org/ibex/Surface.java index d2130e3..7e23169 100644 --- a/src/org/ibex/Surface.java +++ b/src/org/ibex/Surface.java @@ -247,8 +247,7 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { dirty(0, root.height - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height); dirty(0, root.maxheight - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height); } - root.resize(root.x, root.y, root.maxwidth, root.maxheight); - root.place(); + root.reflow(); setSize(root.width, root.height); /*String oldcursor = cursor; cursor = "default"; -- 1.7.10.4