| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 updateLogicalHeight(); | 233 updateLogicalHeight(); |
| 234 | 234 |
| 235 if (previousHeight != logicalHeight()) | 235 if (previousHeight != logicalHeight()) |
| 236 relayoutChildren = true; | 236 relayoutChildren = true; |
| 237 | 237 |
| 238 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft !=
logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); | 238 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft !=
logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); |
| 239 | 239 |
| 240 // Add overflow from children (unless we're multi-column, since in that case
all our child overflow is clipped anyway). | 240 // Add overflow from children (unless we're multi-column, since in that case
all our child overflow is clipped anyway). |
| 241 computeOverflow(oldClientAfterEdge); | 241 computeOverflow(oldClientAfterEdge); |
| 242 | |
| 243 m_descendantsWithFloatsMarkedForLayout = false; | |
| 244 } | 242 } |
| 245 | 243 |
| 246 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child) | 244 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child) |
| 247 { | 245 { |
| 248 LayoutUnit startPosition = borderStart() + paddingStart(); | 246 LayoutUnit startPosition = borderStart() + paddingStart(); |
| 249 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 247 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
| 250 startPosition -= verticalScrollbarWidth(); | 248 startPosition -= verticalScrollbarWidth(); |
| 251 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava
ilableLogicalWidth(); | 249 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava
ilableLogicalWidth(); |
| 252 | 250 |
| 253 LayoutUnit childMarginStart = marginStartForChild(child); | 251 LayoutUnit childMarginStart = marginStartForChild(child); |
| 254 LayoutUnit newPosition = startPosition + childMarginStart; | 252 LayoutUnit newPosition = startPosition + childMarginStart; |
| 255 | 253 |
| 256 // If the child has an offset from the content edge to avoid floats then use
that, otherwise let any negative | 254 // If the child has an offset from the content edge to avoid floats then use
that, otherwise let any negative |
| 257 // margin pull it back over the content edge or any positive margin push it
out. | 255 // margin pull it back over the content edge or any positive margin push it
out. |
| 258 // If the child is being centred then the margin calculated to do that has f
actored in any offset required to | 256 // If the child is being centred then the margin calculated to do that has f
actored in any offset required to |
| 259 // avoid floats, so use it if necessary. | 257 // avoid floats, so use it if necessary. |
| 260 if (style()->textAlign() == WEBKIT_CENTER || child->style()->marginStartUsin
g(style()).isAuto()) | 258 if (style()->textAlign() == WEBKIT_CENTER || child->style()->marginStartUsin
g(style()).isAuto()) |
| 261 newPosition = std::max(newPosition, childMarginStart); | 259 newPosition = std::max(newPosition, childMarginStart); |
| 262 | 260 |
| 263 setLogicalLeftForChild(child, style()->isLeftToRightDirection() ? newPositio
n : totalAvailableLogicalWidth - newPosition - logicalWidthForChild(child)); | 261 child->setX(style()->isLeftToRightDirection() ? newPosition : totalAvailable
LogicalWidth - newPosition - logicalWidthForChild(child)); |
| 264 } | |
| 265 | |
| 266 void RenderBlockFlow::setLogicalLeftForChild(RenderBox* child, LayoutUnit logica
lLeft) | |
| 267 { | |
| 268 child->setX(logicalLeft); | |
| 269 } | |
| 270 | |
| 271 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical
Top) | |
| 272 { | |
| 273 child->setY(logicalTop); | |
| 274 } | 262 } |
| 275 | 263 |
| 276 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo) | 264 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo) |
| 277 { | 265 { |
| 278 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. | 266 // The child is a normal flow object. Compute the margins we will use for co
llapsing now. |
| 279 child->computeAndSetBlockDirectionMargins(this); | 267 child->computeAndSetBlockDirectionMargins(this); |
| 280 | 268 |
| 281 // Try to guess our correct logical top position. In most cases this guess w
ill | 269 // Try to guess our correct logical top position. In most cases this guess w
ill |
| 282 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) | 270 // be correct. Only if we're wrong (when we compute the real logical top pos
ition) |
| 283 // will we have to potentially relayout. | 271 // will we have to potentially relayout. |
| 284 // Go ahead and position the child as though it didn't collapse with the top
. | 272 // Go ahead and position the child as though it didn't collapse with the top
. |
| 285 setLogicalTopForChild(child, estimateLogicalTopPosition(child, marginInfo)); | 273 child->setY(estimateLogicalTopPosition(child, marginInfo)); |
| 286 | 274 |
| 287 child->layoutIfNeeded(); | 275 child->layoutIfNeeded(); |
| 288 | 276 |
| 289 // Cache if we are at the top of the block right now. | 277 // Cache if we are at the top of the block right now. |
| 290 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); | 278 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); |
| 291 | 279 |
| 292 // Now determine the correct ypos based off examination of collapsing margin | 280 // Now determine the correct ypos based off examination of collapsing margin |
| 293 // values. | 281 // values. |
| 294 setLogicalTopForChild(child, collapseMargins(child, marginInfo, childIsSelfC
ollapsing)); | 282 child->setY(collapseMargins(child, marginInfo, childIsSelfCollapsing)); |
| 295 | 283 |
| 296 // FIXME(sky): Is it still actually possible for the child to need layout he
re? | 284 // FIXME(sky): Is it still actually possible for the child to need layout he
re? |
| 297 // This used to be needed for floats and/or margin collapsing. | 285 // This used to be needed for floats and/or margin collapsing. |
| 298 child->layoutIfNeeded(); | 286 child->layoutIfNeeded(); |
| 299 | 287 |
| 300 // If we previously encountered a self-collapsing sibling of this child that
had clearance then | 288 // If we previously encountered a self-collapsing sibling of this child that
had clearance then |
| 301 // we set this bit to ensure we would not collapse the child's margins, and
those of any subsequent | 289 // we set this bit to ensure we would not collapse the child's margins, and
those of any subsequent |
| 302 // self-collapsing siblings, with our parent. If this child is not self-coll
apsing then it can | 290 // self-collapsing siblings, with our parent. If this child is not self-coll
apsing then it can |
| 303 // collapse its margins with the parent so reset the bit. | 291 // collapse its margins with the parent so reset the bit. |
| 304 if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollaps
ing) | 292 if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollaps
ing) |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 MarginInfo childMarginInfo(childBlockFlow, childBlockFlow->borderBefore() +
childBlockFlow->paddingBefore(), childBlockFlow->borderAfter() + childBlockFlow-
>paddingAfter()); | 624 MarginInfo childMarginInfo(childBlockFlow, childBlockFlow->borderBefore() +
childBlockFlow->paddingBefore(), childBlockFlow->borderAfter() + childBlockFlow-
>paddingAfter()); |
| 637 if (!childMarginInfo.canCollapseMarginBeforeWithChildren()) | 625 if (!childMarginInfo.canCollapseMarginBeforeWithChildren()) |
| 638 return; | 626 return; |
| 639 | 627 |
| 640 RenderBox* grandchildBox = childBlockFlow->firstChildBox(); | 628 RenderBox* grandchildBox = childBlockFlow->firstChildBox(); |
| 641 for ( ; grandchildBox; grandchildBox = grandchildBox->nextSiblingBox()) { | 629 for ( ; grandchildBox; grandchildBox = grandchildBox->nextSiblingBox()) { |
| 642 if (!grandchildBox->isFloatingOrOutOfFlowPositioned()) | 630 if (!grandchildBox->isFloatingOrOutOfFlowPositioned()) |
| 643 break; | 631 break; |
| 644 } | 632 } |
| 645 | 633 |
| 646 // Give up if there is clearance on the box, since it probably won't collaps
e into us. | 634 if (!grandchildBox) |
| 647 if (!grandchildBox || grandchildBox->style()->clear() != CNONE) | |
| 648 return; | 635 return; |
| 649 | 636 |
| 650 // Make sure to update the block margins now for the grandchild box so that
we're looking at current values. | 637 // Make sure to update the block margins now for the grandchild box so that
we're looking at current values. |
| 651 if (grandchildBox->needsLayout()) { | 638 if (grandchildBox->needsLayout()) { |
| 652 grandchildBox->computeAndSetBlockDirectionMargins(this); | 639 grandchildBox->computeAndSetBlockDirectionMargins(this); |
| 653 if (grandchildBox->isRenderBlock()) { | 640 if (grandchildBox->isRenderBlock()) { |
| 654 RenderBlock* grandchildBlock = toRenderBlock(grandchildBox); | 641 RenderBlock* grandchildBlock = toRenderBlock(grandchildBox); |
| 655 grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style()->has
MarginBeforeQuirk()); | 642 grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style()->has
MarginBeforeQuirk()); |
| 656 grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style()->hasM
arginAfterQuirk()); | 643 grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style()->hasM
arginAfterQuirk()); |
| 657 } | 644 } |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 | 981 |
| 995 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState()
!= SelectionBoth) { | 982 if (lastSelectedLine && selectionState() != SelectionEnd && selectionState()
!= SelectionBoth) { |
| 996 // Go ahead and update our lastY to be the bottom of the last selected l
ine. | 983 // Go ahead and update our lastY to be the bottom of the last selected l
ine. |
| 997 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) +
lastSelectedLine->selectionBottom(); | 984 lastLogicalTop = rootBlock->blockDirectionOffset(offsetFromRootBlock) +
lastSelectedLine->selectionBottom(); |
| 998 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine
->selectionBottom()); | 985 lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine
->selectionBottom()); |
| 999 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi
ne->selectionBottom()); | 986 lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLi
ne->selectionBottom()); |
| 1000 } | 987 } |
| 1001 return result; | 988 return result; |
| 1002 } | 989 } |
| 1003 | 990 |
| 1004 bool RenderBlockFlow::avoidsFloats() const | |
| 1005 { | |
| 1006 return RenderBox::avoidsFloats(); | |
| 1007 } | |
| 1008 | |
| 1009 LayoutUnit RenderBlockFlow::logicalLeftSelectionOffset(RenderBlock* rootBlock, L
ayoutUnit position) | 991 LayoutUnit RenderBlockFlow::logicalLeftSelectionOffset(RenderBlock* rootBlock, L
ayoutUnit position) |
| 1010 { | 992 { |
| 1011 LayoutUnit logicalLeft = logicalLeftOffsetForLine(position, false); | 993 LayoutUnit logicalLeft = logicalLeftOffsetForLine(position, false); |
| 1012 if (logicalLeft == logicalLeftOffsetForContent()) | 994 if (logicalLeft == logicalLeftOffsetForContent()) |
| 1013 return RenderBlock::logicalLeftSelectionOffset(rootBlock, position); | 995 return RenderBlock::logicalLeftSelectionOffset(rootBlock, position); |
| 1014 | 996 |
| 1015 RenderBlock* cb = this; | 997 RenderBlock* cb = this; |
| 1016 while (cb != rootBlock) { | 998 while (cb != rootBlock) { |
| 1017 logicalLeft += cb->logicalLeft(); | 999 logicalLeft += cb->logicalLeft(); |
| 1018 cb = cb->containingBlock(); | 1000 cb = cb->containingBlock(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1042 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() | 1024 RenderBlockFlow::RenderBlockFlowRareData& RenderBlockFlow::ensureRareData() |
| 1043 { | 1025 { |
| 1044 if (m_rareData) | 1026 if (m_rareData) |
| 1045 return *m_rareData; | 1027 return *m_rareData; |
| 1046 | 1028 |
| 1047 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); | 1029 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); |
| 1048 return *m_rareData; | 1030 return *m_rareData; |
| 1049 } | 1031 } |
| 1050 | 1032 |
| 1051 } // namespace blink | 1033 } // namespace blink |
| OLD | NEW |