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

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.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: Comment fixes 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/third_party/DroidSans/README.chromium ('k') | Source/wtf/unicode/CharacterNames.h » ('j') | 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 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 else 1930 else
1931 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); 1931 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0);
1932 } 1932 }
1933 firstLine = false; 1933 firstLine = false;
1934 } 1934 }
1935 } 1935 }
1936 1936
1937 void RenderBlockFlow::checkLinesForTextOverflow() 1937 void RenderBlockFlow::checkLinesForTextOverflow()
1938 { 1938 {
1939 // Determine the width of the ellipsis using the current font. 1939 // Determine the width of the ellipsis using the current font.
1940 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP ) if horizontal ellipsis is "not renderable"
1941 const Font& font = style()->font(); 1940 const Font& font = style()->font();
1941
1942 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst opCharacter};
1943 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3)) ;
1942 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); 1944 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1));
1945 AtomicString& selectedEllipsisStr = ellipsisStr;
1946
1943 const Font& firstLineFont = firstLineStyle()->font(); 1947 const Font& firstLineFont = firstLineStyle()->font();
1944 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 1948 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004
1945 TextDirection ellipsisDirection = LTR; 1949 TextDirection ellipsisDirection = LTR;
1946 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); 1950 float firstLineEllipsisWidth = 0;
1947 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi rection)); 1951 float ellipsisWidth = 0;
1952 bool useHorizontalEllipsis = true;
Dominik Röttsches 2015/01/14 08:18:01 This shouldn't be needed anymore.
h.joshi 2015/01/14 10:17:27 Done.
1953
1954 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three
1955 // Full Stops (002E) can be used.
1956 if (firstLineFont.primaryFontHasGlyphForCharacter(horizontalEllipsis)) {
1957 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection));
1958 } else {
1959 useHorizontalEllipsis = false;
Dominik Röttsches 2015/01/14 08:18:01 Dito.
h.joshi 2015/01/14 10:17:27 Done.
h.joshi 2015/01/14 10:17:27 Done.
1960 selectedEllipsisStr = fullstopCharacterStr;
1961 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, fullStopString, 1, firstLineStyle(), ellipsisDirection));
1962 }
1963 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0;
1964
1965 if (!ellipsisWidth) {
1966 if (font.primaryFontHasGlyphForCharacter(horizontalEllipsis)) {
1967 selectedEllipsisStr = ellipsisStr;
1968 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE llipsis, 1, style(), ellipsisDirection));
1969 } else {
1970 selectedEllipsisStr = fullstopCharacterStr;
1971 ellipsisWidth = font.width(constructTextRun(this, font, fullStopStri ng, 1, style(), ellipsisDirection));
1972 }
1973 }
1948 1974
1949 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see 1975 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see
1950 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and 1976 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and
1951 // check the left edge of the line box to see if it is less 1977 // check the left edge of the line box to see if it is less
1952 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" 1978 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()"
1953 bool ltr = style()->isLeftToRightDirection(); 1979 bool ltr = style()->isLeftToRightDirection();
1954 ETextAlign textAlign = style()->textAlign(); 1980 ETextAlign textAlign = style()->textAlign();
1955 bool firstLine = true; 1981 bool firstLine = true;
1956 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 1982 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
1957 float currLogicalLeft = curr->logicalLeft(); 1983 float currLogicalLeft = curr->logicalLeft();
1958 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); 1984 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine);
1959 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); 1985 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine);
1960 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; 1986 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft;
1961 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { 1987 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) {
1962 // This line spills out of our box in the appropriate direction. No w we need to see if the line 1988 // This line spills out of our box in the appropriate direction. No w we need to see if the line
1963 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to 1989 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to
1964 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis 1990 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis
1965 // space. 1991 // space.
1966 1992
1967 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; 1993 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h;
1968 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; 1994 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge;
1969 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { 1995 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) {
1970 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); 1996 float totalLogicalWidth = curr->placeEllipsis(selectedEllipsisSt r, ltr, blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat());
1971 1997
1972 float logicalLeft = 0; // We are only intersted in the delta fro m the base position. 1998 float logicalLeft = 0; // We are only intersted in the delta fro m the base position.
1973 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t oFloat(); 1999 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t oFloat();
1974 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); 2000 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
1975 if (ltr) 2001 if (ltr)
1976 curr->adjustLogicalPosition(logicalLeft, 0); 2002 curr->adjustLogicalPosition(logicalLeft, 0);
1977 else 2003 else
1978 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); 2004 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0);
1979 } 2005 }
1980 } 2006 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); 2071 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat ();
2046 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2072 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft;
2047 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2073 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2048 2074
2049 if (!style()->isLeftToRightDirection()) 2075 if (!style()->isLeftToRightDirection())
2050 return logicalWidth() - logicalLeft; 2076 return logicalWidth() - logicalLeft;
2051 return logicalLeft; 2077 return logicalLeft;
2052 } 2078 }
2053 2079
2054 } 2080 }
OLDNEW
« 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