WebCore:
Reviewed by John Sullivan.
- when -webkit-line-break: after-white-space is specified but the text
does not auto-wrap, do not shrink the trailing space to fit in the
available width
Test: fast/text/whitespace/nowrap-line-break-after-white-space.html
- when shrinking such trailing space, do not shrink below zero
Covered by existing tests
* rendering/bidi.cpp:
(WebCore::RenderBlock::computeHorizontalPositionsForLine):
(WebCore::RenderBlock::layoutInlineChildren):
LayoutTests:
Reviewed by John Sullivan.
- test that when -webkit-line-break: after-white-space is combined with
white-space: nowrap, the trailing space is not shrunk to fit the in
the available width
- updates results for that and for not shrinking trailing space to less
than zero
* fast/text/whitespace/nowrap-line-break-after-white-space-expected.txt: Added.
* fast/text/whitespace/nowrap-line-break-after-white-space.html: Added.
* platform/mac/fast/block/float/editable-text-overlapping-float-expected.txt:
* platform/mac/fast/inline/long-wrapped-line-expected.txt:
* platform/mac/fast/text/whitespace/tab-character-basics-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42265 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index 72c99d6..bf7a67c 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -647,7 +647,7 @@
// particular with RTL blocks, wide lines should still spill out to the left.
if (style()->direction() == LTR) {
if (totWidth > availableWidth && trailingSpaceRun)
- trailingSpaceRun->m_box->setWidth(trailingSpaceRun->m_box->width() - totWidth + availableWidth);
+ trailingSpaceRun->m_box->setWidth(max(0, trailingSpaceRun->m_box->width() - totWidth + availableWidth));
} else {
if (trailingSpaceRun)
trailingSpaceRun->m_box->setWidth(0);
@@ -669,7 +669,7 @@
// for right to left fall through to right aligned
if (style()->direction() == LTR) {
if (totWidth > availableWidth && trailingSpaceRun)
- trailingSpaceRun->m_box->setWidth(trailingSpaceRun->m_box->width() - totWidth + availableWidth);
+ trailingSpaceRun->m_box->setWidth(max(0, trailingSpaceRun->m_box->width() - totWidth + availableWidth));
break;
}
case RIGHT:
@@ -686,7 +686,7 @@
x += availableWidth - totWidth;
} else {
if (totWidth > availableWidth && trailingSpaceRun) {
- trailingSpaceRun->m_box->setWidth(trailingSpaceRun->m_box->width() - totWidth + availableWidth);
+ trailingSpaceRun->m_box->setWidth(max(0, trailingSpaceRun->m_box->width() - totWidth + availableWidth));
totWidth -= trailingSpaceRun->m_box->width();
} else
x += availableWidth - totWidth;
@@ -698,7 +698,7 @@
if (trailingSpaceRun) {
totWidth -= trailingSpaceRun->m_box->width();
trailingSpaceWidth = min(trailingSpaceRun->m_box->width(), (availableWidth - totWidth + 1) / 2);
- trailingSpaceRun->m_box->setWidth(trailingSpaceWidth);
+ trailingSpaceRun->m_box->setWidth(max(0, trailingSpaceWidth));
}
if (style()->direction() == LTR)
x += max((availableWidth - totWidth) / 2, 0);
@@ -953,7 +953,8 @@
ASSERT(resolver.position() == end);
BidiRun* trailingSpaceRun = 0;
- if (!previousLineBrokeCleanly && resolver.runCount() && resolver.logicallyLastRun()->m_object->style()->breakOnlyAfterWhiteSpace()) {
+ if (!previousLineBrokeCleanly && resolver.runCount() && resolver.logicallyLastRun()->m_object->style()->breakOnlyAfterWhiteSpace()
+ && resolver.logicallyLastRun()->m_object->style()->autoWrap()) {
trailingSpaceRun = resolver.logicallyLastRun();
RenderObject* lastObject = trailingSpaceRun->m_object;
if (lastObject->isText()) {