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 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 | 1201 |
1202 if (isFullLayout) { | 1202 if (isFullLayout) { |
1203 // Ensure the old line boxes will be erased. | 1203 // Ensure the old line boxes will be erased. |
1204 if (firstLineBox()) | 1204 if (firstLineBox()) |
1205 setShouldDoFullPaintInvalidation(true); | 1205 setShouldDoFullPaintInvalidation(true); |
1206 lineBoxes()->deleteLineBoxes(); | 1206 lineBoxes()->deleteLineBoxes(); |
1207 } | 1207 } |
1208 | 1208 |
1209 // Text truncation kicks in in two cases: | 1209 // Text truncation kicks in in two cases: |
1210 // 1) If your overflow isn't visible and your text-overflow-mode isn't c lip. | 1210 // 1) If your overflow isn't visible and your text-overflow-mode isn't c lip. |
1211 // 2) If you're an anonymous block with a block parent that satisfies #1 that was created | 1211 // 2) If you're an anonymous paragraph with a parent that satisfies #1. |
ojan
2014/11/21 05:35:51
This code changed in https://codereview.chromium.o
| |
1212 // to accomodate a block that has inline and block children. | |
1213 // FIXME: CSS3 says that descendants that are clipped must also know how to truncate. This is insanely | 1212 // FIXME: CSS3 says that descendants that are clipped must also know how to truncate. This is insanely |
1214 // difficult to figure out in general (especially in the middle of doing lay out), so we only handle the | 1213 // difficult to figure out in general (especially in the middle of doing lay out), so we only handle the |
1215 // simple case of an anonymous block truncating when it's parent is clipped. | 1214 // simple case of an anonymous block truncating when it's parent is clipped. |
1216 bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip()) | 1215 bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip()) |
1217 || (isAnonymousBlock() && parent() && parent()->style()->textOverflow() && parent()->hasOverflowClip()); | 1216 || (isAnonymousBlock() && parent() && parent()->style()->textOverflow() && parent()->hasOverflowClip()); |
1218 | 1217 |
1219 // Walk all the lines and delete our ellipsis line boxes if they exist. | 1218 // Walk all the lines and delete our ellipsis line boxes if they exist. |
1220 if (hasTextOverflow) | 1219 if (hasTextOverflow) |
1221 deleteEllipsisLineBoxes(); | 1220 deleteEllipsisLineBoxes(); |
1222 | 1221 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1505 void RenderBlockFlow::deleteEllipsisLineBoxes() | 1504 void RenderBlockFlow::deleteEllipsisLineBoxes() |
1506 { | 1505 { |
1507 ETextAlign textAlign = style()->textAlign(); | 1506 ETextAlign textAlign = style()->textAlign(); |
1508 bool ltr = style()->isLeftToRightDirection(); | 1507 bool ltr = style()->isLeftToRightDirection(); |
1509 bool firstLine = true; | 1508 bool firstLine = true; |
1510 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1509 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
1511 if (curr->hasEllipsisBox()) { | 1510 if (curr->hasEllipsisBox()) { |
1512 curr->clearTruncation(); | 1511 curr->clearTruncation(); |
1513 | 1512 |
1514 // Shift the line back where it belongs if we cannot accomodate an e llipsis. | 1513 // Shift the line back where it belongs if we cannot accomodate an e llipsis. |
1515 float logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), firstL ine).toFloat(); | 1514 float logicalLeft = logicalLeftOffsetForLine(firstLine).toFloat(); |
ojan
2014/11/21 05:35:51
These lines and the ones below are the bug. We're
| |
1516 float availableLogicalWidth = logicalRightOffsetForLine(curr->lineTo p(), false) - logicalLeft; | 1515 float availableLogicalWidth = logicalRightOffsetForLine(false) - log icalLeft; |
1517 float totalLogicalWidth = curr->logicalWidth(); | 1516 float totalLogicalWidth = curr->logicalWidth(); |
1518 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); | 1517 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota lLogicalWidth, availableLogicalWidth, 0); |
1519 | 1518 |
1520 if (ltr) | 1519 if (ltr) |
1521 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); | 1520 curr->adjustLogicalPosition((logicalLeft - curr->logicalLeft()), 0); |
1522 else | 1521 else |
1523 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); | 1522 curr->adjustLogicalPosition(-(curr->logicalLeft() - logicalLeft) , 0); |
1524 } | 1523 } |
1525 firstLine = false; | 1524 firstLine = false; |
1526 } | 1525 } |
(...skipping 13 matching lines...) Expand all Loading... | |
1540 | 1539 |
1541 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see | 1540 // For LTR text truncation, we want to get the right edge of our padding box , and then we want to see |
1542 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and | 1541 // if the right edge of a line box exceeds that. For RTL, we use the left e dge of the padding box and |
1543 // check the left edge of the line box to see if it is less | 1542 // check the left edge of the line box to see if it is less |
1544 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" | 1543 // Include the scrollbar for overflow blocks, which means we want to use "co ntentWidth()" |
1545 bool ltr = style()->isLeftToRightDirection(); | 1544 bool ltr = style()->isLeftToRightDirection(); |
1546 ETextAlign textAlign = style()->textAlign(); | 1545 ETextAlign textAlign = style()->textAlign(); |
1547 bool firstLine = true; | 1546 bool firstLine = true; |
1548 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1547 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
1549 float currLogicalLeft = curr->logicalLeft(); | 1548 float currLogicalLeft = curr->logicalLeft(); |
1550 LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->lineTop(), f irstLine); | 1549 LayoutUnit blockRightEdge = logicalRightOffsetForLine(firstLine); |
1551 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->lineTop(), fir stLine); | 1550 LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(firstLine); |
1552 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; | 1551 LayoutUnit lineBoxEdge = ltr ? currLogicalLeft + curr->logicalWidth() : currLogicalLeft; |
1553 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { | 1552 if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < bloc kLeftEdge)) { |
1554 // This line spills out of our box in the appropriate direction. No w we need to see if the line | 1553 // This line spills out of our box in the appropriate direction. No w we need to see if the line |
1555 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to | 1554 // can be truncated. In order for truncation to be possible, the li ne must have sufficient space to |
1556 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis | 1555 // accommodate our truncation string, and no replaced elements (imag es, tables) can overlap the ellipsis |
1557 // space. | 1556 // space. |
1558 | 1557 |
1559 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; | 1558 LayoutUnit width = firstLine ? firstLineEllipsisWidth : ellipsisWidt h; |
1560 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; | 1559 LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge; |
1561 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { | 1560 if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, wi dth)) { |
(...skipping 14 matching lines...) Expand all Loading... | |
1576 | 1575 |
1577 LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(bool firstLine) | 1576 LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(bool firstLine) |
1578 { | 1577 { |
1579 ETextAlign textAlign = style()->textAlign(); | 1578 ETextAlign textAlign = style()->textAlign(); |
1580 | 1579 |
1581 if (textAlign == TASTART) // FIXME: Handle TAEND here | 1580 if (textAlign == TASTART) // FIXME: Handle TAEND here |
1582 return startOffsetForLine(firstLine); | 1581 return startOffsetForLine(firstLine); |
1583 | 1582 |
1584 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here | 1583 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here |
1585 float totalLogicalWidth = 0; | 1584 float totalLogicalWidth = 0; |
1586 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); | 1585 float logicalLeft = logicalLeftOffsetForLine(false).toFloat(); |
1587 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 1586 float availableLogicalWidth = logicalRightOffsetForLine(false) - logicalLeft ; |
1588 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 1587 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
1589 | 1588 |
1590 if (!style()->isLeftToRightDirection()) | 1589 if (!style()->isLeftToRightDirection()) |
1591 return logicalWidth() - logicalLeft; | 1590 return logicalWidth() - logicalLeft; |
1592 return logicalLeft; | 1591 return logicalLeft; |
1593 } | 1592 } |
1594 | 1593 |
1595 } | 1594 } |
OLD | NEW |