Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Unified Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 836863002: Add tab support to RenderBlockLineLayout::stripTrailingSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/text/trailing_whitespace_wrapping-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlockLineLayout.cpp
diff --git a/Source/core/rendering/RenderBlockLineLayout.cpp b/Source/core/rendering/RenderBlockLineLayout.cpp
index b31f46799b50a31d90fbfbaf82731fc63da9c7c3..4eaf44250e35ec52ee3a842a786555e0bb3db519 100644
--- a/Source/core/rendering/RenderBlockLineLayout.cpp
+++ b/Source/core/rendering/RenderBlockLineLayout.cpp
@@ -1164,17 +1164,28 @@ static LayoutUnit getBorderPaddingMargin(RenderBoxModelObject* child, bool endOf
child->borderStart();
}
-static inline void stripTrailingSpace(float& inlineMax, float& inlineMin, RenderObject* trailingSpaceChild)
+static inline void stripTrailingSpace(float& inlineMax, float& inlineMin,
+ RenderObject* trailingSpaceChild)
{
if (trailingSpaceChild && trailingSpaceChild->isText()) {
- // Collapse away the trailing space at the end of a block.
+ // Collapse away the trailing space at the end of a block by finding
+ // the first white-space character and subtracting its width. Subsequent
+ // white-space characters have been collapsed into the first one (which
+ // can be either a space or a tab character).
RenderText* text = toRenderText(trailingSpaceChild);
- bool useComplexCodePath = !text->canUseSimpleFontCodePath();
- const UChar space = ' ';
- const Font& font = text->style()->font(); // FIXME: This ignores first-line.
- TextRun run = constructTextRun(text, font, &space, 1, text->style(), LTR);
- if (useComplexCodePath)
- run.setUseComplexCodePath(true);
+ UChar trailingWhitespaceChar = ' ';
+ for (unsigned i = text->textLength(); i > 0; i--) {
+ UChar c = text->characterAt(i - 1);
+ if (!Character::treatAsSpace(c))
+ break;
+ trailingWhitespaceChar = c;
+ }
+
+ // FIXME: This ignores first-line.
+ const Font& font = text->style()->font();
+ TextRun run = constructTextRun(text, font, &trailingWhitespaceChar, 1,
+ text->style(), text->style()->direction());
+ run.setUseComplexCodePath(!text->canUseSimpleFontCodePath());
float spaceWidth = font.width(run);
inlineMax -= spaceWidth + font.fontDescription().wordSpacing();
if (inlineMin > inlineMax)
« no previous file with comments | « LayoutTests/fast/text/trailing_whitespace_wrapping-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698