[webkit-changes] cvs commit: WebCore/manual-tests
pre-tab-selection-rect.html
Darin
darin at opensource.apple.com
Fri Dec 16 08:18:45 PST 2005
darin 05/12/16 08:18:45
Modified: . ChangeLog
khtml/rendering render_text.cpp
Added: manual-tests pre-tab-selection-rect.html
Log:
Reviewed and landed by Darin.
Fix for: http://bugzilla.opendarwin.org/show_bug.cgi?id=6043
Incorrect selection highlighting in pre-formatted text with tabs
* khtml/rendering/render_text.cpp: Correct parameters in calls to RenderText::width().
(InlineTextBox::selectionRect):
(InlineTextBox::placeEllipsisBox):
(InlineTextBox::paintDecoration):
(InlineTextBox::paintMarker):
(InlineTextBox::paintMarkedTextUnderline):
* manual-tests/pre-tab-selection-rect.html: Added.
Revision Changes Path
1.547 +15 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.546
retrieving revision 1.547
diff -u -r1.546 -r1.547
--- ChangeLog 16 Dec 2005 16:13:08 -0000 1.546
+++ ChangeLog 16 Dec 2005 16:18:38 -0000 1.547
@@ -1,6 +1,21 @@
2005-12-16 Mitz Pettel <opendarwin.org at mitzpettel.com>
Reviewed and landed by Darin.
+
+ Fix for: http://bugzilla.opendarwin.org/show_bug.cgi?id=6043
+ Incorrect selection highlighting in pre-formatted text with tabs
+
+ * khtml/rendering/render_text.cpp: Correct parameters in calls to RenderText::width().
+ (InlineTextBox::selectionRect):
+ (InlineTextBox::placeEllipsisBox):
+ (InlineTextBox::paintDecoration):
+ (InlineTextBox::paintMarker):
+ (InlineTextBox::paintMarkedTextUnderline):
+ * manual-tests/pre-tab-selection-rect.html: Added.
+
+2005-12-16 Mitz Pettel <opendarwin.org at mitzpettel.com>
+
+ Reviewed and landed by Darin.
Test: fast/js/replace-child-siblings.html
1.211 +11 -10 WebCore/khtml/rendering/render_text.cpp
Index: render_text.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/rendering/render_text.cpp,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -r1.210 -r1.211
--- render_text.cpp 14 Dec 2005 18:46:03 -0000 1.210
+++ render_text.cpp 16 Dec 2005 16:18:44 -0000 1.211
@@ -141,16 +141,17 @@
int selEnd = selStart;
int selTop = rootBox->selectionTop();
int selHeight = rootBox->selectionHeight();
+ int leadWidth = 0;
// FIXME: For justified text, just return the entire text box's rect. At the moment there's still no easy
// way to get the width of a run including the justification padding.
if (sPos > 0 && !m_toAdd) {
// The selection begins in the middle of our run.
- int w = textObj->width(m_start, sPos, m_firstLine, m_x);
+ leadWidth = textObj->width(m_start, sPos, textPos(), m_firstLine);
if (m_reversed)
- selStart -= w;
+ selStart -= leadWidth;
else
- selStart += w;
+ selStart += leadWidth;
}
if (m_toAdd || (sPos == 0 && ePos == m_len)) {
@@ -161,7 +162,7 @@
}
else {
// Our run is partially selected, and so we need to measure.
- int w = textObj->width(sPos + m_start, ePos - sPos, m_firstLine);
+ int w = textObj->width(sPos + m_start, ePos - sPos, textPos() + leadWidth, m_firstLine);
if (sPos + m_start > 0 && textObj->str->s[sPos + m_start].isSpace() && !textObj->str->s[sPos + m_start - 1].isSpace())
w += textObj->style(m_firstLine)->wordSpacing();
if (m_reversed)
@@ -232,7 +233,7 @@
// Set the truncation index on the text run. The ellipsis needs to be placed just after the last visible character.
m_truncation = offset + m_start;
- return m_x + static_cast<RenderText*>(m_object)->width(m_start, offset, m_firstLine);
+ return m_x + static_cast<RenderText*>(m_object)->width(m_start, offset, textPos(), m_firstLine);
}
}
else {
@@ -564,7 +565,7 @@
return;
int width = (m_truncation == cNoTruncation) ?
- m_width : static_cast<RenderText*>(m_object)->width(m_start, m_truncation - m_start, m_firstLine);
+ m_width : static_cast<RenderText*>(m_object)->width(m_start, m_truncation - m_start, textPos(), m_firstLine);
// Get the text decoration colors.
QColor underline, overline, linethrough;
@@ -601,7 +602,7 @@
if (paintStart <= marker.startOffset) {
paintStart = marker.startOffset;
useWholeWidth = false;
- start = static_cast<RenderText*>(m_object)->width(m_start, paintStart - m_start, m_firstLine);
+ start = static_cast<RenderText*>(m_object)->width(m_start, paintStart - m_start, textPos(), m_firstLine);
}
if (paintEnd != marker.endOffset) { // end points at the last char, not past it
paintEnd = kMin(paintEnd, marker.endOffset);
@@ -612,7 +613,7 @@
useWholeWidth = false;
}
if (!useWholeWidth) {
- width = static_cast<RenderText*>(m_object)->width(paintStart, paintEnd - paintStart, m_firstLine);
+ width = static_cast<RenderText*>(m_object)->width(paintStart, paintEnd - paintStart, textPos() + start, m_firstLine);
}
// IMPORTANT: The misspelling underline is not considered when calculating the text bounds, so we have to
@@ -650,7 +651,7 @@
if (paintStart <= underline.startOffset) {
paintStart = underline.startOffset;
useWholeWidth = false;
- start = static_cast<RenderText*>(m_object)->width(m_start, paintStart - m_start, m_firstLine);
+ start = static_cast<RenderText*>(m_object)->width(m_start, paintStart - m_start, textPos(), m_firstLine);
}
if (paintEnd != underline.endOffset) { // end points at the last char, not past it
paintEnd = kMin(paintEnd, (unsigned)underline.endOffset);
@@ -661,7 +662,7 @@
useWholeWidth = false;
}
if (!useWholeWidth) {
- width = static_cast<RenderText*>(m_object)->width(paintStart, paintEnd - paintStart, m_firstLine);
+ width = static_cast<RenderText*>(m_object)->width(paintStart, paintEnd - paintStart, textPos() + start, m_firstLine);
}
int underlineOffset = m_height - 3;
1.1 WebCore/manual-tests/pre-tab-selection-rect.html
Index: pre-tab-selection-rect.html
===================================================================
<html>
<head>
<title>Highlighting preformatted text after tab</title>
<style type="text/css">
#t4 { font-size: 36px; }
#t4:first-line { font-size:16px; }
</style>
<script type="text/javascript">
function test1()
{
var t = document.getElementById('t1').childNodes[1];
window.getSelection().setBaseAndExtent(t, 1, t, 13);
}
function test2()
{
var t = document.getElementById('t2').childNodes[0];
window.getSelection().setBaseAndExtent(t, 5, t, 23);
}
function test3()
{
var t = document.getElementById('t3').childNodes[0];
window.getSelection().setBaseAndExtent(t, 5, t, 23);
}
function test4()
{
var t = document.getElementById('t4').childNodes[0];
window.getSelection().setBaseAndExtent(t, 11, t, 29);
}
</script>
</head>
<body>
<p>
This is a test for <i>http://bugzilla.opendarwin.org/show_bug.cgi?id=6043
Incorrect selection highlighting in pre-formatted text with tabs</i>.
</p>
<hr>
<p>
Instructions:
</p>
<p>
1. Click <a href="#" onclick="window.setTimeout(test1,1);">test 1</a>.
The entire word “highlighting” below should be highlighted.
</p>
<pre id="t1"><span>Buggy</span> highlighting</pre>
<p>
2. Click <a href="#" onclick="window.setTimeout(test2,1);">test 2</a>.
The words “buggy highlighting” below should be fully highlighted.
</p>
<pre id="t2" style="padding-left: 10px;">Very buggy highlighting</pre>
<p>
3. Click <a href="#" onclick="window.setTimeout(test3,1);">test 3</a>.
The words “buggy highlighting” below should be fully highlighted.
</p>
<pre id="t3" style="margin-left: 10px;">Very buggy highlighting</pre>
<p>
4. Click <a href="#" onclick="window.setTimeout(test4,1);">test 4</a>.
The words “buggy highlighting” below should be fully highlighted.
</p>
<p id="t4">
Even more buggy highlighting.
</p>
</body>
</html>
More information about the webkit-changes
mailing list