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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 | 1543 |
1544 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned()
) { | 1544 if (o->isReplaced() || o->isFloating() || o->isOutOfFlowPositioned()
) { |
1545 LayoutBox* box = toLayoutBox(o); | 1545 LayoutBox* box = toLayoutBox(o); |
1546 | 1546 |
1547 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *box); | 1547 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *box); |
1548 | 1548 |
1549 if (o->isOutOfFlowPositioned()) { | 1549 if (o->isOutOfFlowPositioned()) { |
1550 o->containingBlock()->insertPositionedObject(box); | 1550 o->containingBlock()->insertPositionedObject(box); |
1551 } else if (o->isFloating()) { | 1551 } else if (o->isFloating()) { |
1552 layoutState.floats().append(FloatWithRect(box)); | 1552 layoutState.floats().append(FloatWithRect(box)); |
| 1553 if (box->needsLayout()) { |
| 1554 box->layout(); |
| 1555 dirtyLinesFromChangedChild(o); |
| 1556 } |
1553 } else if (isFullLayout || o->needsLayout()) { | 1557 } else if (isFullLayout || o->needsLayout()) { |
1554 // Replaced element. | 1558 // Replaced element. |
1555 box->dirtyLineBoxes(isFullLayout); | 1559 box->dirtyLineBoxes(isFullLayout); |
1556 if (isFullLayout) | 1560 if (isFullLayout) |
1557 replacedChildren.append(box); | 1561 replacedChildren.append(box); |
1558 else | 1562 else |
1559 o->layoutIfNeeded(); | 1563 o->layoutIfNeeded(); |
1560 } | 1564 } |
1561 } else if (o->isText() || (o->isLayoutInline() && !walker.atEndOfInl
ine())) { | 1565 } else if (o->isText() || (o->isLayoutInline() && !walker.atEndOfInl
ine())) { |
1562 if (!o->isText()) | 1566 if (!o->isText()) |
(...skipping 29 matching lines...) Expand all Loading... |
1592 // See if we have any lines that spill out of our block. If we do, then we
will possibly need to | 1596 // See if we have any lines that spill out of our block. If we do, then we
will possibly need to |
1593 // truncate text. | 1597 // truncate text. |
1594 if (hasTextOverflow) | 1598 if (hasTextOverflow) |
1595 checkLinesForTextOverflow(); | 1599 checkLinesForTextOverflow(); |
1596 | 1600 |
1597 // Ensure the new line boxes will be painted. | 1601 // Ensure the new line boxes will be painted. |
1598 if (isFullLayout && firstLineBox()) | 1602 if (isFullLayout && firstLineBox()) |
1599 setShouldDoFullPaintInvalidation(); | 1603 setShouldDoFullPaintInvalidation(); |
1600 } | 1604 } |
1601 | 1605 |
1602 void LayoutBlockFlow::checkFloatsInCleanLine(RootInlineBox* line, Vector<FloatWi
thRect>& floats, size_t& floatIndex, bool& encounteredNewFloat, bool& dirtiedByF
loat) | |
1603 { | |
1604 Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr(); | |
1605 if (!cleanLineFloats) | |
1606 return; | |
1607 | |
1608 for (auto* floatingBox : *cleanLineFloats) { | |
1609 floatingBox->layoutIfNeeded(); | |
1610 LayoutSize newSize = floatingBox->size() + | |
1611 LayoutSize(floatingBox->marginWidth(), floatingBox->marginHeight()); | |
1612 if (floats[floatIndex].object != floatingBox) { | |
1613 encounteredNewFloat = true; | |
1614 return; | |
1615 } | |
1616 | |
1617 if (floats[floatIndex].rect.size() != newSize) { | |
1618 LayoutUnit floatTop = isHorizontalWritingMode() ? floats[floatIndex]
.rect.y() : floats[floatIndex].rect.x(); | |
1619 LayoutUnit floatHeight = isHorizontalWritingMode() ? std::max(floats
[floatIndex].rect.height(), newSize.height()) | |
1620 : std::max(floats[floatIndex].rect.width(), newSize.width()); | |
1621 floatHeight = std::min(floatHeight, LayoutUnit::max() - floatTop); | |
1622 line->markDirty(); | |
1623 markLinesDirtyInBlockRange(line->lineBottomWithLeading(), floatTop +
floatHeight, line); | |
1624 floats[floatIndex].rect.setSize(newSize); | |
1625 dirtiedByFloat = true; | |
1626 } | |
1627 floatIndex++; | |
1628 } | |
1629 } | |
1630 | |
1631 RootInlineBox* LayoutBlockFlow::determineStartPosition(LineLayoutState& layoutSt
ate, InlineBidiResolver& resolver) | 1606 RootInlineBox* LayoutBlockFlow::determineStartPosition(LineLayoutState& layoutSt
ate, InlineBidiResolver& resolver) |
1632 { | 1607 { |
1633 RootInlineBox* curr = 0; | 1608 RootInlineBox* curr = 0; |
1634 RootInlineBox* last = 0; | 1609 RootInlineBox* last = 0; |
1635 | 1610 |
1636 // FIXME: This entire float-checking block needs to be broken into a new fun
ction. | 1611 // FIXME: This entire float-checking block needs to be broken into a new fun
ction. |
1637 bool dirtiedByFloat = false; | 1612 bool dirtiedByFloat = false; |
1638 if (!layoutState.isFullLayout()) { | 1613 if (!layoutState.isFullLayout()) { |
1639 // Paginate all of the clean lines. | 1614 // Paginate all of the clean lines. |
1640 bool paginated = view()->layoutState() && view()->layoutState()->isPagin
ated(); | 1615 bool paginated = view()->layoutState() && view()->layoutState()->isPagin
ated(); |
1641 LayoutUnit paginationDelta = 0; | 1616 LayoutUnit paginationDelta = 0; |
1642 size_t floatIndex = 0; | |
1643 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR
ootBox()) { | 1617 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR
ootBox()) { |
1644 if (paginated) { | 1618 if (paginated) { |
1645 paginationDelta -= curr->paginationStrut(); | 1619 paginationDelta -= curr->paginationStrut(); |
1646 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt
ate.flowThread()); | 1620 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt
ate.flowThread()); |
1647 if (paginationDelta) { | 1621 if (paginationDelta) { |
1648 if (containsFloats() || !layoutState.floats().isEmpty()) { | 1622 if (containsFloats() || !layoutState.floats().isEmpty()) { |
1649 // FIXME: Do better eventually. For now if we ever shif
t because of pagination and floats are present just go to a full layout. | 1623 // FIXME: Do better eventually. For now if we ever shif
t because of pagination and floats are present just go to a full layout. |
1650 layoutState.markForFullLayout(); | 1624 layoutState.markForFullLayout(); |
1651 break; | 1625 break; |
1652 } | 1626 } |
1653 | 1627 |
1654 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina
tionDelta); | 1628 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina
tionDelta); |
1655 curr->adjustBlockDirectionPosition(paginationDelta.toFloat()
); | 1629 curr->adjustBlockDirectionPosition(paginationDelta.toFloat()
); |
1656 } | 1630 } |
1657 } | 1631 } |
1658 | 1632 |
1659 // If a new float has been inserted before this line or before its l
ast known float, just do a full layout. | |
1660 bool encounteredNewFloat = false; | |
1661 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou
nteredNewFloat, dirtiedByFloat); | |
1662 if (encounteredNewFloat) | |
1663 layoutState.markForFullLayout(); | |
1664 | |
1665 if (dirtiedByFloat || layoutState.isFullLayout()) | 1633 if (dirtiedByFloat || layoutState.isFullLayout()) |
1666 break; | 1634 break; |
1667 } | 1635 } |
1668 // Check if a new float has been inserted after the last known float. | |
1669 if (!curr && floatIndex < layoutState.floats().size()) | |
1670 layoutState.markForFullLayout(); | |
1671 } | 1636 } |
1672 | 1637 |
1673 if (layoutState.isFullLayout()) { | 1638 if (layoutState.isFullLayout()) { |
1674 // If we encountered a new float and have inline children, mark ourself
to force us to issue paint invalidations. | 1639 // If we encountered a new float and have inline children, mark ourself
to force us to issue paint invalidations. |
1675 if (layoutState.hasInlineChild() && !selfNeedsLayout()) { | 1640 if (layoutState.hasInlineChild() && !selfNeedsLayout()) { |
1676 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Flo
atDescendantChanged, MarkOnlyThis); | 1641 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::Flo
atDescendantChanged, MarkOnlyThis); |
1677 setShouldDoFullPaintInvalidation(); | 1642 setShouldDoFullPaintInvalidation(); |
1678 } | 1643 } |
1679 | 1644 |
1680 deleteLineBoxTree(); | 1645 deleteLineBoxTree(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi
()))); | 1705 resolver.setStatus(BidiStatus(direction, isOverride(style()->unicodeBidi
()))); |
1741 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines
(this, resolver.runs(), &resolver), 0); | 1706 InlineIterator iter = InlineIterator(this, bidiFirstSkippingEmptyInlines
(this, resolver.runs(), &resolver), 0); |
1742 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 1707 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
1743 } | 1708 } |
1744 return curr; | 1709 return curr; |
1745 } | 1710 } |
1746 | 1711 |
1747 void LayoutBlockFlow::determineEndPosition(LineLayoutState& layoutState, RootInl
ineBox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStat
us) | 1712 void LayoutBlockFlow::determineEndPosition(LineLayoutState& layoutState, RootInl
ineBox* startLine, InlineIterator& cleanLineStart, BidiStatus& cleanLineBidiStat
us) |
1748 { | 1713 { |
1749 ASSERT(!layoutState.endLine()); | 1714 ASSERT(!layoutState.endLine()); |
1750 size_t floatIndex = layoutState.floatIndex(); | |
1751 RootInlineBox* last = 0; | 1715 RootInlineBox* last = 0; |
1752 for (RootInlineBox* curr = startLine->nextRootBox(); curr; curr = curr->next
RootBox()) { | 1716 for (RootInlineBox* curr = startLine->nextRootBox(); curr; curr = curr->next
RootBox()) { |
1753 if (!curr->isDirty()) { | |
1754 bool encounteredNewFloat = false; | |
1755 bool dirtiedByFloat = false; | |
1756 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou
nteredNewFloat, dirtiedByFloat); | |
1757 if (encounteredNewFloat) | |
1758 return; | |
1759 } | |
1760 if (curr->isDirty()) | 1717 if (curr->isDirty()) |
1761 last = 0; | 1718 last = 0; |
1762 else if (!last) | 1719 else if (!last) |
1763 last = curr; | 1720 last = curr; |
1764 } | 1721 } |
1765 | 1722 |
1766 if (!last) | 1723 if (!last) |
1767 return; | 1724 return; |
1768 | 1725 |
1769 // At this point, |last| is the first line in a run of clean lines that ends
with the last line | 1726 // At this point, |last| is the first line in a run of clean lines that ends
with the last line |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 1985 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
2029 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 1986 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
2030 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 1987 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2031 | 1988 |
2032 if (!style()->isLeftToRightDirection()) | 1989 if (!style()->isLeftToRightDirection()) |
2033 return logicalWidth() - logicalLeft; | 1990 return logicalWidth() - logicalLeft; |
2034 return logicalLeft; | 1991 return logicalLeft; |
2035 } | 1992 } |
2036 | 1993 |
2037 } | 1994 } |
OLD | NEW |