Commit 932806a9 authored by ap's avatar ap

Reviewed by Hyatt.

        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=10842
        REGRESSION (r15418): contenteditable div truncates rightmost Japanese character
        
        Make sure we only break after a space (and not any other valid line-break) if
        the style is -webkit-line-break: after-white-space (e.g. for a contentEditable div).
        I also did a logic shuffle at Mitz's request to prevent doing an if on the same expression
        twice in quick succession.

        Test: fast/text/line-breaks-after-white-space.html

        * rendering/bidi.cpp:
        (WebCore::RenderBlock::findNextLineBreak): 



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16696 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 243119ad
2006-10-01 Graham Dennis <graham.dennis@gmail.com>
Reviewed by Hyatt.
Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=10842
REGRESSION (r15418): contenteditable div truncates rightmost Japanese character
* fast/text/line-breaks-after-white-space-expected.checksum: Added.
* fast/text/line-breaks-after-white-space-expected.png: Added.
* fast/text/line-breaks-after-white-space-expected.txt: Added.
* fast/text/line-breaks-after-white-space.html: Added.
2006-10-01 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Maciej and Darin.
c538247b02b53bb4f4266d027cf0059a
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x220
RenderBlock {HTML} at (0,0) size 800x220
RenderBody {BODY} at (8,8) size 784x192
RenderBlock (anonymous) at (0,0) size 784x18
RenderText {#text} at (0,0) size 82x18
text run at (0,0) width 82: "This is good:"
RenderBlock {DIV} at (0,38) size 200x48
RenderBlock {P} at (0,0) size 200x48 [border: (1px solid #008000)]
RenderText {#text} at (1,1) size 194x46
text run at (1,1) width 194: "lorem ipsum dolor sit??"
text run at (1,24) width 40: "amet"
RenderBlock (anonymous) at (0,106) size 784x18
RenderText {#text} at (0,0) size 249x18
text run at (0,0) width 249: "The following should look like \x{201C}good\x{201D}:"
RenderBlock {DIV} at (0,144) size 200x48
RenderBlock {P} at (0,0) size 200x48 [border: (1px solid #008000)]
RenderText {#text} at (1,1) size 194x46
text run at (1,1) width 194: "lorem ipsum dolor sit??"
text run at (1,24) width 40: "amet"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<title>Line breaks (using the style -webkit-line-break: after-white-space)</title>
</head>
<body>
This is good:
<div style="font-size: 20px; width:200px;">
<p style="border:solid green 1px;">
lorem ipsum dolor sit??amet
</p>
</div>
The following should look like &ldquo;good&rdquo;:
<div style="-webkit-line-break: after-white-space; font-size: 20px; width:200px;">
<p style="border:solid green 1px;">
lorem ipsum dolor sit??amet
</p>
</div>
</body>
</html>
2006-10-01 Graham Dennis <graham.dennis@gmail.com>
Reviewed by Hyatt.
Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=10842
REGRESSION (r15418): contenteditable div truncates rightmost Japanese character
Make sure we only break after a space (and not any other valid line-break) if
the style is -webkit-line-break: after-white-space (e.g. for a contentEditable div).
I also did a logic shuffle at Mitz's request to prevent doing an if on the same expression
twice in quick succession.
* rendering/bidi.cpp:
(WebCore::RenderBlock::findNextLineBreak):
2006-10-01 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Maciej and Darin.
......@@ -2262,28 +2262,29 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
if (o->style()->autoWrap() || breakWords) {
// If we break only after white-space, consider the current character
// as candidate width for this line.
int charWidth = o->style()->breakOnlyAfterWhiteSpace() && !midWordBreak ?
t->width(pos, 1, f, w + tmpW) + (applyWordSpacing ? wordSpacing : 0) : 0;
if (w + tmpW + charWidth > width) {
if (o->style()->breakOnlyAfterWhiteSpace() && !midWordBreak) {
// Check if line is too big even without the extra space
// at the end of the line. If it is not, do nothing.
// If the line needs the extra whitespace to be too long,
// then move the line break to the space and skip all
// additional whitespace.
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);
bool lineWasTooWide = false;
if (w + tmpW <= width && currentCharacterIsWS && o->style()->breakOnlyAfterWhiteSpace() && !midWordBreak) {
int charWidth = t->width(pos, 1, f, w + tmpW) + (applyWordSpacing ? wordSpacing : 0);
// Check if line is too big even without the extra space
// at the end of the line. If it is not, do nothing.
// If the line needs the extra whitespace to be too long,
// then move the line break to the space and skip all
// additional whitespace.
if (w + tmpW + charWidth > width) {
lineWasTooWide = true;
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);
}
}
if (lineWasTooWide || w + tmpW > width) {
if (lBreak.obj && lBreak.obj->style()->preserveNewline() && lBreak.obj->isText() && static_cast<RenderText*>(lBreak.obj)->text()[lBreak.pos] == '\n') {
if (!stoppedIgnoringSpaces && pos > 0) {
// We need to stop right before the newline and then start up again.
......
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