From d3323169180d00890bc4b9bfe85ac09156c6e569 Mon Sep 17 00:00:00 2001 From: Alexander Malmberg Date: Sun, 15 Jun 2003 15:18:54 +0000 Subject: [PATCH] Handle text containers with no area. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16929 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/GSHorizontalTypesetter.m | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 567f6ee6e..91f976268 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-06-15 16:26 Alexander Malmberg + + * Source/GSHorizontalTypesetter.m: Use NSIsEmptyRect instead of + comparing for equality with NSZeroRect. + (-layoutLineNewParagraph:): Handle text containers with no area. + 2003-06-15 14:57 Alexander Malmberg * configure.ac: Don't add GNUSTEP_HDIR/GNUSTEP_LDIR to diff --git a/Source/GSHorizontalTypesetter.m b/Source/GSHorizontalTypesetter.m index 4436547dd..f6811753b 100644 --- a/Source/GSHorizontalTypesetter.m +++ b/Source/GSHorizontalTypesetter.m @@ -455,7 +455,7 @@ Return values 0, 1, 2 are mostly the same as from break; } - if (NSEqualRects(r, NSZeroRect) || NSMaxY(r) + shift.height > container_height) + if (NSIsEmptyRect(r) || NSMaxY(r) + shift.height > container_height) break; g = g2; @@ -511,7 +511,7 @@ Return values 0, 1, 2 are mostly the same as from movementDirection: NSLineMoveDown remainingRect: &remain]; - if (!NSEqualRects(r, NSZeroRect)) + if (!NSIsEmptyRect(r)) { r2 = r; r2.size.width = 1; @@ -544,9 +544,19 @@ Return values 0, 1, 2 are mostly the same as from line_height = max_line_height; } - /* If we find out that we need to increase the line height, we have to + /* + If we find out that we need to increase the line height, we have to start over. The increased line height might give _completely_ different - line frag rects, so we can't reuse the layout information. */ + line frag rects, so we can't reuse the layout information. + + OPT: However, we could recreate the line frag rects and see if they + match before throwing away layout information, since most of the time + they will be equivalent. + + Also, in the very common case of a simple rectangular text container, we + can always extend the current line frag rects as long as they don't extend + past the bottom of the container. + */ #define WANT_LINE_HEIGHT(h) \ @@ -610,7 +620,8 @@ restart: if (!line_frags_num) { if (curPoint.y == 0.0 && - line_height > [curTextContainer containerSize].height) + line_height > [curTextContainer containerSize].height && + [curTextContainer containerSize].height > 0.0) { /* Try to make sure each container contains at least one line frag rect by shrinking our line height. */