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

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

Issue 134473008: Remove CSS regions support, keeping a bare minimum to support "region-based" multicol. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/rendering/RenderBlockFlow.h" 32 #include "core/rendering/RenderBlockFlow.h"
33 33
34 #include "core/accessibility/AXObjectCache.h" 34 #include "core/accessibility/AXObjectCache.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/rendering/FastTextAutosizer.h" 36 #include "core/rendering/FastTextAutosizer.h"
37 #include "core/rendering/HitTestLocation.h" 37 #include "core/rendering/HitTestLocation.h"
38 #include "core/rendering/LayoutRectRecorder.h" 38 #include "core/rendering/LayoutRectRecorder.h"
39 #include "core/rendering/LayoutRepainter.h" 39 #include "core/rendering/LayoutRepainter.h"
40 #include "core/rendering/RenderFlowThread.h"
40 #include "core/rendering/RenderLayer.h" 41 #include "core/rendering/RenderLayer.h"
41 #include "core/rendering/RenderMultiColumnBlock.h" 42 #include "core/rendering/RenderMultiColumnBlock.h"
42 #include "core/rendering/RenderNamedFlowFragment.h"
43 #include "core/rendering/RenderNamedFlowThread.h"
44 #include "core/rendering/RenderText.h" 43 #include "core/rendering/RenderText.h"
45 #include "core/rendering/RenderView.h" 44 #include "core/rendering/RenderView.h"
46 #include "core/rendering/line/LineWidth.h" 45 #include "core/rendering/line/LineWidth.h"
47 #include "core/rendering/svg/SVGTextRunRenderingContext.h" 46 #include "core/rendering/svg/SVGTextRunRenderingContext.h"
48 #include "platform/text/BidiTextRun.h" 47 #include "platform/text/BidiTextRun.h"
49 48
50 using namespace std; 49 using namespace std;
51 50
52 namespace WebCore { 51 namespace WebCore {
53 52
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 RenderBlockFlow* RenderBlockFlow::createAnonymousBlockFlow() const 174 RenderBlockFlow* RenderBlockFlow::createAnonymousBlockFlow() const
176 { 175 {
177 return toRenderBlockFlow(createAnonymousWithParentRendererAndDisplay(this, B LOCK)); 176 return toRenderBlockFlow(createAnonymousWithParentRendererAndDisplay(this, B LOCK));
178 } 177 }
179 178
180 void RenderBlockFlow::willBeDestroyed() 179 void RenderBlockFlow::willBeDestroyed()
181 { 180 {
182 if (lineGridBox()) 181 if (lineGridBox())
183 lineGridBox()->destroy(); 182 lineGridBox()->destroy();
184 183
185 if (renderNamedFlowFragment())
186 setRenderNamedFlowFragment(0);
187
188 RenderBlock::willBeDestroyed(); 184 RenderBlock::willBeDestroyed();
189 } 185 }
190 186
191 void RenderBlockFlow::checkForPaginationLogicalHeightChange(LayoutUnit& pageLogi calHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight) 187 void RenderBlockFlow::checkForPaginationLogicalHeightChange(LayoutUnit& pageLogi calHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight)
192 { 188 {
193 ColumnInfo* colInfo = columnInfo(); 189 ColumnInfo* colInfo = columnInfo();
194 if (hasColumns()) { 190 if (hasColumns()) {
195 if (!pageLogicalHeight) { 191 if (!pageLogicalHeight) {
196 LayoutUnit oldLogicalHeight = logicalHeight(); 192 LayoutUnit oldLogicalHeight = logicalHeight();
197 setLogicalHeight(0); 193 setLogicalHeight(0);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 297
302 bool pageLogicalHeightChanged = false; 298 bool pageLogicalHeightChanged = false;
303 bool hasSpecifiedPageLogicalHeight = false; 299 bool hasSpecifiedPageLogicalHeight = false;
304 checkForPaginationLogicalHeightChange(pageLogicalHeight, pageLogicalHeightCh anged, hasSpecifiedPageLogicalHeight); 300 checkForPaginationLogicalHeightChange(pageLogicalHeight, pageLogicalHeightCh anged, hasSpecifiedPageLogicalHeight);
305 301
306 RenderView* renderView = view(); 302 RenderView* renderView = view();
307 LayoutStateMaintainer statePusher(renderView, this, locationOffset(), hasCol umns() || hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMo de(), pageLogicalHeight, pageLogicalHeightChanged, columnInfo()); 303 LayoutStateMaintainer statePusher(renderView, this, locationOffset(), hasCol umns() || hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMo de(), pageLogicalHeight, pageLogicalHeightChanged, columnInfo());
308 304
309 // Regions changing widths can force us to relayout our children. 305 // Regions changing widths can force us to relayout our children.
310 RenderFlowThread* flowThread = flowThreadContainingBlock(); 306 RenderFlowThread* flowThread = flowThreadContainingBlock();
311 if (logicalWidthChangedInRegions(flowThread))
312 relayoutChildren = true;
313 if (updateRegionsAndShapesLogicalSize(flowThread)) 307 if (updateRegionsAndShapesLogicalSize(flowThread))
314 relayoutChildren = true; 308 relayoutChildren = true;
315 if (!relayoutChildren && isRenderNamedFlowFragmentContainer())
316 relayoutChildren = true;
317 309
318 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track 310 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
319 // our current maximal positive and negative margins. These values are used when we 311 // our current maximal positive and negative margins. These values are used when we
320 // are collapsed with adjacent blocks, so for example, if you have block A a nd B 312 // are collapsed with adjacent blocks, so for example, if you have block A a nd B
321 // collapsing together, then you'd take the maximal positive margin from bot h A and B 313 // collapsing together, then you'd take the maximal positive margin from bot h A and B
322 // and subtract it from the maximal negative margin from both A and B to get the 314 // and subtract it from the maximal negative margin from both A and B to get the
323 // true collapsed margin. This algorithm is recursive, so when we finish lay out() 315 // true collapsed margin. This algorithm is recursive, so when we finish lay out()
324 // our block knows its current maximal positive/negative values. 316 // our block knows its current maximal positive/negative values.
325 // 317 //
326 // Start out by setting our margin values to our current margins. Table cell s have 318 // Start out by setting our margin values to our current margins. Table cell s have
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (shouldBreakAtLineToAvoidWidow()) { 378 if (shouldBreakAtLineToAvoidWidow()) {
387 statePusher.pop(); 379 statePusher.pop();
388 setEverHadLayout(true); 380 setEverHadLayout(true);
389 return false; 381 return false;
390 } 382 }
391 383
392 // Calculate our new height. 384 // Calculate our new height.
393 LayoutUnit oldHeight = logicalHeight(); 385 LayoutUnit oldHeight = logicalHeight();
394 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 386 LayoutUnit oldClientAfterEdge = clientLogicalBottom();
395 387
396 // Before updating the final size of the flow thread make sure a forced brea k is applied after the content.
397 // This ensures the size information is correctly computed for the last auto -height region receiving content.
398 if (isRenderFlowThread()) 388 if (isRenderFlowThread())
399 toRenderFlowThread(this)->applyBreakAfterContent(oldClientAfterEdge); 389 toRenderFlowThread(this)->applyBreakAfterContent(oldClientAfterEdge);
400 390
401 updateLogicalHeight(); 391 updateLogicalHeight();
402 LayoutUnit newHeight = logicalHeight(); 392 LayoutUnit newHeight = logicalHeight();
403 if (oldHeight != newHeight) { 393 if (oldHeight != newHeight) {
404 if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !child renInline()) { 394 if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !child renInline()) {
405 // One of our children's floats may have become an overhanging float for us. We need to look for it. 395 // One of our children's floats may have become an overhanging float for us. We need to look for it.
406 for (RenderObject* child = firstChild(); child; child = child->nextS ibling()) { 396 for (RenderObject* child = firstChild(); child; child = child->nextS ibling()) {
407 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowP ositioned()) { 397 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowP ositioned()) {
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 marginInfo.clearMargin(); 1113 marginInfo.clearMargin();
1124 } 1114 }
1125 1115
1126 if (marginInfo.margin()) 1116 if (marginInfo.margin())
1127 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); 1117 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child));
1128 } 1118 }
1129 1119
1130 // If margins would pull us past the top of the next page, then we need to p ull back and pretend like the margins 1120 // If margins would pull us past the top of the next page, then we need to p ull back and pretend like the margins
1131 // collapsed into the page edge. 1121 // collapsed into the page edge.
1132 LayoutState* layoutState = view()->layoutState(); 1122 LayoutState* layoutState = view()->layoutState();
1133 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTop > beforeCollapseLogicalTop 1123 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTop > beforeCollapseLogicalTop) {
1134 && hasNextPage(beforeCollapseLogicalTop)) {
1135 LayoutUnit oldLogicalTop = logicalTop; 1124 LayoutUnit oldLogicalTop = logicalTop;
1136 logicalTop = min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop )); 1125 logicalTop = min(logicalTop, nextPageLogicalTop(beforeCollapseLogicalTop ));
1137 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); 1126 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
1138 } 1127 }
1139 1128
1140 if (previousBlockFlow) { 1129 if (previousBlockFlow) {
1141 // If |child| is a self-collapsing block it may have collapsed into a pr evious sibling and although it hasn't reduced the height of the parent yet 1130 // If |child| is a self-collapsing block it may have collapsed into a pr evious sibling and although it hasn't reduced the height of the parent yet
1142 // any floats from the parent will now overhang. 1131 // any floats from the parent will now overhang.
1143 LayoutUnit oldLogicalHeight = logicalHeight(); 1132 LayoutUnit oldLogicalHeight = logicalHeight();
1144 setLogicalHeight(logicalTop); 1133 setLogicalHeight(logicalTop);
(...skipping 29 matching lines...) Expand all
1174 } 1163 }
1175 1164
1176 RenderLayer* childLayer = child->layer(); 1165 RenderLayer* childLayer = child->layer();
1177 if (childLayer->staticBlockPosition() != logicalTop) { 1166 if (childLayer->staticBlockPosition() != logicalTop) {
1178 childLayer->setStaticBlockPosition(logicalTop); 1167 childLayer->setStaticBlockPosition(logicalTop);
1179 if (hasStaticBlockPosition) 1168 if (hasStaticBlockPosition)
1180 child->setChildNeedsLayout(MarkOnlyThis); 1169 child->setChildNeedsLayout(MarkOnlyThis);
1181 } 1170 }
1182 } 1171 }
1183 1172
1184 LayoutUnit RenderBlockFlow::computeStartPositionDeltaForChildAvoidingFloats(cons t RenderBox* child, LayoutUnit childMarginStart, RenderRegion* region) 1173 LayoutUnit RenderBlockFlow::computeStartPositionDeltaForChildAvoidingFloats(cons t RenderBox* child, LayoutUnit childMarginStart)
1185 { 1174 {
1186 LayoutUnit startPosition = startOffsetForContent(region); 1175 LayoutUnit startPosition = startOffsetForContent();
1187 1176
1188 // Add in our start margin. 1177 // Add in our start margin.
1189 LayoutUnit oldPosition = startPosition + childMarginStart; 1178 LayoutUnit oldPosition = startPosition + childMarginStart;
1190 LayoutUnit newPosition = oldPosition; 1179 LayoutUnit newPosition = oldPosition;
1191 1180
1192 LayoutUnit blockOffset = logicalTopForChild(child); 1181 LayoutUnit blockOffset = logicalTopForChild(child);
1193 if (region) 1182 LayoutUnit startOff = startOffsetForLine(blockOffset, false, logicalHeightFo rChild(child));
1194 blockOffset = max(blockOffset, blockOffset + (region->logicalTopForFlowT hreadContent() - offsetFromLogicalTopOfFirstPage()));
1195
1196 LayoutUnit startOff = startOffsetForLineInRegion(blockOffset, false, region, logicalHeightForChild(child));
1197 1183
1198 if (style()->textAlign() != WEBKIT_CENTER && !child->style()->marginStartUsi ng(style()).isAuto()) { 1184 if (style()->textAlign() != WEBKIT_CENTER && !child->style()->marginStartUsi ng(style()).isAuto()) {
1199 if (childMarginStart < 0) 1185 if (childMarginStart < 0)
1200 startOff += childMarginStart; 1186 startOff += childMarginStart;
1201 newPosition = max(newPosition, startOff); // Let the float sit in the ch ild's margin if it can fit. 1187 newPosition = max(newPosition, startOff); // Let the float sit in the ch ild's margin if it can fit.
1202 } else if (startOff != startPosition) { 1188 } else if (startOff != startPosition) {
1203 newPosition = startOff + childMarginStart; 1189 newPosition = startOff + childMarginStart;
1204 } 1190 }
1205 1191
1206 return newPosition - oldPosition; 1192 return newPosition - oldPosition;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 } 1354 }
1369 1355
1370 // Collapse the result with our current margins. 1356 // Collapse the result with our current margins.
1371 if (!discardMarginBefore) 1357 if (!discardMarginBefore)
1372 logicalTopEstimate += max(marginInfo.positiveMargin(), positiveMargi nBefore) - max(marginInfo.negativeMargin(), negativeMarginBefore); 1358 logicalTopEstimate += max(marginInfo.positiveMargin(), positiveMargi nBefore) - max(marginInfo.negativeMargin(), negativeMarginBefore);
1373 } 1359 }
1374 1360
1375 // Adjust logicalTopEstimate down to the next page if the margins are so lar ge that we don't fit on the current 1361 // Adjust logicalTopEstimate down to the next page if the margins are so lar ge that we don't fit on the current
1376 // page. 1362 // page.
1377 LayoutState* layoutState = view()->layoutState(); 1363 LayoutState* layoutState = view()->layoutState();
1378 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTopEstimate > logicalHeight() 1364 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTopEstimate > logicalHeight())
1379 && hasNextPage(logicalHeight()))
1380 logicalTopEstimate = min(logicalTopEstimate, nextPageLogicalTop(logicalH eight())); 1365 logicalTopEstimate = min(logicalTopEstimate, nextPageLogicalTop(logicalH eight()));
1381 1366
1382 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); 1367 logicalTopEstimate += getClearDelta(child, logicalTopEstimate);
1383 1368
1384 estimateWithoutPagination = logicalTopEstimate; 1369 estimateWithoutPagination = logicalTopEstimate;
1385 1370
1386 if (layoutState->isPaginated()) { 1371 if (layoutState->isPaginated()) {
1387 // If the object has a page or column break value of "before", then we s hould shift to the top of the next page. 1372 // If the object has a page or column break value of "before", then we s hould shift to the top of the next page.
1388 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); 1373 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate);
1389 1374
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 return childStyle->marginBeforeCollapse() == MSEPARATE; 1553 return childStyle->marginBeforeCollapse() == MSEPARATE;
1569 1554
1570 // FIXME: See |mustDiscardMarginBeforeForChild| above. 1555 // FIXME: See |mustDiscardMarginBeforeForChild| above.
1571 return false; 1556 return false;
1572 } 1557 }
1573 1558
1574 LayoutUnit RenderBlockFlow::applyBeforeBreak(RenderBox* child, LayoutUnit logica lOffset) 1559 LayoutUnit RenderBlockFlow::applyBeforeBreak(RenderBox* child, LayoutUnit logica lOffset)
1575 { 1560 {
1576 // FIXME: Add page break checking here when we support printing. 1561 // FIXME: Add page break checking here when we support printing.
1577 RenderFlowThread* flowThread = flowThreadContainingBlock(); 1562 RenderFlowThread* flowThread = flowThreadContainingBlock();
1578 bool isInsideMulticolFlowThread = flowThread && !flowThread->isRenderNamedFl owThread(); 1563 bool isInsideMulticolFlowThread = flowThread;
1579 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns(); 1564 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns();
1580 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight; // FIXME: Once columns can print we have to check this. 1565 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight; // FIXME: Once columns can print we have to check this.
1581 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread() ;
1582 bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBe fore() == PBALWAYS) 1566 bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBe fore() == PBALWAYS)
1583 || (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS) 1567 || (checkPageBreaks && child->style()->pageBreakBefore() == PBALWAYS);
1584 || (checkRegionBreaks && child->style()->regionBreakBefore() == PBALWAYS ); 1568 if (checkBeforeAlways && inNormalFlow(child)) {
1585 if (checkBeforeAlways && inNormalFlow(child) && hasNextPage(logicalOffset, I ncludePageBoundary)) {
1586 if (checkColumnBreaks) { 1569 if (checkColumnBreaks) {
1587 if (isInsideMulticolFlowThread) 1570 if (isInsideMulticolFlowThread) {
1588 checkRegionBreaks = true; 1571 LayoutUnit offsetBreakAdjustment = 0;
1589 else 1572 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirst Page() + logicalOffset, child, true, &offsetBreakAdjustment))
1573 return logicalOffset + offsetBreakAdjustment;
1574 } else {
1590 view()->layoutState()->addForcedColumnBreak(child, logicalOffset ); 1575 view()->layoutState()->addForcedColumnBreak(child, logicalOffset );
1591 } 1576 }
1592 if (checkRegionBreaks) {
1593 LayoutUnit offsetBreakAdjustment = 0;
1594 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirstPage () + logicalOffset, child, true, &offsetBreakAdjustment))
1595 return logicalOffset + offsetBreakAdjustment;
1596 } 1577 }
1597 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); 1578 return nextPageLogicalTop(logicalOffset, IncludePageBoundary);
1598 } 1579 }
1599 return logicalOffset; 1580 return logicalOffset;
1600 } 1581 }
1601 1582
1602 LayoutUnit RenderBlockFlow::applyAfterBreak(RenderBox* child, LayoutUnit logical Offset, MarginInfo& marginInfo) 1583 LayoutUnit RenderBlockFlow::applyAfterBreak(RenderBox* child, LayoutUnit logical Offset, MarginInfo& marginInfo)
1603 { 1584 {
1604 // FIXME: Add page break checking here when we support printing. 1585 // FIXME: Add page break checking here when we support printing.
1605 RenderFlowThread* flowThread = flowThreadContainingBlock(); 1586 RenderFlowThread* flowThread = flowThreadContainingBlock();
1606 bool isInsideMulticolFlowThread = flowThread && !flowThread->isRenderNamedFl owThread(); 1587 bool isInsideMulticolFlowThread = flowThread;
1607 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns(); 1588 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns();
1608 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight; // FIXME: Once columns can print we have to check this. 1589 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo gicalHeight; // FIXME: Once columns can print we have to check this.
1609 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread() ;
1610 bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAft er() == PBALWAYS) 1590 bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAft er() == PBALWAYS)
1611 || (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS) 1591 || (checkPageBreaks && child->style()->pageBreakAfter() == PBALWAYS);
1612 || (checkRegionBreaks && child->style()->regionBreakAfter() == PBALWAYS) ; 1592 if (checkAfterAlways && inNormalFlow(child)) {
1613 if (checkAfterAlways && inNormalFlow(child) && hasNextPage(logicalOffset, In cludePageBoundary)) {
1614 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? Lay outUnit() : marginInfo.margin(); 1593 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? Lay outUnit() : marginInfo.margin();
1615 1594
1616 // So our margin doesn't participate in the next collapsing steps. 1595 // So our margin doesn't participate in the next collapsing steps.
1617 marginInfo.clearMargin(); 1596 marginInfo.clearMargin();
1618 1597
1619 if (checkColumnBreaks) { 1598 if (checkColumnBreaks) {
1620 if (isInsideMulticolFlowThread) 1599 if (isInsideMulticolFlowThread) {
1621 checkRegionBreaks = true; 1600 LayoutUnit offsetBreakAdjustment = 0;
1622 else 1601 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirst Page() + logicalOffset + marginOffset, child, false, &offsetBreakAdjustment))
1602 return logicalOffset + marginOffset + offsetBreakAdjustment;
1603 } else {
1623 view()->layoutState()->addForcedColumnBreak(child, logicalOffset ); 1604 view()->layoutState()->addForcedColumnBreak(child, logicalOffset );
1624 } 1605 }
1625 if (checkRegionBreaks) {
1626 LayoutUnit offsetBreakAdjustment = 0;
1627 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirstPage () + logicalOffset + marginOffset, child, false, &offsetBreakAdjustment))
1628 return logicalOffset + marginOffset + offsetBreakAdjustment;
1629 } 1606 }
1630 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); 1607 return nextPageLogicalTop(logicalOffset, IncludePageBoundary);
1631 } 1608 }
1632 return logicalOffset; 1609 return logicalOffset;
1633 } 1610 }
1634 1611
1635 void RenderBlockFlow::addOverflowFromFloats() 1612 void RenderBlockFlow::addOverflowFromFloats()
1636 { 1613 {
1637 if (!m_floatingObjects) 1614 if (!m_floatingObjects)
1638 return; 1615 return;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 logicalBottom = lowestFloatLogicalBottom(); 1724 logicalBottom = lowestFloatLogicalBottom();
1748 break; 1725 break;
1749 } 1726 }
1750 1727
1751 // We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default). 1728 // We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default).
1752 LayoutUnit result = clearSet ? max<LayoutUnit>(0, logicalBottom - logicalTop ) : LayoutUnit(); 1729 LayoutUnit result = clearSet ? max<LayoutUnit>(0, logicalBottom - logicalTop ) : LayoutUnit();
1753 if (!result && child->avoidsFloats()) { 1730 if (!result && child->avoidsFloats()) {
1754 LayoutUnit newLogicalTop = logicalTop; 1731 LayoutUnit newLogicalTop = logicalTop;
1755 while (true) { 1732 while (true) {
1756 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog icalWidthForLine(newLogicalTop, false, logicalHeightForChild(child)); 1733 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog icalWidthForLine(newLogicalTop, false, logicalHeightForChild(child));
1757 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi dthForContent(newLogicalTop)) 1734 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi dthForContent())
1758 return newLogicalTop - logicalTop; 1735 return newLogicalTop - logicalTop;
1759 1736
1760 RenderRegion* region = regionAtBlockOffset(logicalTopForChild(child) ); 1737 LayoutRect borderBox = child->borderBoxRect();
1761 LayoutRect borderBox = child->borderBoxRectInRegion(region, DoNotCac heRenderBoxRegionInfo);
1762 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height(); 1738 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height();
1763 1739
1764 // FIXME: None of this is right for perpendicular writing-mode child ren. 1740 // FIXME: None of this is right for perpendicular writing-mode child ren.
1765 LayoutUnit childOldLogicalWidth = child->logicalWidth(); 1741 LayoutUnit childOldLogicalWidth = child->logicalWidth();
1766 LayoutUnit childOldMarginLeft = child->marginLeft(); 1742 LayoutUnit childOldMarginLeft = child->marginLeft();
1767 LayoutUnit childOldMarginRight = child->marginRight(); 1743 LayoutUnit childOldMarginRight = child->marginRight();
1768 LayoutUnit childOldLogicalTop = child->logicalTop(); 1744 LayoutUnit childOldLogicalTop = child->logicalTop();
1769 1745
1770 child->setLogicalTop(newLogicalTop); 1746 child->setLogicalTop(newLogicalTop);
1771 child->updateLogicalWidth(); 1747 child->updateLogicalWidth();
1772 region = regionAtBlockOffset(logicalTopForChild(child)); 1748 borderBox = child->borderBoxRect();
1773 borderBox = child->borderBoxRectInRegion(region, DoNotCacheRenderBox RegionInfo);
1774 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height(); 1749 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height();
1775 1750
1776 child->setLogicalTop(childOldLogicalTop); 1751 child->setLogicalTop(childOldLogicalTop);
1777 child->setLogicalWidth(childOldLogicalWidth); 1752 child->setLogicalWidth(childOldLogicalWidth);
1778 child->setMarginLeft(childOldMarginLeft); 1753 child->setMarginLeft(childOldMarginLeft);
1779 child->setMarginRight(childOldMarginRight); 1754 child->setMarginRight(childOldMarginRight);
1780 1755
1781 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA tNewLogicalTopOffset) { 1756 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA tNewLogicalTopOffset) {
1782 // Even though we may not be moving, if the logical width did sh rink because of the presence of new floats, then 1757 // Even though we may not be moving, if the logical width did sh rink because of the presence of new floats, then
1783 // we need to force a relayout as though we shifted. This happen s because of the dynamic addition of overhanging floats 1758 // we need to force a relayout as though we shifted. This happen s because of the dynamic addition of overhanging floats
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 break; 1814 break;
1840 } 1815 }
1841 } 1816 }
1842 } 1817 }
1843 } 1818 }
1844 } 1819 }
1845 1820
1846 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); 1821 parentBlockFlow->markAllDescendantsWithFloatsForLayout();
1847 parentBlockFlow->markSiblingsWithFloatsForLayout(); 1822 parentBlockFlow->markSiblingsWithFloatsForLayout();
1848 } 1823 }
1849
1850 if (renderNamedFlowFragment())
1851 renderNamedFlowFragment()->setStyleForNamedFlowFragment(style());
1852 } 1824 }
1853 1825
1854 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop) 1826 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou tUnit logicalTop)
1855 { 1827 {
1856 if (child->style()->isOriginalDisplayInlineType()) 1828 if (child->style()->isOriginalDisplayInlineType())
1857 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false)); 1829 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor Line(logicalTop, false));
1858 else 1830 else
1859 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent (logicalTop)); 1831 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent ());
1860 } 1832 }
1861 1833
1862 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox* child, LayoutUn it blockOffset, LayoutUnit inlinePosition) 1834 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox* child, LayoutUn it blockOffset, LayoutUnit inlinePosition)
1863 { 1835 {
1864 if (flowThreadContainingBlock()) {
1865 // Shift the inline position to exclude the region offset.
1866 inlinePosition += startOffsetForContent() - startOffsetForContent(blockO ffset);
1867 }
1868 child->layer()->setStaticInlinePosition(inlinePosition); 1836 child->layer()->setStaticInlinePosition(inlinePosition);
1869 } 1837 }
1870 1838
1871 void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, boo l fullRemoveInsert) 1839 void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, boo l fullRemoveInsert)
1872 { 1840 {
1873 RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock); 1841 RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock);
1874 moveAllChildrenTo(toBlockFlow, fullRemoveInsert); 1842 moveAllChildrenTo(toBlockFlow, fullRemoveInsert);
1875 1843
1876 // When a portion of the render tree is being detached, anonymous blocks 1844 // When a portion of the render tree is being detached, anonymous blocks
1877 // will be combined as their children are deleted. In this process, the 1845 // will be combined as their children are deleted. In this process, the
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2169 // FIXME: Dynamic changes to the font or to the inline position need to resu lt in a deep relayout. 2137 // FIXME: Dynamic changes to the font or to the inline position need to resu lt in a deep relayout.
2170 // (https://bugs.webkit.org/show_bug.cgi?id=79944) 2138 // (https://bugs.webkit.org/show_bug.cgi?id=79944)
2171 float remainder = fmodf(fmodf(right + layoutOffset - lineGridOffset, maxChar Width), maxCharWidth); 2139 float remainder = fmodf(fmodf(right + layoutOffset - lineGridOffset, maxChar Width), maxCharWidth);
2172 right -= LayoutUnit::fromFloatCeil(remainder); 2140 right -= LayoutUnit::fromFloatCeil(remainder);
2173 return right; 2141 return right;
2174 } 2142 }
2175 2143
2176 LayoutPoint RenderBlockFlow::computeLogicalLocationForFloat(const FloatingObject * floatingObject, LayoutUnit logicalTopOffset) const 2144 LayoutPoint RenderBlockFlow::computeLogicalLocationForFloat(const FloatingObject * floatingObject, LayoutUnit logicalTopOffset) const
2177 { 2145 {
2178 RenderBox* childBox = floatingObject->renderer(); 2146 RenderBox* childBox = floatingObject->renderer();
2179 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset) ; // Constant part of left offset. 2147 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa rt of left offset.
2180 LayoutUnit logicalRightOffset; // Constant part of right offset. 2148 LayoutUnit logicalRightOffset; // Constant part of right offset.
2181 // FIXME Bug 102948: This only works for shape outside directly set on this block. 2149 // FIXME Bug 102948: This only works for shape outside directly set on this block.
2182 ShapeInsideInfo* shapeInsideInfo = this->layoutShapeInsideInfo(); 2150 ShapeInsideInfo* shapeInsideInfo = this->layoutShapeInsideInfo();
2183 // FIXME: Implement behavior for right floats. 2151 // FIXME: Implement behavior for right floats.
2184 if (shapeInsideInfo) { 2152 if (shapeInsideInfo) {
2185 LayoutSize floatLogicalSize = logicalSizeForFloat(floatingObject); 2153 LayoutSize floatLogicalSize = logicalSizeForFloat(floatingObject);
2186 // floatingObject's logicalSize doesn't contain the actual height at thi s point, so we need to calculate it 2154 // floatingObject's logicalSize doesn't contain the actual height at thi s point, so we need to calculate it
2187 floatLogicalSize.setHeight(logicalHeightForChild(childBox) + marginBefor eForChild(childBox) + marginAfterForChild(childBox)); 2155 floatLogicalSize.setHeight(logicalHeightForChild(childBox) + marginBefor eForChild(childBox) + marginAfterForChild(childBox));
2188 2156
2189 // FIXME: If the float doesn't fit in the shape we should push it under the content box 2157 // FIXME: If the float doesn't fit in the shape we should push it under the content box
2190 logicalTopOffset = shapeInsideInfo->computeFirstFitPositionForFloat(floa tLogicalSize); 2158 logicalTopOffset = shapeInsideInfo->computeFirstFitPositionForFloat(floa tLogicalSize);
2191 if (logicalHeight() > logicalTopOffset) 2159 if (logicalHeight() > logicalTopOffset)
2192 logicalTopOffset = logicalHeight(); 2160 logicalTopOffset = logicalHeight();
2193 2161
2194 SegmentList segments = shapeInsideInfo->computeSegmentsForLine(logicalTo pOffset, floatLogicalSize.height()); 2162 SegmentList segments = shapeInsideInfo->computeSegmentsForLine(logicalTo pOffset, floatLogicalSize.height());
2195 // FIXME: Add support for shapes with multiple segments. 2163 // FIXME: Add support for shapes with multiple segments.
2196 if (segments.size() == 1) { 2164 if (segments.size() == 1) {
2197 // The segment offsets are relative to the content box. 2165 // The segment offsets are relative to the content box.
2198 logicalRightOffset = logicalLeftOffset + segments[0].logicalRight; 2166 logicalRightOffset = logicalLeftOffset + segments[0].logicalRight;
2199 logicalLeftOffset += segments[0].logicalLeft; 2167 logicalLeftOffset += segments[0].logicalLeft;
2200 } 2168 }
2201 } else { 2169 } else {
2202 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffset); 2170 logicalRightOffset = logicalRightOffsetForContent();
2203 } 2171 }
2204 2172
2205 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log icalRightOffset - logicalLeftOffset); // The width we look for. 2173 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log icalRightOffset - logicalLeftOffset); // The width we look for.
2206 2174
2207 LayoutUnit floatLogicalLeft; 2175 LayoutUnit floatLogicalLeft;
2208 2176
2209 bool insideFlowThread = flowThreadContainingBlock(); 2177 bool insideFlowThread = flowThreadContainingBlock();
2210 2178
2211 if (childBox->style()->floating() == LeftFloat) { 2179 if (childBox->style()->floating() == LeftFloat) {
2212 LayoutUnit heightRemainingLeft = 1; 2180 LayoutUnit heightRemainingLeft = 1;
2213 LayoutUnit heightRemainingRight = 1; 2181 LayoutUnit heightRemainingRight = 1;
2214 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOffset , logicalLeftOffset, false, &heightRemainingLeft); 2182 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOffset , logicalLeftOffset, false, &heightRemainingLeft);
2215 while (logicalRightOffsetForPositioningFloat(logicalTopOffset, logicalRi ghtOffset, false, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth) { 2183 while (logicalRightOffsetForPositioningFloat(logicalTopOffset, logicalRi ghtOffset, false, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth) {
2216 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); 2184 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight);
2217 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOf fset, logicalLeftOffset, false, &heightRemainingLeft); 2185 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOf fset, logicalLeftOffset, false, &heightRemainingLeft);
2218 if (insideFlowThread) { 2186 if (insideFlowThread) {
2219 // Have to re-evaluate all of our offsets, since they may have c hanged. 2187 // Have to re-evaluate all of our offsets, since they may have c hanged.
2220 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset. 2188 logicalRightOffset = logicalRightOffsetForContent(); // Constant part of right offset.
2221 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset. 2189 logicalLeftOffset = logicalLeftOffsetForContent(); // Constant p art of left offset.
2222 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset); 2190 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset);
2223 } 2191 }
2224 } 2192 }
2225 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft() , floatLogicalLeft); 2193 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft() , floatLogicalLeft);
2226 } else { 2194 } else {
2227 LayoutUnit heightRemainingLeft = 1; 2195 LayoutUnit heightRemainingLeft = 1;
2228 LayoutUnit heightRemainingRight = 1; 2196 LayoutUnit heightRemainingRight = 1;
2229 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopOffse t, logicalRightOffset, false, &heightRemainingRight); 2197 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopOffse t, logicalRightOffset, false, &heightRemainingRight);
2230 while (floatLogicalLeft - logicalLeftOffsetForPositioningFloat(logicalTo pOffset, logicalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) { 2198 while (floatLogicalLeft - logicalLeftOffsetForPositioningFloat(logicalTo pOffset, logicalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) {
2231 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); 2199 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight);
2232 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopO ffset, logicalRightOffset, false, &heightRemainingRight); 2200 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopO ffset, logicalRightOffset, false, &heightRemainingRight);
2233 if (insideFlowThread) { 2201 if (insideFlowThread) {
2234 // Have to re-evaluate all of our offsets, since they may have c hanged. 2202 // Have to re-evaluate all of our offsets, since they may have c hanged.
2235 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs et); // Constant part of right offset. 2203 logicalRightOffset = logicalRightOffsetForContent(); // Constant part of right offset.
2236 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset ); // Constant part of left offset. 2204 logicalLeftOffset = logicalLeftOffsetForContent(); // Constant p art of left offset.
2237 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset); 2205 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo gicalRightOffset - logicalLeftOffset);
2238 } 2206 }
2239 } 2207 }
2240 // Use the original width of the float here, since the local variable 2208 // Use the original width of the float here, since the local variable
2241 // |floatLogicalWidth| was capped to the available line width. See 2209 // |floatLogicalWidth| was capped to the available line width. See
2242 // fast/block/float/clamped-right-float.html. 2210 // fast/block/float/clamped-right-float.html.
2243 floatLogicalLeft -= logicalWidthForFloat(floatingObject); 2211 floatLogicalLeft -= logicalWidthForFloat(floatingObject);
2244 } 2212 }
2245 2213
2246 return LayoutPoint(floatLogicalLeft, logicalTopOffset); 2214 return LayoutPoint(floatLogicalLeft, logicalTopOffset);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 return constructTextRun(context, font, string, style, 2790 return constructTextRun(context, font, string, style,
2823 determineDirectionality(string, hasStrongDirectionality), 2791 determineDirectionality(string, hasStrongDirectionality),
2824 expansion, flags); 2792 expansion, flags);
2825 } 2793 }
2826 2794
2827 RootInlineBox* RenderBlockFlow::createRootInlineBox() 2795 RootInlineBox* RenderBlockFlow::createRootInlineBox()
2828 { 2796 {
2829 return new RootInlineBox(this); 2797 return new RootInlineBox(this);
2830 } 2798 }
2831 2799
2832 void RenderBlockFlow::createRenderNamedFlowFragmentIfNeeded()
2833 {
2834 if (!RuntimeEnabledFeatures::cssRegionsEnabled()
2835 || renderNamedFlowFragment()
2836 || isRenderNamedFlowFragment())
2837 return;
2838
2839 RenderStyle* styleToUse = style();
2840 if (styleToUse->isDisplayRegionType() && styleToUse->hasFlowFrom() && docume nt().renderView()) {
2841 RenderNamedFlowFragment* flowFragment = RenderNamedFlowFragment::createA nonymous(&document());
2842 flowFragment->setStyleForNamedFlowFragment(styleToUse);
2843 setRenderNamedFlowFragment(flowFragment);
2844 addChild(flowFragment);
2845 }
2846 }
2847
2848 void RenderBlockFlow::insertedIntoTree()
2849 {
2850 RenderBlock::insertedIntoTree();
2851
2852 createRenderNamedFlowFragmentIfNeeded();
2853 }
2854
2855 bool RenderBlockFlow::canHaveChildren() const
2856 {
2857 return !renderNamedFlowFragment() ? RenderBlock::canHaveChildren() : renderN amedFlowFragment()->canHaveChildren();
2858 }
2859
2860 bool RenderBlockFlow::canHaveGeneratedChildren() const
2861 {
2862 return !renderNamedFlowFragment() ? RenderBlock::canHaveGeneratedChildren() : renderNamedFlowFragment()->canHaveGeneratedChildren();
2863 }
2864
2865 void RenderBlockFlow::updateLogicalHeight()
2866 {
2867 RenderBlock::updateLogicalHeight();
2868
2869 if (renderNamedFlowFragment())
2870 renderNamedFlowFragment()->setLogicalHeight(max<LayoutUnit>(0, logicalHe ight() - borderAndPaddingLogicalHeight()));
2871 }
2872
2873 void RenderBlockFlow::setRenderNamedFlowFragment(RenderNamedFlowFragment* flowFr agment)
2874 {
2875 RenderBlockFlow::RenderBlockFlowRareData& rareData = ensureRareData();
2876 if (rareData.m_renderNamedFlowFragment)
2877 rareData.m_renderNamedFlowFragment->destroy();
2878 rareData.m_renderNamedFlowFragment = flowFragment;
2879 }
2880
2881 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() 2800 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData()
2882 { 2801 {
2883 if (m_rareData) 2802 if (m_rareData)
2884 return *m_rareData; 2803 return *m_rareData;
2885 2804
2886 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2805 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2887 return *m_rareData; 2806 return *m_rareData;
2888 } 2807 }
2889 2808
2890 } // namespace WebCore 2809 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698