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 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1528 // the replaced elements later. In partial layout mode, line boxes are n ot | 1528 // the replaced elements later. In partial layout mode, line boxes are n ot |
| 1529 // deleted and only dirtied. In that case, we can layout the replaced | 1529 // deleted and only dirtied. In that case, we can layout the replaced |
| 1530 // elements at the same time. | 1530 // elements at the same time. |
| 1531 Vector<LayoutBox*> replacedChildren; | 1531 Vector<LayoutBox*> replacedChildren; |
| 1532 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { | 1532 for (InlineWalker walker(this); !walker.atEnd(); walker.advance()) { |
| 1533 LayoutObject* o = walker.current(); | 1533 LayoutObject* o = walker.current(); |
| 1534 | 1534 |
| 1535 if (!layoutState.hasInlineChild() && o->isInline()) | 1535 if (!layoutState.hasInlineChild() && o->isInline()) |
| 1536 layoutState.setHasInlineChild(true); | 1536 layoutState.setHasInlineChild(true); |
| 1537 | 1537 |
| 1538 if (o->isBR() && o->style()->clear() != CNONE) | |
| 1539 layoutState.setContainsBRWithClear(true); | |
| 1540 | |
| 1541 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned() ) { | 1538 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned() ) { |
| 1542 LayoutBox* box = toLayoutBox(o); | 1539 LayoutBox* box = toLayoutBox(o); |
| 1543 | 1540 |
| 1544 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *box); | 1541 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *box); |
| 1545 | 1542 |
| 1546 if (o->isOutOfFlowPositioned()) { | 1543 if (o->isOutOfFlowPositioned()) { |
| 1547 o->containingBlock()->insertPositionedObject(box); | 1544 o->containingBlock()->insertPositionedObject(box); |
| 1548 } else if (o->isFloating()) { | 1545 } else if (o->isFloating()) { |
| 1549 layoutState.floats().append(FloatWithRect(box)); | 1546 layoutState.floats().append(FloatWithRect(box)); |
| 1550 } else if (isFullLayout || o->needsLayout()) { | 1547 } else if (isFullLayout || o->needsLayout()) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1648 layoutState.markForFullLayout(); | 1645 layoutState.markForFullLayout(); |
| 1649 break; | 1646 break; |
| 1650 } | 1647 } |
| 1651 | 1648 |
| 1652 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta); | 1649 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta); |
| 1653 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); | 1650 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); |
| 1654 } | 1651 } |
| 1655 } | 1652 } |
| 1656 | 1653 |
| 1657 // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without diff iculty. | 1654 // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without diff iculty. |
| 1658 if (!firstLineBoxWithBreakAndClearance && curr->endsWithBreak()) { | 1655 if (!firstLineBoxWithBreakAndClearance && lineBoxHasBRWithClearance( curr)) |
| 1659 InlineBox* lastBox = style()->isLeftToRightDirection() ? curr->l astLeafChild() : curr->firstLeafChild(); | 1656 firstLineBoxWithBreakAndClearance = curr; |
| 1660 if (lastBox && lastBox->layoutObject().isBR() && lastBox->layout Object().style()->clear() != CNONE) | |
| 1661 firstLineBoxWithBreakAndClearance = curr; | |
| 1662 } | |
| 1663 | 1657 |
| 1664 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. | 1658 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. |
| 1665 bool encounteredNewFloat = false; | 1659 bool encounteredNewFloat = false; |
| 1666 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); | 1660 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); |
| 1667 if (encounteredNewFloat) | 1661 if (encounteredNewFloat) |
| 1668 layoutState.markForFullLayout(); | 1662 layoutState.markForFullLayout(); |
| 1669 | 1663 |
| 1670 if (dirtiedByFloat || layoutState.isFullLayout()) | 1664 if (dirtiedByFloat || layoutState.isFullLayout()) |
| 1671 break; | 1665 break; |
| 1672 } | 1666 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1744 TextDirection direction = style()->direction(); | 1738 TextDirection direction = style()->direction(); |
| 1745 if (style()->unicodeBidi() == Plaintext) | 1739 if (style()->unicodeBidi() == Plaintext) |
| 1746 direction = determinePlaintextDirectionality(this); | 1740 direction = determinePlaintextDirectionality(this); |
| 1747 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); | 1741 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi ()))); |
| 1748 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, resolver.runs(), &resolver), 0); | 1742 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines (this, resolver.runs(), &resolver), 0); |
| 1749 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 1743 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
| 1750 } | 1744 } |
| 1751 return curr; | 1745 return curr; |
| 1752 } | 1746 } |
| 1753 | 1747 |
| 1748 | |
| 1749 bool LayoutBlockFlow::lineBoxHasBRWithClearance(RootInlineBox* curr) | |
| 1750 { | |
| 1751 // If the linebox breaks cleanly and with clearance then dirty from at least this point onwards so that we can clear the correct floats without difficulty. | |
| 1752 if (!curr->endsWithBreak()) | |
| 1753 return false; | |
| 1754 InlineBox* lastBox = style()->isLeftToRightDirection() ? curr->lastLeafChild () : curr->firstLeafChild(); | |
|
leviw_travelin_and_unemployed
2015/06/22 18:22:42
I understand you're moving this code around. If we
rhogan
2015/06/22 20:27:15
Had to look it up: lineBreakObj() is the object *a
| |
| 1755 return lastBox && lastBox->layoutObject().isBR() && lastBox->layoutObject(). style()->clear() != CNONE; | |
| 1756 } | |
| 1757 | |
| 1754 void LayoutBlockFlow::determineEndPosition(LineLayoutState& layoutState, RootInl ineBox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStat us) | 1758 void LayoutBlockFlow::determineEndPosition(LineLayoutState& layoutState, RootInl ineBox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStat us) |
| 1755 { | 1759 { |
| 1756 ASSERT(!layoutState.endLine()); | 1760 ASSERT(!layoutState.endLine()); |
| 1757 size_t floatIndex = layoutState.floatIndex(); | 1761 size_t floatIndex = layoutState.floatIndex(); |
| 1758 RootInlineBox* last = nullptr; | 1762 RootInlineBox* last = nullptr; |
| 1759 for (RootInlineBox* curr = startLine->nextRootBox(); curr; curr = curr->next RootBox()) { | 1763 for (RootInlineBox* curr = startLine->nextRootBox(); curr; curr = curr->next RootBox()) { |
| 1760 if (!curr->isDirty()) { | 1764 if (!curr->isDirty()) { |
| 1761 bool encounteredNewFloat = false; | 1765 bool encounteredNewFloat = false; |
| 1762 bool dirtiedByFloat = false; | 1766 bool dirtiedByFloat = false; |
| 1763 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); | 1767 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); |
| 1764 if (encounteredNewFloat) | 1768 if (encounteredNewFloat) |
| 1765 return; | 1769 return; |
| 1770 if (lineBoxHasBRWithClearance(curr)) | |
| 1771 return; | |
| 1766 } | 1772 } |
| 1767 if (curr->isDirty()) | 1773 if (curr->isDirty()) |
| 1768 last = nullptr; | 1774 last = nullptr; |
| 1769 else if (!last) | 1775 else if (!last) |
| 1770 last = curr; | 1776 last = curr; |
| 1771 } | 1777 } |
| 1772 | 1778 |
| 1773 if (!last) | 1779 if (!last) |
| 1774 return; | 1780 return; |
| 1775 | 1781 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1830 | 1836 |
| 1831 return true; | 1837 return true; |
| 1832 } | 1838 } |
| 1833 | 1839 |
| 1834 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) | 1840 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) |
| 1835 { | 1841 { |
| 1836 if (resolver.position() == endLineStart) { | 1842 if (resolver.position() == endLineStart) { |
| 1837 if (resolver.status() != endLineStatus) | 1843 if (resolver.status() != endLineStatus) |
| 1838 return false; | 1844 return false; |
| 1839 | 1845 |
| 1840 // A trailing BR can be collapsed as it usually doesn't contribute to th e height, | |
| 1841 // but if it has a clear style we need to force it to layout in the cont ext of floats | |
| 1842 // to honor that style. | |
| 1843 if (layoutState.containsBRWithClear() && containsFloats()) | |
| 1844 return false; | |
| 1845 return checkPaginationAndFloatsAtEndLine(layoutState); | 1846 return checkPaginationAndFloatsAtEndLine(layoutState); |
| 1846 } | 1847 } |
| 1847 | 1848 |
| 1848 // The first clean line doesn't match, but we can check a handful of followi ng lines to try | 1849 // The first clean line doesn't match, but we can check a handful of followi ng lines to try |
| 1849 // to match back up. | 1850 // to match back up. |
| 1850 static int numLines = 8; // The # of lines we're willing to match against. | 1851 static int numLines = 8; // The # of lines we're willing to match against. |
| 1851 RootInlineBox* originalEndLine = layoutState.endLine(); | 1852 RootInlineBox* originalEndLine = layoutState.endLine(); |
| 1852 RootInlineBox* line = originalEndLine; | 1853 RootInlineBox* line = originalEndLine; |
| 1853 for (int i = 0; i < numLines && line; i++, line = line->nextRootBox()) { | 1854 for (int i = 0; i < numLines && line; i++, line = line->nextRootBox()) { |
| 1854 if (line->lineBreakObj() == resolver.position().object() && line->lineBr eakPos() == resolver.position().offset()) { | 1855 if (line->lineBreakObj() == resolver.position().object() && line->lineBr eakPos() == resolver.position().offset()) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2060 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2061 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
| 2061 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; | 2062 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight() , false) - logicalLeft; |
| 2062 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2063 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
| 2063 | 2064 |
| 2064 if (!style()->isLeftToRightDirection()) | 2065 if (!style()->isLeftToRightDirection()) |
| 2065 return logicalWidth() - logicalLeft; | 2066 return logicalWidth() - logicalLeft; |
| 2066 return logicalLeft; | 2067 return logicalLeft; |
| 2067 } | 2068 } |
| 2068 | 2069 |
| 2069 } | 2070 } |
| OLD | NEW |