LayoutTests:
Reviewed by Darin and David Hyatt.
- Test for http://bugs.webkit.org/show_bug.cgi?id=12423
Mixing white-space:pre text with non white-space:pre text does not wrap properly
* fast/block/basic/white-space-pre-wraps-expected.checksum: Added.
* fast/block/basic/white-space-pre-wraps-expected.png: Added.
* fast/block/basic/white-space-pre-wraps-expected.txt: Added.
* fast/block/basic/white-space-pre-wraps.html: Added.
WebCore:
Reviewed by Darin and David Hyatt.
- fix http://bugs.webkit.org/show_bug.cgi?id=12423
Mixing white-space:pre text with non white-space:pre text does not wrap properly
Test: fast/block/basic/white-space-pre-wraps.html
* rendering/bidi.cpp:
(WebCore::RenderBlock::findNextLineBreak): Wrap a non-wrapping text run if it
appears on a line with previous text runs that do wrap.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@19206 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index 1c0adee..2ab80f0 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -1997,6 +1997,8 @@
bool prevLineBrokeCleanly = previousLineBrokeCleanly;
previousLineBrokeCleanly = false;
+
+ bool autoWrapWasEverTrueOnLine = false;
EWhiteSpace currWS = style()->whiteSpace();
EWhiteSpace lastWS = currWS;
@@ -2005,6 +2007,7 @@
lastWS = last->isReplaced() ? last->parent()->style()->whiteSpace() : last->style()->whiteSpace();
bool autoWrap = RenderStyle::autoWrap(currWS);
+ autoWrapWasEverTrueOnLine = autoWrapWasEverTrueOnLine || autoWrap;
bool preserveNewline = RenderStyle::preserveNewline(currWS);
bool collapseWhiteSpace = RenderStyle::collapseWhiteSpace(currWS);
@@ -2396,7 +2399,10 @@
// keep adding to |tmpW|. Just update and continue.
checkForBreak = true;
}
- bool canPlaceOnLine = (w + tmpW <= width) || !autoWrap;
+ bool willFitOnLine = (w + tmpW <= width);
+ bool canPlaceOnLine = willFitOnLine || !autoWrap;
+ if (!willFitOnLine && !autoWrap && autoWrapWasEverTrueOnLine)
+ canPlaceOnLine = false;
if (canPlaceOnLine && checkForBreak) {
w += tmpW;
tmpW = 0;