Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
| index ab7e8b01ebab2e21126cbee1ec5a99d4c9e871d7..2c1a81a93b84068b7285844449c79e302e00cb24 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlowLine.cpp |
| @@ -2399,7 +2399,6 @@ void LayoutBlockFlow::checkLinesForTextOverflow() { |
| // the line box to see if it is less Include the scrollbar for overflow |
| // blocks, which means we want to use "contentWidth()". |
| bool ltr = style()->isLeftToRightDirection(); |
| - ETextAlign textAlign = style()->textAlign(); |
| IndentTextOrNot indentText = IndentText; |
| for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
| LayoutUnit currLogicalLeft = curr->logicalLeft(); |
| @@ -2422,25 +2421,86 @@ void LayoutBlockFlow::checkLinesForTextOverflow() { |
| LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
| if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, |
| width)) { |
| - LayoutUnit totalLogicalWidth = curr->placeEllipsis( |
| - selectedEllipsisStr, ltr, blockLeftEdge, blockRightEdge, width); |
| - LayoutUnit logicalLeft; // We are only interested in the delta from the |
| - // base position. |
| - LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdge; |
| - updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, |
| - totalLogicalWidth, availableLogicalWidth, |
| - 0); |
| - if (ltr) |
| - curr->moveInInlineDirection(logicalLeft); |
| - else |
| - curr->moveInInlineDirection( |
| - logicalLeft - (availableLogicalWidth - totalLogicalWidth)); |
| + placeEllipsis(curr, blockLeftEdge, blockRightEdge, selectedEllipsisStr, |
| + width, LayoutUnit(), false); |
| + } else { |
| + tryPlacingEllipsisOnAtomicInlines(curr, blockRightEdge, blockLeftEdge, |
| + width, selectedEllipsisStr); |
| } |
| } |
| indentText = DoNotIndentText; |
| } |
| } |
| +void LayoutBlockFlow::tryPlacingEllipsisOnAtomicInlines( |
| + RootInlineBox* root, |
| + LayoutUnit blockRightEdge, |
| + LayoutUnit blockLeftEdge, |
| + LayoutUnit ellipsisWidth, |
| + const AtomicString& selectedEllipsisStr) { |
| + bool ltr = style()->isLeftToRightDirection(); |
| + LayoutUnit logicalLeftOffset = blockLeftEdge; |
| + |
| + bool foundBox = false; |
| + for (InlineBox* box = ltr ? root->firstChild() : root->lastChild(); box; |
| + box = ltr ? box->nextOnLine() : box->prevOnLine()) { |
| + if (!box->getLineLayoutItem().isAtomicInlineLevel() || |
| + !box->getLineLayoutItem().isLayoutBlockFlow()) |
| + continue; |
| + |
| + RootInlineBox* firstRootBox = |
| + LineLayoutBlockFlow(box->getLineLayoutItem()).firstRootBox(); |
| + if (!firstRootBox) |
| + continue; |
| + |
| + bool placedEllipsis = false; |
| + // Move the right edge of the block in so that we can test it against the |
| + // width of the root line boxes. |
| + for (RootInlineBox* curr = firstRootBox; curr; curr = curr->nextRootBox()) { |
|
eae
2017/02/21 21:55:17
It might be easier to move the ltr check outside o
|
| + LayoutUnit currLogicalLeft = logicalLeftOffset + curr->logicalLeft(); |
| + LayoutUnit ellipsisEdge = |
| + ltr ? currLogicalLeft + curr->logicalWidth() + ellipsisWidth |
| + : box->logicalLeft() + curr->logicalLeft() - ellipsisWidth; |
| + |
| + if ((ltr && ellipsisEdge > blockRightEdge) || |
| + (!ltr && ellipsisEdge < blockLeftEdge)) { |
| + placeEllipsis( |
| + curr, blockLeftEdge, blockRightEdge, selectedEllipsisStr, |
| + ellipsisWidth, |
| + ltr ? logicalLeftOffset : LayoutUnit(box->logicalLeft().ceil()), |
| + foundBox); |
| + placedEllipsis = true; |
| + } |
| + } |
| + foundBox |= placedEllipsis; |
| + logicalLeftOffset += box->logicalWidth(); |
| + } |
| +} |
| + |
| +void LayoutBlockFlow::placeEllipsis(RootInlineBox* curr, |
| + LayoutUnit blockLeftEdge, |
| + LayoutUnit blockRightEdge, |
| + const AtomicString& selectedEllipsisStr, |
| + LayoutUnit ellipsisWidth, |
| + LayoutUnit logicalLeftOffset, |
| + bool foundBox) { |
| + bool ltr = style()->isLeftToRightDirection(); |
| + ETextAlign textAlign = style()->textAlign(); |
| + LayoutUnit totalLogicalWidth = curr->placeEllipsis( |
| + selectedEllipsisStr, ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, |
| + logicalLeftOffset, foundBox); |
| + LayoutUnit logicalLeft; |
| + LayoutUnit availableLogicalWidth = blockRightEdge - blockLeftEdge; |
| + updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, |
| + totalLogicalWidth, availableLogicalWidth, 0); |
| + if (ltr) { |
| + curr->moveInInlineDirection(logicalLeft); |
| + } else { |
| + curr->moveInInlineDirection(logicalLeft - |
| + (availableLogicalWidth - totalLogicalWidth)); |
|
eae
2017/02/21 21:55:17
What happens if totalLogicalWidth is more than ava
|
| + } |
| +} |
| + |
| void LayoutBlockFlow::markLinesDirtyInBlockRange(LayoutUnit logicalTop, |
| LayoutUnit logicalBottom, |
| RootInlineBox* highest) { |