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

Unified Diff: Source/core/layout/LayoutBlockFlowLine.cpp

Issue 781003003: Using fullstop Unicode if horizontal ellipsis not present (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@diff_font_render
Patch Set: Rebase patch Created 5 years, 6 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/third_party/DroidSans/README.chromium ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutBlockFlowLine.cpp
diff --git a/Source/core/layout/LayoutBlockFlowLine.cpp b/Source/core/layout/LayoutBlockFlowLine.cpp
index 374d30d077d07a11484dd9f5d0b867e4df4d6919..da0f618e19de4b9407078532fe3bfbdf2650fddc 100644
--- a/Source/core/layout/LayoutBlockFlowLine.cpp
+++ b/Source/core/layout/LayoutBlockFlowLine.cpp
@@ -1859,14 +1859,40 @@ void LayoutBlockFlow::deleteEllipsisLineBoxes()
void LayoutBlockFlow::checkLinesForTextOverflow()
{
// Determine the width of the ellipsis using the current font.
- // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP) if horizontal ellipsis is "not renderable"
const Font& font = style()->font();
+
+ const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullstopCharacter};
+ DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3));
DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsisCharacter, 1));
+ AtomicString& selectedEllipsisStr = ellipsisStr;
+
const Font& firstLineFont = firstLineStyle()->font();
// FIXME: We should probably not hard-code the direction here. https://crbug.com/333004
TextDirection ellipsisDirection = LTR;
- float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsisCharacter, 1, *firstLineStyle(), ellipsisDirection));
- float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef(), ellipsisDirection));
+ float firstLineEllipsisWidth = 0;
+ float ellipsisWidth = 0;
+
+ // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three
+ // Full Stops (002E) can be used.
+ ASSERT(firstLineFont.primaryFont());
+ if (firstLineFont.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter)) {
+ firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsisCharacter, 1, *firstLineStyle(), ellipsisDirection));
+ } else {
+ selectedEllipsisStr = fullstopCharacterStr;
+ firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, fullStopString, 1, *firstLineStyle(), ellipsisDirection));
+ }
+ ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0;
+
+ if (!ellipsisWidth) {
+ ASSERT(font.primaryFont());
+ if (font.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter)) {
+ selectedEllipsisStr = ellipsisStr;
+ ellipsisWidth = font.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef(), ellipsisDirection));
+ } else {
+ selectedEllipsisStr = fullstopCharacterStr;
+ ellipsisWidth = font.width(constructTextRun(this, font, fullStopString, 1, styleRef(), ellipsisDirection));
+ }
+ }
// For LTR text truncation, we want to get the right edge of our padding box, and then we want to see
// if the right edge of a line box exceeds that. For RTL, we use the left edge of the padding box and
@@ -1889,8 +1915,7 @@ void LayoutBlockFlow::checkLinesForTextOverflow()
LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidth;
LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge;
if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, width)) {
- LayoutUnit totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width);
-
+ LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllipsisStr, ltr, blockLeftEdge, blockRightEdge, width);
LayoutUnit logicalLeft; // We are only interested in the delta from the base position.
LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdge;
updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
« no previous file with comments | « LayoutTests/third_party/DroidSans/README.chromium ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698