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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 | 663 |
664 // Position is used to properly position both replaced elements and | 664 // Position is used to properly position both replaced elements and |
665 // to update the static normal flow x/y of positioned elements. | 665 // to update the static normal flow x/y of positioned elements. |
666 if (r->m_object->isText()) | 666 if (r->m_object->isText()) |
667 toLayoutText(r->m_object)->positionLineBox(r->m_box); | 667 toLayoutText(r->m_object)->positionLineBox(r->m_box); |
668 else if (r->m_object->isBox()) | 668 else if (r->m_object->isBox()) |
669 toLayoutBox(r->m_object)->positionLineBox(r->m_box); | 669 toLayoutBox(r->m_object)->positionLineBox(r->m_box); |
670 } | 670 } |
671 } | 671 } |
672 | 672 |
673 void LayoutBlockFlow::appendFloatingObjectToLastLine(FloatingObject* floatingObj ect) | 673 void LayoutBlockFlow::appendFloatingObjectToLastLine(FloatingObject& floatingObj ect) |
674 { | 674 { |
675 ASSERT(!floatingObject->originatingLine()); | 675 ASSERT(!floatingObject.originatingLine()); |
676 floatingObject->setOriginatingLine(lastRootBox()); | 676 floatingObject.setOriginatingLine(lastRootBox()); |
677 lastRootBox()->appendFloat(floatingObject->layoutObject()); | 677 lastRootBox()->appendFloat(floatingObject.layoutObject()); |
678 } | 678 } |
679 | 679 |
680 // This function constructs line boxes for all of the text runs in the resolver and computes their position. | 680 // This function constructs line boxes for all of the text runs in the resolver and computes their position. |
681 RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas urements& wordMeasurements) | 681 RootInlineBox* LayoutBlockFlow::createLineBoxesFromBidiRuns(unsigned bidiLevel, BidiRunList<BidiRun>& bidiRuns, const InlineIterator& end, LineInfo& lineInfo, V erticalPositionCache& verticalPositionCache, BidiRun* trailingSpaceRun, WordMeas urements& wordMeasurements) |
682 { | 682 { |
683 if (!bidiRuns.runCount()) | 683 if (!bidiRuns.runCount()) |
684 return 0; | 684 return 0; |
685 | 685 |
686 // FIXME: Why is this only done when we had runs? | 686 // FIXME: Why is this only done when we had runs? |
687 lineInfo.setLastLine(!end.object()); | 687 lineInfo.setLastLine(!end.object()); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 FloatingObjectSetIterator it = floatingObjectSet.begin(); | 907 FloatingObjectSetIterator it = floatingObjectSet.begin(); |
908 FloatingObjectSetIterator end = floatingObjectSet.end(); | 908 FloatingObjectSetIterator end = floatingObjectSet.end(); |
909 if (layoutState.lastFloat()) { | 909 if (layoutState.lastFloat()) { |
910 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat()); | 910 FloatingObjectSetIterator lastFloatIterator = floatingObject Set.find(layoutState.lastFloat()); |
911 ASSERT(lastFloatIterator != end); | 911 ASSERT(lastFloatIterator != end); |
912 ++lastFloatIterator; | 912 ++lastFloatIterator; |
913 it = lastFloatIterator; | 913 it = lastFloatIterator; |
914 } | 914 } |
915 for (; it != end; ++it) { | 915 for (; it != end; ++it) { |
916 FloatingObject* f = it->get(); | 916 FloatingObject* f = it->get(); |
917 appendFloatingObjectToLastLine(f); | 917 appendFloatingObjectToLastLine(*f); |
Julien - ping for review
2015/03/16 15:27:54
|f| should be a reference (and probably renamed to
Sunil Ratnu
2015/03/17 11:31:19
Done.
| |
918 ASSERT(f->layoutObject() == layoutState.floats()[layoutState .floatIndex()].object); | 918 ASSERT(f->layoutObject() == layoutState.floats()[layoutState .floatIndex()].object); |
919 // If a float's geometry has changed, give up on syncing wit h clean lines. | 919 // If a float's geometry has changed, give up on syncing wit h clean lines. |
920 if (layoutState.floats()[layoutState.floatIndex()].rect != f ->frameRect()) | 920 if (layoutState.floats()[layoutState.floatIndex()].rect != f ->frameRect()) |
921 checkForEndLineMatch = false; | 921 checkForEndLineMatch = false; |
922 layoutState.setFloatIndex(layoutState.floatIndex() + 1); | 922 layoutState.setFloatIndex(layoutState.floatIndex() + 1); |
923 } | 923 } |
924 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating ObjectSet.last().get() : 0); | 924 layoutState.setLastFloat(!floatingObjectSet.isEmpty() ? floating ObjectSet.last().get() : 0); |
925 } | 925 } |
926 } | 926 } |
927 | 927 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1055 VerticalPositionCache verticalPositionCache; | 1055 VerticalPositionCache verticalPositionCache; |
1056 LayoutUnit blockLogicalHeight = logicalHeight(); | 1056 LayoutUnit blockLogicalHeight = logicalHeight(); |
1057 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache); | 1057 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache); |
1058 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); | 1058 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); |
1059 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight); | 1059 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight); |
1060 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight); | 1060 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight); |
1061 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom()); | 1061 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom()); |
1062 } | 1062 } |
1063 | 1063 |
1064 for (; it != end; ++it) | 1064 for (; it != end; ++it) |
1065 appendFloatingObjectToLastLine(it->get()); | 1065 appendFloatingObjectToLastLine(it->getReference()); |
1066 } | 1066 } |
1067 } | 1067 } |
1068 | 1068 |
1069 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) | 1069 void LayoutBlockFlow::markDirtyFloatsForPaintInvalidation(Vector<FloatWithRect>& floats) |
1070 { | 1070 { |
1071 size_t floatCount = floats.size(); | 1071 size_t floatCount = floats.size(); |
1072 // Floats that did not have layout did not paint invalidations when we laid them out. They would have | 1072 // Floats that did not have layout did not paint invalidations when we laid them out. They would have |
1073 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be | 1073 // painted by now if they had moved, but if they stayed at (0, 0), they stil l need to be |
1074 // painted. | 1074 // painted. |
1075 for (size_t i = 0; i < floatCount; ++i) { | 1075 for (size_t i = 0; i < floatCount; ++i) { |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1840 | 1840 |
1841 RootInlineBox* lastLine = layoutState.endLine(); | 1841 RootInlineBox* lastLine = layoutState.endLine(); |
1842 while (RootInlineBox* nextLine = lastLine->nextRootBox()) | 1842 while (RootInlineBox* nextLine = lastLine->nextRootBox()) |
1843 lastLine = nextLine; | 1843 lastLine = nextLine; |
1844 | 1844 |
1845 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue (lineDelta); | 1845 LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue (lineDelta); |
1846 | 1846 |
1847 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 1847 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
1848 FloatingObjectSetIterator end = floatingObjectSet.end(); | 1848 FloatingObjectSetIterator end = floatingObjectSet.end(); |
1849 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { | 1849 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { |
1850 FloatingObject* floatingObject = it->get(); | 1850 FloatingObject& floatingObject = it->getReference(); |
1851 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom ForFloat(floatingObject) < logicalBottom) | 1851 if (logicalBottomForFloat(floatingObject) >= logicalTop && logicalBottom ForFloat(floatingObject) < logicalBottom) |
1852 return false; | 1852 return false; |
1853 } | 1853 } |
1854 | 1854 |
1855 return true; | 1855 return true; |
1856 } | 1856 } |
1857 | 1857 |
1858 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) | 1858 bool LayoutBlockFlow::matchedEndLine(LineLayoutState& layoutState, const InlineB idiResolver& resolver, const InlineIterator& endLineStart, const BidiStatus& end LineStatus) |
1859 { | 1859 { |
1860 if (resolver.position() == endLineStart) { | 1860 if (resolver.position() == endLineStart) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1997 | 1997 |
1998 // We only connect floats to lines for pagination purposes if the floats occ ur at the start of | 1998 // We only connect floats to lines for pagination purposes if the floats occ ur at the start of |
1999 // the line and the previous line had a hard break (so this line is either t he first in the block | 1999 // the line and the previous line had a hard break (so this line is either t he first in the block |
2000 // or follows a <br>). | 2000 // or follows a <br>). |
2001 if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty()) | 2001 if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty()) |
2002 return true; | 2002 return true; |
2003 | 2003 |
2004 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); | 2004 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); |
2005 ASSERT(floatingObjectSet.last() == newFloat); | 2005 ASSERT(floatingObjectSet.last() == newFloat); |
2006 | 2006 |
2007 LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat); | 2007 LayoutUnit floatLogicalTop = logicalTopForFloat(*newFloat); |
Julien - ping for review
2015/03/16 15:27:54
Again |newFloat| looks like it should be a referen
Sunil Ratnu
2015/03/17 11:31:19
Done.
| |
2008 int paginationStrut = newFloat->paginationStrut(); | 2008 int paginationStrut = newFloat->paginationStrut(); |
2009 | 2009 |
2010 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag inationStrut()) | 2010 if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPag inationStrut()) |
2011 return true; | 2011 return true; |
2012 | 2012 |
2013 FloatingObjectSetIterator it = floatingObjectSet.end(); | 2013 FloatingObjectSetIterator it = floatingObjectSet.end(); |
2014 --it; // Last float is newFloat, skip that one. | 2014 --it; // Last float is newFloat, skip that one. |
2015 FloatingObjectSetIterator begin = floatingObjectSet.begin(); | 2015 FloatingObjectSetIterator begin = floatingObjectSet.begin(); |
2016 while (it != begin) { | 2016 while (it != begin) { |
2017 --it; | 2017 --it; |
2018 FloatingObject* floatingObject = it->get(); | 2018 FloatingObject* floatingObject = it->get(); |
2019 if (floatingObject == lastFloatFromPreviousLine) | 2019 if (floatingObject == lastFloatFromPreviousLine) |
2020 break; | 2020 break; |
2021 if (logicalTopForFloat(floatingObject) == logicalHeight() + lineInfo.flo atPaginationStrut()) { | 2021 if (logicalTopForFloat(*floatingObject) == logicalHeight() + lineInfo.fl oatPaginationStrut()) { |
2022 floatingObject->setPaginationStrut(paginationStrut + floatingObject- >paginationStrut()); | 2022 floatingObject->setPaginationStrut(paginationStrut + floatingObject- >paginationStrut()); |
2023 LayoutBox* floatBox = floatingObject->layoutObject(); | 2023 LayoutBox* floatBox = floatingObject->layoutObject(); |
2024 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar ginBeforeForChild(*floatBox) + paginationStrut); | 2024 setLogicalTopForChild(*floatBox, logicalTopForChild(*floatBox) + mar ginBeforeForChild(*floatBox) + paginationStrut); |
2025 if (floatBox->isLayoutBlock()) | 2025 if (floatBox->isLayoutBlock()) |
2026 floatBox->forceChildLayout(); | 2026 floatBox->forceChildLayout(); |
2027 else | 2027 else |
2028 floatBox->layoutIfNeeded(); | 2028 floatBox->layoutIfNeeded(); |
2029 // Save the old logical top before calling removePlacedObject which will set | 2029 // Save the old logical top before calling removePlacedObject which will set |
2030 // isPlaced to false. Otherwise it will trigger an assert in logical TopForFloat. | 2030 // isPlaced to false. Otherwise it will trigger an assert in logical TopForFloat. |
2031 LayoutUnit oldLogicalTop = logicalTopForFloat(floatingObject); | 2031 LayoutUnit oldLogicalTop = logicalTopForFloat(*floatingObject); |
2032 m_floatingObjects->removePlacedObject(floatingObject); | 2032 m_floatingObjects->removePlacedObject(floatingObject); |
2033 setLogicalTopForFloat(floatingObject, oldLogicalTop + paginationStru t); | 2033 setLogicalTopForFloat(*floatingObject, oldLogicalTop + paginationStr ut); |
2034 m_floatingObjects->addPlacedObject(floatingObject); | 2034 m_floatingObjects->addPlacedObject(floatingObject); |
2035 } | 2035 } |
2036 } | 2036 } |
2037 | 2037 |
2038 // Just update the line info's pagination strut without altering our logical height yet. If the line ends up containing | 2038 // Just update the line info's pagination strut without altering our logical height yet. If the line ends up containing |
2039 // no content, then we don't want to improperly grow the height of the block . | 2039 // no content, then we don't want to improperly grow the height of the block . |
2040 lineInfo.setFloatPaginationStrut(lineInfo.floatPaginationStrut() + paginatio nStrut); | 2040 lineInfo.setFloatPaginationStrut(lineInfo.floatPaginationStrut() + paginatio nStrut); |
2041 return true; | 2041 return true; |
2042 } | 2042 } |
2043 | 2043 |
2044 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine) | 2044 LayoutUnit LayoutBlockFlow::startAlignedOffsetForLine(LayoutUnit position, bool firstLine) |
2045 { | 2045 { |
2046 ETextAlign textAlign = style()->textAlign(); | 2046 ETextAlign textAlign = style()->textAlign(); |
2047 | 2047 |
2048 if (textAlign == TASTART) // FIXME: Handle TAEND here | 2048 if (textAlign == TASTART) // FIXME: Handle TAEND here |
2049 return startOffsetForLine(position, firstLine); | 2049 return startOffsetForLine(position, firstLine); |
2050 | 2050 |
2051 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here | 2051 // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here |
2052 float totalLogicalWidth = 0; | 2052 float totalLogicalWidth = 0; |
2053 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); | 2053 float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), false).toFloat (); |
2054 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; | 2054 float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), fal se) - logicalLeft; |
2055 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); | 2055 updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWid th, availableLogicalWidth, 0); |
2056 | 2056 |
2057 if (!style()->isLeftToRightDirection()) | 2057 if (!style()->isLeftToRightDirection()) |
2058 return logicalWidth() - logicalLeft; | 2058 return logicalWidth() - logicalLeft; |
2059 return logicalLeft; | 2059 return logicalLeft; |
2060 } | 2060 } |
2061 | 2061 |
2062 } | 2062 } |
OLD | NEW |