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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 trailingWhitespaceChar = c; | 1187 trailingWhitespaceChar = c; |
1188 } | 1188 } |
1189 | 1189 |
1190 // FIXME: This ignores first-line. | 1190 // FIXME: This ignores first-line. |
1191 const Font& font = text->style()->font(); | 1191 const Font& font = text->style()->font(); |
1192 TextRun run = constructTextRun(text, font, &trailingWhitespaceChar, 1, | 1192 TextRun run = constructTextRun(text, font, &trailingWhitespaceChar, 1, |
1193 text->styleRef(), text->style()->direction()); | 1193 text->styleRef(), text->style()->direction()); |
1194 run.setCodePath(text->canUseSimpleFontCodePath() | 1194 run.setCodePath(text->canUseSimpleFontCodePath() |
1195 ? TextRun::ForceSimple | 1195 ? TextRun::ForceSimple |
1196 : TextRun::ForceComplex); | 1196 : TextRun::ForceComplex); |
1197 float spaceWidth = font.width(run); | 1197 float characterSpaceWidth = font.width(run); |
1198 inlineMax -= spaceWidth + font.fontDescription().wordSpacing(); | 1198 inlineMax -= characterSpaceWidth + font.fontDescription().wordSpacing(); |
1199 if (inlineMin > inlineMax) | 1199 if (inlineMin > inlineMax) |
1200 inlineMin = inlineMax; | 1200 inlineMin = inlineMax; |
1201 } | 1201 } |
1202 } | 1202 } |
1203 | 1203 |
1204 // When converting between floating point and LayoutUnits we risk losing precisi
on | 1204 // When converting between floating point and LayoutUnits we risk losing precisi
on |
1205 // with each conversion. When this occurs while accumulating our preferred width
s, | 1205 // with each conversion. When this occurs while accumulating our preferred width
s, |
1206 // we can wind up with a line width that's larger than our maxPreferredWidth due
to | 1206 // we can wind up with a line width that's larger than our maxPreferredWidth due
to |
1207 // pure float accumulation. | 1207 // pure float accumulation. |
1208 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) | 1208 static inline LayoutUnit adjustFloatForSubPixelLayout(float value) |
1209 { | 1209 { |
1210 return LayoutUnit::fromFloatCeil(value); | 1210 return LayoutUnit::fromFloatCeil(value); |
1211 } | 1211 } |
1212 | 1212 |
1213 // FIXME: This function should be broken into something less monolithic. | 1213 // FIXME: This function should be broken into something less monolithic. |
1214 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T
hey can probably reuse code. | 1214 // FIXME: The main loop here is very similar to LineBreaker::nextSegmentBreak. T
hey can probably reuse code. |
1215 void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
Width, LayoutUnit& maxLogicalWidth) | 1215 void LayoutBlockFlow::computeInlinePreferredLogicalWidths(LayoutUnit& minLogical
Width, LayoutUnit& maxLogicalWidth) |
1216 { | 1216 { |
1217 FloatWillBeLayoutUnit inlineMax; | 1217 FloatWillBeLayoutUnit inlineMax; |
1218 FloatWillBeLayoutUnit inlineMin; | 1218 FloatWillBeLayoutUnit inlineMin; |
1219 | 1219 |
1220 const ComputedStyle& styleToUse = styleRef(); | 1220 const ComputedStyle& styleToUse = styleRef(); |
1221 LayoutBlock* containingBlock = this->containingBlock(); | 1221 LayoutBlock* containingBlock = this->containingBlock(); |
1222 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L
ayoutUnit(); | 1222 LayoutUnit cw = containingBlock ? containingBlock->contentLogicalWidth() : L
ayoutUnit(); |
1223 | 1223 |
1224 // If we are at the start of a line, we want to ignore all white-space. | 1224 // If we are at the start of a line, we want to ignore all white-space. |
1225 // Also strip spaces if we previously had text that ended in a trailing spac
e. | 1225 // Also strip spaces if we previously had text that ended in a trailing char
acterSpace. |
1226 bool stripFrontSpaces = true; | 1226 bool stripFrontSpaces = true; |
1227 LayoutObject* trailingSpaceChild = 0; | 1227 LayoutObject* trailingSpaceChild = 0; |
1228 | 1228 |
1229 // Firefox and Opera will allow a table cell to grow to fit an image inside
it under | 1229 // Firefox and Opera will allow a table cell to grow to fit an image inside
it under |
1230 // very specific cirucumstances (in order to match common WinIE layouts). | 1230 // very specific cirucumstances (in order to match common WinIE layouts). |
1231 // Not supporting the quirk has caused us to mis-layout some real sites. (Se
e Bugzilla 10517.) | 1231 // Not supporting the quirk has caused us to mis-layout some real sites. (Se
e Bugzilla 10517.) |
1232 bool allowImagesToBreak = !document().inQuirksMode() || !isTableCell() || !s
tyleToUse.logicalWidth().isIntrinsicOrAuto(); | 1232 bool allowImagesToBreak = !document().inQuirksMode() || !isTableCell() || !s
tyleToUse.logicalWidth().isIntrinsicOrAuto(); |
1233 | 1233 |
1234 bool autoWrap, oldAutoWrap; | 1234 bool autoWrap, oldAutoWrap; |
1235 autoWrap = oldAutoWrap = styleToUse.autoWrap(); | 1235 autoWrap = oldAutoWrap = styleToUse.autoWrap(); |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 } | 1939 } |
1940 firstLine = false; | 1940 firstLine = false; |
1941 } | 1941 } |
1942 } | 1942 } |
1943 | 1943 |
1944 void LayoutBlockFlow::checkLinesForTextOverflow() | 1944 void LayoutBlockFlow::checkLinesForTextOverflow() |
1945 { | 1945 { |
1946 // Determine the width of the ellipsis using the current font. | 1946 // Determine the width of the ellipsis using the current font. |
1947 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" | 1947 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" |
1948 const Font& font = style()->font(); | 1948 const Font& font = style()->font(); |
1949 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); | 1949 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&characterHorizontalEllipsis
, 1)); |
1950 const Font& firstLineFont = firstLineStyle()->font(); | 1950 const Font& firstLineFont = firstLineStyle()->font(); |
1951 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 | 1951 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 |
1952 TextDirection ellipsisDirection = LTR; | 1952 TextDirection ellipsisDirection = LTR; |
1953 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi
rstLineFont, &horizontalEllipsis, 1, *firstLineStyle(), ellipsisDirection)); | 1953 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi
rstLineFont, &characterHorizontalEllipsis, 1, *firstLineStyle(), ellipsisDirecti
on)); |
1954 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon
t.width(constructTextRun(this, font, &horizontalEllipsis, 1, styleRef(), ellipsi
sDirection)); | 1954 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon
t.width(constructTextRun(this, font, &characterHorizontalEllipsis, 1, styleRef()
, ellipsisDirection)); |
1955 | 1955 |
1956 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see | 1956 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see |
1957 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and | 1957 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and |
1958 // check the left edge of the line box to see if it is less | 1958 // check the left edge of the line box to see if it is less |
1959 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" | 1959 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" |
1960 bool ltr = style()->isLeftToRightDirection(); | 1960 bool ltr = style()->isLeftToRightDirection(); |
1961 ETextAlign textAlign = style()->textAlign(); | 1961 ETextAlign textAlign = style()->textAlign(); |
1962 bool firstLine = true; | 1962 bool firstLine = true; |
1963 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 1963 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
1964 float currLogicalLeft = curr->logicalLeft(); | 1964 float currLogicalLeft = curr->logicalLeft(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2052 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
2053 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2053 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
2054 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2054 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2055 | 2055 |
2056 if (!style()->isLeftToRightDirection()) | 2056 if (!style()->isLeftToRightDirection()) |
2057 return logicalWidth() - logicalLeft; | 2057 return logicalWidth() - logicalLeft; |
2058 return logicalLeft; | 2058 return logicalLeft; |
2059 } | 2059 } |
2060 | 2060 |
2061 } | 2061 } |
OLD | NEW |