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. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
4 * All right reserved. | 4 * All right reserved. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 } | 1069 } |
1070 | 1070 |
1071 void LayoutBlockFlow::layoutRunsAndFloatsInRange( | 1071 void LayoutBlockFlow::layoutRunsAndFloatsInRange( |
1072 LineLayoutState& layoutState, | 1072 LineLayoutState& layoutState, |
1073 InlineBidiResolver& resolver, | 1073 InlineBidiResolver& resolver, |
1074 const InlineIterator& cleanLineStart, | 1074 const InlineIterator& cleanLineStart, |
1075 const BidiStatus& cleanLineBidiStatus) { | 1075 const BidiStatus& cleanLineBidiStatus) { |
1076 const ComputedStyle& styleToUse = styleRef(); | 1076 const ComputedStyle& styleToUse = styleRef(); |
1077 bool paginated = | 1077 bool paginated = |
1078 view()->layoutState() && view()->layoutState()->isPaginated(); | 1078 view()->layoutState() && view()->layoutState()->isPaginated(); |
| 1079 bool recalculateStruts = layoutState.needsPaginationStrutRecalculation(); |
1079 LineMidpointState& lineMidpointState = resolver.midpointState(); | 1080 LineMidpointState& lineMidpointState = resolver.midpointState(); |
1080 InlineIterator endOfLine = resolver.position(); | 1081 InlineIterator endOfLine = resolver.position(); |
1081 LayoutTextInfo layoutTextInfo; | 1082 LayoutTextInfo layoutTextInfo; |
1082 VerticalPositionCache verticalPositionCache; | 1083 VerticalPositionCache verticalPositionCache; |
1083 | 1084 |
1084 // Pagination may require us to delete and re-create a line due to floats. | 1085 // Pagination may require us to delete and re-create a line due to floats. |
1085 // When this happens, | 1086 // When this happens, |
1086 // we need to store the pagination strut in the meantime. | 1087 // we need to store the pagination strut in the meantime. |
1087 LayoutUnit paginationStrutFromDeletedLine; | 1088 LayoutUnit paginationStrutFromDeletedLine; |
1088 | 1089 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced | 1184 resolver.markCurrentRunEmpty(); // FIXME: This can probably be replaced |
1184 // by an ASSERT (or just removed). | 1185 // by an ASSERT (or just removed). |
1185 | 1186 |
1186 // If we decided to re-create the line due to pagination, we better have a | 1187 // If we decided to re-create the line due to pagination, we better have a |
1187 // new line now. | 1188 // new line now. |
1188 ASSERT(lineBox || !paginationStrutFromDeletedLine); | 1189 ASSERT(lineBox || !paginationStrutFromDeletedLine); |
1189 | 1190 |
1190 if (lineBox) { | 1191 if (lineBox) { |
1191 lineBox->setLineBreakInfo(endOfLine.getLineLayoutItem(), | 1192 lineBox->setLineBreakInfo(endOfLine.getLineLayoutItem(), |
1192 endOfLine.offset(), resolver.status()); | 1193 endOfLine.offset(), resolver.status()); |
1193 if (paginated) { | 1194 if (recalculateStruts) { |
1194 if (paginationStrutFromDeletedLine) { | 1195 if (paginationStrutFromDeletedLine) { |
1195 // This is a line that got re-created because it got pushed to the | 1196 // This is a line that got re-created because it got pushed to the |
1196 // next fragmentainer, and there were floats in the vicinity that | 1197 // next fragmentainer, and there were floats in the vicinity that |
1197 // affected the available width. | 1198 // affected the available width. |
1198 // Restore the pagination info for this line. | 1199 // Restore the pagination info for this line. |
1199 lineBox->setIsFirstAfterPageBreak(true); | 1200 lineBox->setIsFirstAfterPageBreak(true); |
1200 lineBox->setPaginationStrut(paginationStrutFromDeletedLine); | 1201 lineBox->setPaginationStrut(paginationStrutFromDeletedLine); |
1201 paginationStrutFromDeletedLine = LayoutUnit(); | 1202 paginationStrutFromDeletedLine = LayoutUnit(); |
1202 } else { | 1203 } else { |
1203 LayoutUnit adjustment; | 1204 LayoutUnit adjustment; |
(...skipping 28 matching lines...) Expand all Loading... |
1232 } | 1233 } |
1233 } | 1234 } |
1234 } | 1235 } |
1235 } | 1236 } |
1236 } | 1237 } |
1237 } | 1238 } |
1238 | 1239 |
1239 if (!paginationStrutFromDeletedLine) { | 1240 if (!paginationStrutFromDeletedLine) { |
1240 for (const auto& positionedObject : lineBreaker.positionedObjects()) { | 1241 for (const auto& positionedObject : lineBreaker.positionedObjects()) { |
1241 if (positionedObject.style()->isOriginalDisplayInlineType()) { | 1242 if (positionedObject.style()->isOriginalDisplayInlineType()) { |
1242 // Auto-positioend "inline" out-of-flow objects have already been | 1243 // Auto-positioned "inline" out-of-flow objects have already been |
1243 // positioned, but if we're paginated, we need to update their | 1244 // positioned, but if we're paginated, or just ceased to be so, we |
1244 // position now, since the line they "belong" to may have been pushed | 1245 // need to update their position now, since the line they "belong" to |
1245 // by a pagination strut. | 1246 // may have been pushed by a pagination strut, or pulled back because |
1246 if (paginated && lineBox) | 1247 // a pagination strut was removed. |
| 1248 if (recalculateStruts && lineBox) |
1247 positionedObject.layer()->setStaticBlockPosition( | 1249 positionedObject.layer()->setStaticBlockPosition( |
1248 lineBox->lineTopWithLeading()); | 1250 lineBox->lineTopWithLeading()); |
1249 continue; | 1251 continue; |
1250 } | 1252 } |
1251 setStaticPositions(LineLayoutBlockFlow(this), positionedObject, | 1253 setStaticPositions(LineLayoutBlockFlow(this), positionedObject, |
1252 DoNotIndentText); | 1254 DoNotIndentText); |
1253 } | 1255 } |
1254 | 1256 |
1255 if (!layoutState.lineInfo().isEmpty()) | 1257 if (!layoutState.lineInfo().isEmpty()) |
1256 layoutState.lineInfo().setFirstLine(false); | 1258 layoutState.lineInfo().setFirstLine(false); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1339 lineBox->lineBottomWithLeading(), lineBox); | 1341 lineBox->lineBottomWithLeading(), lineBox); |
1340 } | 1342 } |
1341 } | 1343 } |
1342 | 1344 |
1343 clearDidBreakAtLineToAvoidWidow(); | 1345 clearDidBreakAtLineToAvoidWidow(); |
1344 } | 1346 } |
1345 | 1347 |
1346 void LayoutBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) { | 1348 void LayoutBlockFlow::linkToEndLineIfNeeded(LineLayoutState& layoutState) { |
1347 if (layoutState.endLine()) { | 1349 if (layoutState.endLine()) { |
1348 if (layoutState.endLineMatched()) { | 1350 if (layoutState.endLineMatched()) { |
1349 bool paginated = | 1351 bool recalculateStruts = layoutState.needsPaginationStrutRecalculation(); |
1350 view()->layoutState() && view()->layoutState()->isPaginated(); | |
1351 // Attach all the remaining lines, and then adjust their y-positions as | 1352 // Attach all the remaining lines, and then adjust their y-positions as |
1352 // needed. | 1353 // needed. |
1353 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop(); | 1354 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop(); |
1354 for (RootInlineBox* line = layoutState.endLine(); line; | 1355 for (RootInlineBox* line = layoutState.endLine(); line; |
1355 line = line->nextRootBox()) { | 1356 line = line->nextRootBox()) { |
1356 line->attachLine(); | 1357 line->attachLine(); |
1357 if (paginated) { | 1358 if (recalculateStruts) { |
1358 delta -= line->paginationStrut(); | 1359 delta -= line->paginationStrut(); |
1359 adjustLinePositionForPagination(*line, delta); | 1360 adjustLinePositionForPagination(*line, delta); |
1360 } | 1361 } |
1361 if (delta) | 1362 if (delta) |
1362 line->moveInBlockDirection(delta); | 1363 line->moveInBlockDirection(delta); |
1363 if (Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr()) { | 1364 if (Vector<LayoutBox*>* cleanLineFloats = line->floatsPtr()) { |
1364 for (auto* box : *cleanLineFloats) { | 1365 for (auto* box : *cleanLineFloats) { |
1365 FloatingObject* floatingObject = insertFloatingObject(*box); | 1366 FloatingObject* floatingObject = insertFloatingObject(*box); |
1366 ASSERT(!floatingObject->originatingLine()); | 1367 ASSERT(!floatingObject->originatingLine()); |
1367 floatingObject->setOriginatingLine(line); | 1368 floatingObject->setOriginatingLine(line); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 // Figure out if we should clear out our line boxes. | 1890 // Figure out if we should clear out our line boxes. |
1890 // FIXME: Handle resize eventually! | 1891 // FIXME: Handle resize eventually! |
1891 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren; | 1892 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren; |
1892 LineLayoutState layoutState(isFullLayout); | 1893 LineLayoutState layoutState(isFullLayout); |
1893 | 1894 |
1894 if (isFullLayout) { | 1895 if (isFullLayout) { |
1895 // Ensure the old line boxes will be erased. | 1896 // Ensure the old line boxes will be erased. |
1896 if (firstLineBox()) | 1897 if (firstLineBox()) |
1897 setShouldDoFullPaintInvalidation(); | 1898 setShouldDoFullPaintInvalidation(); |
1898 lineBoxes()->deleteLineBoxes(); | 1899 lineBoxes()->deleteLineBoxes(); |
| 1900 } else if (const LayoutState* boxState = view()->layoutState()) { |
| 1901 // We'll attempt to keep the line boxes that we have, but we may need to |
| 1902 // add, change or remove pagination struts in front of them. |
| 1903 if (boxState->isPaginated() || boxState->paginationStateChanged()) |
| 1904 layoutState.setNeedsPaginationStrutRecalculation(); |
1899 } | 1905 } |
1900 | 1906 |
1901 // Text truncation kicks in if overflow isn't visible and text-overflow isn't | 1907 // Text truncation kicks in if overflow isn't visible and text-overflow isn't |
1902 // 'clip'. If this is an anonymous block, we have to examine the parent. | 1908 // 'clip'. If this is an anonymous block, we have to examine the parent. |
1903 // FIXME: CSS3 says that descendants that are clipped must also know how to | 1909 // FIXME: CSS3 says that descendants that are clipped must also know how to |
1904 // truncate. This is insanely difficult to figure out in general (especially | 1910 // truncate. This is insanely difficult to figure out in general (especially |
1905 // in the middle of doing layout), so we only handle the simple case of an | 1911 // in the middle of doing layout), so we only handle the simple case of an |
1906 // anonymous block truncating when its parent is clipped. | 1912 // anonymous block truncating when its parent is clipped. |
1907 bool hasTextOverflow = shouldTruncateOverflowingText(this); | 1913 bool hasTextOverflow = shouldTruncateOverflowingText(this); |
1908 | 1914 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 LineLayoutState& layoutState, | 2004 LineLayoutState& layoutState, |
1999 InlineBidiResolver& resolver) { | 2005 InlineBidiResolver& resolver) { |
2000 RootInlineBox* curr = nullptr; | 2006 RootInlineBox* curr = nullptr; |
2001 RootInlineBox* last = nullptr; | 2007 RootInlineBox* last = nullptr; |
2002 RootInlineBox* firstLineBoxWithBreakAndClearance = 0; | 2008 RootInlineBox* firstLineBoxWithBreakAndClearance = 0; |
2003 | 2009 |
2004 // FIXME: This entire float-checking block needs to be broken into a new | 2010 // FIXME: This entire float-checking block needs to be broken into a new |
2005 // function. | 2011 // function. |
2006 if (!layoutState.isFullLayout()) { | 2012 if (!layoutState.isFullLayout()) { |
2007 // Paginate all of the clean lines. | 2013 // Paginate all of the clean lines. |
2008 bool paginated = | 2014 bool recalculateStruts = layoutState.needsPaginationStrutRecalculation(); |
2009 view()->layoutState() && view()->layoutState()->isPaginated(); | |
2010 LayoutUnit paginationDelta; | 2015 LayoutUnit paginationDelta; |
2011 for (curr = firstRootBox(); curr && !curr->isDirty(); | 2016 for (curr = firstRootBox(); curr && !curr->isDirty(); |
2012 curr = curr->nextRootBox()) { | 2017 curr = curr->nextRootBox()) { |
2013 if (paginated) { | 2018 if (recalculateStruts) { |
2014 paginationDelta -= curr->paginationStrut(); | 2019 paginationDelta -= curr->paginationStrut(); |
2015 adjustLinePositionForPagination(*curr, paginationDelta); | 2020 adjustLinePositionForPagination(*curr, paginationDelta); |
2016 if (paginationDelta) { | 2021 if (paginationDelta) { |
2017 if (containsFloats() || !layoutState.floats().isEmpty()) { | 2022 if (containsFloats() || !layoutState.floats().isEmpty()) { |
2018 // FIXME: Do better eventually. For now if we ever shift because of | 2023 // FIXME: Do better eventually. For now if we ever shift because of |
2019 // pagination and floats are present just go to a full layout. | 2024 // pagination and floats are present just go to a full layout. |
2020 layoutState.markForFullLayout(); | 2025 layoutState.markForFullLayout(); |
2021 break; | 2026 break; |
2022 } | 2027 } |
2023 curr->moveInBlockDirection(paginationDelta); | 2028 curr->moveInBlockDirection(paginationDelta); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2176 layoutState.setEndLine(last); | 2181 layoutState.setEndLine(last); |
2177 } | 2182 } |
2178 | 2183 |
2179 bool LayoutBlockFlow::checkPaginationAndFloatsAtEndLine( | 2184 bool LayoutBlockFlow::checkPaginationAndFloatsAtEndLine( |
2180 LineLayoutState& layoutState) { | 2185 LineLayoutState& layoutState) { |
2181 if (!m_floatingObjects || !layoutState.endLine()) | 2186 if (!m_floatingObjects || !layoutState.endLine()) |
2182 return true; | 2187 return true; |
2183 | 2188 |
2184 LayoutUnit lineDelta = logicalHeight() - layoutState.endLineLogicalTop(); | 2189 LayoutUnit lineDelta = logicalHeight() - layoutState.endLineLogicalTop(); |
2185 | 2190 |
2186 bool paginated = | 2191 if (layoutState.needsPaginationStrutRecalculation()) { |
2187 view()->layoutState() && view()->layoutState()->isPaginated(); | |
2188 if (paginated) { | |
2189 // Check all lines from here to the end, and see if the hypothetical new | 2192 // Check all lines from here to the end, and see if the hypothetical new |
2190 // position for the lines will result | 2193 // position for the lines will result |
2191 // in a different available line width. | 2194 // in a different available line width. |
2192 for (RootInlineBox* lineBox = layoutState.endLine(); lineBox; | 2195 for (RootInlineBox* lineBox = layoutState.endLine(); lineBox; |
2193 lineBox = lineBox->nextRootBox()) { | 2196 lineBox = lineBox->nextRootBox()) { |
2194 // This isn't the real move we're going to do, so don't update the line | 2197 // This isn't the real move we're going to do, so don't update the line |
2195 // box's pagination strut yet. | 2198 // box's pagination strut yet. |
2196 LayoutUnit oldPaginationStrut = lineBox->paginationStrut(); | 2199 LayoutUnit oldPaginationStrut = lineBox->paginationStrut(); |
2197 lineDelta -= oldPaginationStrut; | 2200 lineDelta -= oldPaginationStrut; |
2198 adjustLinePositionForPagination(*lineBox, lineDelta); | 2201 adjustLinePositionForPagination(*lineBox, lineDelta); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 | 2517 |
2515 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { | 2518 bool LayoutBlockFlow::paintedOutputOfObjectHasNoEffectRegardlessOfSize() const { |
2516 // LayoutBlockFlow is in charge of paint invalidation of the first line. | 2519 // LayoutBlockFlow is in charge of paint invalidation of the first line. |
2517 if (firstLineBox()) | 2520 if (firstLineBox()) |
2518 return false; | 2521 return false; |
2519 | 2522 |
2520 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 2523 return LayoutBlock::paintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
2521 } | 2524 } |
2522 | 2525 |
2523 } // namespace blink | 2526 } // namespace blink |
OLD | NEW |