Don't cause layout_char to wrap around when adding lengthChange.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18842 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2004-03-13 02:22:12 +00:00
parent 9f403efdaa
commit 07176d3800
2 changed files with 33 additions and 13 deletions

View file

@ -1,3 +1,13 @@
2004-03-13 03:19 Alexander Malmberg <alexander@malmberg.org>
* Source/NSLayoutManager.m
(-textStorage:edited:range:changeInLength:invalidatedRange:): Handle
the case where layout_char is inside the modified range explicitly to
avoid accidentally causing the value to wrap around.
(-drawGlyphsForGlyphRange:atPoint:): Remove dead (since the change
2003-11-01) code. Update comments.
2004-03-12 Quentin Mathe <qmathe@club-internet.fr>
* Source/GSToolbarView.m: Bug fixes related to clipped items and more

View file

@ -1437,11 +1437,14 @@ container
cellFrame.size = la->size;
cellFrame.origin.y -= cellFrame.size.height;
/* Drawing the cell might mess up our state. */
/* Drawing the cell might mess up our state, so we reset
the font and color afterwards. */
/* TODO:
optimize this. probably cheaper to not save and
explicitly reset just the stuff we actually use, or to
collect attachments and draw them in bunches of eg. 4
optimize this?
collect attachments and draw them in bunches of eg. 4?
probably not worth effort. better to optimize font and
color setting :)
should they really be drawn in our coordinate system?
*/
@ -1450,10 +1453,6 @@ container
characterIndex: char_index
layoutManager: self];
[f set];
if (color == nil)
{
color = defaultTextColor;
}
[color set];
}
continue;
@ -1799,9 +1798,20 @@ this file describes this.
if (layout_char > r.location)
{
layout_char += lengthChange;
if (layout_char < r.location)
layout_char = r.location;
if (layout_char >= r.location + r.length)
layout_char += lengthChange;
else
{
/*
The last layout information we had is inside the range that
is being invalidated.
In this case, there'll be no soft-invalidated layout information
to save. However, we still have layout information that we need
to discard.
*/
layout_char = r.location;
}
}
if (!layout_char)
@ -1827,7 +1837,7 @@ this file describes this.
/*
Note that r.location might equal layout_char, in which case
r.location won't actually have any text container or line frag.
r.location might not actually have any text container or line frag.
*/
if (!r.location)
{
@ -2104,7 +2114,7 @@ no_soft_invalidation:
In other words, unless the selection spans over the entire changed
range, the changed range is deselected.
One important property of this behavios is that if length is 0 before,
One important property of this behavior is that if length is 0 before,
it will be 0 after.
*/
if (_selected_range.location >= NSMaxRange(range) - lengthChange)