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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/text/trailing_whitespace_wrapping-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved. 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ight reserved.
4 * Copyright (C) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 if (endOfInline) { 1157 if (endOfInline) {
1158 return getBPMWidth(child->marginEnd(), childStyle->marginEnd()) + 1158 return getBPMWidth(child->marginEnd(), childStyle->marginEnd()) +
1159 getBPMWidth(child->paddingEnd(), childStyle->paddingEnd()) + 1159 getBPMWidth(child->paddingEnd(), childStyle->paddingEnd()) +
1160 child->borderEnd(); 1160 child->borderEnd();
1161 } 1161 }
1162 return getBPMWidth(child->marginStart(), childStyle->marginStart()) + 1162 return getBPMWidth(child->marginStart(), childStyle->marginStart()) +
1163 getBPMWidth(child->paddingStart(), childStyle->paddingStart()) + 1163 getBPMWidth(child->paddingStart(), childStyle->paddingStart()) +
1164 child->borderStart(); 1164 child->borderStart();
1165 } 1165 }
1166 1166
1167 static inline void stripTrailingSpace(float& inlineMax, float& inlineMin, Render Object* trailingSpaceChild) 1167 static inline void stripTrailingSpace(float& inlineMax, float& inlineMin,
1168 RenderObject* trailingSpaceChild)
1168 { 1169 {
1169 if (trailingSpaceChild && trailingSpaceChild->isText()) { 1170 if (trailingSpaceChild && trailingSpaceChild->isText()) {
1170 // Collapse away the trailing space at the end of a block. 1171 // Collapse away the trailing space at the end of a block by finding
1172 // the first white-space character and subtracting its width. Subsequent
1173 // white-space characters have been collapsed into the first one (which
1174 // can be either a space or a tab character).
1171 RenderText* text = toRenderText(trailingSpaceChild); 1175 RenderText* text = toRenderText(trailingSpaceChild);
1172 bool useComplexCodePath = !text->canUseSimpleFontCodePath(); 1176 UChar trailingWhitespaceChar = ' ';
1173 const UChar space = ' '; 1177 for (unsigned i = text->textLength(); i > 0; i--) {
1174 const Font& font = text->style()->font(); // FIXME: This ignores first-l ine. 1178 UChar c = text->characterAt(i - 1);
1175 TextRun run = constructTextRun(text, font, &space, 1, text->style(), LTR ); 1179 if (!Character::treatAsSpace(c))
1176 if (useComplexCodePath) 1180 break;
1177 run.setUseComplexCodePath(true); 1181 trailingWhitespaceChar = c;
1182 }
1183
1184 // FIXME: This ignores first-line.
1185 const Font& font = text->style()->font();
1186 TextRun run = constructTextRun(text, font, &trailingWhitespaceChar, 1,
1187 text->style(), text->style()->direction());
1188 run.setUseComplexCodePath(!text->canUseSimpleFontCodePath());
1178 float spaceWidth = font.width(run); 1189 float spaceWidth = font.width(run);
1179 inlineMax -= spaceWidth + font.fontDescription().wordSpacing(); 1190 inlineMax -= spaceWidth + font.fontDescription().wordSpacing();
1180 if (inlineMin > inlineMax) 1191 if (inlineMin > inlineMax)
1181 inlineMin = inlineMax; 1192 inlineMin = inlineMax;
1182 } 1193 }
1183 } 1194 }
1184 1195
1185 static inline void updatePreferredWidth(LayoutUnit& preferredWidth, float& resul t) 1196 static inline void updatePreferredWidth(LayoutUnit& preferredWidth, float& resul t)
1186 { 1197 {
1187 LayoutUnit snappedResult = LayoutUnit::fromFloatCeil(result); 1198 LayoutUnit snappedResult = LayoutUnit::fromFloatCeil(result);
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); 2056 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat ();
2046 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2057 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft;
2047 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2058 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2048 2059
2049 if (!style()->isLeftToRightDirection()) 2060 if (!style()->isLeftToRightDirection())
2050 return logicalWidth() - logicalLeft; 2061 return logicalWidth() - logicalLeft;
2051 return logicalLeft; 2062 return logicalLeft;
2052 } 2063 }
2053 2064
2054 } 2065 }
OLDNEW
« 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