| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 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/RenderLayer.h" | 40 #include "core/rendering/RenderLayer.h" |
| 41 #include "core/rendering/RenderNamedFlowFragment.h" | |
| 42 #include "core/rendering/RenderNamedFlowThread.h" | |
| 43 #include "core/rendering/RenderText.h" | 41 #include "core/rendering/RenderText.h" |
| 44 #include "core/rendering/RenderView.h" | 42 #include "core/rendering/RenderView.h" |
| 45 #include "core/rendering/line/LineWidth.h" | 43 #include "core/rendering/line/LineWidth.h" |
| 46 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 44 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
| 47 #include "platform/text/BidiTextRun.h" | 45 #include "platform/text/BidiTextRun.h" |
| 48 | 46 |
| 49 using namespace std; | 47 using namespace std; |
| 50 | 48 |
| 51 namespace WebCore { | 49 namespace WebCore { |
| 52 | 50 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 LayoutUnit positiveMargin() const { return m_positiveMargin; } | 136 LayoutUnit positiveMargin() const { return m_positiveMargin; } |
| 139 LayoutUnit negativeMargin() const { return m_negativeMargin; } | 137 LayoutUnit negativeMargin() const { return m_negativeMargin; } |
| 140 bool discardMargin() const { return m_discardMargin; } | 138 bool discardMargin() const { return m_discardMargin; } |
| 141 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } | 139 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } |
| 142 }; | 140 }; |
| 143 static bool inNormalFlow(RenderBox* child) | 141 static bool inNormalFlow(RenderBox* child) |
| 144 { | 142 { |
| 145 RenderBlock* curr = child->containingBlock(); | 143 RenderBlock* curr = child->containingBlock(); |
| 146 RenderView* renderView = child->view(); | 144 RenderView* renderView = child->view(); |
| 147 while (curr && curr != renderView) { | 145 while (curr && curr != renderView) { |
| 148 if (curr->hasColumns() || curr->isRenderFlowThread()) | 146 if (curr->hasColumns()) |
| 149 return true; | 147 return true; |
| 150 if (curr->isFloatingOrOutOfFlowPositioned()) | 148 if (curr->isFloatingOrOutOfFlowPositioned()) |
| 151 return false; | 149 return false; |
| 152 curr = curr->containingBlock(); | 150 curr = curr->containingBlock(); |
| 153 } | 151 } |
| 154 return true; | 152 return true; |
| 155 } | 153 } |
| 156 | 154 |
| 157 RenderBlockFlow::RenderBlockFlow(ContainerNode* node) | 155 RenderBlockFlow::RenderBlockFlow(ContainerNode* node) |
| 158 : RenderBlock(node) | 156 : RenderBlock(node) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 174 RenderBlockFlow* RenderBlockFlow::createAnonymousBlockFlow() const | 172 RenderBlockFlow* RenderBlockFlow::createAnonymousBlockFlow() const |
| 175 { | 173 { |
| 176 return toRenderBlockFlow(createAnonymousWithParentRendererAndDisplay(this, B
LOCK)); | 174 return toRenderBlockFlow(createAnonymousWithParentRendererAndDisplay(this, B
LOCK)); |
| 177 } | 175 } |
| 178 | 176 |
| 179 void RenderBlockFlow::willBeDestroyed() | 177 void RenderBlockFlow::willBeDestroyed() |
| 180 { | 178 { |
| 181 if (lineGridBox()) | 179 if (lineGridBox()) |
| 182 lineGridBox()->destroy(); | 180 lineGridBox()->destroy(); |
| 183 | 181 |
| 184 if (renderNamedFlowFragment()) | |
| 185 setRenderNamedFlowFragment(0); | |
| 186 | |
| 187 RenderBlock::willBeDestroyed(); | 182 RenderBlock::willBeDestroyed(); |
| 188 } | 183 } |
| 189 | 184 |
| 190 bool RenderBlockFlow::relayoutForPagination(bool hasSpecifiedPageLogicalHeight,
LayoutUnit pageLogicalHeight, LayoutStateMaintainer& statePusher) | 185 bool RenderBlockFlow::relayoutForPagination(bool hasSpecifiedPageLogicalHeight,
LayoutUnit pageLogicalHeight, LayoutStateMaintainer& statePusher) |
| 191 { | 186 { |
| 192 if (!hasColumns()) | 187 if (!hasColumns()) |
| 193 return false; | 188 return false; |
| 194 | 189 |
| 195 OwnPtr<RenderOverflow> savedOverflow = m_overflow.release(); | 190 OwnPtr<RenderOverflow> savedOverflow = m_overflow.release(); |
| 196 if (childrenInline()) | 191 if (childrenInline()) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 266 |
| 272 rebuildFloatsFromIntruding(); | 267 rebuildFloatsFromIntruding(); |
| 273 | 268 |
| 274 bool pageLogicalHeightChanged = false; | 269 bool pageLogicalHeightChanged = false; |
| 275 bool hasSpecifiedPageLogicalHeight = false; | 270 bool hasSpecifiedPageLogicalHeight = false; |
| 276 checkForPaginationLogicalHeightChange(pageLogicalHeight, pageLogicalHeightCh
anged, hasSpecifiedPageLogicalHeight); | 271 checkForPaginationLogicalHeightChange(pageLogicalHeight, pageLogicalHeightCh
anged, hasSpecifiedPageLogicalHeight); |
| 277 | 272 |
| 278 RenderView* renderView = view(); | 273 RenderView* renderView = view(); |
| 279 LayoutStateMaintainer statePusher(renderView, this, locationOffset(), hasCol
umns() || hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMo
de(), pageLogicalHeight, pageLogicalHeightChanged, columnInfo()); | 274 LayoutStateMaintainer statePusher(renderView, this, locationOffset(), hasCol
umns() || hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMo
de(), pageLogicalHeight, pageLogicalHeightChanged, columnInfo()); |
| 280 | 275 |
| 281 // Regions changing widths can force us to relayout our children. | |
| 282 RenderFlowThread* flowThread = flowThreadContainingBlock(); | |
| 283 if (logicalWidthChangedInRegions(flowThread)) | |
| 284 relayoutChildren = true; | |
| 285 if (updateRegionsAndShapesLogicalSize(flowThread)) | |
| 286 relayoutChildren = true; | |
| 287 if (!relayoutChildren && isRenderNamedFlowFragmentContainer()) | |
| 288 relayoutChildren = true; | |
| 289 | |
| 290 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg,
to track | 276 // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg,
to track |
| 291 // our current maximal positive and negative margins. These values are used
when we | 277 // our current maximal positive and negative margins. These values are used
when we |
| 292 // are collapsed with adjacent blocks, so for example, if you have block A a
nd B | 278 // are collapsed with adjacent blocks, so for example, if you have block A a
nd B |
| 293 // collapsing together, then you'd take the maximal positive margin from bot
h A and B | 279 // collapsing together, then you'd take the maximal positive margin from bot
h A and B |
| 294 // and subtract it from the maximal negative margin from both A and B to get
the | 280 // and subtract it from the maximal negative margin from both A and B to get
the |
| 295 // true collapsed margin. This algorithm is recursive, so when we finish lay
out() | 281 // true collapsed margin. This algorithm is recursive, so when we finish lay
out() |
| 296 // our block knows its current maximal positive/negative values. | 282 // our block knows its current maximal positive/negative values. |
| 297 // | 283 // |
| 298 // Start out by setting our margin values to our current margins. Table cell
s have | 284 // Start out by setting our margin values to our current margins. Table cell
s have |
| 299 // no margins, so we don't fill in the values for table cells. | 285 // no margins, so we don't fill in the values for table cells. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 326 |
| 341 if (relayoutForPagination(hasSpecifiedPageLogicalHeight, pageLogicalHeight,
statePusher) || relayoutToAvoidWidows(statePusher)) { | 327 if (relayoutForPagination(hasSpecifiedPageLogicalHeight, pageLogicalHeight,
statePusher) || relayoutToAvoidWidows(statePusher)) { |
| 342 ASSERT(!shouldBreakAtLineToAvoidWidow()); | 328 ASSERT(!shouldBreakAtLineToAvoidWidow()); |
| 343 return; | 329 return; |
| 344 } | 330 } |
| 345 | 331 |
| 346 // Calculate our new height. | 332 // Calculate our new height. |
| 347 LayoutUnit oldHeight = logicalHeight(); | 333 LayoutUnit oldHeight = logicalHeight(); |
| 348 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); | 334 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); |
| 349 | 335 |
| 350 // Before updating the final size of the flow thread make sure a forced brea
k is applied after the content. | |
| 351 // This ensures the size information is correctly computed for the last auto
-height region receiving content. | |
| 352 if (isRenderFlowThread()) | |
| 353 toRenderFlowThread(this)->applyBreakAfterContent(oldClientAfterEdge); | |
| 354 | |
| 355 updateLogicalHeight(); | 336 updateLogicalHeight(); |
| 356 LayoutUnit newHeight = logicalHeight(); | 337 LayoutUnit newHeight = logicalHeight(); |
| 357 if (oldHeight != newHeight) { | 338 if (oldHeight != newHeight) { |
| 358 if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !child
renInline()) { | 339 if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !child
renInline()) { |
| 359 // One of our children's floats may have become an overhanging float
for us. We need to look for it. | 340 // One of our children's floats may have become an overhanging float
for us. We need to look for it. |
| 360 for (RenderObject* child = firstChild(); child; child = child->nextS
ibling()) { | 341 for (RenderObject* child = firstChild(); child; child = child->nextS
ibling()) { |
| 361 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowP
ositioned()) { | 342 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowP
ositioned()) { |
| 362 RenderBlockFlow* block = toRenderBlockFlow(child); | 343 RenderBlockFlow* block = toRenderBlockFlow(child); |
| 363 if (block->lowestFloatLogicalBottom() + block->logicalTop()
> newHeight) | 344 if (block->lowestFloatLogicalBottom() + block->logicalTop()
> newHeight) |
| 364 addOverhangingFloats(block, false); | 345 addOverhangingFloats(block, false); |
| 365 } | 346 } |
| 366 } | 347 } |
| 367 } | 348 } |
| 368 } | 349 } |
| 369 | 350 |
| 370 bool heightChanged = (previousHeight != newHeight); | 351 bool heightChanged = (previousHeight != newHeight); |
| 371 if (heightChanged) | 352 if (heightChanged) |
| 372 relayoutChildren = true; | 353 relayoutChildren = true; |
| 373 | 354 |
| 374 layoutPositionedObjects(relayoutChildren || isRoot()); | 355 layoutPositionedObjects(relayoutChildren || isRoot()); |
| 375 | 356 |
| 376 updateRegionsAndShapesAfterChildLayout(flowThread, heightChanged); | |
| 377 | |
| 378 // Add overflow from children (unless we're multi-column, since in that case
all our child overflow is clipped anyway). | 357 // Add overflow from children (unless we're multi-column, since in that case
all our child overflow is clipped anyway). |
| 379 computeOverflow(oldClientAfterEdge); | 358 computeOverflow(oldClientAfterEdge); |
| 380 | 359 |
| 381 statePusher.pop(); | 360 statePusher.pop(); |
| 382 | 361 |
| 383 fitBorderToLinesIfNeeded(); | 362 fitBorderToLinesIfNeeded(); |
| 384 | 363 |
| 385 if (frameView()->partialLayout().isStopping()) | 364 if (frameView()->partialLayout().isStopping()) |
| 386 return; | 365 return; |
| 387 | 366 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 , m_atAfterSideOfBlock(false) | 836 , m_atAfterSideOfBlock(false) |
| 858 , m_hasMarginBeforeQuirk(false) | 837 , m_hasMarginBeforeQuirk(false) |
| 859 , m_hasMarginAfterQuirk(false) | 838 , m_hasMarginAfterQuirk(false) |
| 860 , m_determinedMarginBeforeQuirk(false) | 839 , m_determinedMarginBeforeQuirk(false) |
| 861 , m_discardMargin(false) | 840 , m_discardMargin(false) |
| 862 { | 841 { |
| 863 RenderStyle* blockStyle = blockFlow->style(); | 842 RenderStyle* blockStyle = blockFlow->style(); |
| 864 ASSERT(blockFlow->isRenderView() || blockFlow->parent()); | 843 ASSERT(blockFlow->isRenderView() || blockFlow->parent()); |
| 865 m_canCollapseWithChildren = !blockFlow->isRenderView() && !blockFlow->isRoot
() && !blockFlow->isOutOfFlowPositioned() | 844 m_canCollapseWithChildren = !blockFlow->isRenderView() && !blockFlow->isRoot
() && !blockFlow->isOutOfFlowPositioned() |
| 866 && !blockFlow->isFloating() && !blockFlow->isTableCell() && !blockFlow->
hasOverflowClip() && !blockFlow->isInlineBlockOrInlineTable() | 845 && !blockFlow->isFloating() && !blockFlow->isTableCell() && !blockFlow->
hasOverflowClip() && !blockFlow->isInlineBlockOrInlineTable() |
| 867 && !blockFlow->isRenderFlowThread() && !blockFlow->isWritingModeRoot() &
& !blockFlow->parent()->isFlexibleBox() | 846 && !blockFlow->isWritingModeRoot() && !blockFlow->parent()->isFlexibleBo
x() |
| 868 && blockStyle->hasAutoColumnCount() && blockStyle->hasAutoColumnWidth()
&& !blockStyle->columnSpan(); | 847 && blockStyle->hasAutoColumnCount() && blockStyle->hasAutoColumnWidth()
&& !blockStyle->columnSpan(); |
| 869 | 848 |
| 870 m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !before
BorderPadding && blockStyle->marginBeforeCollapse() != MSEPARATE; | 849 m_canCollapseMarginBeforeWithChildren = m_canCollapseWithChildren && !before
BorderPadding && blockStyle->marginBeforeCollapse() != MSEPARATE; |
| 871 | 850 |
| 872 // If any height other than auto is specified in CSS, then we don't collapse
our bottom | 851 // If any height other than auto is specified in CSS, then we don't collapse
our bottom |
| 873 // margins with our children's margins. To do otherwise would be to risk odd
visual | 852 // margins with our children's margins. To do otherwise would be to risk odd
visual |
| 874 // effects when the children overflow out of the parent block and yet still
collapse | 853 // effects when the children overflow out of the parent block and yet still
collapse |
| 875 // with it. We also don't collapse if we have any bottom border/padding. | 854 // with it. We also don't collapse if we have any bottom border/padding. |
| 876 m_canCollapseMarginAfterWithChildren = m_canCollapseWithChildren && !afterBo
rderPadding | 855 m_canCollapseMarginAfterWithChildren = m_canCollapseWithChildren && !afterBo
rderPadding |
| 877 && (blockStyle->logicalHeight().isAuto() && !blockStyle->logicalHeight()
.value()) && blockStyle->marginAfterCollapse() != MSEPARATE; | 856 && (blockStyle->logicalHeight().isAuto() && !blockStyle->logicalHeight()
.value()) && blockStyle->marginAfterCollapse() != MSEPARATE; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 } | 1106 } |
| 1128 | 1107 |
| 1129 RenderLayer* childLayer = child->layer(); | 1108 RenderLayer* childLayer = child->layer(); |
| 1130 if (childLayer->staticBlockPosition() != logicalTop) { | 1109 if (childLayer->staticBlockPosition() != logicalTop) { |
| 1131 childLayer->setStaticBlockPosition(logicalTop); | 1110 childLayer->setStaticBlockPosition(logicalTop); |
| 1132 if (hasStaticBlockPosition) | 1111 if (hasStaticBlockPosition) |
| 1133 child->setChildNeedsLayout(MarkOnlyThis); | 1112 child->setChildNeedsLayout(MarkOnlyThis); |
| 1134 } | 1113 } |
| 1135 } | 1114 } |
| 1136 | 1115 |
| 1137 LayoutUnit RenderBlockFlow::computeStartPositionDeltaForChildAvoidingFloats(cons
t RenderBox* child, LayoutUnit childMarginStart, RenderRegion* region) | 1116 LayoutUnit RenderBlockFlow::computeStartPositionDeltaForChildAvoidingFloats(cons
t RenderBox* child, LayoutUnit childMarginStart) |
| 1138 { | 1117 { |
| 1139 LayoutUnit startPosition = startOffsetForContent(region); | 1118 LayoutUnit startPosition = startOffsetForContent(); |
| 1140 | 1119 |
| 1141 // Add in our start margin. | 1120 // Add in our start margin. |
| 1142 LayoutUnit oldPosition = startPosition + childMarginStart; | 1121 LayoutUnit oldPosition = startPosition + childMarginStart; |
| 1143 LayoutUnit newPosition = oldPosition; | 1122 LayoutUnit newPosition = oldPosition; |
| 1144 | 1123 |
| 1145 LayoutUnit blockOffset = logicalTopForChild(child); | 1124 LayoutUnit blockOffset = logicalTopForChild(child); |
| 1146 if (region) | 1125 LayoutUnit startOff = startOffsetForLine(blockOffset, false, logicalHeightFo
rChild(child)); |
| 1147 blockOffset = max(blockOffset, blockOffset + (region->logicalTopForFlowT
hreadContent() - offsetFromLogicalTopOfFirstPage())); | |
| 1148 | |
| 1149 LayoutUnit startOff = startOffsetForLineInRegion(blockOffset, false, region,
logicalHeightForChild(child)); | |
| 1150 | 1126 |
| 1151 if (style()->textAlign() != WEBKIT_CENTER && !child->style()->marginStartUsi
ng(style()).isAuto()) { | 1127 if (style()->textAlign() != WEBKIT_CENTER && !child->style()->marginStartUsi
ng(style()).isAuto()) { |
| 1152 if (childMarginStart < 0) | 1128 if (childMarginStart < 0) |
| 1153 startOff += childMarginStart; | 1129 startOff += childMarginStart; |
| 1154 newPosition = max(newPosition, startOff); // Let the float sit in the ch
ild's margin if it can fit. | 1130 newPosition = max(newPosition, startOff); // Let the float sit in the ch
ild's margin if it can fit. |
| 1155 } else if (startOff != startPosition) { | 1131 } else if (startOff != startPosition) { |
| 1156 newPosition = startOff + childMarginStart; | 1132 newPosition = startOff + childMarginStart; |
| 1157 } | 1133 } |
| 1158 | 1134 |
| 1159 return newPosition - oldPosition; | 1135 return newPosition - oldPosition; |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 | 1498 |
| 1523 // FIXME: See |mustDiscardMarginBeforeForChild| above. | 1499 // FIXME: See |mustDiscardMarginBeforeForChild| above. |
| 1524 return false; | 1500 return false; |
| 1525 } | 1501 } |
| 1526 | 1502 |
| 1527 LayoutUnit RenderBlockFlow::applyBeforeBreak(RenderBox* child, LayoutUnit logica
lOffset) | 1503 LayoutUnit RenderBlockFlow::applyBeforeBreak(RenderBox* child, LayoutUnit logica
lOffset) |
| 1528 { | 1504 { |
| 1529 // FIXME: Add page break checking here when we support printing. | 1505 // FIXME: Add page break checking here when we support printing. |
| 1530 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); | 1506 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); |
| 1531 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; // FIXME: Once columns can print we have to check this. | 1507 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; // FIXME: Once columns can print we have to check this. |
| 1532 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 1508 bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBe
fore() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakBefore() ==
PBALWAYS); |
| 1533 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread()
; | |
| 1534 bool checkBeforeAlways = (checkColumnBreaks && child->style()->columnBreakBe
fore() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakBefore() ==
PBALWAYS) | |
| 1535 || (checkRegionBreaks && child->style()->regionBreakBefore() == PBALWAYS
); | |
| 1536 if (checkBeforeAlways && inNormalFlow(child) && hasNextPage(logicalOffset, I
ncludePageBoundary)) { | 1509 if (checkBeforeAlways && inNormalFlow(child) && hasNextPage(logicalOffset, I
ncludePageBoundary)) { |
| 1537 if (checkColumnBreaks) | 1510 if (checkColumnBreaks) |
| 1538 view()->layoutState()->addForcedColumnBreak(child, logicalOffset); | 1511 view()->layoutState()->addForcedColumnBreak(child, logicalOffset); |
| 1539 if (checkRegionBreaks) { | |
| 1540 LayoutUnit offsetBreakAdjustment = 0; | |
| 1541 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset, child, true, &offsetBreakAdjustment)) | |
| 1542 return logicalOffset + offsetBreakAdjustment; | |
| 1543 } | |
| 1544 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); | 1512 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); |
| 1545 } | 1513 } |
| 1546 return logicalOffset; | 1514 return logicalOffset; |
| 1547 } | 1515 } |
| 1548 | 1516 |
| 1549 LayoutUnit RenderBlockFlow::applyAfterBreak(RenderBox* child, LayoutUnit logical
Offset, MarginInfo& marginInfo) | 1517 LayoutUnit RenderBlockFlow::applyAfterBreak(RenderBox* child, LayoutUnit logical
Offset, MarginInfo& marginInfo) |
| 1550 { | 1518 { |
| 1551 // FIXME: Add page break checking here when we support printing. | 1519 // FIXME: Add page break checking here when we support printing. |
| 1552 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); | 1520 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns(); |
| 1553 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; // FIXME: Once columns can print we have to check this. | 1521 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->m_pageLo
gicalHeight; // FIXME: Once columns can print we have to check this. |
| 1554 RenderFlowThread* flowThread = flowThreadContainingBlock(); | 1522 bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAft
er() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakAfter() == PBA
LWAYS); |
| 1555 bool checkRegionBreaks = flowThread && flowThread->isRenderNamedFlowThread()
; | |
| 1556 bool checkAfterAlways = (checkColumnBreaks && child->style()->columnBreakAft
er() == PBALWAYS) || (checkPageBreaks && child->style()->pageBreakAfter() == PBA
LWAYS) | |
| 1557 || (checkRegionBreaks && child->style()->regionBreakAfter() == PBALWAYS)
; | |
| 1558 if (checkAfterAlways && inNormalFlow(child) && hasNextPage(logicalOffset, In
cludePageBoundary)) { | 1523 if (checkAfterAlways && inNormalFlow(child) && hasNextPage(logicalOffset, In
cludePageBoundary)) { |
| 1559 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? Lay
outUnit() : marginInfo.margin(); | |
| 1560 | |
| 1561 // So our margin doesn't participate in the next collapsing steps. | 1524 // So our margin doesn't participate in the next collapsing steps. |
| 1562 marginInfo.clearMargin(); | 1525 marginInfo.clearMargin(); |
| 1563 | 1526 |
| 1564 if (checkColumnBreaks) | 1527 if (checkColumnBreaks) |
| 1565 view()->layoutState()->addForcedColumnBreak(child, logicalOffset); | 1528 view()->layoutState()->addForcedColumnBreak(child, logicalOffset); |
| 1566 if (checkRegionBreaks) { | |
| 1567 LayoutUnit offsetBreakAdjustment = 0; | |
| 1568 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirstPage
() + logicalOffset + marginOffset, child, false, &offsetBreakAdjustment)) | |
| 1569 return logicalOffset + marginOffset + offsetBreakAdjustment; | |
| 1570 } | |
| 1571 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); | 1529 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); |
| 1572 } | 1530 } |
| 1573 return logicalOffset; | 1531 return logicalOffset; |
| 1574 } | 1532 } |
| 1575 | 1533 |
| 1576 void RenderBlockFlow::addOverflowFromFloats() | 1534 void RenderBlockFlow::addOverflowFromFloats() |
| 1577 { | 1535 { |
| 1578 if (!m_floatingObjects) | 1536 if (!m_floatingObjects) |
| 1579 return; | 1537 return; |
| 1580 | 1538 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 logicalBottom = lowestFloatLogicalBottom(); | 1646 logicalBottom = lowestFloatLogicalBottom(); |
| 1689 break; | 1647 break; |
| 1690 } | 1648 } |
| 1691 | 1649 |
| 1692 // 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). | 1650 // 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). |
| 1693 LayoutUnit result = clearSet ? max<LayoutUnit>(0, logicalBottom - logicalTop
) : LayoutUnit(); | 1651 LayoutUnit result = clearSet ? max<LayoutUnit>(0, logicalBottom - logicalTop
) : LayoutUnit(); |
| 1694 if (!result && child->avoidsFloats()) { | 1652 if (!result && child->avoidsFloats()) { |
| 1695 LayoutUnit newLogicalTop = logicalTop; | 1653 LayoutUnit newLogicalTop = logicalTop; |
| 1696 while (true) { | 1654 while (true) { |
| 1697 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog
icalWidthForLine(newLogicalTop, false, logicalHeightForChild(child)); | 1655 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog
icalWidthForLine(newLogicalTop, false, logicalHeightForChild(child)); |
| 1698 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi
dthForContent(newLogicalTop)) | 1656 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi
dthForContent()) |
| 1699 return newLogicalTop - logicalTop; | 1657 return newLogicalTop - logicalTop; |
| 1700 | 1658 |
| 1701 RenderRegion* region = regionAtBlockOffset(logicalTopForChild(child)
); | 1659 LayoutRect borderBox = child->borderBoxRect(); |
| 1702 LayoutRect borderBox = child->borderBoxRectInRegion(region, DoNotCac
heRenderBoxRegionInfo); | |
| 1703 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit
ingMode() ? borderBox.width() : borderBox.height(); | 1660 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit
ingMode() ? borderBox.width() : borderBox.height(); |
| 1704 | 1661 |
| 1705 // FIXME: None of this is right for perpendicular writing-mode child
ren. | 1662 // FIXME: None of this is right for perpendicular writing-mode child
ren. |
| 1706 LayoutUnit childOldLogicalWidth = child->logicalWidth(); | 1663 LayoutUnit childOldLogicalWidth = child->logicalWidth(); |
| 1707 LayoutUnit childOldMarginLeft = child->marginLeft(); | 1664 LayoutUnit childOldMarginLeft = child->marginLeft(); |
| 1708 LayoutUnit childOldMarginRight = child->marginRight(); | 1665 LayoutUnit childOldMarginRight = child->marginRight(); |
| 1709 LayoutUnit childOldLogicalTop = child->logicalTop(); | 1666 LayoutUnit childOldLogicalTop = child->logicalTop(); |
| 1710 | 1667 |
| 1711 child->setLogicalTop(newLogicalTop); | 1668 child->setLogicalTop(newLogicalTop); |
| 1712 child->updateLogicalWidth(); | 1669 child->updateLogicalWidth(); |
| 1713 region = regionAtBlockOffset(logicalTopForChild(child)); | 1670 borderBox = child->borderBoxRect(); |
| 1714 borderBox = child->borderBoxRectInRegion(region, DoNotCacheRenderBox
RegionInfo); | |
| 1715 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWrit
ingMode() ? borderBox.width() : borderBox.height(); | 1671 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWrit
ingMode() ? borderBox.width() : borderBox.height(); |
| 1716 | 1672 |
| 1717 child->setLogicalTop(childOldLogicalTop); | 1673 child->setLogicalTop(childOldLogicalTop); |
| 1718 child->setLogicalWidth(childOldLogicalWidth); | 1674 child->setLogicalWidth(childOldLogicalWidth); |
| 1719 child->setMarginLeft(childOldMarginLeft); | 1675 child->setMarginLeft(childOldMarginLeft); |
| 1720 child->setMarginRight(childOldMarginRight); | 1676 child->setMarginRight(childOldMarginRight); |
| 1721 | 1677 |
| 1722 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA
tNewLogicalTopOffset) { | 1678 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA
tNewLogicalTopOffset) { |
| 1723 // Even though we may not be moving, if the logical width did sh
rink because of the presence of new floats, then | 1679 // Even though we may not be moving, if the logical width did sh
rink because of the presence of new floats, then |
| 1724 // we need to force a relayout as though we shifted. This happen
s because of the dynamic addition of overhanging floats | 1680 // 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 Loading... |
| 1780 break; | 1736 break; |
| 1781 } | 1737 } |
| 1782 } | 1738 } |
| 1783 } | 1739 } |
| 1784 } | 1740 } |
| 1785 } | 1741 } |
| 1786 | 1742 |
| 1787 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); | 1743 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); |
| 1788 parentBlockFlow->markSiblingsWithFloatsForLayout(); | 1744 parentBlockFlow->markSiblingsWithFloatsForLayout(); |
| 1789 } | 1745 } |
| 1790 | |
| 1791 if (renderNamedFlowFragment()) | |
| 1792 renderNamedFlowFragment()->setStyleForNamedFlowFragment(style()); | |
| 1793 } | 1746 } |
| 1794 | 1747 |
| 1795 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou
tUnit logicalTop) | 1748 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox* child, Layou
tUnit logicalTop) |
| 1796 { | 1749 { |
| 1797 if (child->style()->isOriginalDisplayInlineType()) | 1750 if (child->style()->isOriginalDisplayInlineType()) |
| 1798 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor
Line(logicalTop, false)); | 1751 setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetFor
Line(logicalTop, false)); |
| 1799 else | 1752 else |
| 1800 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent
(logicalTop)); | 1753 setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent
()); |
| 1801 } | 1754 } |
| 1802 | 1755 |
| 1803 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox* child, LayoutUn
it blockOffset, LayoutUnit inlinePosition) | 1756 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox* child, LayoutUn
it blockOffset, LayoutUnit inlinePosition) |
| 1804 { | 1757 { |
| 1805 if (flowThreadContainingBlock()) { | |
| 1806 // Shift the inline position to exclude the region offset. | |
| 1807 inlinePosition += startOffsetForContent() - startOffsetForContent(blockO
ffset); | |
| 1808 } | |
| 1809 child->layer()->setStaticInlinePosition(inlinePosition); | 1758 child->layer()->setStaticInlinePosition(inlinePosition); |
| 1810 } | 1759 } |
| 1811 | 1760 |
| 1812 void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, boo
l fullRemoveInsert) | 1761 void RenderBlockFlow::moveAllChildrenIncludingFloatsTo(RenderBlock* toBlock, boo
l fullRemoveInsert) |
| 1813 { | 1762 { |
| 1814 RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock); | 1763 RenderBlockFlow* toBlockFlow = toRenderBlockFlow(toBlock); |
| 1815 moveAllChildrenTo(toBlockFlow, fullRemoveInsert); | 1764 moveAllChildrenTo(toBlockFlow, fullRemoveInsert); |
| 1816 | 1765 |
| 1817 // When a portion of the render tree is being detached, anonymous blocks | 1766 // When a portion of the render tree is being detached, anonymous blocks |
| 1818 // will be combined as their children are deleted. In this process, the | 1767 // will be combined as their children are deleted. In this process, the |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 // FIXME: Dynamic changes to the font or to the inline position need to resu
lt in a deep relayout. | 2059 // FIXME: Dynamic changes to the font or to the inline position need to resu
lt in a deep relayout. |
| 2111 // (https://bugs.webkit.org/show_bug.cgi?id=79944) | 2060 // (https://bugs.webkit.org/show_bug.cgi?id=79944) |
| 2112 float remainder = fmodf(fmodf(right + layoutOffset - lineGridOffset, maxChar
Width), maxCharWidth); | 2061 float remainder = fmodf(fmodf(right + layoutOffset - lineGridOffset, maxChar
Width), maxCharWidth); |
| 2113 right -= LayoutUnit::fromFloatCeil(remainder); | 2062 right -= LayoutUnit::fromFloatCeil(remainder); |
| 2114 return right; | 2063 return right; |
| 2115 } | 2064 } |
| 2116 | 2065 |
| 2117 LayoutPoint RenderBlockFlow::computeLogicalLocationForFloat(const FloatingObject
* floatingObject, LayoutUnit logicalTopOffset) const | 2066 LayoutPoint RenderBlockFlow::computeLogicalLocationForFloat(const FloatingObject
* floatingObject, LayoutUnit logicalTopOffset) const |
| 2118 { | 2067 { |
| 2119 RenderBox* childBox = floatingObject->renderer(); | 2068 RenderBox* childBox = floatingObject->renderer(); |
| 2120 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset)
; // Constant part of left offset. | 2069 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa
rt of left offset. |
| 2121 LayoutUnit logicalRightOffset; // Constant part of right offset. | 2070 LayoutUnit logicalRightOffset; // Constant part of right offset. |
| 2122 // FIXME Bug 102948: This only works for shape outside directly set on this
block. | 2071 // FIXME Bug 102948: This only works for shape outside directly set on this
block. |
| 2123 ShapeInsideInfo* shapeInsideInfo = this->layoutShapeInsideInfo(); | 2072 ShapeInsideInfo* shapeInsideInfo = this->layoutShapeInsideInfo(); |
| 2124 // FIXME: Implement behavior for right floats. | 2073 // FIXME: Implement behavior for right floats. |
| 2125 if (shapeInsideInfo) { | 2074 if (shapeInsideInfo) { |
| 2126 LayoutSize floatLogicalSize = logicalSizeForFloat(floatingObject); | 2075 LayoutSize floatLogicalSize = logicalSizeForFloat(floatingObject); |
| 2127 // floatingObject's logicalSize doesn't contain the actual height at thi
s point, so we need to calculate it | 2076 // floatingObject's logicalSize doesn't contain the actual height at thi
s point, so we need to calculate it |
| 2128 floatLogicalSize.setHeight(logicalHeightForChild(childBox) + marginBefor
eForChild(childBox) + marginAfterForChild(childBox)); | 2077 floatLogicalSize.setHeight(logicalHeightForChild(childBox) + marginBefor
eForChild(childBox) + marginAfterForChild(childBox)); |
| 2129 | 2078 |
| 2130 // FIXME: If the float doesn't fit in the shape we should push it under
the content box | 2079 // FIXME: If the float doesn't fit in the shape we should push it under
the content box |
| 2131 logicalTopOffset = shapeInsideInfo->computeFirstFitPositionForFloat(floa
tLogicalSize); | 2080 logicalTopOffset = shapeInsideInfo->computeFirstFitPositionForFloat(floa
tLogicalSize); |
| 2132 if (logicalHeight() > logicalTopOffset) | 2081 if (logicalHeight() > logicalTopOffset) |
| 2133 logicalTopOffset = logicalHeight(); | 2082 logicalTopOffset = logicalHeight(); |
| 2134 | 2083 |
| 2135 SegmentList segments = shapeInsideInfo->computeSegmentsForLine(logicalTo
pOffset, floatLogicalSize.height()); | 2084 SegmentList segments = shapeInsideInfo->computeSegmentsForLine(logicalTo
pOffset, floatLogicalSize.height()); |
| 2136 // FIXME: Add support for shapes with multiple segments. | 2085 // FIXME: Add support for shapes with multiple segments. |
| 2137 if (segments.size() == 1) { | 2086 if (segments.size() == 1) { |
| 2138 // The segment offsets are relative to the content box. | 2087 // The segment offsets are relative to the content box. |
| 2139 logicalRightOffset = logicalLeftOffset + segments[0].logicalRight; | 2088 logicalRightOffset = logicalLeftOffset + segments[0].logicalRight; |
| 2140 logicalLeftOffset += segments[0].logicalLeft; | 2089 logicalLeftOffset += segments[0].logicalLeft; |
| 2141 } | 2090 } |
| 2142 } else { | 2091 } else { |
| 2143 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffset); | 2092 logicalRightOffset = logicalRightOffsetForContent(); |
| 2144 } | 2093 } |
| 2145 | 2094 |
| 2146 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log
icalRightOffset - logicalLeftOffset); // The width we look for. | 2095 LayoutUnit floatLogicalWidth = min(logicalWidthForFloat(floatingObject), log
icalRightOffset - logicalLeftOffset); // The width we look for. |
| 2147 | 2096 |
| 2148 LayoutUnit floatLogicalLeft; | 2097 LayoutUnit floatLogicalLeft; |
| 2149 | 2098 |
| 2150 bool insideFlowThread = flowThreadContainingBlock(); | |
| 2151 | |
| 2152 if (childBox->style()->floating() == LeftFloat) { | 2099 if (childBox->style()->floating() == LeftFloat) { |
| 2153 LayoutUnit heightRemainingLeft = 1; | 2100 LayoutUnit heightRemainingLeft = 1; |
| 2154 LayoutUnit heightRemainingRight = 1; | 2101 LayoutUnit heightRemainingRight = 1; |
| 2155 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOffset
, logicalLeftOffset, false, &heightRemainingLeft); | 2102 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOffset
, logicalLeftOffset, false, &heightRemainingLeft); |
| 2156 while (logicalRightOffsetForPositioningFloat(logicalTopOffset, logicalRi
ghtOffset, false, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth)
{ | 2103 while (logicalRightOffsetForPositioningFloat(logicalTopOffset, logicalRi
ghtOffset, false, &heightRemainingRight) - floatLogicalLeft < floatLogicalWidth)
{ |
| 2157 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); | 2104 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); |
| 2158 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOf
fset, logicalLeftOffset, false, &heightRemainingLeft); | 2105 floatLogicalLeft = logicalLeftOffsetForPositioningFloat(logicalTopOf
fset, logicalLeftOffset, false, &heightRemainingLeft); |
| 2159 if (insideFlowThread) { | |
| 2160 // Have to re-evaluate all of our offsets, since they may have c
hanged. | |
| 2161 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs
et); // Constant part of right offset. | |
| 2162 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset
); // Constant part of left offset. | |
| 2163 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo
gicalRightOffset - logicalLeftOffset); | |
| 2164 } | |
| 2165 } | 2106 } |
| 2166 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft()
, floatLogicalLeft); | 2107 floatLogicalLeft = max(logicalLeftOffset - borderAndPaddingLogicalLeft()
, floatLogicalLeft); |
| 2167 } else { | 2108 } else { |
| 2168 LayoutUnit heightRemainingLeft = 1; | 2109 LayoutUnit heightRemainingLeft = 1; |
| 2169 LayoutUnit heightRemainingRight = 1; | 2110 LayoutUnit heightRemainingRight = 1; |
| 2170 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopOffse
t, logicalRightOffset, false, &heightRemainingRight); | 2111 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopOffse
t, logicalRightOffset, false, &heightRemainingRight); |
| 2171 while (floatLogicalLeft - logicalLeftOffsetForPositioningFloat(logicalTo
pOffset, logicalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) { | 2112 while (floatLogicalLeft - logicalLeftOffsetForPositioningFloat(logicalTo
pOffset, logicalLeftOffset, false, &heightRemainingLeft) < floatLogicalWidth) { |
| 2172 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); | 2113 logicalTopOffset += min(heightRemainingLeft, heightRemainingRight); |
| 2173 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopO
ffset, logicalRightOffset, false, &heightRemainingRight); | 2114 floatLogicalLeft = logicalRightOffsetForPositioningFloat(logicalTopO
ffset, logicalRightOffset, false, &heightRemainingRight); |
| 2174 if (insideFlowThread) { | |
| 2175 // Have to re-evaluate all of our offsets, since they may have c
hanged. | |
| 2176 logicalRightOffset = logicalRightOffsetForContent(logicalTopOffs
et); // Constant part of right offset. | |
| 2177 logicalLeftOffset = logicalLeftOffsetForContent(logicalTopOffset
); // Constant part of left offset. | |
| 2178 floatLogicalWidth = min(logicalWidthForFloat(floatingObject), lo
gicalRightOffset - logicalLeftOffset); | |
| 2179 } | |
| 2180 } | 2115 } |
| 2181 // Use the original width of the float here, since the local variable | 2116 // Use the original width of the float here, since the local variable |
| 2182 // |floatLogicalWidth| was capped to the available line width. See | 2117 // |floatLogicalWidth| was capped to the available line width. See |
| 2183 // fast/block/float/clamped-right-float.html. | 2118 // fast/block/float/clamped-right-float.html. |
| 2184 floatLogicalLeft -= logicalWidthForFloat(floatingObject); | 2119 floatLogicalLeft -= logicalWidthForFloat(floatingObject); |
| 2185 } | 2120 } |
| 2186 | 2121 |
| 2187 return LayoutPoint(floatLogicalLeft, logicalTopOffset); | 2122 return LayoutPoint(floatLogicalLeft, logicalTopOffset); |
| 2188 } | 2123 } |
| 2189 | 2124 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 return constructTextRun(context, font, string, style, | 2698 return constructTextRun(context, font, string, style, |
| 2764 determineDirectionality(string, hasStrongDirectionality), | 2699 determineDirectionality(string, hasStrongDirectionality), |
| 2765 expansion, flags); | 2700 expansion, flags); |
| 2766 } | 2701 } |
| 2767 | 2702 |
| 2768 RootInlineBox* RenderBlockFlow::createRootInlineBox() | 2703 RootInlineBox* RenderBlockFlow::createRootInlineBox() |
| 2769 { | 2704 { |
| 2770 return new RootInlineBox(this); | 2705 return new RootInlineBox(this); |
| 2771 } | 2706 } |
| 2772 | 2707 |
| 2773 void RenderBlockFlow::createRenderNamedFlowFragmentIfNeeded() | |
| 2774 { | |
| 2775 if (!RuntimeEnabledFeatures::cssRegionsEnabled() | |
| 2776 || renderNamedFlowFragment() | |
| 2777 || isRenderNamedFlowFragment()) | |
| 2778 return; | |
| 2779 | |
| 2780 RenderStyle* styleToUse = style(); | |
| 2781 if (styleToUse->isDisplayRegionType() && styleToUse->hasFlowFrom() && docume
nt().renderView()) { | |
| 2782 RenderNamedFlowFragment* flowFragment = RenderNamedFlowFragment::createA
nonymous(&document()); | |
| 2783 flowFragment->setStyleForNamedFlowFragment(styleToUse); | |
| 2784 setRenderNamedFlowFragment(flowFragment); | |
| 2785 addChild(flowFragment); | |
| 2786 } | |
| 2787 } | |
| 2788 | |
| 2789 void RenderBlockFlow::insertedIntoTree() | |
| 2790 { | |
| 2791 RenderBlock::insertedIntoTree(); | |
| 2792 | |
| 2793 createRenderNamedFlowFragmentIfNeeded(); | |
| 2794 } | |
| 2795 | |
| 2796 bool RenderBlockFlow::canHaveChildren() const | |
| 2797 { | |
| 2798 return !renderNamedFlowFragment() ? RenderBlock::canHaveChildren() : renderN
amedFlowFragment()->canHaveChildren(); | |
| 2799 } | |
| 2800 | |
| 2801 bool RenderBlockFlow::canHaveGeneratedChildren() const | |
| 2802 { | |
| 2803 return !renderNamedFlowFragment() ? RenderBlock::canHaveGeneratedChildren()
: renderNamedFlowFragment()->canHaveGeneratedChildren(); | |
| 2804 } | |
| 2805 | |
| 2806 void RenderBlockFlow::updateLogicalHeight() | 2708 void RenderBlockFlow::updateLogicalHeight() |
| 2807 { | 2709 { |
| 2808 RenderBlock::updateLogicalHeight(); | 2710 RenderBlock::updateLogicalHeight(); |
| 2809 | |
| 2810 if (renderNamedFlowFragment()) | |
| 2811 renderNamedFlowFragment()->setLogicalHeight(max<LayoutUnit>(0, logicalHe
ight() - borderAndPaddingLogicalHeight())); | |
| 2812 } | |
| 2813 | |
| 2814 void RenderBlockFlow::setRenderNamedFlowFragment(RenderNamedFlowFragment* flowFr
agment) | |
| 2815 { | |
| 2816 RenderBlockFlow::RenderBlockFlowRareData& rareData = ensureRareData(); | |
| 2817 if (rareData.m_renderNamedFlowFragment) | |
| 2818 rareData.m_renderNamedFlowFragment->destroy(); | |
| 2819 rareData.m_renderNamedFlowFragment = flowFragment; | |
| 2820 } | 2711 } |
| 2821 | 2712 |
| 2822 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 2713 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
| 2823 { | 2714 { |
| 2824 if (m_rareData) | 2715 if (m_rareData) |
| 2825 return *m_rareData; | 2716 return *m_rareData; |
| 2826 | 2717 |
| 2827 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 2718 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
| 2828 return *m_rareData; | 2719 return *m_rareData; |
| 2829 } | 2720 } |
| 2830 | 2721 |
| 2831 } // namespace WebCore | 2722 } // namespace WebCore |
| OLD | NEW |