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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 // Compute our overflow now. | 710 // Compute our overflow now. |
711 lineBox->computeOverflow(lineBox->lineTop(), lineBox->lineBottom(), textBoxD ataMap); | 711 lineBox->computeOverflow(lineBox->lineTop(), lineBox->lineBottom(), textBoxD ataMap); |
712 | 712 |
713 return lineBox; | 713 return lineBox; |
714 } | 714 } |
715 | 715 |
716 static void deleteLineRange(LineLayoutState& layoutState, RootInlineBox* startLi ne, RootInlineBox* stopLine = 0) | 716 static void deleteLineRange(LineLayoutState& layoutState, RootInlineBox* startLi ne, RootInlineBox* stopLine = 0) |
717 { | 717 { |
718 RootInlineBox* boxToDelete = startLine; | 718 RootInlineBox* boxToDelete = startLine; |
719 while (boxToDelete && boxToDelete != stopLine) { | 719 while (boxToDelete && boxToDelete != stopLine) { |
720 layoutState.updateRepaintRangeFromBox(boxToDelete); | 720 layoutState.updatePaintInvalidationRangeFromBox(boxToDelete); |
721 // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineB oxTree(). | 721 // Note: deleteLineRange(firstRootBox()) is not identical to deleteLineB oxTree(). |
722 // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when tr aversing. | 722 // deleteLineBoxTree uses nextLineBox() instead of nextRootBox() when tr aversing. |
723 RootInlineBox* next = boxToDelete->nextRootBox(); | 723 RootInlineBox* next = boxToDelete->nextRootBox(); |
724 boxToDelete->deleteLine(); | 724 boxToDelete->deleteLine(); |
725 boxToDelete = next; | 725 boxToDelete = next; |
726 } | 726 } |
727 } | 727 } |
728 | 728 |
729 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState) | 729 void RenderBlockFlow::layoutRunsAndFloats(LineLayoutState& layoutState) |
730 { | 730 { |
731 // We want to skip ahead to the first dirty line | 731 // We want to skip ahead to the first dirty line |
732 InlineBidiResolver resolver; | 732 InlineBidiResolver resolver; |
733 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); | 733 RootInlineBox* startLine = determineStartPosition(layoutState, resolver); |
734 | 734 |
735 if (containsFloats()) | 735 if (containsFloats()) |
736 layoutState.setLastFloat(m_floatingObjects->set().last().get()); | 736 layoutState.setLastFloat(m_floatingObjects->set().last().get()); |
737 | 737 |
738 // We also find the first clean line and extract these lines. We will add t hem back | 738 // We also find the first clean line and extract these lines. We will add t hem back |
739 // if we determine that we're able to synchronize after handling all our dir ty lines. | 739 // if we determine that we're able to synchronize after handling all our dir ty lines. |
740 InlineIterator cleanLineStart; | 740 InlineIterator cleanLineStart; |
741 BidiStatus cleanLineBidiStatus; | 741 BidiStatus cleanLineBidiStatus; |
742 if (!layoutState.isFullLayout() && startLine) | 742 if (!layoutState.isFullLayout() && startLine) |
743 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); | 743 determineEndPosition(layoutState, startLine, cleanLineStart, cleanLineBi diStatus); |
744 | 744 |
745 if (startLine) { | 745 if (startLine) { |
746 if (!layoutState.usesRepaintBounds()) | 746 if (!layoutState.usesPaintInvalidationBounds()) |
747 layoutState.setRepaintRange(logicalHeight()); | 747 layoutState.setPaintInvalidationRange(logicalHeight()); |
748 deleteLineRange(layoutState, startLine); | 748 deleteLineRange(layoutState, startLine); |
749 } | 749 } |
750 | 750 |
751 if (!layoutState.isFullLayout() && lastRootBox() && lastRootBox()->endsWithB reak()) { | 751 if (!layoutState.isFullLayout() && lastRootBox() && lastRootBox()->endsWithB reak()) { |
752 // If the last line before the start line ends with a line break that cl ear floats, | 752 // If the last line before the start line ends with a line break that cl ear floats, |
753 // adjust the height accordingly. | 753 // adjust the height accordingly. |
754 // A line break can be either the first or the last object on a line, de pending on its direction. | 754 // A line break can be either the first or the last object on a line, de pending on its direction. |
755 if (InlineBox* lastLeafChild = lastRootBox()->lastLeafChild()) { | 755 if (InlineBox* lastLeafChild = lastRootBox()->lastLeafChild()) { |
756 RenderObject* lastObject = &lastLeafChild->renderer(); | 756 RenderObject* lastObject = &lastLeafChild->renderer(); |
757 if (!lastObject->isBR()) | 757 if (!lastObject->isBR()) |
758 lastObject = &lastRootBox()->firstLeafChild()->renderer(); | 758 lastObject = &lastRootBox()->firstLeafChild()->renderer(); |
759 if (lastObject->isBR()) { | 759 if (lastObject->isBR()) { |
760 EClear clear = lastObject->style()->clear(); | 760 EClear clear = lastObject->style()->clear(); |
761 if (clear != CNONE) | 761 if (clear != CNONE) |
762 clearFloats(clear); | 762 clearFloats(clear); |
763 } | 763 } |
764 } | 764 } |
765 } | 765 } |
766 | 766 |
767 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); | 767 layoutRunsAndFloatsInRange(layoutState, resolver, cleanLineStart, cleanLineB idiStatus); |
768 linkToEndLineIfNeeded(layoutState); | 768 linkToEndLineIfNeeded(layoutState); |
769 repaintDirtyFloats(layoutState.floats()); | 769 paintInvalidationForDirtyFloats(layoutState.floats()); |
770 } | 770 } |
771 | 771 |
772 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. | 772 // Before restarting the layout loop with a new logicalHeight, remove all floats that were added and reset the resolver. |
773 inline const InlineIterator& RenderBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) | 773 inline const InlineIterator& RenderBlockFlow::restartLayoutRunsAndFloatsInRange( LayoutUnit oldLogicalHeight, LayoutUnit newLogicalHeight, FloatingObject* lastF loatFromPreviousLine, InlineBidiResolver& resolver, const InlineIterator& oldEn d) |
774 { | 774 { |
775 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); | 775 removeFloatingObjectsBelow(lastFloatFromPreviousLine, oldLogicalHeight); |
776 setLogicalHeight(newLogicalHeight); | 776 setLogicalHeight(newLogicalHeight); |
777 resolver.setPositionIgnoringNestedIsolates(oldEnd); | 777 resolver.setPositionIgnoringNestedIsolates(oldEnd); |
778 return oldEnd; | 778 return oldEnd; |
779 } | 779 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 // inline flow boxes. | 852 // inline flow boxes. |
853 | 853 |
854 LayoutUnit oldLogicalHeight = logicalHeight(); | 854 LayoutUnit oldLogicalHeight = logicalHeight(); |
855 RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status ().context->level(), bidiRuns, endOfLine, layoutState.lineInfo(), verticalPositi onCache, trailingSpaceRun, wordMeasurements); | 855 RootInlineBox* lineBox = createLineBoxesFromBidiRuns(resolver.status ().context->level(), bidiRuns, endOfLine, layoutState.lineInfo(), verticalPositi onCache, trailingSpaceRun, wordMeasurements); |
856 | 856 |
857 bidiRuns.deleteRuns(); | 857 bidiRuns.deleteRuns(); |
858 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). | 858 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). |
859 | 859 |
860 if (lineBox) { | 860 if (lineBox) { |
861 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset() , resolver.status()); | 861 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset() , resolver.status()); |
862 if (layoutState.usesRepaintBounds()) | 862 if (layoutState.usesPaintInvalidationBounds()) |
863 layoutState.updateRepaintRangeFromBox(lineBox); | 863 layoutState.updatePaintInvalidationRangeFromBox(lineBox); |
864 | 864 |
865 if (paginated) { | 865 if (paginated) { |
866 LayoutUnit adjustment = 0; | 866 LayoutUnit adjustment = 0; |
867 adjustLinePositionForPagination(lineBox, adjustment, layoutS tate.flowThread()); | 867 adjustLinePositionForPagination(lineBox, adjustment, layoutS tate.flowThread()); |
868 if (adjustment) { | 868 if (adjustment) { |
869 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o ldLogicalHeight, layoutState.lineInfo().isFirstLine()); | 869 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o ldLogicalHeight, layoutState.lineInfo().isFirstLine()); |
870 lineBox->adjustBlockDirectionPosition(adjustment.toFloat ()); | 870 lineBox->adjustBlockDirectionPosition(adjustment.toFloat ()); |
871 if (layoutState.usesRepaintBounds()) | 871 if (layoutState.usesPaintInvalidationBounds()) |
872 layoutState.updateRepaintRangeFromBox(lineBox); | 872 layoutState.updatePaintInvalidationRangeFromBox(line Box); |
873 | 873 |
874 if (availableLogicalWidthForLine(oldLogicalHeight + adju stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { | 874 if (availableLogicalWidthForLine(oldLogicalHeight + adju stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { |
875 // We have to delete this line, remove all floats th at got added, and let line layout re-run. | 875 // We have to delete this line, remove all floats th at got added, and let line layout re-run. |
876 lineBox->deleteLine(); | 876 lineBox->deleteLine(); |
877 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, previousEndofLine); | 877 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, previousEndofLine); |
878 continue; | 878 continue; |
879 } | 879 } |
880 | 880 |
881 setLogicalHeight(lineBox->lineBottomWithLeading()); | 881 setLogicalHeight(lineBox->lineBottomWithLeading()); |
882 } | 882 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 bool paginated = view()->layoutState() && view()->layoutState()->isP aginated(); | 988 bool paginated = view()->layoutState() && view()->layoutState()->isP aginated(); |
989 // Attach all the remaining lines, and then adjust their y-positions as needed. | 989 // Attach all the remaining lines, and then adjust their y-positions as needed. |
990 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ; | 990 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ; |
991 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) { | 991 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) { |
992 line->attachLine(); | 992 line->attachLine(); |
993 if (paginated) { | 993 if (paginated) { |
994 delta -= line->paginationStrut(); | 994 delta -= line->paginationStrut(); |
995 adjustLinePositionForPagination(line, delta, layoutState.flo wThread()); | 995 adjustLinePositionForPagination(line, delta, layoutState.flo wThread()); |
996 } | 996 } |
997 if (delta) { | 997 if (delta) { |
998 layoutState.updateRepaintRangeFromBox(line, delta); | 998 layoutState.updatePaintInvalidationRangeFromBox(line, delta) ; |
999 line->adjustBlockDirectionPosition(delta.toFloat()); | 999 line->adjustBlockDirectionPosition(delta.toFloat()); |
1000 } | 1000 } |
1001 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) { | 1001 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) { |
1002 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); | 1002 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); |
1003 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin (); f != end; ++f) { | 1003 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin (); f != end; ++f) { |
1004 FloatingObject* floatingObject = insertFloatingObject(*f ); | 1004 FloatingObject* floatingObject = insertFloatingObject(*f ); |
1005 ASSERT(!floatingObject->originatingLine()); | 1005 ASSERT(!floatingObject->originatingLine()); |
1006 floatingObject->setOriginatingLine(line); | 1006 floatingObject->setOriginatingLine(line); |
1007 setLogicalHeight(logicalTopForChild(*f) - marginBeforeFo rChild(*f) + delta); | 1007 setLogicalHeight(logicalTopForChild(*f) - marginBeforeFo rChild(*f) + delta); |
1008 positionNewFloats(); | 1008 positionNewFloats(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1045 ASSERT(lastFloatIterator != end); | 1045 ASSERT(lastFloatIterator != end); |
1046 ++lastFloatIterator; | 1046 ++lastFloatIterator; |
1047 it = lastFloatIterator; | 1047 it = lastFloatIterator; |
1048 } | 1048 } |
1049 for (; it != end; ++it) | 1049 for (; it != end; ++it) |
1050 appendFloatingObjectToLastLine(it->get()); | 1050 appendFloatingObjectToLastLine(it->get()); |
1051 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe t.last().get() : 0); | 1051 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSe t.last().get() : 0); |
1052 } | 1052 } |
1053 } | 1053 } |
1054 | 1054 |
1055 void RenderBlockFlow::repaintDirtyFloats(Vector<FloatWithRect>& floats) | 1055 void RenderBlockFlow::paintInvalidationForDirtyFloats(Vector<FloatWithRect>& flo ats) |
leviw_travelin_and_unemployed
2014/08/15 18:45:48
Ditto.
dsinclair
2014/08/15 19:03:19
Done.
| |
1056 { | 1056 { |
1057 size_t floatCount = floats.size(); | 1057 size_t floatCount = floats.size(); |
1058 // Floats that did not have layout did not paint invalidations when we laid them out. They would have | 1058 // Floats that did not have layout did not paint invalidations when we laid them out. They would have |
1059 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be | 1059 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be |
1060 // painted. | 1060 // painted. |
1061 for (size_t i = 0; i < floatCount; ++i) { | 1061 for (size_t i = 0; i < floatCount; ++i) { |
1062 if (!floats[i].everHadLayout) { | 1062 if (!floats[i].everHadLayout) { |
1063 RenderBox* f = floats[i].object; | 1063 RenderBox* f = floats[i].object; |
1064 if (!f->x() && !f->y() && f->checkForPaintInvalidation()) { | 1064 if (!f->x() && !f->y() && f->checkForPaintInvalidation()) { |
1065 f->setShouldDoFullPaintInvalidation(true); | 1065 f->setShouldDoFullPaintInvalidation(true); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 oldAutoWrap = autoWrap; | 1489 oldAutoWrap = autoWrap; |
1490 } | 1490 } |
1491 | 1491 |
1492 if (styleToUse->collapseWhiteSpace()) | 1492 if (styleToUse->collapseWhiteSpace()) |
1493 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); | 1493 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); |
1494 | 1494 |
1495 updatePreferredWidth(minLogicalWidth, inlineMin); | 1495 updatePreferredWidth(minLogicalWidth, inlineMin); |
1496 updatePreferredWidth(maxLogicalWidth, inlineMax); | 1496 updatePreferredWidth(maxLogicalWidth, inlineMax); |
1497 } | 1497 } |
1498 | 1498 |
1499 void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& re paintLogicalTop, LayoutUnit& repaintLogicalBottom, LayoutUnit afterEdge) | 1499 void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa intInvalidationLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUni t afterEdge) |
1500 { | 1500 { |
1501 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 1501 RenderFlowThread* flowThread = flowThreadContainingBlock(); |
1502 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread-> hasRegions(); | 1502 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread-> hasRegions(); |
1503 | 1503 |
1504 // Figure out if we should clear out our line boxes. | 1504 // Figure out if we should clear out our line boxes. |
1505 // FIXME: Handle resize eventually! | 1505 // FIXME: Handle resize eventually! |
1506 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination; | 1506 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination; |
1507 LineLayoutState layoutState(isFullLayout, repaintLogicalTop, repaintLogicalB ottom, flowThread); | 1507 LineLayoutState layoutState(isFullLayout, paintInvalidationLogicalTop, paint InvalidationLogicalBottom, flowThread); |
1508 | 1508 |
1509 if (isFullLayout) { | 1509 if (isFullLayout) { |
1510 // Ensure the old line boxes will be erased. | 1510 // Ensure the old line boxes will be erased. |
1511 if (firstLineBox()) | 1511 if (firstLineBox()) |
1512 setShouldDoFullPaintInvalidation(true); | 1512 setShouldDoFullPaintInvalidation(true); |
1513 lineBoxes()->deleteLineBoxes(); | 1513 lineBoxes()->deleteLineBoxes(); |
1514 } | 1514 } |
1515 | 1515 |
1516 // Text truncation kicks in in two cases: | 1516 // Text truncation kicks in in two cases: |
1517 // 1) If your overflow isn't visible and your text-overflow-mode isn't c lip. | 1517 // 1) If your overflow isn't visible and your text-overflow-mode isn't c lip. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1646 if (paginated) { | 1646 if (paginated) { |
1647 paginationDelta -= curr->paginationStrut(); | 1647 paginationDelta -= curr->paginationStrut(); |
1648 adjustLinePositionForPagination(curr, paginationDelta, layoutSta te.flowThread()); | 1648 adjustLinePositionForPagination(curr, paginationDelta, layoutSta te.flowThread()); |
1649 if (paginationDelta) { | 1649 if (paginationDelta) { |
1650 if (containsFloats() || !layoutState.floats().isEmpty()) { | 1650 if (containsFloats() || !layoutState.floats().isEmpty()) { |
1651 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout. | 1651 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout. |
1652 layoutState.markForFullLayout(); | 1652 layoutState.markForFullLayout(); |
1653 break; | 1653 break; |
1654 } | 1654 } |
1655 | 1655 |
1656 layoutState.updateRepaintRangeFromBox(curr, paginationDelta) ; | 1656 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina tionDelta); |
1657 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); | 1657 curr->adjustBlockDirectionPosition(paginationDelta.toFloat() ); |
1658 } | 1658 } |
1659 } | 1659 } |
1660 | 1660 |
1661 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. | 1661 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. |
1662 bool encounteredNewFloat = false; | 1662 bool encounteredNewFloat = false; |
1663 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); | 1663 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); |
1664 if (encounteredNewFloat) | 1664 if (encounteredNewFloat) |
1665 layoutState.markForFullLayout(); | 1665 layoutState.markForFullLayout(); |
1666 | 1666 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2033 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); | 2033 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); |
2034 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 2034 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; |
2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2035 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
2036 | 2036 |
2037 if (!style()->isLeftToRightDirection()) | 2037 if (!style()->isLeftToRightDirection()) |
2038 return logicalWidth() - logicalLeft; | 2038 return logicalWidth() - logicalLeft; |
2039 return logicalLeft; | 2039 return logicalLeft; |
2040 } | 2040 } |
2041 | 2041 |
2042 } | 2042 } |
OLD | NEW |