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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop -
1)); | 618 needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop -
1)); |
619 } | 619 } |
620 | 620 |
621 setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInf
o, textBoxDataMap, verticalPositionCache, wordMeasurements); | 621 setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInf
o, textBoxDataMap, verticalPositionCache, wordMeasurements); |
622 } else { | 622 } else { |
623 isAfterExpansion = false; | 623 isAfterExpansion = false; |
624 if (!r->m_object->isLayoutInline()) { | 624 if (!r->m_object->isLayoutInline()) { |
625 LayoutBox* layoutBox = toLayoutBox(r->m_object); | 625 LayoutBox* layoutBox = toLayoutBox(r->m_object); |
626 if (layoutBox->isRubyRun()) | 626 if (layoutBox->isRubyRun()) |
627 setMarginsForRubyRun(r, toLayoutRubyRun(layoutBox), previous
Object, lineInfo); | 627 setMarginsForRubyRun(r, toLayoutRubyRun(layoutBox), previous
Object, lineInfo); |
628 r->m_box->setLogicalWidth(logicalWidthForChild(*layoutBox).toFlo
at()); | 628 r->m_box->setLogicalWidth(logicalWidthForChild(*layoutBox)); |
629 totalLogicalWidth += marginStartForChild(*layoutBox) + marginEnd
ForChild(*layoutBox); | 629 totalLogicalWidth += marginStartForChild(*layoutBox) + marginEnd
ForChild(*layoutBox); |
630 needsWordSpacing = true; | 630 needsWordSpacing = true; |
631 } | 631 } |
632 } | 632 } |
633 | 633 |
634 totalLogicalWidth += r->m_box->logicalWidth(); | 634 totalLogicalWidth += r->m_box->logicalWidth(); |
635 previousObject = r->m_object; | 635 previousObject = r->m_object; |
636 } | 636 } |
637 | 637 |
638 if (isAfterExpansion && !expansionOpportunities.isEmpty()) { | 638 if (isAfterExpansion && !expansionOpportunities.isEmpty()) { |
(...skipping 15 matching lines...) Expand all Loading... |
654 | 654 |
655 // Now make sure we place replaced layout objects correctly. | 655 // Now make sure we place replaced layout objects correctly. |
656 for (BidiRun* r = firstRun; r; r = r->next()) { | 656 for (BidiRun* r = firstRun; r; r = r->next()) { |
657 ASSERT(r->m_box); | 657 ASSERT(r->m_box); |
658 if (!r->m_box) | 658 if (!r->m_box) |
659 continue; // Skip runs with no line boxes. | 659 continue; // Skip runs with no line boxes. |
660 | 660 |
661 // Align positioned boxes with the top of the line box. This is | 661 // Align positioned boxes with the top of the line box. This is |
662 // a reasonable approximation of an appropriate y position. | 662 // a reasonable approximation of an appropriate y position. |
663 if (r->m_object->isOutOfFlowPositioned()) | 663 if (r->m_object->isOutOfFlowPositioned()) |
664 r->m_box->setLogicalTop(logicalHeight().toFloat()); | 664 r->m_box->setLogicalTop(logicalHeight()); |
665 | 665 |
666 // Position is used to properly position both replaced elements and | 666 // Position is used to properly position both replaced elements and |
667 // to update the static normal flow x/y of positioned elements. | 667 // to update the static normal flow x/y of positioned elements. |
668 if (r->m_object->isText()) | 668 if (r->m_object->isText()) |
669 toLayoutText(r->m_object)->positionLineBox(r->m_box); | 669 toLayoutText(r->m_object)->positionLineBox(r->m_box); |
670 else if (r->m_object->isBox()) | 670 else if (r->m_object->isBox()) |
671 toLayoutBox(r->m_object)->positionLineBox(r->m_box); | 671 toLayoutBox(r->m_object)->positionLineBox(r->m_box); |
672 } | 672 } |
673 } | 673 } |
674 | 674 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 if (lineBox) { | 855 if (lineBox) { |
856 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset()
, resolver.status()); | 856 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset()
, resolver.status()); |
857 if (layoutState.usesPaintInvalidationBounds()) | 857 if (layoutState.usesPaintInvalidationBounds()) |
858 layoutState.updatePaintInvalidationRangeFromBox(lineBox); | 858 layoutState.updatePaintInvalidationRangeFromBox(lineBox); |
859 | 859 |
860 if (paginated) { | 860 if (paginated) { |
861 LayoutUnit adjustment = 0; | 861 LayoutUnit adjustment = 0; |
862 adjustLinePositionForPagination(*lineBox, adjustment, layout
State.flowThread()); | 862 adjustLinePositionForPagination(*lineBox, adjustment, layout
State.flowThread()); |
863 if (adjustment) { | 863 if (adjustment) { |
864 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o
ldLogicalHeight, layoutState.lineInfo().isFirstLine()); | 864 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o
ldLogicalHeight, layoutState.lineInfo().isFirstLine()); |
865 lineBox->moveInBlockDirection(adjustment.toFloat()); | 865 lineBox->moveInBlockDirection(adjustment); |
866 if (layoutState.usesPaintInvalidationBounds()) | 866 if (layoutState.usesPaintInvalidationBounds()) |
867 layoutState.updatePaintInvalidationRangeFromBox(line
Box); | 867 layoutState.updatePaintInvalidationRangeFromBox(line
Box); |
868 | 868 |
869 if (availableLogicalWidthForLine(oldLogicalHeight + adju
stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { | 869 if (availableLogicalWidthForLine(oldLogicalHeight + adju
stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { |
870 // We have to delete this line, remove all floats th
at got added, and let line layout re-run. | 870 // We have to delete this line, remove all floats th
at got added, and let line layout re-run. |
871 lineBox->deleteLine(); | 871 lineBox->deleteLine(); |
872 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog
icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver,
previousEndofLine); | 872 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog
icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver,
previousEndofLine); |
873 logicalWidthIsAvailable = true; | 873 logicalWidthIsAvailable = true; |
874 } else { | 874 } else { |
875 setLogicalHeight(lineBox->lineBottomWithLeading()); | 875 setLogicalHeight(lineBox->lineBottomWithLeading()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 // Attach all the remaining lines, and then adjust their y-positions
as needed. | 985 // Attach all the remaining lines, and then adjust their y-positions
as needed. |
986 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop()
; | 986 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop()
; |
987 for (RootInlineBox* line = layoutState.endLine(); line; line = line-
>nextRootBox()) { | 987 for (RootInlineBox* line = layoutState.endLine(); line; line = line-
>nextRootBox()) { |
988 line->attachLine(); | 988 line->attachLine(); |
989 if (paginated) { | 989 if (paginated) { |
990 delta -= line->paginationStrut(); | 990 delta -= line->paginationStrut(); |
991 adjustLinePositionForPagination(*line, delta, layoutState.fl
owThread()); | 991 adjustLinePositionForPagination(*line, delta, layoutState.fl
owThread()); |
992 } | 992 } |
993 if (delta) { | 993 if (delta) { |
994 layoutState.updatePaintInvalidationRangeFromBox(line, delta)
; | 994 layoutState.updatePaintInvalidationRangeFromBox(line, delta)
; |
995 line->moveInBlockDirection(delta.toFloat()); | 995 line->moveInBlockDirection(delta); |
996 } | 996 } |
997 if (Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr()) { | 997 if (Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr()) { |
998 for (auto* box : *cleanLineFloats) { | 998 for (auto* box : *cleanLineFloats) { |
999 FloatingObject* floatingObject = insertFloatingObject(*b
ox); | 999 FloatingObject* floatingObject = insertFloatingObject(*b
ox); |
1000 ASSERT(!floatingObject->originatingLine()); | 1000 ASSERT(!floatingObject->originatingLine()); |
1001 floatingObject->setOriginatingLine(line); | 1001 floatingObject->setOriginatingLine(line); |
1002 setLogicalHeight(logicalTopForChild(*box) - marginBefore
ForChild(*box) + delta); | 1002 setLogicalHeight(logicalTopForChild(*box) - marginBefore
ForChild(*box) + delta); |
1003 positionNewFloats(); | 1003 positionNewFloats(); |
1004 } | 1004 } |
1005 } | 1005 } |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 isPrevChildInlineFlow = true; | 1489 isPrevChildInlineFlow = true; |
1490 else | 1490 else |
1491 isPrevChildInlineFlow = false; | 1491 isPrevChildInlineFlow = false; |
1492 | 1492 |
1493 oldAutoWrap = autoWrap; | 1493 oldAutoWrap = autoWrap; |
1494 } | 1494 } |
1495 | 1495 |
1496 if (styleToUse.collapseWhiteSpace()) | 1496 if (styleToUse.collapseWhiteSpace()) |
1497 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); | 1497 stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild); |
1498 | 1498 |
1499 minLogicalWidth = std::max(minLogicalWidth, LayoutUnit::fromFloatCeil(inline
Min.toFloat())); | 1499 minLogicalWidth = std::max(minLogicalWidth, inlineMin); |
1500 maxLogicalWidth = std::max(maxLogicalWidth, LayoutUnit::fromFloatCeil(inline
Max.toFloat())); | 1500 maxLogicalWidth = std::max(maxLogicalWidth, inlineMax); |
1501 } | 1501 } |
1502 | 1502 |
1503 void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa
intInvalidationLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUni
t afterEdge) | 1503 void LayoutBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& pa
intInvalidationLogicalTop, LayoutUnit& paintInvalidationLogicalBottom, LayoutUni
t afterEdge) |
1504 { | 1504 { |
1505 LayoutFlowThread* flowThread = flowThreadContainingBlock(); | 1505 LayoutFlowThread* flowThread = flowThreadContainingBlock(); |
1506 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread->
hasColumnSets(); | 1506 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread->
hasColumnSets(); |
1507 | 1507 |
1508 // Figure out if we should clear out our line boxes. | 1508 // Figure out if we should clear out our line boxes. |
1509 // FIXME: Handle resize eventually! | 1509 // FIXME: Handle resize eventually! |
1510 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren
|| clearLinesForPagination; | 1510 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren
|| clearLinesForPagination; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 paginationDelta -= curr->paginationStrut(); | 1651 paginationDelta -= curr->paginationStrut(); |
1652 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt
ate.flowThread()); | 1652 adjustLinePositionForPagination(*curr, paginationDelta, layoutSt
ate.flowThread()); |
1653 if (paginationDelta) { | 1653 if (paginationDelta) { |
1654 if (containsFloats() || !layoutState.floats().isEmpty()) { | 1654 if (containsFloats() || !layoutState.floats().isEmpty()) { |
1655 // FIXME: Do better eventually. For now if we ever shif
t because of pagination and floats are present just go to a full layout. | 1655 // FIXME: Do better eventually. For now if we ever shif
t because of pagination and floats are present just go to a full layout. |
1656 layoutState.markForFullLayout(); | 1656 layoutState.markForFullLayout(); |
1657 break; | 1657 break; |
1658 } | 1658 } |
1659 | 1659 |
1660 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina
tionDelta); | 1660 layoutState.updatePaintInvalidationRangeFromBox(curr, pagina
tionDelta); |
1661 curr->moveInBlockDirection(paginationDelta.toFloat()); | 1661 curr->moveInBlockDirection(paginationDelta); |
1662 } | 1662 } |
1663 } | 1663 } |
1664 | 1664 |
1665 // 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. | 1665 // 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. |
1666 if (!firstLineBoxWithBreakAndClearance && lineBoxHasBRWithClearance(
curr)) | 1666 if (!firstLineBoxWithBreakAndClearance && lineBoxHasBRWithClearance(
curr)) |
1667 firstLineBoxWithBreakAndClearance = curr; | 1667 firstLineBoxWithBreakAndClearance = curr; |
1668 | 1668 |
1669 // If a new float has been inserted before this line or before its l
ast known float, just do a full layout. | 1669 // If a new float has been inserted before this line or before its l
ast known float, just do a full layout. |
1670 bool encounteredNewFloat = false; | 1670 bool encounteredNewFloat = false; |
1671 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou
nteredNewFloat, dirtiedByFloat); | 1671 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou
nteredNewFloat, dirtiedByFloat); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 | 1914 |
1915 void LayoutBlockFlow::deleteEllipsisLineBoxes() | 1915 void LayoutBlockFlow::deleteEllipsisLineBoxes() |
1916 { | 1916 { |
1917 ETextAlign textAlign = style()->textAlign(); | 1917 ETextAlign textAlign = style()->textAlign(); |
1918 bool firstLine = true; | 1918 bool firstLine = true; |
1919 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ | 1919 for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox())
{ |
1920 if (curr->hasEllipsisBox()) { | 1920 if (curr->hasEllipsisBox()) { |
1921 curr->clearTruncation(); | 1921 curr->clearTruncation(); |
1922 | 1922 |
1923 // Shift the line back where it belongs if we cannot accomodate an e
llipsis. | 1923 // Shift the line back where it belongs if we cannot accomodate an e
llipsis. |
1924 LayoutUnit logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), f
irstLine).toFloat(); | 1924 LayoutUnit logicalLeft = logicalLeftOffsetForLine(curr->lineTop(), f
irstLine); |
1925 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(curr->l
ineTop(), false) - logicalLeft; | 1925 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(curr->l
ineTop(), false) - logicalLeft; |
1926 LayoutUnit totalLogicalWidth = curr->logicalWidth(); | 1926 LayoutUnit totalLogicalWidth = curr->logicalWidth(); |
1927 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota
lLogicalWidth, availableLogicalWidth, 0); | 1927 updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, tota
lLogicalWidth, availableLogicalWidth, 0); |
1928 | 1928 |
1929 curr->moveInInlineDirection(logicalLeft - curr->logicalLeft()); | 1929 curr->moveInInlineDirection(logicalLeft - curr->logicalLeft()); |
1930 } | 1930 } |
1931 firstLine = false; | 1931 firstLine = false; |
1932 } | 1932 } |
1933 } | 1933 } |
1934 | 1934 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2069 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
2070 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 2070 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
2071 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2071 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2072 | 2072 |
2073 if (!style()->isLeftToRightDirection()) | 2073 if (!style()->isLeftToRightDirection()) |
2074 return logicalWidth() - logicalLeft; | 2074 return logicalWidth() - logicalLeft; |
2075 return logicalLeft; | 2075 return logicalLeft; |
2076 } | 2076 } |
2077 | 2077 |
2078 } | 2078 } |
OLD | NEW |