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

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 593673003: Different fonts selected for width calculation and actual painting (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@ellipsis_not_present
Patch Set: Rebasing Test Expectation file Created 6 years, 2 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 | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/RenderText.cpp » ('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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 else 1925 else
1926 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); 1926 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0);
1927 } 1927 }
1928 firstLine = false; 1928 firstLine = false;
1929 } 1929 }
1930 } 1930 }
1931 1931
1932 void RenderBlockFlow::checkLinesForTextOverflow() 1932 void RenderBlockFlow::checkLinesForTextOverflow()
1933 { 1933 {
1934 // Determine the width of the ellipsis using the current font. 1934 // Determine the width of the ellipsis using the current font.
1935 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP ) if horizontal ellipsis is "not renderable"
1936 const Font& font = style()->font(); 1935 const Font& font = style()->font();
1936
1937 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst opCharacter};
1938 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3)) ;
1937 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); 1939 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1));
1940
1938 const Font& firstLineFont = firstLineStyle()->font(); 1941 const Font& firstLineFont = firstLineStyle()->font();
1939 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 1942 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004
1940 TextDirection ellipsisDirection = LTR; 1943 TextDirection ellipsisDirection = LTR;
1941 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); 1944 float firstLineEllipsisWidth = 0;
1942 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi rection)); 1945 float ellipsisWidth = 0;
1946
1947 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three
1948 // Full Stops (002E) can be used.
1949 if (firstLineFont.primaryFontHasGlyphForCharacter(horizontalEllipsis)) {
1950 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection));
1951 } else {
1952 ellipsisStr = fullstopCharacterStr;
1953 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, &fullstopCharacter, 1, firstLineStyle(), ellipsisDirection)) * 3;
1954 }
1955 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0;
1956
1957 if (!ellipsisWidth) {
1958 if (font.primaryFontHasGlyphForCharacter(horizontalEllipsis))
1959 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE llipsis, 1, style(), ellipsisDirection));
1960 else
1961 ellipsisWidth = font.width(constructTextRun(this, font, &fullstopCha racter, 1, style(), ellipsisDirection)) * 3;
1962 }
1943 1963
1944 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see 1964 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see
1945 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and 1965 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and
1946 // check the left edge of the line box to see if it is less 1966 // check the left edge of the line box to see if it is less
1947 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" 1967 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()"
1948 bool ltr = style()->isLeftToRightDirection(); 1968 bool ltr = style()->isLeftToRightDirection();
1949 ETextAlign textAlign = style()->textAlign(); 1969 ETextAlign textAlign = style()->textAlign();
1950 bool firstLine = true; 1970 bool firstLine = true;
1951 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { 1971 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
1952 float currLogicalLeft = curr->logicalLeft(); 1972 float currLogicalLeft = curr->logicalLeft();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); 2062 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat ();
2043 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; 2063 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft;
2044 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); 2064 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0);
2045 2065
2046 if (!style()->isLeftToRightDirection()) 2066 if (!style()->isLeftToRightDirection())
2047 return logicalWidth() - logicalLeft; 2067 return logicalWidth() - logicalLeft;
2048 return logicalLeft; 2068 return logicalLeft;
2049 } 2069 }
2050 2070
2051 } 2071 }
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/RenderText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698