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

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

Issue 752723004: Use references in RenderBlock and RenderBlockFlow methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 494
495 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); 495 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
496 496
497 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). 497 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
498 computeOverflow(oldClientAfterEdge); 498 computeOverflow(oldClientAfterEdge);
499 499
500 m_descendantsWithFloatsMarkedForLayout = false; 500 m_descendantsWithFloatsMarkedForLayout = false;
501 return true; 501 return true;
502 } 502 }
503 503
504 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child) 504 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox* child)
Julien - ping for review 2014/11/26 18:52:35 This function could also take a reference.
505 { 505 {
506 LayoutUnit startPosition = borderStart() + paddingStart(); 506 LayoutUnit startPosition = borderStart() + paddingStart();
507 LayoutUnit initialStartPosition = startPosition; 507 LayoutUnit initialStartPosition = startPosition;
508 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 508 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
509 startPosition -= verticalScrollbarWidth(); 509 startPosition -= verticalScrollbarWidth();
510 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); 510 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth();
511 511
512 LayoutUnit childMarginStart = marginStartForChild(child); 512 LayoutUnit childMarginStart = marginStartForChild(*child);
Julien - ping for review 2014/11/26 18:52:35 It seems like the function could also use a refere
513 LayoutUnit newPosition = startPosition + childMarginStart; 513 LayoutUnit newPosition = startPosition + childMarginStart;
514 514
515 LayoutUnit positionToAvoidFloats; 515 LayoutUnit positionToAvoidFloats;
516 if (child->avoidsFloats() && containsFloats() && !flowThreadContainingBlock( )) 516 if (child->avoidsFloats() && containsFloats() && !flowThreadContainingBlock( ))
517 positionToAvoidFloats = startOffsetForLine(logicalTopForChild(child), fa lse, logicalHeightForChild(child)); 517 positionToAvoidFloats = startOffsetForLine(logicalTopForChild(*child), f alse, logicalHeightForChild(*child));
518 518
519 // If the child has an offset from the content edge to avoid floats then use that, otherwise let any negative 519 // If the child has an offset from the content edge to avoid floats then use that, otherwise let any negative
520 // margin pull it back over the content edge or any positive margin push it out. 520 // margin pull it back over the content edge or any positive margin push it out.
521 // If the child is being centred then the margin calculated to do that has f actored in any offset required to 521 // If the child is being centred then the margin calculated to do that has f actored in any offset required to
522 // avoid floats, so use it if necessary. 522 // avoid floats, so use it if necessary.
523 if (style()->textAlign() == WEBKIT_CENTER || child->style()->marginStartUsin g(style()).isAuto()) 523 if (style()->textAlign() == WEBKIT_CENTER || child->style()->marginStartUsin g(style()).isAuto())
524 newPosition = std::max(newPosition, positionToAvoidFloats + childMarginS tart); 524 newPosition = std::max(newPosition, positionToAvoidFloats + childMarginS tart);
525 else if (positionToAvoidFloats > initialStartPosition) 525 else if (positionToAvoidFloats > initialStartPosition)
526 newPosition = std::max(newPosition, positionToAvoidFloats); 526 newPosition = std::max(newPosition, positionToAvoidFloats);
527 527
528 setLogicalLeftForChild(child, style()->isLeftToRightDirection() ? newPositio n : totalAvailableLogicalWidth - newPosition - logicalWidthForChild(child)); 528 setLogicalLeftForChild(child, style()->isLeftToRightDirection() ? newPositio n : totalAvailableLogicalWidth - newPosition - logicalWidthForChild(*child));
529 } 529 }
530 530
531 void RenderBlockFlow::setLogicalLeftForChild(RenderBox* child, LayoutUnit logica lLeft) 531 void RenderBlockFlow::setLogicalLeftForChild(RenderBox* child, LayoutUnit logica lLeft)
532 { 532 {
533 if (isHorizontalWritingMode()) { 533 if (isHorizontalWritingMode()) {
534 child->setX(logicalLeft); 534 child->setX(logicalLeft);
535 } else { 535 } else {
536 child->setY(logicalLeft); 536 child->setY(logicalLeft);
537 } 537 }
538 } 538 }
(...skipping 16 matching lines...) Expand all
555 child->computeAndSetBlockDirectionMargins(this); 555 child->computeAndSetBlockDirectionMargins(this);
556 556
557 // Try to guess our correct logical top position. In most cases this guess w ill 557 // Try to guess our correct logical top position. In most cases this guess w ill
558 // be correct. Only if we're wrong (when we compute the real logical top pos ition) 558 // be correct. Only if we're wrong (when we compute the real logical top pos ition)
559 // will we have to potentially relayout. 559 // will we have to potentially relayout.
560 LayoutUnit estimateWithoutPagination; 560 LayoutUnit estimateWithoutPagination;
561 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination); 561 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination);
562 562
563 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves. 563 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves.
564 LayoutRect oldRect = child->frameRect(); 564 LayoutRect oldRect = child->frameRect();
565 LayoutUnit oldLogicalTop = logicalTopForChild(child); 565 LayoutUnit oldLogicalTop = logicalTopForChild(*child);
Julien - ping for review 2014/11/26 18:52:35 Same comment.
566 566
567 // Go ahead and position the child as though it didn't collapse with the top . 567 // Go ahead and position the child as though it didn't collapse with the top .
568 setLogicalTopForChild(child, logicalTopEstimate); 568 setLogicalTopForChild(child, logicalTopEstimate);
569 569
570 RenderBlockFlow* childRenderBlockFlow = child->isRenderBlockFlow() ? toRende rBlockFlow(child) : 0; 570 RenderBlockFlow* childRenderBlockFlow = child->isRenderBlockFlow() ? toRende rBlockFlow(child) : 0;
571 bool markDescendantsWithFloats = false; 571 bool markDescendantsWithFloats = false;
572 if (logicalTopEstimate != oldLogicalTop && childRenderBlockFlow && !childRen derBlockFlow->avoidsFloats() && childRenderBlockFlow->containsFloats()) { 572 if (logicalTopEstimate != oldLogicalTop && childRenderBlockFlow && !childRen derBlockFlow->avoidsFloats() && childRenderBlockFlow->containsFloats()) {
573 markDescendantsWithFloats = true; 573 markDescendantsWithFloats = true;
574 } else if (UNLIKELY(logicalTopEstimate.mightBeSaturated())) { 574 } else if (UNLIKELY(logicalTopEstimate.mightBeSaturated())) {
575 // logicalTopEstimate, returned by estimateLogicalTopPosition, might be saturated for 575 // logicalTopEstimate, returned by estimateLogicalTopPosition, might be saturated for
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // This has to be done after checking for clear, so that margins can be rese t if a clear occurred. 653 // This has to be done after checking for clear, so that margins can be rese t if a clear occurred.
654 if (marginInfo.atBeforeSideOfBlock() && !childIsSelfCollapsing) 654 if (marginInfo.atBeforeSideOfBlock() && !childIsSelfCollapsing)
655 marginInfo.setAtBeforeSideOfBlock(false); 655 marginInfo.setAtBeforeSideOfBlock(false);
656 656
657 // Now place the child in the correct left position 657 // Now place the child in the correct left position
658 determineLogicalLeftPositionForChild(child); 658 determineLogicalLeftPositionForChild(child);
659 659
660 LayoutSize childOffset = child->location() - oldRect.location(); 660 LayoutSize childOffset = child->location() - oldRect.location();
661 661
662 // Update our height now that the child has been placed in the correct posit ion. 662 // Update our height now that the child has been placed in the correct posit ion.
663 setLogicalHeight(logicalHeight() + logicalHeightForChild(child)); 663 setLogicalHeight(logicalHeight() + logicalHeightForChild(*child));
664 if (mustSeparateMarginAfterForChild(child)) { 664 if (mustSeparateMarginAfterForChild(child)) {
665 setLogicalHeight(logicalHeight() + marginAfterForChild(child)); 665 setLogicalHeight(logicalHeight() + marginAfterForChild(*child));
666 marginInfo.clearMargin(); 666 marginInfo.clearMargin();
667 } 667 }
668 // If the child has overhanging floats that intrude into following siblings (or possibly out 668 // If the child has overhanging floats that intrude into following siblings (or possibly out
669 // of this block), then the parent gets notified of the floats now. 669 // of this block), then the parent gets notified of the floats now.
670 if (childRenderBlockFlow) 670 if (childRenderBlockFlow)
671 addOverhangingFloats(childRenderBlockFlow, !childNeededLayout); 671 addOverhangingFloats(childRenderBlockFlow, !childNeededLayout);
672 672
673 // If the child moved, we have to invalidate its paint as well as any floati ng/positioned 673 // If the child moved, we have to invalidate its paint as well as any floati ng/positioned
674 // descendants. An exception is if we need a layout. In this case, we know w e're going to 674 // descendants. An exception is if we need a layout. In this case, we know w e're going to
675 // invalidate our paint (and the child) anyway. 675 // invalidate our paint (and the child) anyway.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 } 866 }
867 867
868 LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(RenderBox* child, LayoutU nit logicalOffset, bool includeMargins) 868 LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(RenderBox* child, LayoutU nit logicalOffset, bool includeMargins)
869 { 869 {
870 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo wThreadContainingBlock(); 870 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo wThreadContainingBlock();
871 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight(); 871 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight();
872 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr eaks && child->style()->columnBreakInside() == PBAVOID) 872 bool isUnsplittable = child->isUnsplittableForPagination() || (checkColumnBr eaks && child->style()->columnBreakInside() == PBAVOID)
873 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID); 873 || (checkPageBreaks && child->style()->pageBreakInside() == PBAVOID);
874 if (!isUnsplittable) 874 if (!isUnsplittable)
875 return logicalOffset; 875 return logicalOffset;
876 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); 876 LayoutUnit childLogicalHeight = logicalHeightForChild(*child) + (includeMarg ins ? marginBeforeForChild(*child) + marginAfterForChild(*child) : LayoutUnit()) ;
877 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 877 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
878 updateMinimumPageHeight(logicalOffset, childLogicalHeight); 878 updateMinimumPageHeight(logicalOffset, childLogicalHeight);
879 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) 879 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight)
880 return logicalOffset; 880 return logicalOffset;
881 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 881 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
882 if (remainingLogicalHeight < childLogicalHeight) 882 if (remainingLogicalHeight < childLogicalHeight)
883 return logicalOffset + remainingLogicalHeight; 883 return logicalOffset + remainingLogicalHeight;
884 return logicalOffset; 884 return logicalOffset;
885 } 885 }
886 886
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1038
1039 while (next) { 1039 while (next) {
1040 RenderBox* child = next; 1040 RenderBox* child = next;
1041 next = child->nextSiblingBox(); 1041 next = child->nextSiblingBox();
1042 1042
1043 child->setMayNeedPaintInvalidation(true); 1043 child->setMayNeedPaintInvalidation(true);
1044 1044
1045 if (childToExclude == child) 1045 if (childToExclude == child)
1046 continue; // Skip this child, since it will be positioned by the spe cialized subclass (fieldsets and ruby runs). 1046 continue; // Skip this child, since it will be positioned by the spe cialized subclass (fieldsets and ruby runs).
1047 1047
1048 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child); 1048 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *child);
1049 1049
1050 if (child->isOutOfFlowPositioned()) { 1050 if (child->isOutOfFlowPositioned()) {
1051 child->containingBlock()->insertPositionedObject(child); 1051 child->containingBlock()->insertPositionedObject(child);
1052 adjustPositionedBlock(child, marginInfo); 1052 adjustPositionedBlock(child, marginInfo);
1053 continue; 1053 continue;
1054 } 1054 }
1055 if (child->isFloating()) { 1055 if (child->isFloating()) {
1056 insertFloatingObject(child); 1056 insertFloatingObject(child);
1057 adjustFloatingBlock(marginInfo); 1057 adjustFloatingBlock(marginInfo);
1058 continue; 1058 continue;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 childBeforeNegative = childRenderBlockFlow->maxNegativeMarginAfter() ; 1131 childBeforeNegative = childRenderBlockFlow->maxNegativeMarginAfter() ;
1132 childAfterPositive = childRenderBlockFlow->maxPositiveMarginBefore() ; 1132 childAfterPositive = childRenderBlockFlow->maxPositiveMarginBefore() ;
1133 childAfterNegative = childRenderBlockFlow->maxNegativeMarginBefore() ; 1133 childAfterNegative = childRenderBlockFlow->maxNegativeMarginBefore() ;
1134 } else { 1134 } else {
1135 beforeMargin = child->marginAfter(); 1135 beforeMargin = child->marginAfter();
1136 afterMargin = child->marginBefore(); 1136 afterMargin = child->marginBefore();
1137 } 1137 }
1138 } else { 1138 } else {
1139 // The child is perpendicular to us, which means its margins don't colla pse but are on the 1139 // The child is perpendicular to us, which means its margins don't colla pse but are on the
1140 // "logical left/right" sides of the child box. We can just return the r aw margin in this case. 1140 // "logical left/right" sides of the child box. We can just return the r aw margin in this case.
1141 beforeMargin = marginBeforeForChild(child); 1141 beforeMargin = marginBeforeForChild(*child);
1142 afterMargin = marginAfterForChild(child); 1142 afterMargin = marginAfterForChild(*child);
Julien - ping for review 2014/11/26 18:52:35 Ditto.
1143 } 1143 }
1144 1144
1145 // Resolve uncollapsing margins into their positive/negative buckets. 1145 // Resolve uncollapsing margins into their positive/negative buckets.
1146 if (beforeMargin) { 1146 if (beforeMargin) {
1147 if (beforeMargin > 0) 1147 if (beforeMargin > 0)
1148 childBeforePositive = beforeMargin; 1148 childBeforePositive = beforeMargin;
1149 else 1149 else
1150 childBeforeNegative = -beforeMargin; 1150 childBeforeNegative = -beforeMargin;
1151 } 1151 }
1152 if (afterMargin) { 1152 if (afterMargin) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 logicalTop = logicalHeight() + collapsedBeforePos - collapsedBef oreNeg; 1263 logicalTop = logicalHeight() + collapsedBeforePos - collapsedBef oreNeg;
1264 } 1264 }
1265 } 1265 }
1266 } else { 1266 } else {
1267 if (mustSeparateMarginBeforeForChild(child)) { 1267 if (mustSeparateMarginBeforeForChild(child)) {
1268 ASSERT(!marginInfo.discardMargin() || (marginInfo.discardMargin() && !marginInfo.margin())); 1268 ASSERT(!marginInfo.discardMargin() || (marginInfo.discardMargin() && !marginInfo.margin()));
1269 // If we are at the before side of the block and we collapse, ignore the computed margin 1269 // If we are at the before side of the block and we collapse, ignore the computed margin
1270 // and just add the child margin to the container height. This will correctly position 1270 // and just add the child margin to the container height. This will correctly position
1271 // the child inside the container. 1271 // the child inside the container.
1272 LayoutUnit separateMargin = !marginInfo.canCollapseWithMarginBefore( ) ? marginInfo.margin() : LayoutUnit(0); 1272 LayoutUnit separateMargin = !marginInfo.canCollapseWithMarginBefore( ) ? marginInfo.margin() : LayoutUnit(0);
1273 setLogicalHeight(logicalHeight() + separateMargin + marginBeforeForC hild(child)); 1273 setLogicalHeight(logicalHeight() + separateMargin + marginBeforeForC hild(*child));
Julien - ping for review 2014/11/26 18:52:35 Ditto.
1274 logicalTop = logicalHeight(); 1274 logicalTop = logicalHeight();
1275 } else if (!marginInfo.discardMargin() && (!marginInfo.atBeforeSideOfBlo ck() 1275 } else if (!marginInfo.discardMargin() && (!marginInfo.atBeforeSideOfBlo ck()
1276 || (!marginInfo.canCollapseMarginBeforeWithChildren() 1276 || (!marginInfo.canCollapseMarginBeforeWithChildren()
1277 && (!document().inQuirksMode() || !marginInfo.quirkContainer() || !m arginInfo.hasMarginBeforeQuirk())))) { 1277 && (!document().inQuirksMode() || !marginInfo.quirkContainer() || !m arginInfo.hasMarginBeforeQuirk())))) {
1278 // We're collapsing with a previous sibling's margins and not 1278 // We're collapsing with a previous sibling's margins and not
1279 // with the top of the block. 1279 // with the top of the block.
1280 setLogicalHeight(logicalHeight() + std::max(marginInfo.positiveMargi n(), posTop) - std::max(marginInfo.negativeMargin(), negTop)); 1280 setLogicalHeight(logicalHeight() + std::max(marginInfo.positiveMargi n(), posTop) - std::max(marginInfo.negativeMargin(), negTop));
1281 logicalTop = logicalHeight(); 1281 logicalTop = logicalHeight();
1282 } 1282 }
1283 1283
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1438
1439 // The margins are discarded by a child that specified -webkit-margin-collap se: discard. 1439 // The margins are discarded by a child that specified -webkit-margin-collap se: discard.
1440 // FIXME: Use writing mode independent accessor for marginBeforeCollapse. 1440 // FIXME: Use writing mode independent accessor for marginBeforeCollapse.
1441 if (child->style()->marginBeforeCollapse() == MDISCARD) { 1441 if (child->style()->marginBeforeCollapse() == MDISCARD) {
1442 positiveMarginBefore = 0; 1442 positiveMarginBefore = 0;
1443 negativeMarginBefore = 0; 1443 negativeMarginBefore = 0;
1444 discardMarginBefore = true; 1444 discardMarginBefore = true;
1445 return; 1445 return;
1446 } 1446 }
1447 1447
1448 LayoutUnit beforeChildMargin = marginBeforeForChild(child); 1448 LayoutUnit beforeChildMargin = marginBeforeForChild(*child);
1449 positiveMarginBefore = std::max(positiveMarginBefore, beforeChildMargin); 1449 positiveMarginBefore = std::max(positiveMarginBefore, beforeChildMargin);
1450 negativeMarginBefore = std::max(negativeMarginBefore, -beforeChildMargin); 1450 negativeMarginBefore = std::max(negativeMarginBefore, -beforeChildMargin);
1451 1451
1452 if (!child->isRenderBlockFlow()) 1452 if (!child->isRenderBlockFlow())
1453 return; 1453 return;
1454 1454
1455 RenderBlockFlow* childBlockFlow = toRenderBlockFlow(child); 1455 RenderBlockFlow* childBlockFlow = toRenderBlockFlow(child);
1456 if (childBlockFlow->childrenInline() || childBlockFlow->isWritingModeRoot()) 1456 if (childBlockFlow->childrenInline() || childBlockFlow->isWritingModeRoot())
1457 return; 1457 return;
1458 1458
(...skipping 16 matching lines...) Expand all
1475 if (grandchildBox->isRenderBlock()) { 1475 if (grandchildBox->isRenderBlock()) {
1476 RenderBlock* grandchildBlock = toRenderBlock(grandchildBox); 1476 RenderBlock* grandchildBlock = toRenderBlock(grandchildBox);
1477 grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style()->has MarginBeforeQuirk()); 1477 grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style()->has MarginBeforeQuirk());
1478 grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style()->hasM arginAfterQuirk()); 1478 grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style()->hasM arginAfterQuirk());
1479 } 1479 }
1480 } 1480 }
1481 1481
1482 // If we have a 'clear' value but also have a margin we may not actually req uire clearance to move past any floats. 1482 // If we have a 'clear' value but also have a margin we may not actually req uire clearance to move past any floats.
1483 // If that's the case we want to be sure we estimate the correct position in cluding margins after any floats rather 1483 // If that's the case we want to be sure we estimate the correct position in cluding margins after any floats rather
1484 // than use 'clearance' later which could give us the wrong position. 1484 // than use 'clearance' later which could give us the wrong position.
1485 if (grandchildBox->style()->clear() != CNONE && childBlockFlow->marginBefore ForChild(grandchildBox) == 0) 1485 if (grandchildBox->style()->clear() != CNONE && childBlockFlow->marginBefore ForChild(*grandchildBox) == 0)
1486 return; 1486 return;
1487 1487
1488 // Collapse the margin of the grandchild box with our own to produce an esti mate. 1488 // Collapse the margin of the grandchild box with our own to produce an esti mate.
1489 childBlockFlow->marginBeforeEstimateForChild(grandchildBox, positiveMarginBe fore, negativeMarginBefore, discardMarginBefore); 1489 childBlockFlow->marginBeforeEstimateForChild(grandchildBox, positiveMarginBe fore, negativeMarginBefore, discardMarginBefore);
1490 } 1490 }
1491 1491
1492 LayoutUnit RenderBlockFlow::estimateLogicalTopPosition(RenderBox* child, const M arginInfo& marginInfo, LayoutUnit& estimateWithoutPagination) 1492 LayoutUnit RenderBlockFlow::estimateLogicalTopPosition(RenderBox* child, const M arginInfo& marginInfo, LayoutUnit& estimateWithoutPagination)
1493 { 1493 {
1494 // FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological 1494 // FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological
1495 // relayout if there are intruding floats. 1495 // relayout if there are intruding floats.
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 case CBOTH: 1880 case CBOTH:
1881 logicalBottom = lowestFloatLogicalBottom(); 1881 logicalBottom = lowestFloatLogicalBottom();
1882 break; 1882 break;
1883 } 1883 }
1884 1884
1885 // 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). 1885 // 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).
1886 LayoutUnit result = clearSet ? std::max<LayoutUnit>(0, logicalBottom - logic alTop) : LayoutUnit(); 1886 LayoutUnit result = clearSet ? std::max<LayoutUnit>(0, logicalBottom - logic alTop) : LayoutUnit();
1887 if (!result && child->avoidsFloats()) { 1887 if (!result && child->avoidsFloats()) {
1888 LayoutUnit newLogicalTop = logicalTop; 1888 LayoutUnit newLogicalTop = logicalTop;
1889 while (true) { 1889 while (true) {
1890 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog icalWidthForLine(newLogicalTop, false, logicalHeightForChild(child)); 1890 LayoutUnit availableLogicalWidthAtNewLogicalTopOffset = availableLog icalWidthForLine(newLogicalTop, false, logicalHeightForChild(*child));
1891 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi dthForContent()) 1891 if (availableLogicalWidthAtNewLogicalTopOffset == availableLogicalWi dthForContent())
1892 return newLogicalTop - logicalTop; 1892 return newLogicalTop - logicalTop;
1893 1893
1894 LayoutRect borderBox = child->borderBoxRect(); 1894 LayoutRect borderBox = child->borderBoxRect();
1895 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height(); 1895 LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height();
1896 1896
1897 borderBox = child->borderBoxAfterUpdatingLogicalWidth(newLogicalTop) ; 1897 borderBox = child->borderBoxAfterUpdatingLogicalWidth(newLogicalTop) ;
1898 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height(); 1898 LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWrit ingMode() ? borderBox.width() : borderBox.height();
1899 1899
1900 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA tNewLogicalTopOffset) { 1900 if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthA tNewLogicalTopOffset) {
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 floatBox->setChildNeedsLayout(MarkOnlyThis); 2296 floatBox->setChildNeedsLayout(MarkOnlyThis);
2297 2297
2298 bool needsBlockDirectionLocationSetBeforeLayout = isChildRenderBlock && view ()->layoutState()->needsBlockDirectionLocationSetBeforeLayout(); 2298 bool needsBlockDirectionLocationSetBeforeLayout = isChildRenderBlock && view ()->layoutState()->needsBlockDirectionLocationSetBeforeLayout();
2299 if (!needsBlockDirectionLocationSetBeforeLayout || isWritingModeRoot()) { // We are unsplittable if we're a block flow root. 2299 if (!needsBlockDirectionLocationSetBeforeLayout || isWritingModeRoot()) { // We are unsplittable if we're a block flow root.
2300 floatBox->layoutIfNeeded(); 2300 floatBox->layoutIfNeeded();
2301 } else { 2301 } else {
2302 floatBox->updateLogicalWidth(); 2302 floatBox->updateLogicalWidth();
2303 floatBox->computeAndSetBlockDirectionMargins(this); 2303 floatBox->computeAndSetBlockDirectionMargins(this);
2304 } 2304 }
2305 2305
2306 setLogicalWidthForFloat(newObj.get(), logicalWidthForChild(floatBox) + margi nStartForChild(floatBox) + marginEndForChild(floatBox)); 2306 setLogicalWidthForFloat(newObj.get(), logicalWidthForChild(*floatBox) + marg inStartForChild(*floatBox) + marginEndForChild(*floatBox));
2307 2307
2308 return m_floatingObjects->add(newObj.release()); 2308 return m_floatingObjects->add(newObj.release());
2309 } 2309 }
2310 2310
2311 void RenderBlockFlow::removeFloatingObject(RenderBox* floatBox) 2311 void RenderBlockFlow::removeFloatingObject(RenderBox* floatBox)
2312 { 2312 {
2313 if (m_floatingObjects) { 2313 if (m_floatingObjects) {
2314 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2314 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2315 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(floatBox); 2315 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(floatBox);
2316 if (it != floatingObjectSet.end()) { 2316 if (it != floatingObjectSet.end()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 // The containing block is responsible for positioning floats, so if we have floats in our 2401 // The containing block is responsible for positioning floats, so if we have floats in our
2402 // list that come from somewhere else, do not attempt to position them. 2402 // list that come from somewhere else, do not attempt to position them.
2403 if (floatingObject->renderer()->containingBlock() != this) 2403 if (floatingObject->renderer()->containingBlock() != this)
2404 continue; 2404 continue;
2405 2405
2406 RenderBox* childBox = floatingObject->renderer(); 2406 RenderBox* childBox = floatingObject->renderer();
2407 2407
2408 // FIXME Investigate if this can be removed. crbug.com/370006 2408 // FIXME Investigate if this can be removed. crbug.com/370006
2409 childBox->setMayNeedPaintInvalidation(true); 2409 childBox->setMayNeedPaintInvalidation(true);
2410 2410
2411 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ? marginStartForChild(childBox) : marginEndForChild(childBox); 2411 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ? marginStartForChild(*childBox) : marginEndForChild(*childBox);
2412 if (childBox->style()->clear() & CLEFT) 2412 if (childBox->style()->clear() & CLEFT)
2413 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Left), logicalTop); 2413 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Left), logicalTop);
2414 if (childBox->style()->clear() & CRIGHT) 2414 if (childBox->style()->clear() & CRIGHT)
2415 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Right), logicalTop); 2415 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Right), logicalTop);
2416 2416
2417 LayoutPoint floatLogicalLocation = computeLogicalLocationForFloat(floati ngObject, logicalTop); 2417 LayoutPoint floatLogicalLocation = computeLogicalLocationForFloat(floati ngObject, logicalTop);
2418 2418
2419 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x()); 2419 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
2420 2420
2421 setLogicalLeftForChild(childBox, floatLogicalLocation.x() + childLogical LeftMargin); 2421 setLogicalLeftForChild(childBox, floatLogicalLocation.x() + childLogical LeftMargin);
2422 setLogicalTopForChild(childBox, floatLogicalLocation.y() + marginBeforeF orChild(childBox)); 2422 setLogicalTopForChild(childBox, floatLogicalLocation.y() + marginBeforeF orChild(*childBox));
2423 2423
2424 SubtreeLayoutScope layoutScope(*childBox); 2424 SubtreeLayoutScope layoutScope(*childBox);
2425 LayoutState* layoutState = view()->layoutState(); 2425 LayoutState* layoutState = view()->layoutState();
2426 bool isPaginated = layoutState->isPaginated(); 2426 bool isPaginated = layoutState->isPaginated();
2427 if (isPaginated && !childBox->needsLayout()) 2427 if (isPaginated && !childBox->needsLayout())
2428 childBox->markForPaginationRelayoutIfNeeded(layoutScope); 2428 childBox->markForPaginationRelayoutIfNeeded(layoutScope);
2429 2429
2430 childBox->layoutIfNeeded(); 2430 childBox->layoutIfNeeded();
2431 2431
2432 if (isPaginated) { 2432 if (isPaginated) {
(...skipping 10 matching lines...) Expand all
2443 childBlockFlow->setPaginationStrut(0); 2443 childBlockFlow->setPaginationStrut(0);
2444 } 2444 }
2445 2445
2446 if (newLogicalTop != floatLogicalLocation.y()) { 2446 if (newLogicalTop != floatLogicalLocation.y()) {
2447 floatingObject->setPaginationStrut(newLogicalTop - floatLogicalL ocation.y()); 2447 floatingObject->setPaginationStrut(newLogicalTop - floatLogicalL ocation.y());
2448 2448
2449 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb ject, newLogicalTop); 2449 floatLogicalLocation = computeLogicalLocationForFloat(floatingOb ject, newLogicalTop);
2450 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x()) ; 2450 setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x()) ;
2451 2451
2452 setLogicalLeftForChild(childBox, floatLogicalLocation.x() + chil dLogicalLeftMargin); 2452 setLogicalLeftForChild(childBox, floatLogicalLocation.x() + chil dLogicalLeftMargin);
2453 setLogicalTopForChild(childBox, floatLogicalLocation.y() + margi nBeforeForChild(childBox)); 2453 setLogicalTopForChild(childBox, floatLogicalLocation.y() + margi nBeforeForChild(*childBox));
2454 2454
2455 if (childBox->isRenderBlock()) 2455 if (childBox->isRenderBlock())
2456 childBox->setChildNeedsLayout(MarkOnlyThis); 2456 childBox->setChildNeedsLayout(MarkOnlyThis);
2457 childBox->layoutIfNeeded(); 2457 childBox->layoutIfNeeded();
2458 } 2458 }
2459 } 2459 }
2460 2460
2461 setLogicalTopForFloat(floatingObject, floatLogicalLocation.y()); 2461 setLogicalTopForFloat(floatingObject, floatLogicalLocation.y());
2462 2462
2463 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(childBox) + marginBeforeForChild(childBox) + marginAfterForChild(childBox)); 2463 setLogicalHeightForFloat(floatingObject, logicalHeightForChild(*childBox ) + marginBeforeForChild(*childBox) + marginAfterForChild(*childBox));
2464 2464
2465 m_floatingObjects->addPlacedObject(floatingObject); 2465 m_floatingObjects->addPlacedObject(floatingObject);
2466 2466
2467 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo()) 2467 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo())
2468 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(childBo x)); 2468 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox));
2469 } 2469 }
2470 return true; 2470 return true;
2471 } 2471 }
2472 2472
2473 bool RenderBlockFlow::hasOverhangingFloat(RenderBox* renderer) 2473 bool RenderBlockFlow::hasOverhangingFloat(RenderBox* renderer)
2474 { 2474 {
2475 if (!m_floatingObjects || hasColumns() || !parent()) 2475 if (!m_floatingObjects || hasColumns() || !parent())
2476 return false; 2476 return false;
2477 2477
2478 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2478 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 return logicalHeight; 2592 return logicalHeight;
2593 2593
2594 LayoutUnit logicalBottom; 2594 LayoutUnit logicalBottom;
2595 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2595 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2596 FloatingObjectSetIterator end = floatingObjectSet.end(); 2596 FloatingObjectSetIterator end = floatingObjectSet.end();
2597 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { 2597 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) {
2598 FloatingObject* floatingObject = it->get(); 2598 FloatingObject* floatingObject = it->get();
2599 LayoutUnit floatLogicalBottom = logicalBottomForFloat(floatingObject); 2599 LayoutUnit floatLogicalBottom = logicalBottomForFloat(floatingObject);
2600 ShapeOutsideInfo* shapeOutside = floatingObject->renderer()->shapeOutsid eInfo(); 2600 ShapeOutsideInfo* shapeOutside = floatingObject->renderer()->shapeOutsid eInfo();
2601 if (shapeOutside && (offsetMode == ShapeOutsideFloatShapeOffset)) { 2601 if (shapeOutside && (offsetMode == ShapeOutsideFloatShapeOffset)) {
2602 LayoutUnit shapeLogicalBottom = logicalTopForFloat(floatingObject) + marginBeforeForChild(floatingObject->renderer()) + shapeOutside->shapeLogicalBo ttom(); 2602 LayoutUnit shapeLogicalBottom = logicalTopForFloat(floatingObject) + marginBeforeForChild(*(floatingObject->renderer())) + shapeOutside->shapeLogica lBottom();
2603 // Use the shapeLogicalBottom unless it extends outside of the margi n box, in which case it is clipped. 2603 // Use the shapeLogicalBottom unless it extends outside of the margi n box, in which case it is clipped.
2604 if (shapeLogicalBottom < floatLogicalBottom) 2604 if (shapeLogicalBottom < floatLogicalBottom)
2605 floatLogicalBottom = shapeLogicalBottom; 2605 floatLogicalBottom = shapeLogicalBottom;
2606 } 2606 }
2607 if (floatLogicalBottom > logicalHeight) 2607 if (floatLogicalBottom > logicalHeight)
2608 logicalBottom = logicalBottom ? std::min(floatLogicalBottom, logical Bottom) : floatLogicalBottom; 2608 logicalBottom = logicalBottom ? std::min(floatLogicalBottom, logical Bottom) : floatLogicalBottom;
2609 } 2609 }
2610 2610
2611 return logicalBottom; 2611 return logicalBottom;
2612 } 2612 }
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 FrameView* frameView = document().view(); 3091 FrameView* frameView = document().view();
3092 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3092 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3093 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3093 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3094 if (height() < visibleHeight) 3094 if (height() < visibleHeight)
3095 top += (visibleHeight - height()) / 2; 3095 top += (visibleHeight - height()) / 2;
3096 setY(top); 3096 setY(top);
3097 dialog->setCentered(top); 3097 dialog->setCentered(top);
3098 } 3098 }
3099 3099
3100 } // namespace blink 3100 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698