Quirksmode: Break Tag Extra Space Bug
https://bugs.webkit.org/show_bug.cgi?id=11943
Reviewed by David Hyatt.
Source/WebCore:
Collapse away all space between text and a hard line-break when in a right-aligned
container so that the trailing space doesn't push the text away from the container edge.
Test: fast/text/whitespace/trailing-space-before-br-in-right-aligned-text.html
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::nextSegmentBreak):
LayoutTests:
* fast/text/whitespace/trailing-space-before-br-in-right-aligned-text-expected.html: Added.
* fast/text/whitespace/trailing-space-before-br-in-right-aligned-text.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156053 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
index 9d7e84c..0ab7a92 100644
--- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -2708,6 +2708,11 @@
// run for this object.
if (ignoringSpaces && currentStyle->clear() != CNONE)
ensureLineBoxInsideIgnoredSpaces(lineMidpointState, current.m_obj);
+ // If we were preceded by collapsing space and are in a right-aligned container we need to ensure the space gets
+ // collapsed away so that it doesn't push the text out from the container's right-hand edge.
+ // FIXME: Do this regardless of the container's alignment - will require rebaselining a lot of test results.
+ else if (ignoringSpaces && (blockStyle->textAlign() == RIGHT || blockStyle->textAlign() == WEBKIT_RIGHT))
+ stopIgnoringSpaces(lineMidpointState, InlineIterator(0, current.m_obj, current.m_pos));
if (!lineInfo.isEmpty())
m_clear = currentStyle->clear();
@@ -3099,6 +3104,15 @@
if (currentCharacterIsSpace && !previousCharacterIsSpace) {
ignoreStart.m_obj = current.m_obj;
ignoreStart.m_pos = current.m_pos;
+ // Spaces after right-aligned text and before a line-break get collapsed away completely so that the trailing
+ // space doesn't seem to push the text out from the right-hand edge.
+ // FIXME: Do this regardless of the container's alignment - will require rebaselining a lot of test results.
+ if (next && next->isBR() && (blockStyle->textAlign() == RIGHT || blockStyle->textAlign() == WEBKIT_RIGHT)) {
+ ignoreStart.m_pos--;
+ // If there's just a single trailing space start ignoring it now so it collapses away.
+ if (current.m_pos == t->textLength() - 1)
+ startIgnoringSpaces(lineMidpointState, ignoreStart);
+ }
}
if (!currentCharacterIsWS && previousCharacterIsWS) {