LayoutTests:
Reviewed by Hyatt. Patch by Mitz.
- test and updated results for http://bugzilla.opendarwin.org/show_bug.cgi?id=9670
REGRESSION: RTL white-space:pre-wrap text is offset to the right
* editing/deleting/delete-to-select-table-expected.txt:
* editing/execCommand/boldSelection-expected.txt:
* editing/execCommand/italicizeByCharacter-expected.txt:
* editing/execCommand/modifyForeColorByCharacter-expected.txt:
* editing/execCommand/print-expected.txt:
* editing/execCommand/selectAll-expected.txt:
* editing/execCommand/strikethroughSelection-expected.txt:
* editing/inserting/insert-div-027-expected.txt:
* editing/selection/after-line-wrap-expected.txt:
* editing/selection/mixed-editability-1-expected.txt:
* editing/selection/select-all-001-expected.txt:
* editing/selection/select-all-002-expected.txt:
* editing/selection/select-all-003-expected.txt:
* fast/clip/outline-overflowClip-expected.txt:
* fast/text/international/rtl-white-space-pre-wrap-expected.checksum: Added.
* fast/text/international/rtl-white-space-pre-wrap-expected.png: Added.
* fast/text/international/rtl-white-space-pre-wrap-expected.txt: Added.
* fast/text/international/rtl-white-space-pre-wrap.html: Added.
* fast/text/whitespace/pre-wrap-overflow-selection-expected.txt:
* fast/text/whitespace/pre-wrap-spaces-after-newline-expected.txt:
WebCore:
Reviewed by Hyatt. Patch by Mitz.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9670
REGRESSION: RTL white-space:pre-wrap text is offset to the right
Test: fast/text/international/rtl-white-space-pre-wrap.html
* rendering/RenderText.cpp:
(WebCore::RenderText::caretRect): Fixed LTR case and added the RTL case
of clipping the caret position to the text box when the caret is after
the trailing space of an autowrapped line.
* rendering/bidi.cpp:
(WebCore::RenderBlock::computeHorizontalPositionsForLine): Changed to truncate-
to-fit the logically last text box if it contains the trailing spaces of an
autowrapped line.
(WebCore::RenderBlock::bidiReorderLine): Remember the logically last text run.
In the case of autowrapped text with white space that overflows beyond the line,
the last text run is the one containing the overflowing white space.
(WebCore::RenderBlock::findNextLineBreak): Split overflowing white space on a
line that autowraps only after white space into a separate text run.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15418 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index 4fc1fe3..15d745c 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -84,6 +84,7 @@
// Used to track a list of chained bidi runs.
static BidiRun* sFirstBidiRun;
static BidiRun* sLastBidiRun;
+static BidiRun* sLogicallyLastBidiRun;
static int sBidiRunCount;
static BidiRun* sCompactFirstBidiRun;
static BidiRun* sCompactLastBidiRun;
@@ -867,7 +868,7 @@
// correct static x position. They have no effect on the width.
// Similarly, line break boxes have no effect on the width.
if (r->obj->isText()) {
- RenderText *rt = static_cast<RenderText *>(r->obj);
+ RenderText* rt = static_cast<RenderText*>(r->obj);
int textWidth = rt->width(r->start, r->stop-r->start, totWidth, m_firstLine);
int effectiveWidth = textWidth;
int rtLength = rt->length();
@@ -876,13 +877,6 @@
effectiveWidth += rt->font(m_firstLine)->wordSpacing();
needsWordSpacing = !DeprecatedChar(rt->text()[r->stop-1]).isSpace() && r->stop == rtLength;
}
- if (!r->compact) {
- RenderStyle *style = r->obj->style();
- if (style->autoWrap() && style->breakOnlyAfterWhiteSpace()) {
- // shrink the box as needed to keep the line from overflowing the available width
- textWidth = min(effectiveWidth, availableWidth - totWidth);
- }
- }
r->box->setWidth(textWidth);
} else if (!r->obj->isInlineFlow()) {
r->obj->calcWidth();
@@ -896,6 +890,13 @@
totWidth += r->box->width();
}
+ if (totWidth > availableWidth && sLogicallyLastBidiRun->obj->style(m_firstLine)->autoWrap() &&
+ sLogicallyLastBidiRun->obj->style(m_firstLine)->breakOnlyAfterWhiteSpace() &&
+ !sLogicallyLastBidiRun->compact) {
+ sLogicallyLastBidiRun->box->setWidth(sLogicallyLastBidiRun->box->width() - totWidth + availableWidth);
+ totWidth = availableWidth;
+ }
+
// Armed with the total width of the line (without justification),
// we now examine our text-align property in order to determine where to position the
// objects horizontally. The total width of the line can be increased if we end up
@@ -1388,6 +1389,8 @@
}
}
+ sLogicallyLastBidiRun = sLastBidiRun;
+
// reorder line according to run structure...
// do not reverse for visually ordered web sites
if (!style()->visuallyOrdered()) {
@@ -2270,6 +2273,13 @@
if (w + tmpW <= width) {
lBreak.obj = o;
lBreak.pos = pos;
+ if (pos > 0) {
+ // Separate the trailing space into its own box, which we will
+ // resize to fit on the line in computeHorizontalPositionsForLine().
+ BidiIterator midpoint(0, o, pos);
+ addMidpoint(BidiIterator(0, o, pos-1)); // Stop
+ addMidpoint(BidiIterator(0, o, pos)); // Start
+ }
skipWhitespace(lBreak, bidi);
}
}