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 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 else | 1852 else |
1853 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); | 1853 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); |
1854 } | 1854 } |
1855 firstLine = false; | 1855 firstLine = false; |
1856 } | 1856 } |
1857 } | 1857 } |
1858 | 1858 |
1859 void LayoutBlockFlow::checkLinesForTextOverflow() | 1859 void LayoutBlockFlow::checkLinesForTextOverflow() |
1860 { | 1860 { |
1861 // Determine the width of the ellipsis using the current font. | 1861 // Determine the width of the ellipsis using the current font. |
1862 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" | |
1863 const Font& font = style()->font(); | 1862 const Font& font = style()->font(); |
| 1863 |
| 1864 const UChar fullStopString[] = {fullstopCharacter, fullstopCharacter, fullst
opCharacter}; |
| 1865 DEFINE_STATIC_LOCAL(AtomicString, fullstopCharacterStr, (fullStopString, 3))
; |
1864 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsisCharacter
, 1)); | 1866 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsisCharacter
, 1)); |
| 1867 AtomicString& selectedEllipsisStr = ellipsisStr; |
| 1868 |
1865 const Font& firstLineFont = firstLineStyle()->font(); | 1869 const Font& firstLineFont = firstLineStyle()->font(); |
1866 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 | 1870 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 |
1867 TextDirection ellipsisDirection = LTR; | 1871 TextDirection ellipsisDirection = LTR; |
1868 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi
rstLineFont, &horizontalEllipsisCharacter, 1, *firstLineStyle(), ellipsisDirecti
on)); | 1872 float firstLineEllipsisWidth = 0; |
1869 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon
t.width(constructTextRun(this, font, &horizontalEllipsisCharacter, 1, styleRef()
, ellipsisDirection)); | 1873 float ellipsisWidth = 0; |
| 1874 |
| 1875 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of
three |
| 1876 // Full Stops (002E) can be used. |
| 1877 ASSERT(firstLineFont.primaryFont()); |
| 1878 if (firstLineFont.primaryFont()->glyphForCharacter(horizontalEllipsisCharact
er)) { |
| 1879 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs
tLineFont, &horizontalEllipsisCharacter, 1, *firstLineStyle(), ellipsisDirection
)); |
| 1880 } else { |
| 1881 selectedEllipsisStr = fullstopCharacterStr; |
| 1882 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs
tLineFont, fullStopString, 1, *firstLineStyle(), ellipsisDirection)); |
| 1883 } |
| 1884 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0; |
| 1885 |
| 1886 if (!ellipsisWidth) { |
| 1887 ASSERT(font.primaryFont()); |
| 1888 if (font.primaryFont()->glyphForCharacter(horizontalEllipsisCharacter))
{ |
| 1889 selectedEllipsisStr = ellipsisStr; |
| 1890 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE
llipsisCharacter, 1, styleRef(), ellipsisDirection)); |
| 1891 } else { |
| 1892 selectedEllipsisStr = fullstopCharacterStr; |
| 1893 ellipsisWidth = font.width(constructTextRun(this, font, fullStopStri
ng, 1, styleRef(), ellipsisDirection)); |
| 1894 } |
| 1895 } |
1870 | 1896 |
1871 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see | 1897 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see |
1872 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and | 1898 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and |
1873 // check the left edge of the line box to see if it is less | 1899 // check the left edge of the line box to see if it is less |
1874 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" | 1900 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" |
1875 bool ltr = style()->isLeftToRightDirection(); | 1901 bool ltr = style()->isLeftToRightDirection(); |
1876 ETextAlign textAlign = style()->textAlign(); | 1902 ETextAlign textAlign = style()->textAlign(); |
1877 bool firstLine = true; | 1903 bool firstLine = true; |
1878 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 1904 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
1879 LayoutUnit currLogicalLeft = curr->logicalLeft(); | 1905 LayoutUnit currLogicalLeft = curr->logicalLeft(); |
1880 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f
irstLine); | 1906 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f
irstLine); |
1881 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir
stLine); | 1907 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir
stLine); |
1882 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() :
currLogicalLeft; | 1908 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() :
currLogicalLeft; |
1883 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc
kLeftEdge)) { | 1909 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc
kLeftEdge)) { |
1884 // This line spills out of our box in the appropriate direction. No
w we need to see if the line | 1910 // This line spills out of our box in the appropriate direction. No
w we need to see if the line |
1885 // can be truncated. In order for truncation to be possible, the li
ne must have sufficient space to | 1911 // can be truncated. In order for truncation to be possible, the li
ne must have sufficient space to |
1886 // accommodate our truncation string, and no replaced elements (imag
es, tables) can overlap the ellipsis | 1912 // accommodate our truncation string, and no replaced elements (imag
es, tables) can overlap the ellipsis |
1887 // space. | 1913 // space. |
1888 | 1914 |
1889 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt
h; | 1915 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt
h; |
1890 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 1916 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
1891 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi
dth)) { | 1917 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi
dth)) { |
1892 LayoutUnit totalLogicalWidth = curr->placeEllipsis(ellipsisStr,
ltr, blockLeftEdge, blockRightEdge, width); | 1918 LayoutUnit totalLogicalWidth = curr->placeEllipsis(selectedEllip
sisStr, ltr, blockLeftEdge, blockRightEdge, width); |
1893 | |
1894 LayoutUnit logicalLeft; // We are only interested in the delta f
rom the base position. | 1919 LayoutUnit logicalLeft; // We are only interested in the delta f
rom the base position. |
1895 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg
e; | 1920 LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdg
e; |
1896 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft,
totalLogicalWidth, availableLogicalWidth, 0); | 1921 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft,
totalLogicalWidth, availableLogicalWidth, 0); |
1897 if (ltr) | 1922 if (ltr) |
1898 curr->adjustLogicalPosition(logicalLeft, 0); | 1923 curr->adjustLogicalPosition(logicalLeft, 0); |
1899 else | 1924 else |
1900 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); | 1925 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); |
1901 } | 1926 } |
1902 } | 1927 } |
1903 firstLine = false; | 1928 firstLine = false; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 1992 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
1968 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 1993 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
1969 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 1994 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
1970 | 1995 |
1971 if (!style()->isLeftToRightDirection()) | 1996 if (!style()->isLeftToRightDirection()) |
1972 return logicalWidth() - logicalLeft; | 1997 return logicalWidth() - logicalLeft; |
1973 return logicalLeft; | 1998 return logicalLeft; |
1974 } | 1999 } |
1975 | 2000 |
1976 } | 2001 } |
OLD | NEW |