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 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 else | 1920 else |
1921 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); | 1921 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); |
1922 } | 1922 } |
1923 firstLine = false; | 1923 firstLine = false; |
1924 } | 1924 } |
1925 } | 1925 } |
1926 | 1926 |
1927 void RenderBlockFlow::checkLinesForTextOverflow() | 1927 void RenderBlockFlow::checkLinesForTextOverflow() |
1928 { | 1928 { |
1929 // Determine the width of the ellipsis using the current font. | 1929 // Determine the width of the ellipsis using the current font. |
1930 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" | |
1931 const Font& font = style()->font(); | 1930 const Font& font = style()->font(); |
| 1931 |
| 1932 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst
opCharacter}; |
| 1933 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3))
; |
1932 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); | 1934 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); |
| 1935 |
1933 const Font& firstLineFont = firstLineStyle()->font(); | 1936 const Font& firstLineFont = firstLineStyle()->font(); |
1934 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 | 1937 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 |
1935 TextDirection ellipsisDirection = LTR; | 1938 TextDirection ellipsisDirection = LTR; |
1936 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi
rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); | 1939 float firstLineEllipsisWidth = 0; |
1937 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon
t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi
rection)); | 1940 float ellipsisWidth = 0; |
| 1941 |
| 1942 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of
three |
| 1943 // Full Stops (002E) can be used. |
| 1944 if (firstLineFont.primaryFontHasGlyphForCharacter(horizontalEllipsis)) { |
| 1945 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs
tLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); |
| 1946 } else { |
| 1947 ellipsisStr = fullstopCharacterStr; |
| 1948 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs
tLineFont, &fullstopCharacter, 1, firstLineStyle(), ellipsisDirection)) * 3; |
| 1949 } |
| 1950 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0; |
| 1951 |
| 1952 if (!ellipsisWidth) { |
| 1953 if (font.primaryFontHasGlyphForCharacter(horizontalEllipsis)) |
| 1954 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE
llipsis, 1, style(), ellipsisDirection)); |
| 1955 else |
| 1956 ellipsisWidth = font.width(constructTextRun(this, font, &fullstopCha
racter, 1, style(), ellipsisDirection)) * 3; |
| 1957 } |
1938 | 1958 |
1939 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see | 1959 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see |
1940 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and | 1960 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and |
1941 // check the left edge of the line box to see if it is less | 1961 // check the left edge of the line box to see if it is less |
1942 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" | 1962 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" |
1943 bool ltr = style()->isLeftToRightDirection(); | 1963 bool ltr = style()->isLeftToRightDirection(); |
1944 ETextAlign textAlign = style()->textAlign(); | 1964 ETextAlign textAlign = style()->textAlign(); |
1945 bool firstLine = true; | 1965 bool firstLine = true; |
1946 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 1966 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
1947 float currLogicalLeft = curr->logicalLeft(); | 1967 float currLogicalLeft = curr->logicalLeft(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2057 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
2038 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2058 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
2039 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2059 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2040 | 2060 |
2041 if (!style()->isLeftToRightDirection()) | 2061 if (!style()->isLeftToRightDirection()) |
2042 return logicalWidth() - logicalLeft; | 2062 return logicalWidth() - logicalLeft; |
2043 return logicalLeft; | 2063 return logicalLeft; |
2044 } | 2064 } |
2045 | 2065 |
2046 } | 2066 } |
OLD | NEW |