| 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 | 625 |
| 626 // Position is used to properly position both replaced elements and | 626 // Position is used to properly position both replaced elements and |
| 627 // to update the static normal flow x/y of positioned elements. | 627 // to update the static normal flow x/y of positioned elements. |
| 628 if (r->m_object->isText()) | 628 if (r->m_object->isText()) |
| 629 toRenderText(r->m_object)->positionLineBox(r->m_box); | 629 toRenderText(r->m_object)->positionLineBox(r->m_box); |
| 630 else if (r->m_object->isBox()) | 630 else if (r->m_object->isBox()) |
| 631 toRenderBox(r->m_object)->positionLineBox(r->m_box); | 631 toRenderBox(r->m_object)->positionLineBox(r->m_box); |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 | 634 |
| 635 void RenderBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj
ect) | |
| 636 { | |
| 637 ASSERT(!floatingObject->originatingLine()); | |
| 638 floatingObject->setOriginatingLine(lastRootBox()); | |
| 639 lastRootBox()->appendFloat(floatingObject->renderer()); | |
| 640 } | |
| 641 | |
| 642 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. | 635 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. |
| 643 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) | 636 RootInlineBox* RenderBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) |
| 644 { | 637 { |
| 645 if (!bidiRuns.runCount()) | 638 if (!bidiRuns.runCount()) |
| 646 return 0; | 639 return 0; |
| 647 | 640 |
| 648 // FIXME: Why is this only done when we had runs? | 641 // FIXME: Why is this only done when we had runs? |
| 649 lineInfo.setLastLine(!end.object()); | 642 lineInfo.setLastLine(!end.object()); |
| 650 | 643 |
| 651 RootInlineBox* lineBox = constructLine(bidiRuns, lineInfo); | 644 RootInlineBox* lineBox = constructLine(bidiRuns, lineInfo); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 681 boxToDelete = next; | 674 boxToDelete = next; |
| 682 } | 675 } |
| 683 } | 676 } |
| 684 | 677 |
| 685 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState) | 678 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState) |
| 686 { | 679 { |
| 687 // We want to skip ahead to the first dirty line | 680 // We want to skip ahead to the first dirty line |
| 688 InlineBidiResolver resolver; | 681 InlineBidiResolver resolver; |
| 689 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); | 682 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); |
| 690 | 683 |
| 691 if (containsFloats()) | |
| 692 layoutState.setLastFloat(m_floatingObjects->set().last().get()); | |
| 693 | |
| 694 // We also find the first clean line and extract these lines. We will add t
hem back | 684 // We also find the first clean line and extract these lines. We will add t
hem back |
| 695 // if we determine that we're able to synchronize after handling all our dir
ty lines. | 685 // if we determine that we're able to synchronize after handling all our dir
ty lines. |
| 696 InlineIterator cleanLineStart; | 686 InlineIterator cleanLineStart; |
| 697 BidiStatus cleanLineBidiStatus; | 687 BidiStatus cleanLineBidiStatus; |
| 698 if (!layoutState.isFullLayout() && startLine) | 688 if (!layoutState.isFullLayout() && startLine) |
| 699 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi
diStatus); | 689 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi
diStatus); |
| 700 | 690 |
| 701 if (startLine) { | 691 if (startLine) { |
| 702 if (!layoutState.usesPaintInvalidationBounds()) | 692 if (!layoutState.usesPaintInvalidationBounds()) |
| 703 layoutState.setPaintInvalidationRange(logicalHeight()); | 693 layoutState.setPaintInvalidationRange(logicalHeight()); |
| 704 deleteLineRange(layoutState, startLine); | 694 deleteLineRange(layoutState, startLine); |
| 705 } | 695 } |
| 706 | 696 |
| 707 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB
idiStatus); | 697 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB
idiStatus); |
| 708 linkToEndLineIfNeeded(layoutState); | 698 linkToEndLineIfNeeded(layoutState); |
| 709 markDirtyFloatsForPaintInvalidation(layoutState.floats()); | 699 markDirtyFloatsForPaintInvalidation(layoutState.floats()); |
| 710 } | 700 } |
| 711 | 701 |
| 712 // Before restarting the layout loop with a new logicalHeight, remove all floats
that were added and reset the resolver. | 702 // Before restarting the layout loop with a new logicalHeight, remove all floats
that were added and reset the resolver. |
| 713 inline const InlineIterator& RenderBlockFlow::restartLayoutRunsAndFloatsInRange(
LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF
loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn
d) | 703 inline const InlineIterator& RenderBlockFlow::restartLayoutRunsAndFloatsInRange(
LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF
loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn
d) |
| 714 { | 704 { |
| 715 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); | |
| 716 setLogicalHeight(newLogicalHeight); | 705 setLogicalHeight(newLogicalHeight); |
| 717 resolver.setPositionIgnoringNestedIsolates(oldEnd); | 706 resolver.setPositionIgnoringNestedIsolates(oldEnd); |
| 718 return oldEnd; | 707 return oldEnd; |
| 719 } | 708 } |
| 720 | 709 |
| 721 void RenderBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, | 710 void RenderBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, |
| 722 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, | 711 InlineBidiResolver& resolver, const InlineIterator& cleanLineStart, |
| 723 const BidiStatus& cleanLineBidiStatus) | 712 const BidiStatus& cleanLineBidiStatus) |
| 724 { | 713 { |
| 725 RenderStyle* styleToUse = style(); | 714 RenderStyle* styleToUse = style(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 740 break; | 729 break; |
| 741 } | 730 } |
| 742 } | 731 } |
| 743 | 732 |
| 744 lineMidpointState.reset(); | 733 lineMidpointState.reset(); |
| 745 | 734 |
| 746 layoutState.lineInfo().setEmpty(true); | 735 layoutState.lineInfo().setEmpty(true); |
| 747 layoutState.lineInfo().resetRunsFromLeadingWhitespace(); | 736 layoutState.lineInfo().resetRunsFromLeadingWhitespace(); |
| 748 | 737 |
| 749 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly
(); | 738 bool isNewUBAParagraph = layoutState.lineInfo().previousLineBrokeCleanly
(); |
| 750 FloatingObject* lastFloatFromPreviousLine = (containsFloats()) ? m_float
ingObjects->set().last().get() : 0; | 739 FloatingObject* lastFloatFromPreviousLine = 0; |
| 751 | 740 |
| 752 WordMeasurements wordMeasurements; | 741 WordMeasurements wordMeasurements; |
| 753 endOfLine = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(),
renderTextInfo, | 742 endOfLine = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(),
renderTextInfo, |
| 754 lastFloatFromPreviousLine, wordMeasurements); | 743 lastFloatFromPreviousLine, wordMeasurements); |
| 755 renderTextInfo.m_lineBreakIterator.resetPriorContext(); | 744 renderTextInfo.m_lineBreakIterator.resetPriorContext(); |
| 756 if (resolver.position().atEnd()) { | 745 if (resolver.position().atEnd()) { |
| 757 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi
n with! | 746 // FIXME: We shouldn't be creating any runs in nextLineBreak to begi
n with! |
| 758 // Once BidiRunList is separated from BidiResolver this will not be
needed. | 747 // Once BidiRunList is separated from BidiResolver this will not be
needed. |
| 759 resolver.runs().deleteRuns(); | 748 resolver.runs().deleteRuns(); |
| 760 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). | 749 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla
ced by an ASSERT (or just removed). |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 791 } |
| 803 | 792 |
| 804 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) | 793 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) |
| 805 setStaticPositions(this, lineBreaker.positionedObjects()[i]); | 794 setStaticPositions(this, lineBreaker.positionedObjects()[i]); |
| 806 | 795 |
| 807 if (!layoutState.lineInfo().isEmpty()) { | 796 if (!layoutState.lineInfo().isEmpty()) { |
| 808 layoutState.lineInfo().setFirstLine(false); | 797 layoutState.lineInfo().setFirstLine(false); |
| 809 clearFloats(lineBreaker.clear()); | 798 clearFloats(lineBreaker.clear()); |
| 810 } | 799 } |
| 811 | 800 |
| 812 if (m_floatingObjects && lastRootBox()) { | |
| 813 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(
); | |
| 814 FloatingObjectSetIterator it = floatingObjectSet.begin(); | |
| 815 FloatingObjectSetIterator end = floatingObjectSet.end(); | |
| 816 if (layoutState.lastFloat()) { | |
| 817 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.
find(layoutState.lastFloat()); | |
| 818 ASSERT(lastFloatIterator != end); | |
| 819 ++lastFloatIterator; | |
| 820 it = lastFloatIterator; | |
| 821 } | |
| 822 for (; it != end; ++it) { | |
| 823 FloatingObject* f = it->get(); | |
| 824 appendFloatingObjectToLastLine(f); | |
| 825 ASSERT(f->renderer() == layoutState.floats()[layoutState.floatIn
dex()].object); | |
| 826 // If a float's geometry has changed, give up on syncing with cl
ean lines. | |
| 827 if (layoutState.floats()[layoutState.floatIndex()].rect != f->fr
ameRect()) | |
| 828 checkForEndLineMatch = false; | |
| 829 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | |
| 830 } | |
| 831 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObje
ctSet.last().get() : 0); | |
| 832 } | |
| 833 | |
| 834 lineMidpointState.reset(); | 801 lineMidpointState.reset(); |
| 835 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 802 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
| 836 } | 803 } |
| 837 | 804 |
| 838 clearDidBreakAtLineToAvoidWidow(); | 805 clearDidBreakAtLineToAvoidWidow(); |
| 839 } | 806 } |
| 840 | 807 |
| 841 void RenderBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) | 808 void RenderBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) |
| 842 { | 809 { |
| 843 if (layoutState.endLine()) { | 810 if (layoutState.endLine()) { |
| 844 if (layoutState.endLineMatched()) { | 811 if (layoutState.endLineMatched()) { |
| 845 // Attach all the remaining lines, and then adjust their y-positions
as needed. | 812 // Attach all the remaining lines, and then adjust their y-positions
as needed. |
| 846 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop()
; | 813 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop()
; |
| 847 for (RootInlineBox* line = layoutState.endLine(); line; line = line-
>nextRootBox()) { | 814 for (RootInlineBox* line = layoutState.endLine(); line; line = line-
>nextRootBox()) { |
| 848 line->attachLine(); | 815 line->attachLine(); |
| 849 if (delta) { | 816 if (delta) { |
| 850 layoutState.updatePaintInvalidationRangeFromBox(line, delta)
; | 817 layoutState.updatePaintInvalidationRangeFromBox(line, delta)
; |
| 851 line->adjustBlockDirectionPosition(delta.toFloat()); | 818 line->adjustBlockDirectionPosition(delta.toFloat()); |
| 852 } | 819 } |
| 853 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) { | |
| 854 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); | |
| 855 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin
(); f != end; ++f) { | |
| 856 FloatingObject* floatingObject = insertFloatingObject(*f
); | |
| 857 ASSERT(!floatingObject->originatingLine()); | |
| 858 floatingObject->setOriginatingLine(line); | |
| 859 setLogicalHeight(logicalTopForChild(*f) - marginBeforeFo
rChild(*f) + delta); | |
| 860 positionNewFloats(); | |
| 861 } | |
| 862 } | |
| 863 } | 820 } |
| 864 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); | 821 setLogicalHeight(lastRootBox()->lineBottomWithLeading()); |
| 865 } else { | 822 } else { |
| 866 // Delete all the remaining lines. | 823 // Delete all the remaining lines. |
| 867 deleteLineRange(layoutState, layoutState.endLine()); | 824 deleteLineRange(layoutState, layoutState.endLine()); |
| 868 } | 825 } |
| 869 } | 826 } |
| 870 | |
| 871 if (m_floatingObjects && (layoutState.checkForFloatsFromLastLine() || positi
onNewFloats()) && lastRootBox()) { | |
| 872 // In case we have a float on the last line, it might not be positioned
up to now. | |
| 873 // This has to be done before adding in the bottom border/padding, or th
e float will | |
| 874 // include the padding incorrectly. -dwh | |
| 875 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | |
| 876 FloatingObjectSetIterator it = floatingObjectSet.begin(); | |
| 877 FloatingObjectSetIterator end = floatingObjectSet.end(); | |
| 878 if (layoutState.lastFloat()) { | |
| 879 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find
(layoutState.lastFloat()); | |
| 880 ASSERT(lastFloatIterator != end); | |
| 881 ++lastFloatIterator; | |
| 882 it = lastFloatIterator; | |
| 883 } | |
| 884 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe
t.last().get() : 0); | |
| 885 | |
| 886 if (it == end) | |
| 887 return; | |
| 888 | |
| 889 if (layoutState.checkForFloatsFromLastLine()) { | |
| 890 LayoutUnit bottomVisualOverflow = lastRootBox()->logicalBottomVisual
Overflow(); | |
| 891 LayoutUnit bottomLayoutOverflow = lastRootBox()->logicalBottomLayout
Overflow(); | |
| 892 TrailingFloatsRootInlineBox* trailingFloatsLineBox = new TrailingFlo
atsRootInlineBox(*this); | |
| 893 m_lineBoxes.appendLineBox(trailingFloatsLineBox); | |
| 894 trailingFloatsLineBox->setConstructed(); | |
| 895 GlyphOverflowAndFallbackFontsMap textBoxDataMap; | |
| 896 VerticalPositionCache verticalPositionCache; | |
| 897 LayoutUnit blockLogicalHeight = logicalHeight(); | |
| 898 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight
, textBoxDataMap, verticalPositionCache); | |
| 899 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight,
blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); | |
| 900 trailingFloatsLineBox->setPaginatedLineWidth(availableLogicalWidthFo
rContent()); | |
| 901 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay
outOverflow - blockLogicalHeight); | |
| 902 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis
ualOverflow - blockLogicalHeight); | |
| 903 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver
flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin
eBox->lineBottom()); | |
| 904 } | |
| 905 | |
| 906 for (; it != end; ++it) | |
| 907 appendFloatingObjectToLastLine(it->get()); | |
| 908 } | |
| 909 } | 827 } |
| 910 | 828 |
| 911 void RenderBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) | 829 void RenderBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) |
| 912 { | 830 { |
| 913 size_t floatCount = floats.size(); | 831 size_t floatCount = floats.size(); |
| 914 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have | 832 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have |
| 915 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be | 833 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be |
| 916 // painted. | 834 // painted. |
| 917 for (size_t i = 0; i < floatCount; ++i) { | 835 for (size_t i = 0; i < floatCount; ++i) { |
| 918 if (!floats[i].everHadLayout) { | 836 if (!floats[i].everHadLayout) { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 // No dirty lines were found. | 1432 // No dirty lines were found. |
| 1515 // If the last line didn't break cleanly, treat it as dirty. | 1433 // If the last line didn't break cleanly, treat it as dirty. |
| 1516 if (lastRootBox() && !lastRootBox()->endsWithBreak()) | 1434 if (lastRootBox() && !lastRootBox()->endsWithBreak()) |
| 1517 curr = lastRootBox(); | 1435 curr = lastRootBox(); |
| 1518 } | 1436 } |
| 1519 | 1437 |
| 1520 // If we have no dirty lines, then last is just the last root box. | 1438 // If we have no dirty lines, then last is just the last root box. |
| 1521 last = curr ? curr->prevRootBox() : lastRootBox(); | 1439 last = curr ? curr->prevRootBox() : lastRootBox(); |
| 1522 } | 1440 } |
| 1523 | 1441 |
| 1524 unsigned numCleanFloats = 0; | |
| 1525 if (!layoutState.floats().isEmpty()) { | |
| 1526 LayoutUnit savedLogicalHeight = logicalHeight(); | |
| 1527 // Restore floats from clean lines. | |
| 1528 RootInlineBox* line = firstRootBox(); | |
| 1529 while (line != curr) { | |
| 1530 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) { | |
| 1531 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); | |
| 1532 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin();
f != end; ++f) { | |
| 1533 FloatingObject* floatingObject = insertFloatingObject(*f); | |
| 1534 ASSERT(!floatingObject->originatingLine()); | |
| 1535 floatingObject->setOriginatingLine(line); | |
| 1536 setLogicalHeight(logicalTopForChild(*f) - marginBeforeForChi
ld(*f)); | |
| 1537 positionNewFloats(); | |
| 1538 ASSERT(layoutState.floats()[numCleanFloats].object == *f); | |
| 1539 numCleanFloats++; | |
| 1540 } | |
| 1541 } | |
| 1542 line = line->nextRootBox(); | |
| 1543 } | |
| 1544 setLogicalHeight(savedLogicalHeight); | |
| 1545 } | |
| 1546 layoutState.setFloatIndex(numCleanFloats); | |
| 1547 | |
| 1548 layoutState.lineInfo().setFirstLine(!last); | 1442 layoutState.lineInfo().setFirstLine(!last); |
| 1549 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr
eak()); | 1443 layoutState.lineInfo().setPreviousLineBrokeCleanly(!last || last->endsWithBr
eak()); |
| 1550 | 1444 |
| 1551 if (last) { | 1445 if (last) { |
| 1552 setLogicalHeight(last->lineBottomWithLeading()); | 1446 setLogicalHeight(last->lineBottomWithLeading()); |
| 1553 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l
ineBreakPos()); | 1447 InlineIterator iter = InlineIterator(this, last->lineBreakObj(), last->l
ineBreakPos()); |
| 1554 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); | 1448 resolver.setPosition(iter, numberOfIsolateAncestors(iter)); |
| 1555 resolver.setStatus(last->lineBreakBidiStatus()); | 1449 resolver.setStatus(last->lineBreakBidiStatus()); |
| 1556 } else { | 1450 } else { |
| 1557 TextDirection direction = style()->direction(); | 1451 TextDirection direction = style()->direction(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 | 1490 |
| 1597 for (RootInlineBox* line = last; line; line = line->nextRootBox()) | 1491 for (RootInlineBox* line = last; line; line = line->nextRootBox()) |
| 1598 line->extractLine(); // Disconnect all line boxes from their render obje
cts while preserving | 1492 line->extractLine(); // Disconnect all line boxes from their render obje
cts while preserving |
| 1599 // their connections to one another. | 1493 // their connections to one another. |
| 1600 | 1494 |
| 1601 layoutState.setEndLine(last); | 1495 layoutState.setEndLine(last); |
| 1602 } | 1496 } |
| 1603 | 1497 |
| 1604 bool RenderBlockFlow::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutS
tate) | 1498 bool RenderBlockFlow::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutS
tate) |
| 1605 { | 1499 { |
| 1606 LayoutUnit lineDelta = logicalHeight() - layoutState.endLineLogicalTop(); | 1500 // FIXME(sky): Remove this. |
| 1607 | |
| 1608 if (!lineDelta || !m_floatingObjects) | |
| 1609 return true; | |
| 1610 | |
| 1611 // See if any floats end in the range along which we want to shift the lines
vertically. | |
| 1612 LayoutUnit logicalTop = std::min(logicalHeight(), layoutState.endLineLogical
Top()); | |
| 1613 | |
| 1614 RootInlineBox* lastLine = layoutState.endLine(); | |
| 1615 while (RootInlineBox* nextLine = lastLine->nextRootBox()) | |
| 1616 lastLine = nextLine; | |
| 1617 | |
| 1618 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue
(lineDelta); | |
| 1619 | |
| 1620 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | |
| 1621 FloatingObjectSetIterator end = floatingObjectSet.end(); | |
| 1622 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | |
| 1623 FloatingObject* floatingObject = it->get(); | |
| 1624 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom
ForFloat(floatingObject) < logicalBottom) | |
| 1625 return false; | |
| 1626 } | |
| 1627 | |
| 1628 return true; | 1501 return true; |
| 1629 } | 1502 } |
| 1630 | 1503 |
| 1631 bool RenderBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB
idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end
LineStatus) | 1504 bool RenderBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB
idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end
LineStatus) |
| 1632 { | 1505 { |
| 1633 if (resolver.position() == endLineStart) { | 1506 if (resolver.position() == endLineStart) { |
| 1634 if (resolver.status() != endLineStatus) | 1507 if (resolver.status() != endLineStatus) |
| 1635 return false; | 1508 return false; |
| 1636 return checkPaginationAndFloatsAtEndLine(layoutState); | 1509 return checkPaginationAndFloatsAtEndLine(layoutState); |
| 1637 } | 1510 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 if (ltr) | 1629 if (ltr) |
| 1757 curr->adjustLogicalPosition(logicalLeft, 0); | 1630 curr->adjustLogicalPosition(logicalLeft, 0); |
| 1758 else | 1631 else |
| 1759 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); | 1632 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); |
| 1760 } | 1633 } |
| 1761 } | 1634 } |
| 1762 firstLine = false; | 1635 firstLine = false; |
| 1763 } | 1636 } |
| 1764 } | 1637 } |
| 1765 | 1638 |
| 1766 bool RenderBlockFlow::positionNewFloatOnLine(FloatingObject* newFloat, FloatingO
bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) | |
| 1767 { | |
| 1768 if (!positionNewFloats()) | |
| 1769 return false; | |
| 1770 | |
| 1771 width.shrinkAvailableWidthForNewFloatIfNeeded(newFloat); | |
| 1772 return true; | |
| 1773 } | |
| 1774 | |
| 1775 LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool
firstLine) | 1639 LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool
firstLine) |
| 1776 { | 1640 { |
| 1777 ETextAlign textAlign = style()->textAlign(); | 1641 ETextAlign textAlign = style()->textAlign(); |
| 1778 | 1642 |
| 1779 if (textAlign == TASTART) // FIXME: Handle TAEND here | 1643 if (textAlign == TASTART) // FIXME: Handle TAEND here |
| 1780 return startOffsetForLine(position, firstLine); | 1644 return startOffsetForLine(position, firstLine); |
| 1781 | 1645 |
| 1782 // updateLogicalWidthForAlignment() handles the direction of the block so no
need to consider it here | 1646 // updateLogicalWidthForAlignment() handles the direction of the block so no
need to consider it here |
| 1783 float totalLogicalWidth = 0; | 1647 float totalLogicalWidth = 0; |
| 1784 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); | 1648 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat
(); |
| 1785 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; | 1649 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal
se) - logicalLeft; |
| 1786 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 1650 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 1787 | 1651 |
| 1788 if (!style()->isLeftToRightDirection()) | 1652 if (!style()->isLeftToRightDirection()) |
| 1789 return logicalWidth() - logicalLeft; | 1653 return logicalWidth() - logicalLeft; |
| 1790 return logicalLeft; | 1654 return logicalLeft; |
| 1791 } | 1655 } |
| 1792 | 1656 |
| 1793 } | 1657 } |
| OLD | NEW |