| 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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 break; | 579 break; |
| 580 } | 580 } |
| 581 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 581 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 582 logicalLeft += verticalScrollbarWidth(); | 582 logicalLeft += verticalScrollbarWidth(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi
calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine,
IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) | 585 static void updateLogicalInlinePositions(RenderBlockFlow* block, float& lineLogi
calLeft, float& lineLogicalRight, float& availableLogicalWidth, bool firstLine,
IndentTextOrNot shouldIndentText, LayoutUnit boxLogicalHeight) |
| 586 { | 586 { |
| 587 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(first
Line, boxLogicalHeight); | 587 LayoutUnit lineLogicalHeight = block->minLineHeightForReplacedRenderer(first
Line, boxLogicalHeight); |
| 588 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh
ouldIndentText == IndentText, lineLogicalHeight).toFloat(); | 588 lineLogicalLeft = block->logicalLeftOffsetForLine(block->logicalHeight(), sh
ouldIndentText == IndentText, lineLogicalHeight).toFloat(); |
| 589 // FIXME: This shouldn't be pixel snapped once multicolumn layout has been u
pdated to correctly carry over subpixel values. | 589 lineLogicalRight = block->logicalRightOffsetForLine(block->logicalHeight(),
shouldIndentText == IndentText, lineLogicalHeight).toFloat(); |
| 590 // https://bugs.webkit.org/show_bug.cgi?id=105461 | |
| 591 lineLogicalRight = block->pixelSnappedLogicalRightOffsetForLine(block->logic
alHeight(), shouldIndentText == IndentText, lineLogicalHeight).toFloat(); | |
| 592 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; | 590 availableLogicalWidth = lineLogicalRight - lineLogicalLeft; |
| 593 } | 591 } |
| 594 | 592 |
| 595 void RenderBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* line
Box, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, boo
l reachedEnd, | 593 void RenderBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* line
Box, const LineInfo& lineInfo, BidiRun* firstRun, BidiRun* trailingSpaceRun, boo
l reachedEnd, |
| 596 GlyphOverflowAndFallbac
kFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMea
surements& wordMeasurements) | 594 GlyphOverflowAndFallbac
kFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache, WordMea
surements& wordMeasurements) |
| 597 { | 595 { |
| 598 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWit
hBreak()); | 596 ETextAlign textAlign = textAlignmentForLine(!reachedEnd && !lineBox->endsWit
hBreak()); |
| 599 | 597 |
| 600 // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted
line of an element. For example, the first line of an anonymous block | 598 // CSS 2.1: "'Text-indent' only affects a line if it is the first formatted
line of an element. For example, the first line of an anonymous block |
| 601 // box is only affected if it is the first child of its parent element." | 599 // box is only affected if it is the first child of its parent element." |
| (...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2058 void RenderBlockFlow::deleteEllipsisLineBoxes() | 2056 void RenderBlockFlow::deleteEllipsisLineBoxes() |
| 2059 { | 2057 { |
| 2060 ETextAlign textAlign = style()->textAlign(); | 2058 ETextAlign textAlign = style()->textAlign(); |
| 2061 bool ltr = style()->isLeftToRightDirection(); | 2059 bool ltr = style()->isLeftToRightDirection(); |
| 2062 bool firstLine = true; | 2060 bool firstLine = true; |
| 2063 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 2061 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
| 2064 if (curr->hasEllipsisBox()) { | 2062 if (curr->hasEllipsisBox()) { |
| 2065 curr->clearTruncation(); | 2063 curr->clearTruncation(); |
| 2066 | 2064 |
| 2067 // Shift the line back where it belongs if we cannot accomodate an e
llipsis. | 2065 // Shift the line back where it belongs if we cannot accomodate an e
llipsis. |
| 2068 float logicalLeft = pixelSnappedLogicalLeftOffsetForLine(curr->lineT
op(), firstLine).toFloat(); | 2066 float logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), firstL
ine).toFloat(); |
| 2069 float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTo
p(), false) - logicalLeft; | 2067 float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTo
p(), false) - logicalLeft; |
| 2070 float totalLogicalWidth = curr->logicalWidth(); | 2068 float totalLogicalWidth = curr->logicalWidth(); |
| 2071 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota
lLogicalWidth, availableLogicalWidth, 0); | 2069 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota
lLogicalWidth, availableLogicalWidth, 0); |
| 2072 | 2070 |
| 2073 if (ltr) | 2071 if (ltr) |
| 2074 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()),
0); | 2072 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()),
0); |
| 2075 else | 2073 else |
| 2076 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); | 2074 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft)
, 0); |
| 2077 } | 2075 } |
| 2078 firstLine = false; | 2076 firstLine = false; |
| 2079 } | 2077 } |
| 2080 } | 2078 } |
| 2081 | 2079 |
| 2082 void RenderBlockFlow::checkLinesForTextOverflow() | 2080 void RenderBlockFlow::checkLinesForTextOverflow() |
| 2083 { | 2081 { |
| 2084 // Determine the width of the ellipsis using the current font. | 2082 // Determine the width of the ellipsis using the current font. |
| 2085 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" | 2083 // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP
) if horizontal ellipsis is "not renderable" |
| 2086 const Font& font = style()->font(); | 2084 const Font& font = style()->font(); |
| 2087 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); | 2085 DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1)); |
| 2088 const Font& firstLineFont = firstLineStyle()->font(); | 2086 const Font& firstLineFont = firstLineStyle()->font(); |
| 2089 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 | 2087 // FIXME: We should probably not hard-code the direction here. https://crbug
.com/333004 |
| 2090 TextDirection ellipsisDirection = LTR; | 2088 TextDirection ellipsisDirection = LTR; |
| 2091 int firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firs
tLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); | 2089 float firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, fi
rstLineFont, &horizontalEllipsis, 1, firstLineStyle(), ellipsisDirection)); |
| 2092 int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.
width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDire
ction)); | 2090 float ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : fon
t.width(constructTextRun(this, font, &horizontalEllipsis, 1, style(), ellipsisDi
rection)); |
| 2093 | 2091 |
| 2094 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see | 2092 // For LTR text truncation, we want to get the right edge of our padding box
, and then we want to see |
| 2095 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and | 2093 // if the right edge of a line box exceeds that. For RTL, we use the left e
dge of the padding box and |
| 2096 // check the left edge of the line box to see if it is less | 2094 // check the left edge of the line box to see if it is less |
| 2097 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" | 2095 // Include the scrollbar for overflow blocks, which means we want to use "co
ntentWidth()" |
| 2098 bool ltr = style()->isLeftToRightDirection(); | 2096 bool ltr = style()->isLeftToRightDirection(); |
| 2099 ETextAlign textAlign = style()->textAlign(); | 2097 ETextAlign textAlign = style()->textAlign(); |
| 2100 bool firstLine = true; | 2098 bool firstLine = true; |
| 2101 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 2099 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
| 2102 // FIXME: Use pixelSnappedLogicalRightOffsetForLine instead of snapping
it ourselves once the column workaround in said method has been fixed. | |
| 2103 // https://bugs.webkit.org/show_bug.cgi?id=105461 | |
| 2104 float currLogicalLeft = curr->logicalLeft(); | 2100 float currLogicalLeft = curr->logicalLeft(); |
| 2105 int blockRightEdge = snapSizeToPixel(logicalRightOffsetForLine(curr->lin
eTop(), firstLine), currLogicalLeft); | 2101 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f
irstLine); |
| 2106 int blockLeftEdge = pixelSnappedLogicalLeftOffsetForLine(curr->lineTop()
, firstLine); | 2102 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir
stLine); |
| 2107 int lineBoxEdge = ltr ? snapSizeToPixel(currLogicalLeft + curr->logicalW
idth(), currLogicalLeft) : snapSizeToPixel(currLogicalLeft, 0); | 2103 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() :
currLogicalLeft; |
| 2108 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc
kLeftEdge)) { | 2104 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc
kLeftEdge)) { |
| 2109 // This line spills out of our box in the appropriate direction. No
w we need to see if the line | 2105 // This line spills out of our box in the appropriate direction. No
w we need to see if the line |
| 2110 // can be truncated. In order for truncation to be possible, the li
ne must have sufficient space to | 2106 // can be truncated. In order for truncation to be possible, the li
ne must have sufficient space to |
| 2111 // accommodate our truncation string, and no replaced elements (imag
es, tables) can overlap the ellipsis | 2107 // accommodate our truncation string, and no replaced elements (imag
es, tables) can overlap the ellipsis |
| 2112 // space. | 2108 // space. |
| 2113 | 2109 |
| 2114 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt
h; | 2110 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt
h; |
| 2115 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 2111 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
| 2116 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi
dth)) { | 2112 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi
dth)) { |
| 2117 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr,
blockLeftEdge, blockRightEdge, width.toFloat()); | 2113 float totalLogicalWidth = curr->placeEllipsis(ellipsisStr, ltr,
blockLeftEdge.toFloat(), blockRightEdge.toFloat(), width.toFloat()); |
| 2118 | 2114 |
| 2119 float logicalLeft = 0; // We are only intersted in the delta fro
m the base position. | 2115 float logicalLeft = 0; // We are only intersted in the delta fro
m the base position. |
| 2120 float snappedLogicalLeft = pixelSnappedLogicalLeftOffsetForLine(
curr->lineTop(), firstLine).toFloat(); | 2116 float availableLogicalWidth = (blockRightEdge - blockLeftEdge).t
oFloat(); |
| 2121 float availableLogicalWidth = pixelSnappedLogicalRightOffsetForL
ine(curr->lineTop(), firstLine) - snappedLogicalLeft; | |
| 2122 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft,
totalLogicalWidth, availableLogicalWidth, 0); | 2117 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft,
totalLogicalWidth, availableLogicalWidth, 0); |
| 2123 if (ltr) | 2118 if (ltr) |
| 2124 curr->adjustLogicalPosition(logicalLeft, 0); | 2119 curr->adjustLogicalPosition(logicalLeft, 0); |
| 2125 else | 2120 else |
| 2126 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); | 2121 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); |
| 2127 } | 2122 } |
| 2128 } | 2123 } |
| 2129 firstLine = false; | 2124 firstLine = false; |
| 2130 } | 2125 } |
| 2131 } | 2126 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 2190 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
| 2196 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 2191 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
| 2197 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2192 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 2198 | 2193 |
| 2199 if (!style()->isLeftToRightDirection()) | 2194 if (!style()->isLeftToRightDirection()) |
| 2200 return logicalWidth() - logicalLeft; | 2195 return logicalWidth() - logicalLeft; |
| 2201 return logicalLeft; | 2196 return logicalLeft; |
| 2202 } | 2197 } |
| 2203 | 2198 |
| 2204 } | 2199 } |
| OLD | NEW |