OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 child = child->prevOnLine()) | 1402 child = child->prevOnLine()) |
1403 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->lastLeafChild(); | 1403 leaf = child->isLeaf() ? child : toInlineFlowBox(child)->lastLeafChild(); |
1404 return leaf; | 1404 return leaf; |
1405 } | 1405 } |
1406 | 1406 |
1407 SelectionState InlineFlowBox::getSelectionState() const { | 1407 SelectionState InlineFlowBox::getSelectionState() const { |
1408 return SelectionNone; | 1408 return SelectionNone; |
1409 } | 1409 } |
1410 | 1410 |
1411 bool InlineFlowBox::canAccommodateEllipsis(bool ltr, | 1411 bool InlineFlowBox::canAccommodateEllipsis(bool ltr, |
1412 int blockEdge, | 1412 LayoutUnit blockEdge, |
1413 int ellipsisWidth) const { | 1413 LayoutUnit ellipsisWidth) const { |
1414 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) { | 1414 for (InlineBox* box = firstChild(); box; box = box->nextOnLine()) { |
1415 if (!box->canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth)) | 1415 if (!box->canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth)) |
1416 return false; | 1416 return false; |
1417 } | 1417 } |
1418 return true; | 1418 return true; |
1419 } | 1419 } |
1420 | 1420 |
1421 LayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, | 1421 LayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, |
1422 LayoutUnit blockLeftEdge, | 1422 LayoutUnit blockLeftEdge, |
1423 LayoutUnit blockRightEdge, | 1423 LayoutUnit blockRightEdge, |
1424 LayoutUnit ellipsisWidth, | 1424 LayoutUnit ellipsisWidth, |
1425 LayoutUnit& truncatedWidth, | 1425 LayoutUnit& truncatedWidth, |
1426 bool& foundBox) { | 1426 bool& foundBox) { |
1427 LayoutUnit result(-1); | 1427 LayoutUnit result(-1); |
1428 // We iterate over all children, the foundBox variable tells us when we've | 1428 // We iterate over all children, the foundBox variable tells us when we've |
1429 // found the box containing the ellipsis. All boxes after that one in the | 1429 // found the box containing the ellipsis. All boxes after that one in the |
1430 // flow are hidden. | 1430 // flow are hidden. |
1431 // If our flow is ltr then iterate over the boxes from left to right, | 1431 // If our flow is ltr then iterate over the boxes from left to right, |
1432 // otherwise iterate from right to left. Varying the order allows us to | 1432 // otherwise iterate from right to left. Varying the order allows us to |
1433 // correctly hide the boxes following the ellipsis. | 1433 // correctly hide the boxes following the ellipsis. |
1434 InlineBox* box = ltr ? firstChild() : lastChild(); | 1434 InlineBox* box = ltr ? firstChild() : lastChild(); |
1435 | 1435 |
1436 // NOTE: these will cross after foundBox = true. | 1436 // NOTE: these will cross after foundBox = true. |
1437 int visibleLeftEdge = blockLeftEdge.toInt(); | 1437 LayoutUnit visibleLeftEdge = blockLeftEdge; |
1438 int visibleRightEdge = blockRightEdge.toInt(); | 1438 LayoutUnit visibleRightEdge = blockRightEdge; |
1439 | 1439 |
1440 while (box) { | 1440 while (box) { |
1441 int currResult = | 1441 LayoutUnit currResult = box->placeEllipsisBox( |
1442 box->placeEllipsisBox(ltr, LayoutUnit(visibleLeftEdge), | 1442 ltr, LayoutUnit(visibleLeftEdge), LayoutUnit(visibleRightEdge), |
1443 LayoutUnit(visibleRightEdge), ellipsisWidth, | 1443 ellipsisWidth, truncatedWidth, foundBox); |
1444 truncatedWidth, foundBox) | |
1445 .toInt(); | |
1446 if (currResult != -1 && result == -1) | 1444 if (currResult != -1 && result == -1) |
1447 result = LayoutUnit(currResult); | 1445 result = currResult; |
1448 | 1446 |
1449 // List markers will sit outside the box so don't let them contribute | 1447 // List markers will sit outside the box so don't let them contribute |
1450 // width. | 1448 // width. |
1451 int boxWidth = box->getLineLayoutItem().isListMarker() | 1449 LayoutUnit boxWidth = box->getLineLayoutItem().isListMarker() |
1452 ? 0 | 1450 ? LayoutUnit() |
1453 : box->logicalWidth().round(); | 1451 : box->logicalWidth(); |
1454 if (ltr) { | 1452 if (ltr) { |
1455 visibleLeftEdge += boxWidth; | 1453 visibleLeftEdge += boxWidth; |
1456 box = box->nextOnLine(); | 1454 box = box->nextOnLine(); |
1457 } else { | 1455 } else { |
1458 visibleRightEdge -= boxWidth; | 1456 visibleRightEdge -= boxWidth; |
1459 box = box->prevOnLine(); | 1457 box = box->prevOnLine(); |
1460 } | 1458 } |
1461 } | 1459 } |
1462 return result; | 1460 return result; |
1463 } | 1461 } |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 ASSERT(child->prevOnLine() == prev); | 1687 ASSERT(child->prevOnLine() == prev); |
1690 prev = child; | 1688 prev = child; |
1691 } | 1689 } |
1692 ASSERT(prev == m_lastChild); | 1690 ASSERT(prev == m_lastChild); |
1693 #endif | 1691 #endif |
1694 } | 1692 } |
1695 | 1693 |
1696 #endif | 1694 #endif |
1697 | 1695 |
1698 } // namespace blink | 1696 } // namespace blink |
OLD | NEW |