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 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | |
1943 const Font& firstLineFont = firstLineStyle()->font(); | 1946 const Font& firstLineFont = firstLineStyle()->font(); |
1944 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 | 1947 // FIXME: We should probably not hard-code the direction here. https://crbug .com/333004 |
1945 TextDirection ellipsisDirection = LTR; | 1948 TextDirection ellipsisDirection = LTR; |
1946 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); | 1949 float firstLineEllipsisWidth = 0; |
1947 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi rection)); | 1950 float ellipsisWidth = 0; |
1951 bool useHorizontalEllipsis = true; | |
1952 | |
1953 // As per CSS3 http://www.w3.org/TR/2003/CR-css3-text-20030514/ sequence of three | |
1954 // Full Stops (002E) can be used. | |
1955 if (firstLineFont.primaryFontHasGlyphForCharacter(horizontalEllipsis)) { | |
1956 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); | |
1957 } else { | |
1958 useHorizontalEllipsis = false; | |
1959 firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs tLineFont, fullStopString, 1, firstLineStyle(), ellipsisDirection)); | |
1960 } | |
1961 ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : 0; | |
1962 | |
1963 if (!ellipsisWidth) { | |
1964 if (font.primaryFontHasGlyphForCharacter(horizontalEllipsis)) | |
1965 ellipsisWidth = font.width(constructTextRun(this, font, &horizontalE llipsis, 1, style(), ellipsisDirection)); | |
1966 else | |
Dominik Röttsches
2015/01/08 13:02:25
I think you might be missing useHorizontalEllipsis
| |
1967 ellipsisWidth = font.width(constructTextRun(this, font, fullStopStri ng, 1, style(), ellipsisDirection)); | |
1968 } | |
1948 | 1969 |
1949 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see | 1970 // 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 | 1971 // 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 | 1972 // 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()" | 1973 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" |
1953 bool ltr = style()->isLeftToRightDirection(); | 1974 bool ltr = style()->isLeftToRightDirection(); |
1954 ETextAlign textAlign = style()->textAlign(); | 1975 ETextAlign textAlign = style()->textAlign(); |
1955 bool firstLine = true; | 1976 bool firstLine = true; |
1956 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1977 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
1957 float currLogicalLeft = curr->logicalLeft(); | 1978 float currLogicalLeft = curr->logicalLeft(); |
1958 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); | 1979 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); |
1959 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); | 1980 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); |
1960 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; | 1981 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; |
1961 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { | 1982 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 | 1983 // 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 | 1984 // 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 | 1985 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis |
1965 // space. | 1986 // space. |
1966 | 1987 |
1967 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; | 1988 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; |
1968 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 1989 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
1969 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { | 1990 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { |
1970 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); | 1991 float totalLogicalWidth = 0; |
1992 if (useHorizontalEllipsis) | |
1993 totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr, bl ockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); | |
Dominik Röttsches
2015/01/08 13:02:25
Does this code need to differentiate between first
| |
1994 else | |
1995 totalLogicalWidth = curr->placeEllipsis(fullstopCharacterStr , ltr, blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); | |
1971 | 1996 |
1972 float logicalLeft = 0; // We are only intersted in the delta fro m the base position. | 1997 float logicalLeft = 0; // We are only intersted in the delta fro m the base position. |
1973 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t oFloat(); | 1998 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t oFloat(); |
1974 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); | 1999 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0); |
1975 if (ltr) | 2000 if (ltr) |
1976 curr->adjustLogicalPosition(logicalLeft, 0); | 2001 curr->adjustLogicalPosition(logicalLeft, 0); |
1977 else | 2002 else |
1978 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); | 2003 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW idth - totalLogicalWidth), 0); |
1979 } | 2004 } |
1980 } | 2005 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2045 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); | 2070 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); |
2046 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 2071 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; |
2047 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2072 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
2048 | 2073 |
2049 if (!style()->isLeftToRightDirection()) | 2074 if (!style()->isLeftToRightDirection()) |
2050 return logicalWidth() - logicalLeft; | 2075 return logicalWidth() - logicalLeft; |
2051 return logicalLeft; | 2076 return logicalLeft; |
2052 } | 2077 } |
2053 | 2078 |
2054 } | 2079 } |
OLD | NEW |