Commit 80296ca2 authored by hyatt's avatar hyatt

Rewrite the calculation of min and max width for <pre>s. This

	is the second stage of the whitespace rewrite (third stage
	will be to stop morphing newlines).

	This should fix a bunch of bugs, e.g., especially if you ever
	did the following:
	<td><pre><span>foo</span>
	   more text after the newline</pre></td>

	The new code now properly handles building up the correct min/max
	width for the <pre>.

	If anyone recalls seeing any bugs like this, let me know and
	I can close them.

        * khtml/rendering/render_flow.cpp:
        (RenderFlow::calcInlineMinMaxWidth):
        * khtml/rendering/render_text.cpp:
        (RenderText::trimmedMinMaxWidth):
        (RenderText::calcMinMaxWidth):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2712 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 26179439
2002-11-16 David Hyatt <hyatt@apple.com>
Rewrite the calculation of min and max width for <pre>s. This
is the second stage of the whitespace rewrite (third stage
will be to stop morphing newlines).
This should fix a bunch of bugs, e.g., especially if you ever
did the following:
<td><pre><span>foo</span>
more text after the newline</pre></td>
The new code now properly handles building up the correct min/max
width for the <pre>.
If anyone recalls seeing any bugs like this, let me know and
I can close them.
* khtml/rendering/render_flow.cpp:
(RenderFlow::calcInlineMinMaxWidth):
* khtml/rendering/render_text.cpp:
(RenderText::trimmedMinMaxWidth):
(RenderText::calcMinMaxWidth):
2002-11-16 David Hyatt <hyatt@apple.com>
Fix more edge cases with whitespace handling that caused some
......
2002-11-16 David Hyatt <hyatt@apple.com>
Rewrite the calculation of min and max width for <pre>s. This
is the second stage of the whitespace rewrite (third stage
will be to stop morphing newlines).
This should fix a bunch of bugs, e.g., especially if you ever
did the following:
<td><pre><span>foo</span>
more text after the newline</pre></td>
The new code now properly handles building up the correct min/max
width for the <pre>.
If anyone recalls seeing any bugs like this, let me know and
I can close them.
* khtml/rendering/render_flow.cpp:
(RenderFlow::calcInlineMinMaxWidth):
* khtml/rendering/render_text.cpp:
(RenderText::trimmedMinMaxWidth):
(RenderText::calcMinMaxWidth):
2002-11-16 David Hyatt <hyatt@apple.com>
Fix more edge cases with whitespace handling that caused some
......
2002-11-16 David Hyatt <hyatt@apple.com>
Rewrite the calculation of min and max width for <pre>s. This
is the second stage of the whitespace rewrite (third stage
will be to stop morphing newlines).
This should fix a bunch of bugs, e.g., especially if you ever
did the following:
<td><pre><span>foo</span>
more text after the newline</pre></td>
The new code now properly handles building up the correct min/max
width for the <pre>.
If anyone recalls seeing any bugs like this, let me know and
I can close them.
* khtml/rendering/render_flow.cpp:
(RenderFlow::calcInlineMinMaxWidth):
* khtml/rendering/render_text.cpp:
(RenderText::trimmedMinMaxWidth):
(RenderText::calcMinMaxWidth):
2002-11-16 David Hyatt <hyatt@apple.com>
Fix more edge cases with whitespace handling that caused some
......
......@@ -1451,7 +1451,6 @@ void RenderFlow::calcInlineMinMaxWidth()
// min and max and continue.
if (!hasBreakableChar) {
inlineMin += childMin;
inlineMax += childMax;
}
else {
// We have a breakable character. Now we need to know if
......@@ -1478,9 +1477,16 @@ void RenderFlow::calcInlineMinMaxWidth()
if(m_minWidth < inlineMin) m_minWidth = inlineMin;
inlineMin = endMin;
}
inlineMax += childMax;
}
if (hasBreak) {
inlineMax += beginMax;
if (m_maxWidth < inlineMax) m_maxWidth = inlineMax;
if (m_maxWidth < childMax) m_maxWidth = childMax;
inlineMax = endMax;
}
else
inlineMax += childMax;
}
}
else
......
......@@ -758,8 +758,7 @@ void RenderText::trimmedMinMaxWidth(short& beginMinW, bool& beginWS,
endMinW = m_endMinWidth;
hasBreakableChar = m_hasBreakableChar;
hasBreak = false; // XXXdwh will need to make this work eventually.
// m_hasBreak;
hasBreak = m_hasBreak;
if (len == 0)
return;
......@@ -780,8 +779,31 @@ void RenderText::trimmedMinMaxWidth(short& beginMinW, bool& beginWS,
// Compute our max widths by scanning the string for newlines.
if (hasBreak) {
// XXXdwh this will only be an issue for white-space: pre inlines and
// not for the <pre> element itself.
const Font *f = htmlFont( false );
bool firstLine = true;
beginMaxW = endMaxW = maxW;
for(int i = 0; i < len; i++)
{
int linelen = 0;
while( i+linelen < len && str->s[i+linelen] != '\n')
linelen++;
if (linelen)
{
endMaxW = f->width(str->s, str->l, i, linelen);
if (firstLine) {
firstLine = false;
beginMaxW = endMaxW;
}
i += linelen;
if (i == len-1)
endMaxW = 0;
}
else if (firstLine) {
beginMaxW = 0;
firstLine = false;
}
}
}
}
......@@ -809,11 +831,14 @@ void RenderText::calcMinMaxWidth()
bool firstWord = true;
for(int i = 0; i < len; i++)
{
bool isNewline = false;
// XXXdwh Wrong in the first stage. Will stop mutating newlines
// in a second stage.
if (str->s[i] == '\n') {
if (isPre)
if (isPre) {
m_hasBreak = true;
isNewline = true;
}
else
str->s[i] = ' ';
}
......@@ -821,9 +846,9 @@ void RenderText::calcMinMaxWidth()
bool oldSpace = isSpace;
isSpace = str->s[i].direction() == QChar::DirWS;
if (isSpace && i == 0)
if ((isSpace || isNewline) && i == 0)
m_hasBeginWS = true;
if (isSpace && i == len-1)
if ((isSpace || isNewline) && i == len-1)
m_hasEndWS = true;
if (!ignoringSpaces && !isPre && oldSpace && isSpace)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment