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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 BidiStatus cleanLineBidiStatus; | 749 BidiStatus cleanLineBidiStatus; |
| 750 if (!layoutState.isFullLayout() && startLine) | 750 if (!layoutState.isFullLayout() && startLine) |
| 751 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); | 751 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); |
| 752 | 752 |
| 753 if (startLine) { | 753 if (startLine) { |
| 754 if (!layoutState.usesPaintInvalidationBounds()) | 754 if (!layoutState.usesPaintInvalidationBounds()) |
| 755 layoutState.setPaintInvalidationRange(logicalHeight()); | 755 layoutState.setPaintInvalidationRange(logicalHeight()); |
| 756 deleteLineRange(layoutState, startLine); | 756 deleteLineRange(layoutState, startLine); |
| 757 } | 757 } |
| 758 | 758 |
| 759 if (!layoutState.isFullLayout() && lastRootBox() && lastRootBox()->endsWithB reak()) { | |
| 760 // If the last line before the start line ends with a line break that cl ear floats, | |
| 761 // adjust the height accordingly. | |
| 762 // A line break can be either the first or the last object on a line, de pending on its direction. | |
| 763 if (InlineBox* lastLeafChild = lastRootBox()->lastLeafChild()) { | |
| 764 LayoutObject* lastObject = &lastLeafChild->layoutObject(); | |
| 765 if (!lastObject->isBR()) | |
| 766 lastObject = &lastRootBox()->firstLeafChild()->layoutObject(); | |
| 767 if (lastObject->isBR()) { | |
| 768 EClear clear = lastObject->style()->clear(); | |
| 769 if (clear != CNONE) | |
| 770 clearFloats(clear); | |
| 771 } | |
| 772 } | |
| 773 } | |
| 774 | |
| 775 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); | 759 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); |
| 776 linkToEndLineIfNeeded(layoutState); | 760 linkToEndLineIfNeeded(layoutState); |
| 777 markDirtyFloatsForPaintInvalidation(layoutState.floats()); | 761 markDirtyFloatsForPaintInvalidation(layoutState.floats()); |
| 778 } | 762 } |
| 779 | 763 |
| 780 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. | 764 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. |
| 781 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) | 765 inline const InlineIterator& LayoutBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) |
| 782 { | 766 { |
| 783 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); | 767 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); |
| 784 setLogicalHeight(newLogicalHeight); | 768 setLogicalHeight(newLogicalHeight); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 } | 874 } |
| 891 } | 875 } |
| 892 } | 876 } |
| 893 } | 877 } |
| 894 } | 878 } |
| 895 | 879 |
| 896 if (!logicalWidthIsAvailable) { | 880 if (!logicalWidthIsAvailable) { |
| 897 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) | 881 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) |
| 898 setStaticPositions(this, lineBreaker.positionedObjects()[i]); | 882 setStaticPositions(this, lineBreaker.positionedObjects()[i]); |
| 899 | 883 |
| 900 if (!layoutState.lineInfo().isEmpty()) { | 884 if (!layoutState.lineInfo().isEmpty()) |
| 901 layoutState.lineInfo().setFirstLine(false); | 885 layoutState.lineInfo().setFirstLine(false); |
| 902 clearFloats(lineBreaker.clear()); | 886 clearFloats(lineBreaker.clear()); |
| 903 } | |
| 904 | 887 |
| 905 if (m_floatingObjects && lastRootBox()) { | 888 if (m_floatingObjects && lastRootBox()) { |
| 906 const FloatingObjectSet& floatingObjectSet = m_floatingObjects-> set(); | 889 const FloatingObjectSet& floatingObjectSet = m_floatingObjects-> set(); |
| 907 FloatingObjectSetIterator it = floatingObjectSet.begin(); | 890 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
| 908 FloatingObjectSetIterator end = floatingObjectSet.end(); | 891 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 909 if (layoutState.lastFloat()) { | 892 if (layoutState.lastFloat()) { |
| 910 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat()); | 893 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat()); |
| 911 ASSERT(lastFloatIterator != end); | 894 ASSERT(lastFloatIterator != end); |
| 912 ++lastFloatIterator; | 895 ++lastFloatIterator; |
| 913 it = lastFloatIterator; | 896 it = lastFloatIterator; |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1629 dirtiedByFloat = true; | 1612 dirtiedByFloat = true; |
| 1630 } | 1613 } |
| 1631 floatIndex++; | 1614 floatIndex++; |
| 1632 } | 1615 } |
| 1633 } | 1616 } |
| 1634 | 1617 |
| 1635 RootInlineBox* LayoutBlockFlow::determineStartPosition(LineLayoutState& layoutSt ate, InlineBidiResolver& resolver) | 1618 RootInlineBox* LayoutBlockFlow::determineStartPosition(LineLayoutState& layoutSt ate, InlineBidiResolver& resolver) |
| 1636 { | 1619 { |
| 1637 RootInlineBox* curr = 0; | 1620 RootInlineBox* curr = 0; |
| 1638 RootInlineBox* last = 0; | 1621 RootInlineBox* last = 0; |
| 1622 RootInlineBox* lineBoxWithBreakAndClearance = 0; | |
|
leviw_travelin_and_unemployed
2015/06/08 20:12:35
Maybe firstLineBoxWithBreakAndClearance?
| |
| 1639 | 1623 |
| 1640 // FIXME: This entire float-checking block needs to be broken into a new fun ction. | 1624 // FIXME: This entire float-checking block needs to be broken into a new fun ction. |
| 1641 bool dirtiedByFloat = false; | 1625 bool dirtiedByFloat = false; |
| 1642 if (!layoutState.isFullLayout()) { | 1626 if (!layoutState.isFullLayout()) { |
| 1643 // Paginate all of the clean lines. | 1627 // Paginate all of the clean lines. |
| 1644 bool paginated = view()->layoutState() && view()->layoutState()->isPagin ated(); | 1628 bool paginated = view()->layoutState() && view()->layoutState()->isPagin ated(); |
| 1645 LayoutUnit paginationDelta = 0; | 1629 LayoutUnit paginationDelta = 0; |
| 1646 size_t floatIndex = 0; | 1630 size_t floatIndex = 0; |
| 1647 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR ootBox()) { | 1631 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR ootBox()) { |
| 1648 if (paginated) { | 1632 if (paginated) { |
| 1649 paginationDelta -= curr->paginationStrut(); | 1633 paginationDelta -= curr->paginationStrut(); |
| 1650 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt ate.flowThread()); | 1634 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt ate.flowThread()); |
| 1651 if (paginationDelta) { | 1635 if (paginationDelta) { |
| 1652 if (containsFloats() || !layoutState.floats().isEmpty()) { | 1636 if (containsFloats() || !layoutState.floats().isEmpty()) { |
| 1653 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout. | 1637 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout. |
| 1654 layoutState.markForFullLayout(); | 1638 layoutState.markForFullLayout(); |
| 1655 break; | 1639 break; |
| 1656 } | 1640 } |
| 1657 | 1641 |
| 1658 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta); | 1642 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta); |
| 1659 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); | 1643 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); |
| 1660 } | 1644 } |
| 1661 } | 1645 } |
| 1662 | 1646 |
| 1647 // 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. | |
| 1648 if (!lineBoxWithBreakAndClearance && curr->endsWithBreak()) { | |
| 1649 if (InlineBox* lastLeafChild = curr->lastLeafChild()) { | |
| 1650 LayoutObject* lastObject = style()->isLeftToRightDirection() ? &lastLeafChild->layoutObject() : &curr->firstLeafChild()->layoutObject(); | |
|
leviw_travelin_and_unemployed
2015/06/08 20:12:35
You shouldn't always traverse the first and last l
| |
| 1651 if (lastObject->isBR() && lastObject->style()->clear() != CN ONE) | |
|
leviw_travelin_and_unemployed
2015/06/02 22:10:44
This seems similar to what https://blink.lc/blink/
| |
| 1652 lineBoxWithBreakAndClearance = curr; | |
| 1653 } | |
| 1654 } | |
| 1655 | |
| 1663 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. | 1656 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. |
| 1664 bool encounteredNewFloat = false; | 1657 bool encounteredNewFloat = false; |
| 1665 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); | 1658 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); |
| 1666 if (encounteredNewFloat) | 1659 if (encounteredNewFloat) |
| 1667 layoutState.markForFullLayout(); | 1660 layoutState.markForFullLayout(); |
| 1668 | 1661 |
| 1669 if (dirtiedByFloat || layoutState.isFullLayout()) | 1662 if (dirtiedByFloat || layoutState.isFullLayout()) |
| 1670 break; | 1663 break; |
| 1671 } | 1664 } |
| 1672 // Check if a new float has been inserted after the last known float. | 1665 // Check if a new float has been inserted after the last known float. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1685 // crashes for fast/repaint tests. | 1678 // crashes for fast/repaint tests. |
| 1686 curr = firstRootBox(); | 1679 curr = firstRootBox(); |
| 1687 while (curr) { | 1680 while (curr) { |
| 1688 // Note: This uses nextRootBox() insted of nextLineBox() like delete LineBoxTree does. | 1681 // Note: This uses nextRootBox() insted of nextLineBox() like delete LineBoxTree does. |
| 1689 RootInlineBox* next = curr->nextRootBox(); | 1682 RootInlineBox* next = curr->nextRootBox(); |
| 1690 curr->deleteLine(); | 1683 curr->deleteLine(); |
| 1691 curr = next; | 1684 curr = next; |
| 1692 } | 1685 } |
| 1693 ASSERT(!firstLineBox() && !lastLineBox()); | 1686 ASSERT(!firstLineBox() && !lastLineBox()); |
| 1694 } else { | 1687 } else { |
| 1688 if (lineBoxWithBreakAndClearance) | |
| 1689 curr = lineBoxWithBreakAndClearance; | |
| 1695 if (curr) { | 1690 if (curr) { |
| 1696 // We have a dirty line. | 1691 // We have a dirty line. |
| 1697 if (RootInlineBox* prevRootBox = curr->prevRootBox()) { | 1692 if (RootInlineBox* prevRootBox = curr->prevRootBox()) { |
| 1698 // We have a previous line. | 1693 // We have a previous line. |
| 1699 if (!dirtiedByFloat && (!prevRootBox->endsWithBreak() || !prevRo otBox->lineBreakObj() || (prevRootBox->lineBreakObj()->isText() && prevRootBox-> lineBreakPos() >= toLayoutText(prevRootBox->lineBreakObj())->textLength()))) { | 1694 if (!dirtiedByFloat && (!prevRootBox->endsWithBreak() || !prevRo otBox->lineBreakObj() || (prevRootBox->lineBreakObj()->isText() && prevRootBox-> lineBreakPos() >= toLayoutText(prevRootBox->lineBreakObj())->textLength()))) { |
| 1700 // The previous line didn't break cleanly or broke at a newl ine | 1695 // The previous line didn't break cleanly or broke at a newl ine |
| 1701 // that has been deleted, so treat it as dirty too. | 1696 // that has been deleted, so treat it as dirty too. |
| 1702 curr = prevRootBox; | 1697 curr = prevRootBox; |
| 1703 } | 1698 } |
| 1704 } | 1699 } |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2033 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); | 2028 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); |
| 2034 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 2029 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; |
| 2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2030 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
| 2036 | 2031 |
| 2037 if (!style()->isLeftToRightDirection()) | 2032 if (!style()->isLeftToRightDirection()) |
| 2038 return logicalWidth() - logicalLeft; | 2033 return logicalWidth() - logicalLeft; |
| 2039 return logicalLeft; | 2034 return logicalLeft; |
| 2040 } | 2035 } |
| 2041 | 2036 |
| 2042 } | 2037 } |
| OLD | NEW |