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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 604 |
605 // Position is used to properly position both replaced elements and | 605 // Position is used to properly position both replaced elements and |
606 // to update the static normal flow x/y of positioned elements. | 606 // to update the static normal flow x/y of positioned elements. |
607 if (r->m_object->isText()) | 607 if (r->m_object->isText()) |
608 toLayoutText(r->m_object)->positionLineBox(r->m_box); | 608 toLayoutText(r->m_object)->positionLineBox(r->m_box); |
609 else if (r->m_object->isBox()) | 609 else if (r->m_object->isBox()) |
610 toLayoutBox(r->m_object)->positionLineBox(r->m_box); | 610 toLayoutBox(r->m_object)->positionLineBox(r->m_box); |
611 } | 611 } |
612 } | 612 } |
613 | 613 |
614 void LayoutBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj
ect) | 614 void LayoutBlockFlow::appendFloatingObjectToLastLine(FloatingObject& floatingObj
ect) |
615 { | 615 { |
616 ASSERT(!floatingObject->originatingLine()); | 616 ASSERT(!floatingObject.originatingLine()); |
617 floatingObject->setOriginatingLine(lastRootBox()); | 617 floatingObject.setOriginatingLine(lastRootBox()); |
618 lastRootBox()->appendFloat(floatingObject->layoutObject()); | 618 lastRootBox()->appendFloat(floatingObject.layoutObject()); |
619 } | 619 } |
620 | 620 |
621 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. | 621 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. |
622 RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) | 622 RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) |
623 { | 623 { |
624 if (!bidiRuns.runCount()) | 624 if (!bidiRuns.runCount()) |
625 return nullptr; | 625 return nullptr; |
626 | 626 |
627 // FIXME: Why is this only done when we had runs? | 627 // FIXME: Why is this only done when we had runs? |
628 lineInfo.setLastLine(!end.object()); | 628 lineInfo.setLastLine(!end.object()); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->
set(); | 847 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->
set(); |
848 FloatingObjectSetIterator it = floatingObjectSet.begin(); | 848 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
849 FloatingObjectSetIterator end = floatingObjectSet.end(); | 849 FloatingObjectSetIterator end = floatingObjectSet.end(); |
850 if (layoutState.lastFloat()) { | 850 if (layoutState.lastFloat()) { |
851 FloatingObjectSetIterator lastFloatIterator = floatingObject
Set.find(layoutState.lastFloat()); | 851 FloatingObjectSetIterator lastFloatIterator = floatingObject
Set.find(layoutState.lastFloat()); |
852 ASSERT(lastFloatIterator != end); | 852 ASSERT(lastFloatIterator != end); |
853 ++lastFloatIterator; | 853 ++lastFloatIterator; |
854 it = lastFloatIterator; | 854 it = lastFloatIterator; |
855 } | 855 } |
856 for (; it != end; ++it) { | 856 for (; it != end; ++it) { |
857 FloatingObject* f = it->get(); | 857 FloatingObject& floatingObject = *it->get(); |
858 appendFloatingObjectToLastLine(f); | 858 appendFloatingObjectToLastLine(floatingObject); |
859 ASSERT(f->layoutObject() == layoutState.floats()[layoutState
.floatIndex()].object); | 859 ASSERT(floatingObject.layoutObject() == layoutState.floats()
[layoutState.floatIndex()].object); |
860 // If a float's geometry has changed, give up on syncing wit
h clean lines. | 860 // If a float's geometry has changed, give up on syncing wit
h clean lines. |
861 if (layoutState.floats()[layoutState.floatIndex()].rect != f
->frameRect()) | 861 if (layoutState.floats()[layoutState.floatIndex()].rect != f
loatingObject.frameRect()) |
862 checkForEndLineMatch = false; | 862 checkForEndLineMatch = false; |
863 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | 863 layoutState.setFloatIndex(layoutState.floatIndex() + 1); |
864 } | 864 } |
865 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating
ObjectSet.last().get() : 0); | 865 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating
ObjectSet.last().get() : 0); |
866 } | 866 } |
867 } | 867 } |
868 | 868 |
869 lineMidpointState.reset(); | 869 lineMidpointState.reset(); |
870 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); | 870 resolver.setPosition(endOfLine, numberOfIsolateAncestors(endOfLine)); |
871 } | 871 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 VerticalPositionCache verticalPositionCache; | 995 VerticalPositionCache verticalPositionCache; |
996 LayoutUnit blockLogicalHeight = logicalHeight(); | 996 LayoutUnit blockLogicalHeight = logicalHeight(); |
997 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight
, textBoxDataMap, verticalPositionCache); | 997 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight
, textBoxDataMap, verticalPositionCache); |
998 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight,
blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); | 998 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight,
blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); |
999 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay
outOverflow - blockLogicalHeight); | 999 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay
outOverflow - blockLogicalHeight); |
1000 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis
ualOverflow - blockLogicalHeight); | 1000 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis
ualOverflow - blockLogicalHeight); |
1001 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver
flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin
eBox->lineBottom()); | 1001 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver
flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin
eBox->lineBottom()); |
1002 } | 1002 } |
1003 | 1003 |
1004 for (; it != end; ++it) | 1004 for (; it != end; ++it) |
1005 appendFloatingObjectToLastLine(it->get()); | 1005 appendFloatingObjectToLastLine(*it->get()); |
1006 } | 1006 } |
1007 } | 1007 } |
1008 | 1008 |
1009 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) | 1009 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>&
floats) |
1010 { | 1010 { |
1011 size_t floatCount = floats.size(); | 1011 size_t floatCount = floats.size(); |
1012 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have | 1012 // Floats that did not have layout did not paint invalidations when we laid
them out. They would have |
1013 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be | 1013 // painted by now if they had moved, but if they stayed at (0, 0), they stil
l need to be |
1014 // painted. | 1014 // painted. |
1015 for (size_t i = 0; i < floatCount; ++i) { | 1015 for (size_t i = 0; i < floatCount; ++i) { |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 | 1773 |
1774 RootInlineBox* lastLine = layoutState.endLine(); | 1774 RootInlineBox* lastLine = layoutState.endLine(); |
1775 while (RootInlineBox* nextLine = lastLine->nextRootBox()) | 1775 while (RootInlineBox* nextLine = lastLine->nextRootBox()) |
1776 lastLine = nextLine; | 1776 lastLine = nextLine; |
1777 | 1777 |
1778 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue
(lineDelta); | 1778 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue
(lineDelta); |
1779 | 1779 |
1780 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1780 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1781 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1781 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1782 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 1782 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
1783 FloatingObject* floatingObject = it->get(); | 1783 const FloatingObject& floatingObject = *it->get(); |
1784 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom
ForFloat(floatingObject) < logicalBottom) | 1784 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom
ForFloat(floatingObject) < logicalBottom) |
1785 return false; | 1785 return false; |
1786 } | 1786 } |
1787 | 1787 |
1788 return true; | 1788 return true; |
1789 } | 1789 } |
1790 | 1790 |
1791 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB
idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end
LineStatus) | 1791 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB
idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end
LineStatus) |
1792 { | 1792 { |
1793 if (resolver.position() == endLineStart) { | 1793 if (resolver.position() == endLineStart) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 if (ltr) | 1947 if (ltr) |
1948 curr->adjustLogicalPosition(logicalLeft, 0); | 1948 curr->adjustLogicalPosition(logicalLeft, 0); |
1949 else | 1949 else |
1950 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); | 1950 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); |
1951 } | 1951 } |
1952 } | 1952 } |
1953 firstLine = false; | 1953 firstLine = false; |
1954 } | 1954 } |
1955 } | 1955 } |
1956 | 1956 |
1957 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject* newFloat, FloatingO
bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) | 1957 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject& newFloat, FloatingO
bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) |
1958 { | 1958 { |
1959 if (!positionNewFloats(&width)) | 1959 if (!positionNewFloats(&width)) |
1960 return false; | 1960 return false; |
1961 | 1961 |
1962 // We only connect floats to lines for pagination purposes if the floats occ
ur at the start of | 1962 // We only connect floats to lines for pagination purposes if the floats occ
ur at the start of |
1963 // the line and the previous line had a hard break (so this line is either t
he first in the block | 1963 // the line and the previous line had a hard break (so this line is either t
he first in the block |
1964 // or follows a <br>). | 1964 // or follows a <br>). |
1965 if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() ||
!lineInfo.isEmpty()) | 1965 if (!newFloat.paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !
lineInfo.isEmpty()) |
1966 return true; | 1966 return true; |
1967 | 1967 |
1968 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1968 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1969 ASSERT(floatingObjectSet.last() == newFloat); | 1969 ASSERT(floatingObjectSet.last() == &newFloat); |
1970 | 1970 |
1971 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); | 1971 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); |
1972 int paginationStrut = newFloat->paginationStrut(); | 1972 int paginationStrut = newFloat.paginationStrut(); |
1973 | 1973 |
1974 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag
inationStrut()) | 1974 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag
inationStrut()) |
1975 return true; | 1975 return true; |
1976 | 1976 |
1977 FloatingObjectSetIterator it = floatingObjectSet.end(); | 1977 FloatingObjectSetIterator it = floatingObjectSet.end(); |
1978 --it; // Last float is newFloat, skip that one. | 1978 --it; // Last float is newFloat, skip that one. |
1979 FloatingObjectSetIterator begin = floatingObjectSet.begin(); | 1979 FloatingObjectSetIterator begin = floatingObjectSet.begin(); |
1980 while (it != begin) { | 1980 while (it != begin) { |
1981 --it; | 1981 --it; |
1982 FloatingObject* floatingObject = it->get(); | 1982 FloatingObject& floatingObject = *it->get(); |
1983 if (floatingObject == lastFloatFromPreviousLine) | 1983 if (&floatingObject == lastFloatFromPreviousLine) |
1984 break; | 1984 break; |
1985 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo
atPaginationStrut()) { | 1985 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo
atPaginationStrut()) { |
1986 floatingObject->setPaginationStrut(paginationStrut + floatingObject-
>paginationStrut()); | 1986 floatingObject.setPaginationStrut(paginationStrut + floatingObject.p
aginationStrut()); |
1987 LayoutBox* floatBox = floatingObject->layoutObject(); | 1987 LayoutBox* floatBox = floatingObject.layoutObject(); |
1988 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar
ginBeforeForChild(*floatBox) + paginationStrut); | 1988 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar
ginBeforeForChild(*floatBox) + paginationStrut); |
1989 if (floatBox->isLayoutBlock()) | 1989 if (floatBox->isLayoutBlock()) |
1990 floatBox->forceChildLayout(); | 1990 floatBox->forceChildLayout(); |
1991 else | 1991 else |
1992 floatBox->layoutIfNeeded(); | 1992 floatBox->layoutIfNeeded(); |
1993 // Save the old logical top before calling removePlacedObject which
will set | 1993 // Save the old logical top before calling removePlacedObject which
will set |
1994 // isPlaced to false. Otherwise it will trigger an assert in logical
TopForFloat. | 1994 // isPlaced to false. Otherwise it will trigger an assert in logical
TopForFloat. |
1995 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject); | 1995 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject); |
1996 m_floatingObjects->removePlacedObject(floatingObject); | 1996 m_floatingObjects->removePlacedObject(floatingObject); |
1997 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru
t); | 1997 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru
t); |
(...skipping 19 matching lines...) Expand all Loading... |
2017 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2017 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
2018 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 2018 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
2019 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2019 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
2020 | 2020 |
2021 if (!style()->isLeftToRightDirection()) | 2021 if (!style()->isLeftToRightDirection()) |
2022 return logicalWidth() - logicalLeft; | 2022 return logicalWidth() - logicalLeft; |
2023 return logicalLeft; | 2023 return logicalLeft; |
2024 } | 2024 } |
2025 | 2025 |
2026 } | 2026 } |
OLD | NEW |