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

Side by Side Diff: Source/core/layout/LayoutBlockFlowLine.cpp

Issue 1194623005: Fix ellipsis width when font has no ellipsis glyph (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: NeedsRebaseline 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/TestExpectations ('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 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 } 1918 }
1919 firstLine = false; 1919 firstLine = false;
1920 } 1920 }
1921 } 1921 }
1922 1922
1923 void LayoutBlockFlow::checkLinesForTextOverflow() 1923 void LayoutBlockFlow::checkLinesForTextOverflow()
1924 { 1924 {
1925 // Determine the width of the ellipsis using the current font. 1925 // Determine the width of the ellipsis using the current font.
1926 const Font& font = style()->font(); 1926 const Font& font = style()->font();
1927 1927
1928 const size_t fullStopStringLength = 3;
1928 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst opCharacter}; 1929 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst opCharacter};
1929 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3)) ; 1930 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, ful lStopStringLength));
1930 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsisCharacter , 1)); 1931 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsisCharacter , 1));
1931 AtomicString& selectedEllipsisStr = ellipsisStr; 1932 AtomicString& selectedEllipsisStr = ellipsisStr;
1932 1933
1933 const Font& firstLineFont = firstLineStyle()->font(); 1934 const Font& firstLineFont = firstLineStyle()->font();
1934 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 1935 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004
1935 TextDirection ellipsisDirection = LTR; 1936 TextDirection ellipsisDirection = LTR;
1936 float firstLineEllipsisWidth = 0; 1937 float firstLineEllipsisWidth = 0;
1937 float ellipsisWidth = 0; 1938 float ellipsisWidth = 0;
1938 1939
1939 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three 1940 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three
1940 // Full Stops (002E) can be used. 1941 // Full Stops (002E) can be used.
1941 ASSERT(firstLineFont.primaryFont()); 1942 ASSERT(firstLineFont.primaryFont());
1942 if (firstLineFont.primaryFont()->glyphForCharacter(horizontalEllipsisCharact er)) { 1943 if (firstLineFont.primaryFont()->glyphForCharacter(horizontalEllipsisCharact er)) {
1943 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, &horizontalEllipsisCharacter, 1, *firstLineStyle(), ellipsisDirection )); 1944 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, &horizontalEllipsisCharacter, 1, *firstLineStyle(), ellipsisDirection ));
1944 } else { 1945 } else {
1945 selectedEllipsisStr = fullstopCharacterStr; 1946 selectedEllipsisStr = fullstopCharacterStr;
1946 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, fullStopString, 1, *firstLineStyle(), ellipsisDirection)); 1947 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, fullStopString, fullStopStringLength, *firstLineStyle(), ellipsisDire ction));
1947 } 1948 }
1948 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0; 1949 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0;
1949 1950
1950 if (!ellipsisWidth) { 1951 if (!ellipsisWidth) {
1951 ASSERT(font.primaryFont()); 1952 ASSERT(font.primaryFont());
1952 if (font.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter)) { 1953 if (font.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter)) {
1953 selectedEllipsisStr = ellipsisStr; 1954 selectedEllipsisStr = ellipsisStr;
1954 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE llipsisCharacter, 1, styleRef(), ellipsisDirection)); 1955 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE llipsisCharacter, 1, styleRef(), ellipsisDirection));
1955 } else { 1956 } else {
1956 selectedEllipsisStr = fullstopCharacterStr; 1957 selectedEllipsisStr = fullstopCharacterStr;
1957 ellipsisWidth = font.width(constructTextRun(this, font, fullStopStri ng, 1, styleRef(), ellipsisDirection)); 1958 ellipsisWidth = font.width(constructTextRun(this, font, fullStopStri ng, fullStopStringLength, styleRef(), ellipsisDirection));
1958 } 1959 }
1959 } 1960 }
1960 1961
1961 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see 1962 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see
1962 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and 1963 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and
1963 // check the left edge of the line box to see if it is less 1964 // check the left edge of the line box to see if it is less
1964 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" 1965 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()"
1965 bool ltr = style()->isLeftToRightDirection(); 1966 bool ltr = style()->isLeftToRightDirection();
1966 ETextAlign textAlign = style()->textAlign(); 1967 ETextAlign textAlign = style()->textAlign();
1967 bool firstLine = true; 1968 bool firstLine = true;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); 2057 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false);
2057 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; 2058 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft;
2058 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2059 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2059 2060
2060 if (!style()->isLeftToRightDirection()) 2061 if (!style()->isLeftToRightDirection())
2061 return logicalWidth() - logicalLeft; 2062 return logicalWidth() - logicalLeft;
2062 return logicalLeft; 2063 return logicalLeft;
2063 } 2064 }
2064 2065
2065 } 2066 }
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698