Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: Source/core/rendering/RenderBlockLineLayout.cpp

Issue 143323014: *** DO NOT LAND *** Attempt to understand Regions complexity Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.cpp ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 24
25 #include "core/rendering/FastTextAutosizer.h" 25 #include "core/rendering/FastTextAutosizer.h"
26 #include "core/rendering/LayoutRectRecorder.h" 26 #include "core/rendering/LayoutRectRecorder.h"
27 #include "core/rendering/RenderCounter.h" 27 #include "core/rendering/RenderCounter.h"
28 #include "core/rendering/RenderFlowThread.h"
29 #include "core/rendering/RenderLayer.h" 28 #include "core/rendering/RenderLayer.h"
30 #include "core/rendering/RenderListMarker.h" 29 #include "core/rendering/RenderListMarker.h"
31 #include "core/rendering/RenderRegion.h"
32 #include "core/rendering/RenderRubyRun.h" 30 #include "core/rendering/RenderRubyRun.h"
33 #include "core/rendering/RenderView.h" 31 #include "core/rendering/RenderView.h"
34 #include "core/rendering/TrailingFloatsRootInlineBox.h" 32 #include "core/rendering/TrailingFloatsRootInlineBox.h"
35 #include "core/rendering/VerticalPositionCache.h" 33 #include "core/rendering/VerticalPositionCache.h"
36 #include "core/rendering/line/BreakingContextInlineHeaders.h" 34 #include "core/rendering/line/BreakingContextInlineHeaders.h"
37 #include "core/rendering/line/LineLayoutState.h" 35 #include "core/rendering/line/LineLayoutState.h"
38 #include "core/rendering/svg/SVGRootInlineBox.h" 36 #include "core/rendering/svg/SVGRootInlineBox.h"
39 #include "platform/text/BidiResolver.h" 37 #include "platform/text/BidiResolver.h"
40 #include "wtf/RefCountedLeakCounter.h" 38 #include "wtf/RefCountedLeakCounter.h"
41 #include "wtf/StdLibExtras.h" 39 #include "wtf/StdLibExtras.h"
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 shapeInsideInfo->clearSegments(); 1095 shapeInsideInfo->clearSegments();
1098 if (logicalLineBottom <= shapeLogicalBottom || !shapeContainingBlockHeight | | isOverflowPositionedAlready) 1096 if (logicalLineBottom <= shapeLogicalBottom || !shapeContainingBlockHeight | | isOverflowPositionedAlready)
1099 return; 1097 return;
1100 1098
1101 LayoutUnit newLogicalHeight = block->logicalHeight() + (shapeContainingBlock Height - (lineTop + shapeInsideInfo->owner()->borderAndPaddingAfter())); 1099 LayoutUnit newLogicalHeight = block->logicalHeight() + (shapeContainingBlock Height - (lineTop + shapeInsideInfo->owner()->borderAndPaddingAfter()));
1102 block->setLogicalHeight(newLogicalHeight); 1100 block->setLogicalHeight(newLogicalHeight);
1103 } 1101 }
1104 1102
1105 void RenderBlockFlow::updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo*& sha peInsideInfo, const LayoutSize& logicalOffsetFromShapeContainer, LineLayoutState & layoutState) 1103 void RenderBlockFlow::updateShapeAndSegmentsForCurrentLine(ShapeInsideInfo*& sha peInsideInfo, const LayoutSize& logicalOffsetFromShapeContainer, LineLayoutState & layoutState)
1106 { 1104 {
1107 if (layoutState.flowThread())
1108 return updateShapeAndSegmentsForCurrentLineInFlowThread(shapeInsideInfo, layoutState);
1109
1110 if (!shapeInsideInfo) 1105 if (!shapeInsideInfo)
1111 return; 1106 return;
1112 1107
1113 LayoutUnit lineTop = logicalHeight() + logicalOffsetFromShapeContainer.heigh t(); 1108 LayoutUnit lineTop = logicalHeight() + logicalOffsetFromShapeContainer.heigh t();
1114 LayoutUnit lineLeft = logicalOffsetFromShapeContainer.width(); 1109 LayoutUnit lineLeft = logicalOffsetFromShapeContainer.width();
1115 LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine( ), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInterior LineBoxes); 1110 LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine( ), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInterior LineBoxes);
1116 1111
1117 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which case these segments may be incorrect. 1112 // FIXME: Bug 95361: It is possible for a line to grow beyond lineHeight, in which case these segments may be incorrect.
1118 shapeInsideInfo->updateSegmentsForLine(LayoutSize(lineLeft, lineTop), lineHe ight); 1113 shapeInsideInfo->updateSegmentsForLine(LayoutSize(lineLeft, lineTop), lineHe ight);
1119 1114
1120 pushShapeContentOverflowBelowTheContentBox(this, shapeInsideInfo, lineTop, l ineHeight); 1115 pushShapeContentOverflowBelowTheContentBox(this, shapeInsideInfo, lineTop, l ineHeight);
1121 } 1116 }
1122 1117
1123 void RenderBlockFlow::updateShapeAndSegmentsForCurrentLineInFlowThread(ShapeInsi deInfo*& shapeInsideInfo, LineLayoutState& layoutState)
1124 {
1125 ASSERT(layoutState.flowThread());
1126
1127 RenderRegion* currentRegion = regionAtBlockOffset(logicalHeight());
1128 if (!currentRegion || !currentRegion->logicalHeight())
1129 return;
1130
1131 shapeInsideInfo = currentRegion->shapeInsideInfo();
1132
1133 RenderRegion* nextRegion = 0;
1134 if (!currentRegion->isLastRegion()) {
1135 RenderRegionList regionList = layoutState.flowThread()->renderRegionList ();
1136 RenderRegionList::const_iterator it = regionList.find(currentRegion);
1137 nextRegion = *(++it);
1138 }
1139
1140 // We only want to deal regions with shapes, so we check if the next region has a shape
1141 if (!shapeInsideInfo && nextRegion && !nextRegion->shapeInsideInfo())
1142 return;
1143
1144 LayoutUnit lineHeight = this->lineHeight(layoutState.lineInfo().isFirstLine( ), isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInterior LineBoxes);
1145 LayoutUnit logicalLineTopInFlowThread = logicalHeight() + offsetFromLogicalT opOfFirstPage();
1146 LayoutUnit logicalLineBottomInFlowThread = logicalLineTopInFlowThread + line Height;
1147 LayoutUnit logicalRegionTopInFlowThread = currentRegion->logicalTopForFlowTh readContent();
1148 LayoutUnit logicalRegionBottomInFlowThread = logicalRegionTopInFlowThread + currentRegion->logicalHeight() - currentRegion->borderAndPaddingBefore() - curre ntRegion->borderAndPaddingAfter();
1149
1150 LayoutUnit shapeBottomInFlowThread = LayoutUnit::max();
1151 if (shapeInsideInfo)
1152 shapeBottomInFlowThread = shapeInsideInfo->shapeLogicalBottom() + curren tRegion->logicalTopForFlowThreadContent();
1153
1154 bool lineOverLapsWithShapeBottom = shapeBottomInFlowThread < logicalLineBott omInFlowThread;
1155 bool lineTopAdjustedIntoNextRegion = layoutState.adjustedLogicalLineTop() >= currentRegion->logicalHeight();
1156 bool lineOverLapsWithRegionBottom = logicalLineBottomInFlowThread > logicalR egionBottomInFlowThread || lineTopAdjustedIntoNextRegion;
1157 bool overFlowsToNextRegion = nextRegion && (lineOverLapsWithShapeBottom || l ineOverLapsWithRegionBottom);
1158
1159 // If the line is between two shapes/regions we position the line to the top of the next shape/region
1160 if (overFlowsToNextRegion) {
1161 ASSERT(currentRegion != nextRegion);
1162 LayoutUnit deltaToNextRegion = logicalRegionBottomInFlowThread - logical LineTopInFlowThread;
1163 setLogicalHeight(logicalHeight() + deltaToNextRegion);
1164
1165 currentRegion = nextRegion;
1166 shapeInsideInfo = currentRegion->shapeInsideInfo();
1167
1168 logicalLineTopInFlowThread = logicalHeight() + offsetFromLogicalTopOfFir stPage();
1169 logicalLineBottomInFlowThread = logicalLineTopInFlowThread + lineHeight;
1170 logicalRegionTopInFlowThread = currentRegion->logicalTopForFlowThreadCon tent();
1171 logicalRegionBottomInFlowThread = logicalRegionTopInFlowThread + current Region->logicalHeight() - currentRegion->borderAndPaddingBefore() - currentRegio n->borderAndPaddingAfter();
1172
1173 if (lineTopAdjustedIntoNextRegion)
1174 layoutState.setAdjustedLogicalLineTop(0);
1175 }
1176
1177 if (!shapeInsideInfo)
1178 return;
1179
1180 bool isFirstLineInRegion = logicalLineBottomInFlowThread <= (logicalRegionTo pInFlowThread + lineHeight);
1181 bool isFirstLineAdjusted = (logicalLineTopInFlowThread - logicalRegionTopInF lowThread) < (layoutState.adjustedLogicalLineTop() - currentRegion->borderAndPad dingBefore());
1182 // We position the first line to the top of the shape in the region or to th e previously adjusted position in the shape
1183 if (isFirstLineInRegion || isFirstLineAdjusted) {
1184 LayoutUnit shapeTopOffset = layoutState.adjustedLogicalLineTop();
1185 if (!shapeTopOffset && (shapeInsideInfo->shapeLogicalTop() > 0))
1186 shapeTopOffset = shapeInsideInfo->shapeLogicalTop();
1187
1188 LayoutUnit shapePositionInFlowThread = currentRegion->logicalTopForFlowT hreadContent() + shapeTopOffset;
1189 LayoutUnit shapeTopLineTopDelta = shapePositionInFlowThread - logicalLin eTopInFlowThread - currentRegion->borderAndPaddingBefore();
1190
1191 setLogicalHeight(logicalHeight() + shapeTopLineTopDelta);
1192 logicalLineTopInFlowThread += shapeTopLineTopDelta;
1193 layoutState.setAdjustedLogicalLineTop(0);
1194 }
1195
1196 LayoutUnit lineTop = logicalLineTopInFlowThread - currentRegion->logicalTopF orFlowThreadContent() + currentRegion->borderAndPaddingBefore();
1197 // FIXME: Shape inside on a region does not yet take into account its paddin g for nested flow blocks
1198 shapeInsideInfo->updateSegmentsForLine(LayoutSize(0, lineTop), lineHeight);
1199
1200 if (currentRegion->isLastRegion())
1201 pushShapeContentOverflowBelowTheContentBox(this, shapeInsideInfo, lineTo p, lineHeight);
1202 }
1203
1204 bool RenderBlockFlow::adjustLogicalLineTopAndLogicalHeightIfNeeded(ShapeInsideIn fo* shapeInsideInfo, LayoutUnit absoluteLogicalTop, LineLayoutState& layoutState , InlineBidiResolver& resolver, FloatingObject* lastFloatFromPreviousLine, Inlin eIterator& end, WordMeasurements& wordMeasurements) 1118 bool RenderBlockFlow::adjustLogicalLineTopAndLogicalHeightIfNeeded(ShapeInsideIn fo* shapeInsideInfo, LayoutUnit absoluteLogicalTop, LineLayoutState& layoutState , InlineBidiResolver& resolver, FloatingObject* lastFloatFromPreviousLine, Inlin eIterator& end, WordMeasurements& wordMeasurements)
1205 { 1119 {
1206 LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(shapeInsideInfo, re solver.position(), end, wordMeasurements); 1120 LayoutUnit adjustedLogicalLineTop = adjustLogicalLineTop(shapeInsideInfo, re solver.position(), end, wordMeasurements);
1207 1121
1208 if (shapeInsideInfo && containsFloats()) { 1122 if (shapeInsideInfo && containsFloats()) {
1209 lastFloatFromPreviousLine = m_floatingObjects->set().last(); 1123 lastFloatFromPreviousLine = m_floatingObjects->set().last();
1210 if (!wordMeasurements.size()) { 1124 if (!wordMeasurements.size()) {
1211 LayoutUnit floatLogicalTopOffset = shapeInsideInfo->computeFirstFitP ositionForFloat(logicalSizeForFloat(lastFloatFromPreviousLine)); 1125 LayoutUnit floatLogicalTopOffset = shapeInsideInfo->computeFirstFitP ositionForFloat(logicalSizeForFloat(lastFloatFromPreviousLine));
1212 if (logicalHeight() < floatLogicalTopOffset) 1126 if (logicalHeight() < floatLogicalTopOffset)
1213 adjustedLogicalLineTop = floatLogicalTopOffset; 1127 adjustedLogicalLineTop = floatLogicalTopOffset;
1214 } 1128 }
1215 } 1129 }
1216 1130
1217 if (!adjustedLogicalLineTop) 1131 if (!adjustedLogicalLineTop)
1218 return false; 1132 return false;
1219 1133
1220 LayoutUnit newLogicalHeight = adjustedLogicalLineTop - absoluteLogicalTop; 1134 LayoutUnit newLogicalHeight = adjustedLogicalLineTop - absoluteLogicalTop;
1221 1135
1222 if (layoutState.flowThread()) {
1223 layoutState.setAdjustedLogicalLineTop(adjustedLogicalLineTop);
1224 newLogicalHeight = logicalHeight();
1225 }
1226
1227 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), newLogicalHeight, l astFloatFromPreviousLine, resolver, end); 1136 end = restartLayoutRunsAndFloatsInRange(logicalHeight(), newLogicalHeight, l astFloatFromPreviousLine, resolver, end);
1228 return true; 1137 return true;
1229 } 1138 }
1230 1139
1231 void RenderBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, I nlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiSta tus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines) 1140 void RenderBlockFlow::layoutRunsAndFloatsInRange(LineLayoutState& layoutState, I nlineBidiResolver& resolver, const InlineIterator& cleanLineStart, const BidiSta tus& cleanLineBidiStatus, unsigned consecutiveHyphenatedLines)
1232 { 1141 {
1233 RenderStyle* styleToUse = style(); 1142 RenderStyle* styleToUse = style();
1234 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated (); 1143 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated ();
1235 LineMidpointState& lineMidpointState = resolver.midpointState(); 1144 LineMidpointState& lineMidpointState = resolver.midpointState();
1236 InlineIterator endOfLine = resolver.position(); 1145 InlineIterator endOfLine = resolver.position();
1237 bool checkForEndLineMatch = layoutState.endLine(); 1146 bool checkForEndLineMatch = layoutState.endLine();
1238 RenderTextInfo renderTextInfo; 1147 RenderTextInfo renderTextInfo;
1239 VerticalPositionCache verticalPositionCache; 1148 VerticalPositionCache verticalPositionCache;
1240 1149
1241 LineBreaker lineBreaker(this); 1150 LineBreaker lineBreaker(this);
1242 1151
1243 LayoutSize logicalOffsetFromShapeContainer; 1152 LayoutSize logicalOffsetFromShapeContainer;
1244 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo(); 1153 ShapeInsideInfo* shapeInsideInfo = layoutShapeInsideInfo();
1245 if (shapeInsideInfo) { 1154 if (shapeInsideInfo) {
1246 ASSERT(shapeInsideInfo->owner() == this || allowsShapeInsideInfoSharing( shapeInsideInfo->owner())); 1155 ASSERT(shapeInsideInfo->owner() == this || allowsShapeInsideInfoSharing( shapeInsideInfo->owner()));
1247 if (shapeInsideInfo != this->shapeInsideInfo()) { 1156 if (shapeInsideInfo != this->shapeInsideInfo()) {
1248 // FIXME Bug 100284: If subsequent LayoutStates are pushed, we will have to add 1157 // FIXME Bug 100284: If subsequent LayoutStates are pushed, we will have to add
1249 // their offsets from the original shape-inside container. 1158 // their offsets from the original shape-inside container.
1250 logicalOffsetFromShapeContainer = logicalOffsetFromShapeAncestorCont ainer(shapeInsideInfo->owner()); 1159 logicalOffsetFromShapeContainer = logicalOffsetFromShapeAncestorCont ainer(shapeInsideInfo->owner());
1251 } 1160 }
1252 // Begin layout at the logical top of our shape inside. 1161 // Begin layout at the logical top of our shape inside.
1253 if (logicalHeight() + logicalOffsetFromShapeContainer.height() < shapeIn sideInfo->shapeLogicalTop()) { 1162 if (logicalHeight() + logicalOffsetFromShapeContainer.height() < shapeIn sideInfo->shapeLogicalTop()) {
1254 LayoutUnit logicalHeight = shapeInsideInfo->shapeLogicalTop() - logi calOffsetFromShapeContainer.height(); 1163 LayoutUnit logicalHeight = shapeInsideInfo->shapeLogicalTop() - logi calOffsetFromShapeContainer.height();
1255 if (layoutState.flowThread())
1256 logicalHeight -= shapeInsideInfo->owner()->borderAndPaddingBefor e();
1257 setLogicalHeight(logicalHeight); 1164 setLogicalHeight(logicalHeight);
1258 } 1165 }
1259 } 1166 }
1260 1167
1261 while (!endOfLine.atEnd()) { 1168 while (!endOfLine.atEnd()) {
1262 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end? 1169 // FIXME: Is this check necessary before the first iteration or can it b e moved to the end?
1263 if (checkForEndLineMatch) { 1170 if (checkForEndLineMatch) {
1264 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus)); 1171 layoutState.setEndLineMatched(matchedEndLine(layoutState, resolver, cleanLineStart, cleanLineBidiStatus));
1265 if (layoutState.endLineMatched()) { 1172 if (layoutState.endLineMatched()) {
1266 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0); 1173 resolver.setPosition(InlineIterator(resolver.position().root(), 0, 0), 0);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 bidiRuns.deleteRuns(); 1237 bidiRuns.deleteRuns();
1331 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed). 1238 resolver.markCurrentRunEmpty(); // FIXME: This can probably be repla ced by an ASSERT (or just removed).
1332 1239
1333 if (lineBox) { 1240 if (lineBox) {
1334 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset() , resolver.status()); 1241 lineBox->setLineBreakInfo(endOfLine.object(), endOfLine.offset() , resolver.status());
1335 if (layoutState.usesRepaintBounds()) 1242 if (layoutState.usesRepaintBounds())
1336 layoutState.updateRepaintRangeFromBox(lineBox); 1243 layoutState.updateRepaintRangeFromBox(lineBox);
1337 1244
1338 if (paginated) { 1245 if (paginated) {
1339 LayoutUnit adjustment = 0; 1246 LayoutUnit adjustment = 0;
1340 adjustLinePositionForPagination(lineBox, adjustment, layoutS tate.flowThread()); 1247 adjustLinePositionForPagination(lineBox, adjustment);
1341 if (adjustment) { 1248 if (adjustment) {
1342 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o ldLogicalHeight, layoutState.lineInfo().isFirstLine()); 1249 LayoutUnit oldLineWidth = availableLogicalWidthForLine(o ldLogicalHeight, layoutState.lineInfo().isFirstLine());
1343 lineBox->adjustBlockDirectionPosition(adjustment); 1250 lineBox->adjustBlockDirectionPosition(adjustment);
1344 if (layoutState.usesRepaintBounds()) 1251 if (layoutState.usesRepaintBounds())
1345 layoutState.updateRepaintRangeFromBox(lineBox); 1252 layoutState.updateRepaintRangeFromBox(lineBox);
1346 1253
1347 if (availableLogicalWidthForLine(oldLogicalHeight + adju stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) { 1254 if (availableLogicalWidthForLine(oldLogicalHeight + adju stment, layoutState.lineInfo().isFirstLine()) != oldLineWidth) {
1348 // We have to delete this line, remove all floats th at got added, and let line layout re-run. 1255 // We have to delete this line, remove all floats th at got added, and let line layout re-run.
1349 lineBox->deleteLine(); 1256 lineBox->deleteLine();
1350 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, previousEndofLine); 1257 endOfLine = restartLayoutRunsAndFloatsInRange(oldLog icalHeight, oldLogicalHeight + adjustment, lastFloatFromPreviousLine, resolver, previousEndofLine);
1351 continue; 1258 continue;
1352 } 1259 }
1353 1260
1354 setLogicalHeight(lineBox->lineBottomWithLeading()); 1261 setLogicalHeight(lineBox->lineBottomWithLeading());
1355 } 1262 }
1356
1357 if (layoutState.flowThread())
1358 updateRegionForLine(lineBox);
1359 } 1263 }
1360 } 1264 }
1361 } 1265 }
1362 1266
1363 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i) 1267 for (size_t i = 0; i < lineBreaker.positionedObjects().size(); ++i)
1364 setStaticPositions(this, lineBreaker.positionedObjects()[i]); 1268 setStaticPositions(this, lineBreaker.positionedObjects()[i]);
1365 1269
1366 if (!layoutState.lineInfo().isEmpty()) { 1270 if (!layoutState.lineInfo().isEmpty()) {
1367 layoutState.lineInfo().setFirstLine(false); 1271 layoutState.lineInfo().setFirstLine(false);
1368 clearFloats(lineBreaker.clear()); 1272 clearFloats(lineBreaker.clear());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 { 1365 {
1462 if (layoutState.endLine()) { 1366 if (layoutState.endLine()) {
1463 if (layoutState.endLineMatched()) { 1367 if (layoutState.endLineMatched()) {
1464 bool paginated = view()->layoutState() && view()->layoutState()->isP aginated(); 1368 bool paginated = view()->layoutState() && view()->layoutState()->isP aginated();
1465 // Attach all the remaining lines, and then adjust their y-positions as needed. 1369 // Attach all the remaining lines, and then adjust their y-positions as needed.
1466 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ; 1370 LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop() ;
1467 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) { 1371 for (RootInlineBox* line = layoutState.endLine(); line; line = line- >nextRootBox()) {
1468 line->attachLine(); 1372 line->attachLine();
1469 if (paginated) { 1373 if (paginated) {
1470 delta -= line->paginationStrut(); 1374 delta -= line->paginationStrut();
1471 adjustLinePositionForPagination(line, delta, layoutState.flo wThread()); 1375 adjustLinePositionForPagination(line, delta);
1472 } 1376 }
1473 if (delta) { 1377 if (delta) {
1474 layoutState.updateRepaintRangeFromBox(line, delta); 1378 layoutState.updateRepaintRangeFromBox(line, delta);
1475 line->adjustBlockDirectionPosition(delta); 1379 line->adjustBlockDirectionPosition(delta);
1476 } 1380 }
1477 if (layoutState.flowThread())
1478 updateRegionForLine(line);
1479 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) { 1381 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) {
1480 Vector<RenderBox*>::iterator end = cleanLineFloats->end(); 1382 Vector<RenderBox*>::iterator end = cleanLineFloats->end();
1481 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin (); f != end; ++f) { 1383 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin (); f != end; ++f) {
1482 FloatingObject* floatingObject = insertFloatingObject(*f ); 1384 FloatingObject* floatingObject = insertFloatingObject(*f );
1483 ASSERT(!floatingObject->originatingLine()); 1385 ASSERT(!floatingObject->originatingLine());
1484 floatingObject->setOriginatingLine(line); 1386 floatingObject->setOriginatingLine(line);
1485 setLogicalHeight(logicalTopForChild(*f) - marginBeforeFo rChild(*f) + delta); 1387 setLogicalHeight(logicalTopForChild(*f) - marginBeforeFo rChild(*f) + delta);
1486 positionNewFloats(); 1388 positionNewFloats();
1487 } 1389 }
1488 } 1390 }
(...skipping 13 matching lines...) Expand all
1502 LayoutUnit bottomVisualOverflow = lastRootBox()->logicalBottomVisual Overflow(); 1404 LayoutUnit bottomVisualOverflow = lastRootBox()->logicalBottomVisual Overflow();
1503 LayoutUnit bottomLayoutOverflow = lastRootBox()->logicalBottomLayout Overflow(); 1405 LayoutUnit bottomLayoutOverflow = lastRootBox()->logicalBottomLayout Overflow();
1504 TrailingFloatsRootInlineBox* trailingFloatsLineBox = new TrailingFlo atsRootInlineBox(this); 1406 TrailingFloatsRootInlineBox* trailingFloatsLineBox = new TrailingFlo atsRootInlineBox(this);
1505 m_lineBoxes.appendLineBox(trailingFloatsLineBox); 1407 m_lineBoxes.appendLineBox(trailingFloatsLineBox);
1506 trailingFloatsLineBox->setConstructed(); 1408 trailingFloatsLineBox->setConstructed();
1507 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 1409 GlyphOverflowAndFallbackFontsMap textBoxDataMap;
1508 VerticalPositionCache verticalPositionCache; 1410 VerticalPositionCache verticalPositionCache;
1509 LayoutUnit blockLogicalHeight = logicalHeight(); 1411 LayoutUnit blockLogicalHeight = logicalHeight();
1510 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache); 1412 trailingFloatsLineBox->alignBoxesInBlockDirection(blockLogicalHeight , textBoxDataMap, verticalPositionCache);
1511 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight); 1413 trailingFloatsLineBox->setLineTopBottomPositions(blockLogicalHeight, blockLogicalHeight, blockLogicalHeight, blockLogicalHeight);
1512 trailingFloatsLineBox->setPaginatedLineWidth(availableLogicalWidthFo rContent(blockLogicalHeight)); 1414 trailingFloatsLineBox->setPaginatedLineWidth(availableLogicalWidthFo rContent());
1513 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight); 1415 LayoutRect logicalLayoutOverflow(0, blockLogicalHeight, 1, bottomLay outOverflow - blockLogicalHeight);
1514 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight); 1416 LayoutRect logicalVisualOverflow(0, blockLogicalHeight, 1, bottomVis ualOverflow - blockLogicalHeight);
1515 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom()); 1417 trailingFloatsLineBox->setOverflowFromLogicalRects(logicalLayoutOver flow, logicalVisualOverflow, trailingFloatsLineBox->lineTop(), trailingFloatsLin eBox->lineBottom());
1516 if (layoutState.flowThread())
1517 updateRegionForLine(trailingFloatsLineBox);
1518 } 1418 }
1519 1419
1520 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1420 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1521 FloatingObjectSetIterator it = floatingObjectSet.begin(); 1421 FloatingObjectSetIterator it = floatingObjectSet.begin();
1522 FloatingObjectSetIterator end = floatingObjectSet.end(); 1422 FloatingObjectSetIterator end = floatingObjectSet.end();
1523 if (layoutState.lastFloat()) { 1423 if (layoutState.lastFloat()) {
1524 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find (layoutState.lastFloat()); 1424 FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find (layoutState.lastFloat());
1525 ASSERT(lastFloatIterator != end); 1425 ASSERT(lastFloatIterator != end);
1526 ++lastFloatIterator; 1426 ++lastFloatIterator;
1527 it = lastFloatIterator; 1427 it = lastFloatIterator;
(...skipping 22 matching lines...) Expand all
1550 } 1450 }
1551 } 1451 }
1552 } 1452 }
1553 1453
1554 void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& re paintLogicalTop, LayoutUnit& repaintLogicalBottom, LayoutUnit afterEdge) 1454 void RenderBlockFlow::layoutInlineChildren(bool relayoutChildren, LayoutUnit& re paintLogicalTop, LayoutUnit& repaintLogicalBottom, LayoutUnit afterEdge)
1555 { 1455 {
1556 // Lay out our hypothetical grid line as though it occurs at the top of the block. 1456 // Lay out our hypothetical grid line as though it occurs at the top of the block.
1557 if (view()->layoutState() && view()->layoutState()->lineGrid() == this) 1457 if (view()->layoutState() && view()->layoutState()->lineGrid() == this)
1558 layoutLineGridBox(); 1458 layoutLineGridBox();
1559 1459
1560 RenderFlowThread* flowThread = flowThreadContainingBlock();
1561 bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread-> hasRegions();
1562
1563 // Figure out if we should clear out our line boxes. 1460 // Figure out if we should clear out our line boxes.
1564 // FIXME: Handle resize eventually! 1461 // FIXME: Handle resize eventually!
1565 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination; 1462 bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren ;
1566 LineLayoutState layoutState(isFullLayout, repaintLogicalTop, repaintLogicalB ottom, flowThread); 1463 LineLayoutState layoutState(isFullLayout, repaintLogicalTop, repaintLogicalB ottom);
1567 1464
1568 if (isFullLayout) 1465 if (isFullLayout)
1569 lineBoxes()->deleteLineBoxes(); 1466 lineBoxes()->deleteLineBoxes();
1570 1467
1571 // Text truncation kicks in in two cases: 1468 // Text truncation kicks in in two cases:
1572 // 1) If your overflow isn't visible and your text-overflow-mode isn't c lip. 1469 // 1) If your overflow isn't visible and your text-overflow-mode isn't c lip.
1573 // 2) If you're an anonymous block with a block parent that satisfies #1 that was created 1470 // 2) If you're an anonymous block with a block parent that satisfies #1 that was created
1574 // to accomodate a block that has inline and block children. This exc ludes parents where 1471 // to accomodate a block that has inline and block children. This exc ludes parents where
1575 // canCollapseAnonymousBlockChild is false, notabley flex items and g rid items. 1472 // canCollapseAnonymousBlockChild is false, notabley flex items and g rid items.
1576 // FIXME: CSS3 says that descendants that are clipped must also know how to truncate. This is insanely 1473 // FIXME: CSS3 says that descendants that are clipped must also know how to truncate. This is insanely
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 1588
1692 // FIXME: This entire float-checking block needs to be broken into a new fun ction. 1589 // FIXME: This entire float-checking block needs to be broken into a new fun ction.
1693 bool dirtiedByFloat = false; 1590 bool dirtiedByFloat = false;
1694 if (!layoutState.isFullLayout()) { 1591 if (!layoutState.isFullLayout()) {
1695 // Paginate all of the clean lines. 1592 // Paginate all of the clean lines.
1696 bool paginated = view()->layoutState() && view()->layoutState()->isPagin ated(); 1593 bool paginated = view()->layoutState() && view()->layoutState()->isPagin ated();
1697 LayoutUnit paginationDelta = 0; 1594 LayoutUnit paginationDelta = 0;
1698 size_t floatIndex = 0; 1595 size_t floatIndex = 0;
1699 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR ootBox()) { 1596 for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextR ootBox()) {
1700 if (paginated) { 1597 if (paginated) {
1701 if (lineWidthForPaginatedLineChanged(curr, 0, layoutState.flowTh read())) { 1598 if (lineWidthForPaginatedLineChanged(curr, 0)) {
1702 curr->markDirty(); 1599 curr->markDirty();
1703 break; 1600 break;
1704 } 1601 }
1705 paginationDelta -= curr->paginationStrut(); 1602 paginationDelta -= curr->paginationStrut();
1706 adjustLinePositionForPagination(curr, paginationDelta, layoutSta te.flowThread()); 1603 adjustLinePositionForPagination(curr, paginationDelta);
1707 if (paginationDelta) { 1604 if (paginationDelta) {
1708 if (containsFloats() || !layoutState.floats().isEmpty()) { 1605 if (containsFloats() || !layoutState.floats().isEmpty()) {
1709 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout. 1606 // FIXME: Do better eventually. For now if we ever shif t because of pagination and floats are present just go to a full layout.
1710 layoutState.markForFullLayout(); 1607 layoutState.markForFullLayout();
1711 break; 1608 break;
1712 } 1609 }
1713 1610
1714 layoutState.updateRepaintRangeFromBox(curr, paginationDelta) ; 1611 layoutState.updateRepaintRangeFromBox(curr, paginationDelta) ;
1715 curr->adjustBlockDirectionPosition(paginationDelta); 1612 curr->adjustBlockDirectionPosition(paginationDelta);
1716 } 1613 }
1717 if (layoutState.flowThread())
1718 updateRegionForLine(curr);
1719 } 1614 }
1720 1615
1721 // If a new float has been inserted before this line or before its l ast known float, just do a full layout. 1616 // If a new float has been inserted before this line or before its l ast known float, just do a full layout.
1722 bool encounteredNewFloat = false; 1617 bool encounteredNewFloat = false;
1723 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat); 1618 checkFloatsInCleanLine(curr, layoutState.floats(), floatIndex, encou nteredNewFloat, dirtiedByFloat);
1724 if (encounteredNewFloat) 1619 if (encounteredNewFloat)
1725 layoutState.markForFullLayout(); 1620 layoutState.markForFullLayout();
1726 1621
1727 if (dirtiedByFloat || layoutState.isFullLayout()) 1622 if (dirtiedByFloat || layoutState.isFullLayout())
1728 break; 1623 break;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 line->extractLine(); // Disconnect all line boxes from their render obje cts while preserving 1736 line->extractLine(); // Disconnect all line boxes from their render obje cts while preserving
1842 // their connections to one another. 1737 // their connections to one another.
1843 1738
1844 layoutState.setEndLine(last); 1739 layoutState.setEndLine(last);
1845 } 1740 }
1846 1741
1847 bool RenderBlockFlow::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutS tate) 1742 bool RenderBlockFlow::checkPaginationAndFloatsAtEndLine(LineLayoutState& layoutS tate)
1848 { 1743 {
1849 LayoutUnit lineDelta = logicalHeight() - layoutState.endLineLogicalTop(); 1744 LayoutUnit lineDelta = logicalHeight() - layoutState.endLineLogicalTop();
1850 1745
1851 bool paginated = view()->layoutState() && view()->layoutState()->isPaginated ();
1852 if (paginated && layoutState.flowThread()) {
1853 // Check all lines from here to the end, and see if the hypothetical new position for the lines will result
1854 // in a different available line width.
1855 for (RootInlineBox* lineBox = layoutState.endLine(); lineBox; lineBox = lineBox->nextRootBox()) {
1856 if (paginated) {
1857 // This isn't the real move we're going to do, so don't update t he line box's pagination
1858 // strut yet.
1859 LayoutUnit oldPaginationStrut = lineBox->paginationStrut();
1860 lineDelta -= oldPaginationStrut;
1861 adjustLinePositionForPagination(lineBox, lineDelta, layoutState. flowThread());
1862 lineBox->setPaginationStrut(oldPaginationStrut);
1863 }
1864 if (lineWidthForPaginatedLineChanged(lineBox, lineDelta, layoutState .flowThread()))
1865 return false;
1866 }
1867 }
1868
1869 if (!lineDelta || !m_floatingObjects) 1746 if (!lineDelta || !m_floatingObjects)
1870 return true; 1747 return true;
1871 1748
1872 // See if any floats end in the range along which we want to shift the lines vertically. 1749 // See if any floats end in the range along which we want to shift the lines vertically.
1873 LayoutUnit logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop() ); 1750 LayoutUnit logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop() );
1874 1751
1875 RootInlineBox* lastLine = layoutState.endLine(); 1752 RootInlineBox* lastLine = layoutState.endLine();
1876 while (RootInlineBox* nextLine = lastLine->nextRootBox()) 1753 while (RootInlineBox* nextLine = lastLine->nextRootBox())
1877 lastLine = nextLine; 1754 lastLine = nextLine;
1878 1755
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache); 2122 lineGridBox->alignBoxesInBlockDirection(logicalHeight(), textBoxDataMap, ver ticalPositionCache);
2246 2123
2247 setLineGridBox(lineGridBox); 2124 setLineGridBox(lineGridBox);
2248 2125
2249 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying 2126 // FIXME: If any of the characteristics of the box change compared to the ol d one, then we need to do a deep dirtying
2250 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping 2127 // (similar to what happens when the page height changes). Ideally, though, we only do this if someone is actually snapping
2251 // to this grid. 2128 // to this grid.
2252 } 2129 }
2253 2130
2254 } 2131 }
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.cpp ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698