OLD | NEW |
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 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 else | 1932 else |
1933 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); | 1933 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); |
1934 } | 1934 } |
1935 firstLine = false; | 1935 firstLine = false; |
1936 } | 1936 } |
1937 } | 1937 } |
1938 | 1938 |
1939 void RenderBlockFlow::checkLinesForTextOverflow() | 1939 void RenderBlockFlow::checkLinesForTextOverflow() |
1940 { | 1940 { |
1941 // Determine the width of the ellipsis using the current font. | 1941 // Determine the width of the ellipsis using the current font. |
| 1942 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" |
1942 const Font& font = style()->font(); | 1943 const Font& font = style()->font(); |
1943 | |
1944 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst
opCharacter}; | |
1945 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3))
; | |
1946 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); | 1944 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); |
1947 | |
1948 const Font& firstLineFont = firstLineStyle()->font(); | 1945 const Font& firstLineFont = firstLineStyle()->font(); |
1949 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 | 1946 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 |
1950 TextDirection ellipsisDirection = LTR; | 1947 TextDirection ellipsisDirection = LTR; |
1951 float firstLineEllipsisWidth = 0; | 1948 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi
rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); |
1952 float ellipsisWidth = 0; | 1949 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon
t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi
rection)); |
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 ellipsisStr = fullstopCharacterStr; | |
1960 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs
tLineFont, &fullstopCharacter, 1, firstLineStyle(), ellipsisDirection)) * 3; | |
1961 } | |
1962 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0; | |
1963 | |
1964 if (!ellipsisWidth) { | |
1965 if (font.primaryFontHasGlyphForCharacter(horizontalEllipsis)) | |
1966 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE
llipsis, 1, style(), ellipsisDirection)); | |
1967 else | |
1968 ellipsisWidth = font.width(constructTextRun(this, font, &fullstopCha
racter, 1, style(), ellipsisDirection)) * 3; | |
1969 } | |
1970 | 1950 |
1971 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see | 1951 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see |
1972 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and | 1952 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and |
1973 // check the left edge of the line box to see if it is less | 1953 // check the left edge of the line box to see if it is less |
1974 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" | 1954 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" |
1975 bool ltr = style()->isLeftToRightDirection(); | 1955 bool ltr = style()->isLeftToRightDirection(); |
1976 ETextAlign textAlign = style()->textAlign(); | 1956 ETextAlign textAlign = style()->textAlign(); |
1977 bool firstLine = true; | 1957 bool firstLine = true; |
1978 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 1958 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
1979 float currLogicalLeft = curr->logicalLeft(); | 1959 float currLogicalLeft = curr->logicalLeft(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2049 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
2070 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2050 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
2071 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2051 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2072 | 2052 |
2073 if (!style()->isLeftToRightDirection()) | 2053 if (!style()->isLeftToRightDirection()) |
2074 return logicalWidth() - logicalLeft; | 2054 return logicalWidth() - logicalLeft; |
2075 return logicalLeft; | 2055 return logicalLeft; |
2076 } | 2056 } |
2077 | 2057 |
2078 } | 2058 } |
OLD | NEW |