<pre> bug fix
David Hyatt
hyatt at apple.com
Mon Sep 29 13:12:53 CEST 2003
The bug in Safari described here:
http://www.natural-innovations.com/test/sfripre.html
is a bug in Safari with the calculation of maxwidth for text runs with
white-space: pre.
Here's the fix:
Index: khtml/rendering/render_text.cpp
===================================================================
RCS file:
/local/home/cvs/Labyrinth/WebCore/khtml/rendering/render_text.cpp,v
retrieving revision 1.81
diff -u -p -r1.81 khtml/rendering/render_text.cpp
--- khtml/rendering/render_text.cpp 2003/09/25 16:51:10 1.81
+++ khtml/rendering/render_text.cpp 2003/09/27 21:00:58
@@ -965,10 +965,10 @@ void RenderText::trimmedMinMaxWidth(shor
const Font *f = htmlFont( false );
bool firstLine = true;
beginMaxW = endMaxW = maxW;
- for(int i = 0; i < len; i++)
+ for (int i = 0; i < len; i++)
{
int linelen = 0;
- while( i+linelen < len && str->s[i+linelen] != '\n')
+ while (i+linelen < len && str->s[i+linelen] != '\n')
linelen++;
if (linelen)
@@ -983,13 +983,16 @@ void RenderText::trimmedMinMaxWidth(shor
beginMaxW = endMaxW;
}
i += linelen;
- if (i == len-1)
- endMaxW = 0;
}
else if (firstLine) {
beginMaxW = 0;
firstLine = false;
}
+
+ if (i == len-1)
+ // A <pre> run that ends with a newline, as in, e.g.,
+ // <pre>Some text\n\n<span>More text</pre>
+ endMaxW = 0;
}
}
}
More information about the Khtml-devel
mailing list