Chromium Code Reviews| 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 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1483 oldAutoWrap = autoWrap; | 1483 oldAutoWrap = autoWrap; |
| 1484 } | 1484 } |
| 1485 | 1485 |
| 1486 if (styleToUse.collapseWhiteSpace()) | 1486 if (styleToUse.collapseWhiteSpace()) |
| 1487 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); | 1487 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); |
| 1488 | 1488 |
| 1489 minLogicalWidth = std::max(minLogicalWidth, inlineMin); | 1489 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
| 1490 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); | 1490 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); |
| 1491 } | 1491 } |
| 1492 | 1492 |
| 1493 static bool isInlineWithOutlineAndContinuation(const LayoutObject& o) | |
| 1494 { | |
| 1495 return o.isLayoutInline() && o.styleRef().hasOutline() && !o.isElementContin uation() && toLayoutInline(o).continuation(); | |
| 1496 } | |
| 1497 | |
| 1493 void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa intInvalidationLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUni t afterEdge) | 1498 void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa intInvalidationLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUni t afterEdge) |
| 1494 { | 1499 { |
| 1495 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 1500 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
| 1496 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread-> hasColumnSets(); | 1501 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread-> hasColumnSets(); |
| 1497 | 1502 |
| 1498 // Figure out if we should clear out our line boxes. | 1503 // Figure out if we should clear out our line boxes. |
| 1499 // FIXME: Handle resize eventually! | 1504 // FIXME: Handle resize eventually! |
| 1500 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination; | 1505 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination; |
| 1501 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint InvalidationLogicalBottom, flowThread); | 1506 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint InvalidationLogicalBottom, flowThread); |
| 1502 | 1507 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1516 // difficult to figure out in general (especially in the middle of doing lay out), so we only handle the | 1521 // difficult to figure out in general (especially in the middle of doing lay out), so we only handle the |
| 1517 // simple case of an anonymous block truncating when it's parent is clipped. | 1522 // simple case of an anonymous block truncating when it's parent is clipped. |
| 1518 bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip()) | 1523 bool hasTextOverflow = (style()->textOverflow() && hasOverflowClip()) |
| 1519 || (isAnonymousBlock() && parent() && parent()->isLayoutBlock() && toLay outBlock(parent())->canCollapseAnonymousBlockChild() | 1524 || (isAnonymousBlock() && parent() && parent()->isLayoutBlock() && toLay outBlock(parent())->canCollapseAnonymousBlockChild() |
| 1520 && parent()->style()->textOverflow() && parent()->hasOverflowClip()) ; | 1525 && parent()->style()->textOverflow() && parent()->hasOverflowClip()) ; |
| 1521 | 1526 |
| 1522 // Walk all the lines and delete our ellipsis line boxes if they exist. | 1527 // Walk all the lines and delete our ellipsis line boxes if they exist. |
| 1523 if (hasTextOverflow) | 1528 if (hasTextOverflow) |
| 1524 deleteEllipsisLineBoxes(); | 1529 deleteEllipsisLineBoxes(); |
| 1525 | 1530 |
| 1531 setContainsInlineWithOutlineAndContinuation(false); | |
|
chrishtr
2015/08/27 18:20:59
If the DOM changes to remove all inline children,
Xianzhu
2015/08/27 19:23:12
Nice catch. Done.
| |
| 1532 | |
| 1526 if (firstChild()) { | 1533 if (firstChild()) { |
| 1527 // In full layout mode, clear the line boxes of children upfront. Otherw ise, | 1534 // In full layout mode, clear the line boxes of children upfront. Otherw ise, |
| 1528 // siblings can run into stale root lineboxes during layout. Then layout | 1535 // siblings can run into stale root lineboxes during layout. Then layout |
| 1529 // the replaced elements later. In partial layout mode, line boxes are n ot | 1536 // the replaced elements later. In partial layout mode, line boxes are n ot |
| 1530 // deleted and only dirtied. In that case, we can layout the replaced | 1537 // deleted and only dirtied. In that case, we can layout the replaced |
| 1531 // elements at the same time. | 1538 // elements at the same time. |
| 1532 Vector<LayoutBox*> replacedChildren; | 1539 Vector<LayoutBox*> replacedChildren; |
| 1533 LayoutObject* lastChild = nullptr; | 1540 LayoutObject* lastChild = nullptr; |
| 1534 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | 1541 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
| 1535 LayoutObject* o = walker.current(); | 1542 LayoutObject* o = walker.current(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1560 } | 1567 } |
| 1561 } else if (o->isText() || (o->isLayoutInline() && !walker.atEndOfInl ine())) { | 1568 } else if (o->isText() || (o->isLayoutInline() && !walker.atEndOfInl ine())) { |
| 1562 if (!o->isText()) | 1569 if (!o->isText()) |
| 1563 toLayoutInline(o)->updateAlwaysCreateLineBoxes(layoutState.i sFullLayout()); | 1570 toLayoutInline(o)->updateAlwaysCreateLineBoxes(layoutState.i sFullLayout()); |
| 1564 if (layoutState.isFullLayout() || o->selfNeedsLayout()) | 1571 if (layoutState.isFullLayout() || o->selfNeedsLayout()) |
| 1565 dirtyLineBoxesForObject(o, layoutState.isFullLayout()); | 1572 dirtyLineBoxesForObject(o, layoutState.isFullLayout()); |
| 1566 o->clearNeedsLayout(); | 1573 o->clearNeedsLayout(); |
| 1567 } | 1574 } |
| 1568 if (!o->isText() || !toLayoutText(o)->isAllCollapsibleWhitespace()) | 1575 if (!o->isText() || !toLayoutText(o)->isAllCollapsibleWhitespace()) |
| 1569 lastChild = o; | 1576 lastChild = o; |
| 1577 | |
| 1578 if (!containsInlineWithOutlineAndContinuation() && isInlineWithOutli neAndContinuation(*o)) | |
|
chrishtr
2015/08/27 18:20:59
What's the point of checking for !containsInlineWi
Xianzhu
2015/08/27 19:23:12
Was to avoid the cost of isInlineWithOutlineAndCon
| |
| 1579 setContainsInlineWithOutlineAndContinuation(true); | |
| 1570 } | 1580 } |
| 1571 // If there is a trailing float on the line that will possibly occur aft er a natural line break | 1581 // If there is a trailing float on the line that will possibly occur aft er a natural line break |
| 1572 // then dirty its adjacent lineboxes to ensure it gets placed. | 1582 // then dirty its adjacent lineboxes to ensure it gets placed. |
| 1573 if (lastChild && lastChild->isFloating()) | 1583 if (lastChild && lastChild->isFloating()) |
| 1574 dirtyLinesFromChangedChild(lastChild); | 1584 dirtyLinesFromChangedChild(lastChild); |
| 1575 | 1585 |
| 1576 for (size_t i = 0; i < replacedChildren.size(); i++) | 1586 for (size_t i = 0; i < replacedChildren.size(); i++) |
| 1577 replacedChildren[i]->layoutIfNeeded(); | 1587 replacedChildren[i]->layoutIfNeeded(); |
| 1578 | 1588 |
| 1579 layoutRunsAndFloats(layoutState); | 1589 layoutRunsAndFloats(layoutState); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1852 } | 1862 } |
| 1853 | 1863 |
| 1854 void LayoutBlockFlow::addOverflowFromInlineChildren() | 1864 void LayoutBlockFlow::addOverflowFromInlineChildren() |
| 1855 { | 1865 { |
| 1856 LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : LayoutUnit(); | 1866 LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : LayoutUnit(); |
| 1857 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1867 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
| 1858 addLayoutOverflow(curr->paddedLayoutOverflowRect(endPadding)); | 1868 addLayoutOverflow(curr->paddedLayoutOverflowRect(endPadding)); |
| 1859 LayoutRect visualOverflow = curr->visualOverflowRect(curr->lineTop(), cu rr->lineBottom()); | 1869 LayoutRect visualOverflow = curr->visualOverflowRect(curr->lineTop(), cu rr->lineBottom()); |
| 1860 addContentsVisualOverflow(visualOverflow); | 1870 addContentsVisualOverflow(visualOverflow); |
| 1861 } | 1871 } |
| 1872 | |
| 1873 if (!containsInlineWithOutlineAndContinuation()) | |
| 1874 return; | |
| 1875 | |
| 1876 // Add outline rects of continuations of descendant inlines into visual over flow of this block. | |
| 1877 LayoutRect outlineBoundsOfAllContinuations; | |
| 1878 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | |
| 1879 const LayoutObject& o = *walker.current(); | |
| 1880 if (!isInlineWithOutlineAndContinuation(o)) | |
| 1881 continue; | |
| 1882 | |
| 1883 Vector<LayoutRect> outlineRects; | |
| 1884 toLayoutInline(o).addOutlineRectsForContinuations(outlineRects, LayoutPo int()); | |
| 1885 LayoutRect outlineBounds = unionRect(outlineRects); | |
| 1886 outlineBounds.inflate(o.styleRef().outlineOutsetExtent()); | |
| 1887 outlineBoundsOfAllContinuations.unite(outlineBounds); | |
| 1888 } | |
| 1889 addContentsVisualOverflow(outlineBoundsOfAllContinuations); | |
| 1862 } | 1890 } |
| 1863 | 1891 |
| 1864 void LayoutBlockFlow::deleteEllipsisLineBoxes() | 1892 void LayoutBlockFlow::deleteEllipsisLineBoxes() |
| 1865 { | 1893 { |
| 1866 ETextAlign textAlign = style()->textAlign(); | 1894 ETextAlign textAlign = style()->textAlign(); |
| 1867 bool firstLine = true; | 1895 bool firstLine = true; |
| 1868 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { | 1896 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) { |
| 1869 if (curr->hasEllipsisBox()) { | 1897 if (curr->hasEllipsisBox()) { |
| 1870 curr->clearTruncation(); | 1898 curr->clearTruncation(); |
| 1871 | 1899 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2018 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2046 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
| 2019 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; | 2047 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; |
| 2020 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2048 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
| 2021 | 2049 |
| 2022 if (!style()->isLeftToRightDirection()) | 2050 if (!style()->isLeftToRightDirection()) |
| 2023 return logicalWidth() - logicalLeft; | 2051 return logicalWidth() - logicalLeft; |
| 2024 return logicalLeft; | 2052 return logicalLeft; |
| 2025 } | 2053 } |
| 2026 | 2054 |
| 2027 } | 2055 } |
| OLD | NEW |