| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 664 |
| 665 // Position is used to properly position both replaced elements and | 665 // Position is used to properly position both replaced elements and |
| 666 // to update the static normal flow x/y of positioned elements. | 666 // to update the static normal flow x/y of positioned elements. |
| 667 if (r->m_object->isText()) | 667 if (r->m_object->isText()) |
| 668 toLayoutText(r->m_object)->positionLineBox(r->m_box); | 668 toLayoutText(r->m_object)->positionLineBox(r->m_box); |
| 669 else if (r->m_object->isBox()) | 669 else if (r->m_object->isBox()) |
| 670 toLayoutBox(r->m_object)->positionLineBox(r->m_box); | 670 toLayoutBox(r->m_object)->positionLineBox(r->m_box); |
| 671 } | 671 } |
| 672 } | 672 } |
| 673 | 673 |
| 674 void LayoutBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj
ect) | 674 void LayoutBlockFlow::appendFloatingObjectToLastLine(FloatingObject& floatingObj
ect) |
| 675 { | 675 { |
| 676 ASSERT(!floatingObject->originatingLine()); | 676 ASSERT(!floatingObject.originatingLine()); |
| 677 floatingObject->setOriginatingLine(lastRootBox()); | 677 floatingObject.setOriginatingLine(lastRootBox()); |
| 678 lastRootBox()->appendFloat(floatingObject->layoutObject()); | 678 lastRootBox()->appendFloat(floatingObject.layoutObject()); |
| 679 } | 679 } |
| 680 | 680 |
| 681 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. | 681 // This function constructs line boxes for all of the text runs in the resolver
and computes their position. |
| 682 RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) | 682 RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel,
BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V
erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas
urements& wordMeasurements) |
| 683 { | 683 { |
| 684 if (!bidiRuns.runCount()) | 684 if (!bidiRuns.runCount()) |
| 685 return 0; | 685 return 0; |
| 686 | 686 |
| 687 // FIXME: Why is this only done when we had runs? | 687 // FIXME: Why is this only done when we had runs? |
| 688 lineInfo.setLastLine(!end.object()); | 688 lineInfo.setLastLine(!end.object()); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 FloatingObjectSetIterator end = floatingObjectSet.end(); | 983 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 984 if (layoutState.lastFloat()) { | 984 if (layoutState.lastFloat()) { |
| 985 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lay
outState.lastFloat()); | 985 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lay
outState.lastFloat()); |
| 986 ASSERT(lastFloatIterator != end); | 986 ASSERT(lastFloatIterator != end); |
| 987 ++lastFloatIterator; | 987 ++lastFloatIterator; |
| 988 it = lastFloatIterator; | 988 it = lastFloatIterator; |
| 989 } | 989 } |
| 990 | 990 |
| 991 bool floatChangedSize = false; | 991 bool floatChangedSize = false; |
| 992 for (; it != end; ++it) { | 992 for (; it != end; ++it) { |
| 993 FloatingObject* f = it->get(); | 993 FloatingObject& floatingObject = *it->get(); |
| 994 appendFloatingObjectToLastLine(f); | 994 appendFloatingObjectToLastLine(floatingObject); |
| 995 if (updateFloatIndex) { | 995 if (updateFloatIndex) { |
| 996 ASSERT(f->layoutObject() == layoutState.floats()[layoutState.floatIn
dex()].object); | 996 ASSERT(floatingObject.layoutObject() == layoutState.floats()[layoutS
tate.floatIndex()].object); |
| 997 // If a float's geometry has changed, give up on syncing with clean
lines. | 997 // If a float's geometry has changed, give up on syncing with clean
lines. |
| 998 if (layoutState.floats()[layoutState.floatIndex()].rect != f->frameR
ect()) | 998 if (layoutState.floats()[layoutState.floatIndex()].rect != floatingO
bject.frameRect()) |
| 999 floatChangedSize = true; | 999 floatChangedSize = true; |
| 1000 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | 1000 layoutState.setFloatIndex(layoutState.floatIndex() + 1); |
| 1001 } | 1001 } |
| 1002 } | 1002 } |
| 1003 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSet.la
st().get() : 0); | 1003 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floatingObjectSet.la
st().get() : 0); |
| 1004 return floatChangedSize; | 1004 return floatChangedSize; |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 void LayoutBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) | 1007 void LayoutBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) |
| 1008 { | 1008 { |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1809 | 1809 |
| 1810 RootInlineBox* lastLine = layoutState.endLine(); | 1810 RootInlineBox* lastLine = layoutState.endLine(); |
| 1811 while (RootInlineBox* nextLine = lastLine->nextRootBox()) | 1811 while (RootInlineBox* nextLine = lastLine->nextRootBox()) |
| 1812 lastLine = nextLine; | 1812 lastLine = nextLine; |
| 1813 | 1813 |
| 1814 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue
(lineDelta); | 1814 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue
(lineDelta); |
| 1815 | 1815 |
| 1816 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1816 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
| 1817 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1817 FloatingObjectSetIterator end = floatingObjectSet.end(); |
| 1818 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { | 1818 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++
it) { |
| 1819 FloatingObject* floatingObject = it->get(); | 1819 const FloatingObject& floatingObject = *it->get(); |
| 1820 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom
ForFloat(floatingObject) < logicalBottom) | 1820 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom
ForFloat(floatingObject) < logicalBottom) |
| 1821 return false; | 1821 return false; |
| 1822 } | 1822 } |
| 1823 | 1823 |
| 1824 return true; | 1824 return true; |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB
idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end
LineStatus) | 1827 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB
idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end
LineStatus) |
| 1828 { | 1828 { |
| 1829 if (resolver.position() == endLineStart) { | 1829 if (resolver.position() == endLineStart) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 if (ltr) | 1958 if (ltr) |
| 1959 curr->adjustLogicalPosition(logicalLeft, 0); | 1959 curr->adjustLogicalPosition(logicalLeft, 0); |
| 1960 else | 1960 else |
| 1961 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); | 1961 curr->adjustLogicalPosition(logicalLeft - (availableLogicalW
idth - totalLogicalWidth), 0); |
| 1962 } | 1962 } |
| 1963 } | 1963 } |
| 1964 firstLine = false; | 1964 firstLine = false; |
| 1965 } | 1965 } |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject* newFloat, FloatingO
bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) | 1968 bool LayoutBlockFlow::positionNewFloatOnLine(FloatingObject& newFloat, FloatingO
bject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width) |
| 1969 { | 1969 { |
| 1970 if (!positionNewFloats(&width)) | 1970 if (!positionNewFloats(&width)) |
| 1971 return false; | 1971 return false; |
| 1972 | 1972 |
| 1973 // We only connect floats to lines for pagination purposes if the floats occ
ur at the start of | 1973 // We only connect floats to lines for pagination purposes if the floats occ
ur at the start of |
| 1974 // the line and the previous line had a hard break (so this line is either t
he first in the block | 1974 // the line and the previous line had a hard break (so this line is either t
he first in the block |
| 1975 // or follows a <br>). | 1975 // or follows a <br>). |
| 1976 if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() ||
!lineInfo.isEmpty()) | 1976 if (!newFloat.paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !
lineInfo.isEmpty()) |
| 1977 return true; | 1977 return true; |
| 1978 | 1978 |
| 1979 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1979 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
| 1980 ASSERT(floatingObjectSet.last() == newFloat); | 1980 ASSERT(floatingObjectSet.last() == &newFloat); |
| 1981 | 1981 |
| 1982 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); | 1982 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); |
| 1983 int paginationStrut = newFloat->paginationStrut(); | 1983 int paginationStrut = newFloat.paginationStrut(); |
| 1984 | 1984 |
| 1985 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag
inationStrut()) | 1985 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag
inationStrut()) |
| 1986 return true; | 1986 return true; |
| 1987 | 1987 |
| 1988 FloatingObjectSetIterator it = floatingObjectSet.end(); | 1988 FloatingObjectSetIterator it = floatingObjectSet.end(); |
| 1989 --it; // Last float is newFloat, skip that one. | 1989 --it; // Last float is newFloat, skip that one. |
| 1990 FloatingObjectSetIterator begin = floatingObjectSet.begin(); | 1990 FloatingObjectSetIterator begin = floatingObjectSet.begin(); |
| 1991 while (it != begin) { | 1991 while (it != begin) { |
| 1992 --it; | 1992 --it; |
| 1993 FloatingObject* floatingObject = it->get(); | 1993 FloatingObject& floatingObject = *it->get(); |
| 1994 if (floatingObject == lastFloatFromPreviousLine) | 1994 if (&floatingObject == lastFloatFromPreviousLine) |
| 1995 break; | 1995 break; |
| 1996 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo
atPaginationStrut()) { | 1996 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo
atPaginationStrut()) { |
| 1997 floatingObject->setPaginationStrut(paginationStrut + floatingObject-
>paginationStrut()); | 1997 floatingObject.setPaginationStrut(paginationStrut + floatingObject.p
aginationStrut()); |
| 1998 LayoutBox* floatBox = floatingObject->layoutObject(); | 1998 LayoutBox* floatBox = floatingObject.layoutObject(); |
| 1999 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar
ginBeforeForChild(*floatBox) + paginationStrut); | 1999 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar
ginBeforeForChild(*floatBox) + paginationStrut); |
| 2000 if (floatBox->isLayoutBlock()) | 2000 if (floatBox->isLayoutBlock()) |
| 2001 floatBox->forceChildLayout(); | 2001 floatBox->forceChildLayout(); |
| 2002 else | 2002 else |
| 2003 floatBox->layoutIfNeeded(); | 2003 floatBox->layoutIfNeeded(); |
| 2004 // Save the old logical top before calling removePlacedObject which
will set | 2004 // Save the old logical top before calling removePlacedObject which
will set |
| 2005 // isPlaced to false. Otherwise it will trigger an assert in logical
TopForFloat. | 2005 // isPlaced to false. Otherwise it will trigger an assert in logical
TopForFloat. |
| 2006 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject); | 2006 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject); |
| 2007 m_floatingObjects->removePlacedObject(floatingObject); | 2007 m_floatingObjects->removePlacedObject(floatingObject); |
| 2008 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru
t); | 2008 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru
t); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2028 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); | 2028 LayoutUnit logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false); |
| 2029 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; | 2029 LayoutUnit availableLogicalWidth = logicalRightOffsetForLine(logicalHeight()
, false) - logicalLeft; |
| 2030 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); | 2030 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid
th, availableLogicalWidth, 0); |
| 2031 | 2031 |
| 2032 if (!style()->isLeftToRightDirection()) | 2032 if (!style()->isLeftToRightDirection()) |
| 2033 return logicalWidth() - logicalLeft; | 2033 return logicalWidth() - logicalLeft; |
| 2034 return logicalLeft; | 2034 return logicalLeft; |
| 2035 } | 2035 } |
| 2036 | 2036 |
| 2037 } | 2037 } |
| OLD | NEW |