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

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

Issue 926193003: Move rendering/RenderBox to layout/LayoutBox. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool canCollapseMarginAfterWithLastChild() const { return m_canCollapseMargi nAfterWithLastChild; } 138 bool canCollapseMarginAfterWithLastChild() const { return m_canCollapseMargi nAfterWithLastChild; }
139 bool quirkContainer() const { return m_quirkContainer; } 139 bool quirkContainer() const { return m_quirkContainer; }
140 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQu irk; } 140 bool determinedMarginBeforeQuirk() const { return m_determinedMarginBeforeQu irk; }
141 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; } 141 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; }
142 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; } 142 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; }
143 LayoutUnit positiveMargin() const { return m_positiveMargin; } 143 LayoutUnit positiveMargin() const { return m_positiveMargin; }
144 LayoutUnit negativeMargin() const { return m_negativeMargin; } 144 LayoutUnit negativeMargin() const { return m_negativeMargin; }
145 bool discardMargin() const { return m_discardMargin; } 145 bool discardMargin() const { return m_discardMargin; }
146 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } 146 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; }
147 }; 147 };
148 static bool inNormalFlow(RenderBox* child) 148 static bool inNormalFlow(LayoutBox* child)
149 { 149 {
150 RenderBlock* curr = child->containingBlock(); 150 RenderBlock* curr = child->containingBlock();
151 RenderView* renderView = child->view(); 151 RenderView* renderView = child->view();
152 while (curr && curr != renderView) { 152 while (curr && curr != renderView) {
153 if (curr->hasColumns() || curr->isLayoutFlowThread()) 153 if (curr->hasColumns() || curr->isLayoutFlowThread())
154 return true; 154 return true;
155 if (curr->isFloatingOrOutOfFlowPositioned()) 155 if (curr->isFloatingOrOutOfFlowPositioned())
156 return false; 156 return false;
157 curr = curr->containingBlock(); 157 curr = curr->containingBlock();
158 } 158 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout); 487 layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
488 488
489 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway). 489 // Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
490 computeOverflow(oldClientAfterEdge); 490 computeOverflow(oldClientAfterEdge);
491 491
492 m_descendantsWithFloatsMarkedForLayout = false; 492 m_descendantsWithFloatsMarkedForLayout = false;
493 return true; 493 return true;
494 } 494 }
495 495
496 void RenderBlockFlow::determineLogicalLeftPositionForChild(RenderBox& child) 496 void RenderBlockFlow::determineLogicalLeftPositionForChild(LayoutBox& child)
497 { 497 {
498 LayoutUnit startPosition = borderStart() + paddingStart(); 498 LayoutUnit startPosition = borderStart() + paddingStart();
499 LayoutUnit initialStartPosition = startPosition; 499 LayoutUnit initialStartPosition = startPosition;
500 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) 500 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft())
501 startPosition -= verticalScrollbarWidth(); 501 startPosition -= verticalScrollbarWidth();
502 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth(); 502 LayoutUnit totalAvailableLogicalWidth = borderAndPaddingLogicalWidth() + ava ilableLogicalWidth();
503 503
504 LayoutUnit childMarginStart = marginStartForChild(child); 504 LayoutUnit childMarginStart = marginStartForChild(child);
505 LayoutUnit newPosition = startPosition + childMarginStart; 505 LayoutUnit newPosition = startPosition + childMarginStart;
506 506
507 LayoutUnit positionToAvoidFloats; 507 LayoutUnit positionToAvoidFloats;
508 if (child.avoidsFloats() && containsFloats() && !flowThreadContainingBlock() ) 508 if (child.avoidsFloats() && containsFloats() && !flowThreadContainingBlock() )
509 positionToAvoidFloats = startOffsetForLine(logicalTopForChild(child), fa lse, logicalHeightForChild(child)); 509 positionToAvoidFloats = startOffsetForLine(logicalTopForChild(child), fa lse, logicalHeightForChild(child));
510 510
511 // If the child has an offset from the content edge to avoid floats then use that, otherwise let any negative 511 // If the child has an offset from the content edge to avoid floats then use that, otherwise let any negative
512 // margin pull it back over the content edge or any positive margin push it out. 512 // margin pull it back over the content edge or any positive margin push it out.
513 // If the child is being centred then the margin calculated to do that has f actored in any offset required to 513 // If the child is being centred then the margin calculated to do that has f actored in any offset required to
514 // avoid floats, so use it if necessary. 514 // avoid floats, so use it if necessary.
515 if (style()->textAlign() == WEBKIT_CENTER || child.style()->marginStartUsing (style()).isAuto()) 515 if (style()->textAlign() == WEBKIT_CENTER || child.style()->marginStartUsing (style()).isAuto())
516 newPosition = std::max(newPosition, positionToAvoidFloats + childMarginS tart); 516 newPosition = std::max(newPosition, positionToAvoidFloats + childMarginS tart);
517 else if (positionToAvoidFloats > initialStartPosition) 517 else if (positionToAvoidFloats > initialStartPosition)
518 newPosition = std::max(newPosition, positionToAvoidFloats); 518 newPosition = std::max(newPosition, positionToAvoidFloats);
519 519
520 setLogicalLeftForChild(child, style()->isLeftToRightDirection() ? newPositio n : totalAvailableLogicalWidth - newPosition - logicalWidthForChild(child)); 520 setLogicalLeftForChild(child, style()->isLeftToRightDirection() ? newPositio n : totalAvailableLogicalWidth - newPosition - logicalWidthForChild(child));
521 } 521 }
522 522
523 void RenderBlockFlow::setLogicalLeftForChild(RenderBox& child, LayoutUnit logica lLeft) 523 void RenderBlockFlow::setLogicalLeftForChild(LayoutBox& child, LayoutUnit logica lLeft)
524 { 524 {
525 if (isHorizontalWritingMode()) { 525 if (isHorizontalWritingMode()) {
526 child.setX(logicalLeft); 526 child.setX(logicalLeft);
527 } else { 527 } else {
528 child.setY(logicalLeft); 528 child.setY(logicalLeft);
529 } 529 }
530 } 530 }
531 531
532 void RenderBlockFlow::setLogicalTopForChild(RenderBox& child, LayoutUnit logical Top) 532 void RenderBlockFlow::setLogicalTopForChild(LayoutBox& child, LayoutUnit logical Top)
533 { 533 {
534 if (isHorizontalWritingMode()) { 534 if (isHorizontalWritingMode()) {
535 child.setY(logicalTop); 535 child.setY(logicalTop);
536 } else { 536 } else {
537 child.setX(logicalTop); 537 child.setX(logicalTop);
538 } 538 }
539 } 539 }
540 540
541 void RenderBlockFlow::layoutBlockChild(RenderBox& child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom) 541 void RenderBlockFlow::layoutBlockChild(LayoutBox& child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom)
542 { 542 {
543 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); 543 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore();
544 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); 544 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();
545 545
546 // The child is a normal flow object. Compute the margins we will use for co llapsing now. 546 // The child is a normal flow object. Compute the margins we will use for co llapsing now.
547 child.computeAndSetBlockDirectionMargins(this); 547 child.computeAndSetBlockDirectionMargins(this);
548 548
549 // Try to guess our correct logical top position. In most cases this guess w ill 549 // Try to guess our correct logical top position. In most cases this guess w ill
550 // be correct. Only if we're wrong (when we compute the real logical top pos ition) 550 // be correct. Only if we're wrong (when we compute the real logical top pos ition)
551 // will we have to potentially relayout. 551 // will we have to potentially relayout.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (newHeight != size().height()) 674 if (newHeight != size().height())
675 setLogicalHeight(newHeight); 675 setLogicalHeight(newHeight);
676 } 676 }
677 677
678 if (child.isLayoutMultiColumnSpannerPlaceholder()) { 678 if (child.isLayoutMultiColumnSpannerPlaceholder()) {
679 // The actual column-span:all element is positioned by this placeholder child. 679 // The actual column-span:all element is positioned by this placeholder child.
680 positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child)); 680 positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child));
681 } 681 }
682 } 682 }
683 683
684 LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA fterClear, LayoutUnit estimateWithoutPagination, RenderBox& child, bool atBefore SideOfBlock) 684 LayoutUnit RenderBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA fterClear, LayoutUnit estimateWithoutPagination, LayoutBox& child, bool atBefore SideOfBlock)
685 { 685 {
686 RenderBlockFlow* childBlockFlow = child.isRenderBlockFlow() ? toRenderBlockF low(&child) : 0; 686 RenderBlockFlow* childBlockFlow = child.isRenderBlockFlow() ? toRenderBlockF low(&child) : 0;
687 687
688 if (estimateWithoutPagination != logicalTopAfterClear) { 688 if (estimateWithoutPagination != logicalTopAfterClear) {
689 // Our guess prior to pagination movement was wrong. Before we attempt t o paginate, let's try again at the new 689 // Our guess prior to pagination movement was wrong. Before we attempt t o paginate, let's try again at the new
690 // position. 690 // position.
691 setLogicalHeight(logicalTopAfterClear); 691 setLogicalHeight(logicalTopAfterClear);
692 setLogicalTopForChild(child, logicalTopAfterClear); 692 setLogicalTopForChild(child, logicalTopAfterClear);
693 693
694 if (child.shrinkToAvoidFloats()) { 694 if (child.shrinkToAvoidFloats()) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 855 }
856 } else if (remainingLogicalHeight == pageLogicalHeight) { 856 } else if (remainingLogicalHeight == pageLogicalHeight) {
857 // We're at the very top of a page or column. 857 // We're at the very top of a page or column.
858 if (lineBox != firstRootBox()) 858 if (lineBox != firstRootBox())
859 lineBox.setIsFirstAfterPageBreak(true); 859 lineBox.setIsFirstAfterPageBreak(true);
860 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage()) 860 if (lineBox != firstRootBox() || offsetFromLogicalTopOfFirstPage())
861 setPageBreak(logicalOffset, lineHeight); 861 setPageBreak(logicalOffset, lineHeight);
862 } 862 }
863 } 863 }
864 864
865 LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(RenderBox& child, LayoutU nit logicalOffset, bool includeMargins) 865 LayoutUnit RenderBlockFlow::adjustForUnsplittableChild(LayoutBox& child, LayoutU nit logicalOffset, bool includeMargins)
866 { 866 {
867 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo wThreadContainingBlock(); 867 bool checkColumnBreaks = view()->layoutState()->isPaginatingColumns() || flo wThreadContainingBlock();
868 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight(); 868 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight();
869 bool isUnsplittable = child.isUnsplittableForPagination() || (checkColumnBre aks && child.style()->columnBreakInside() == PBAVOID) 869 bool isUnsplittable = child.isUnsplittableForPagination() || (checkColumnBre aks && child.style()->columnBreakInside() == PBAVOID)
870 || (checkPageBreaks && child.style()->pageBreakInside() == PBAVOID); 870 || (checkPageBreaks && child.style()->pageBreakInside() == PBAVOID);
871 if (!isUnsplittable) 871 if (!isUnsplittable)
872 return logicalOffset; 872 return logicalOffset;
873 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit()); 873 LayoutUnit childLogicalHeight = logicalHeightForChild(child) + (includeMargi ns ? marginBeforeForChild(child) + marginAfterForChild(child) : LayoutUnit());
874 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 874 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
875 updateMinimumPageHeight(logicalOffset, childLogicalHeight); 875 updateMinimumPageHeight(logicalOffset, childLogicalHeight);
876 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight) 876 if (!pageLogicalHeight || childLogicalHeight > pageLogicalHeight)
877 return logicalOffset; 877 return logicalOffset;
878 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary); 878 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logi calOffset, ExcludePageBoundary);
879 if (remainingLogicalHeight < childLogicalHeight) 879 if (remainingLogicalHeight < childLogicalHeight)
880 return logicalOffset + remainingLogicalHeight; 880 return logicalOffset + remainingLogicalHeight;
881 return logicalOffset; 881 return logicalOffset;
882 } 882 }
883 883
884 void RenderBlockFlow::rebuildFloatsFromIntruding() 884 void RenderBlockFlow::rebuildFloatsFromIntruding()
885 { 885 {
886 if (m_floatingObjects) 886 if (m_floatingObjects)
887 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode()); 887 m_floatingObjects->setHorizontalWritingMode(isHorizontalWritingMode());
888 888
889 HashSet<RenderBox*> oldIntrudingFloatSet; 889 HashSet<LayoutBox*> oldIntrudingFloatSet;
890 if (!childrenInline() && m_floatingObjects) { 890 if (!childrenInline() && m_floatingObjects) {
891 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 891 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
892 FloatingObjectSetIterator end = floatingObjectSet.end(); 892 FloatingObjectSetIterator end = floatingObjectSet.end();
893 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { 893 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) {
894 FloatingObject* floatingObject = it->get(); 894 FloatingObject* floatingObject = it->get();
895 if (!floatingObject->isDescendant()) 895 if (!floatingObject->isDescendant())
896 oldIntrudingFloatSet.add(floatingObject->renderer()); 896 oldIntrudingFloatSet.add(floatingObject->renderer());
897 } 897 }
898 } 898 }
899 899
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 // The margin struct caches all our current margin collapsing state. The com pact struct caches state when we encounter compacts, 1023 // The margin struct caches all our current margin collapsing state. The com pact struct caches state when we encounter compacts,
1024 MarginInfo marginInfo(this, beforeEdge, afterEdge); 1024 MarginInfo marginInfo(this, beforeEdge, afterEdge);
1025 1025
1026 // Fieldsets need to find their legend and position it inside the border of the object. 1026 // Fieldsets need to find their legend and position it inside the border of the object.
1027 // The legend then gets skipped during normal layout. The same is true for r uby text. 1027 // The legend then gets skipped during normal layout. The same is true for r uby text.
1028 // It doesn't get included in the normal layout process but is instead skipp ed. 1028 // It doesn't get included in the normal layout process but is instead skipp ed.
1029 LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren, layoutScope); 1029 LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren, layoutScope);
1030 1030
1031 LayoutUnit previousFloatLogicalBottom = 0; 1031 LayoutUnit previousFloatLogicalBottom = 0;
1032 1032
1033 RenderBox* next = firstChildBox(); 1033 LayoutBox* next = firstChildBox();
1034 RenderBox* lastNormalFlowChild = 0; 1034 LayoutBox* lastNormalFlowChild = 0;
1035 1035
1036 while (next) { 1036 while (next) {
1037 RenderBox* child = next; 1037 LayoutBox* child = next;
1038 next = child->nextSiblingBox(); 1038 next = child->nextSiblingBox();
1039 1039
1040 child->setMayNeedPaintInvalidation(); 1040 child->setMayNeedPaintInvalidation();
1041 1041
1042 if (childToExclude == child) 1042 if (childToExclude == child)
1043 continue; // Skip this child, since it will be positioned by the spe cialized subclass (fieldsets and ruby runs). 1043 continue; // Skip this child, since it will be positioned by the spe cialized subclass (fieldsets and ruby runs).
1044 1044
1045 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *child); 1045 updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, *child);
1046 1046
1047 if (child->isOutOfFlowPositioned()) { 1047 if (child->isOutOfFlowPositioned()) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 && (blockStyle.logicalHeight().isAuto() && !blockStyle.logicalHeight().v alue()) && blockStyle.marginAfterCollapse() != MSEPARATE; 1102 && (blockStyle.logicalHeight().isAuto() && !blockStyle.logicalHeight().v alue()) && blockStyle.marginAfterCollapse() != MSEPARATE;
1103 1103
1104 m_quirkContainer = blockFlow->isTableCell() || blockFlow->isBody(); 1104 m_quirkContainer = blockFlow->isTableCell() || blockFlow->isBody();
1105 1105
1106 m_discardMargin = m_canCollapseMarginBeforeWithChildren && blockFlow->mustDi scardMarginBefore(); 1106 m_discardMargin = m_canCollapseMarginBeforeWithChildren && blockFlow->mustDi scardMarginBefore();
1107 1107
1108 m_positiveMargin = (m_canCollapseMarginBeforeWithChildren && !blockFlow->mus tDiscardMarginBefore()) ? blockFlow->maxPositiveMarginBefore() : LayoutUnit(); 1108 m_positiveMargin = (m_canCollapseMarginBeforeWithChildren && !blockFlow->mus tDiscardMarginBefore()) ? blockFlow->maxPositiveMarginBefore() : LayoutUnit();
1109 m_negativeMargin = (m_canCollapseMarginBeforeWithChildren && !blockFlow->mus tDiscardMarginBefore()) ? blockFlow->maxNegativeMarginBefore() : LayoutUnit(); 1109 m_negativeMargin = (m_canCollapseMarginBeforeWithChildren && !blockFlow->mus tDiscardMarginBefore()) ? blockFlow->maxNegativeMarginBefore() : LayoutUnit();
1110 } 1110 }
1111 1111
1112 RenderBlockFlow::MarginValues RenderBlockFlow::marginValuesForChild(RenderBox& c hild) const 1112 RenderBlockFlow::MarginValues RenderBlockFlow::marginValuesForChild(LayoutBox& c hild) const
1113 { 1113 {
1114 LayoutUnit childBeforePositive = 0; 1114 LayoutUnit childBeforePositive = 0;
1115 LayoutUnit childBeforeNegative = 0; 1115 LayoutUnit childBeforeNegative = 0;
1116 LayoutUnit childAfterPositive = 0; 1116 LayoutUnit childAfterPositive = 0;
1117 LayoutUnit childAfterNegative = 0; 1117 LayoutUnit childAfterNegative = 0;
1118 1118
1119 LayoutUnit beforeMargin = 0; 1119 LayoutUnit beforeMargin = 0;
1120 LayoutUnit afterMargin = 0; 1120 LayoutUnit afterMargin = 0;
1121 1121
1122 RenderBlockFlow* childRenderBlockFlow = child.isRenderBlockFlow() ? toRender BlockFlow(&child) : 0; 1122 RenderBlockFlow* childRenderBlockFlow = child.isRenderBlockFlow() ? toRender BlockFlow(&child) : 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 if (afterMargin) { 1162 if (afterMargin) {
1163 if (afterMargin > 0) 1163 if (afterMargin > 0)
1164 childAfterPositive = afterMargin; 1164 childAfterPositive = afterMargin;
1165 else 1165 else
1166 childAfterNegative = -afterMargin; 1166 childAfterNegative = -afterMargin;
1167 } 1167 }
1168 1168
1169 return RenderBlockFlow::MarginValues(childBeforePositive, childBeforeNegativ e, childAfterPositive, childAfterNegative); 1169 return RenderBlockFlow::MarginValues(childBeforePositive, childBeforeNegativ e, childAfterPositive, childAfterNegative);
1170 } 1170 }
1171 1171
1172 LayoutUnit RenderBlockFlow::collapseMargins(RenderBox& child, MarginInfo& margin Info, bool childIsSelfCollapsing) 1172 LayoutUnit RenderBlockFlow::collapseMargins(LayoutBox& child, MarginInfo& margin Info, bool childIsSelfCollapsing)
1173 { 1173 {
1174 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child); 1174 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child);
1175 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); 1175 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child);
1176 1176
1177 // The child discards the before margin when the the after margin has discar d in the case of a self collapsing block. 1177 // The child discards the before margin when the the after margin has discar d in the case of a self collapsing block.
1178 childDiscardMarginBefore = childDiscardMarginBefore || (childDiscardMarginAf ter && childIsSelfCollapsing); 1178 childDiscardMarginBefore = childDiscardMarginBefore || (childDiscardMarginAf ter && childIsSelfCollapsing);
1179 1179
1180 // Get the four margin values for the child and cache them. 1180 // Get the four margin values for the child and cache them.
1181 const RenderBlockFlow::MarginValues childMargins = marginValuesForChild(chil d); 1181 const RenderBlockFlow::MarginValues childMargins = marginValuesForChild(chil d);
1182 1182
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 // into the margin area of the self-collapsing block then the float it c lears is now intruding into |child|. Layout again so that we can look for 1326 // into the margin area of the self-collapsing block then the float it c lears is now intruding into |child|. Layout again so that we can look for
1327 // floats in the parent that overhang |child|'s new logical top. 1327 // floats in the parent that overhang |child|'s new logical top.
1328 bool logicalTopIntrudesIntoFloat = clearanceForSelfCollapsingBlock > 0 & & logicalTop < beforeCollapseLogicalTop; 1328 bool logicalTopIntrudesIntoFloat = clearanceForSelfCollapsingBlock > 0 & & logicalTop < beforeCollapseLogicalTop;
1329 if (logicalTopIntrudesIntoFloat && containsFloats() && !child.avoidsFloa ts() && lowestFloatLogicalBottom() > logicalTop) 1329 if (logicalTopIntrudesIntoFloat && containsFloats() && !child.avoidsFloa ts() && lowestFloatLogicalBottom() > logicalTop)
1330 child.setNeedsLayoutAndFullPaintInvalidation(); 1330 child.setNeedsLayoutAndFullPaintInvalidation();
1331 } 1331 }
1332 1332
1333 return logicalTop; 1333 return logicalTop;
1334 } 1334 }
1335 1335
1336 void RenderBlockFlow::adjustPositionedBlock(RenderBox& child, const MarginInfo& marginInfo) 1336 void RenderBlockFlow::adjustPositionedBlock(LayoutBox& child, const MarginInfo& marginInfo)
1337 { 1337 {
1338 bool isHorizontal = isHorizontalWritingMode(); 1338 bool isHorizontal = isHorizontalWritingMode();
1339 bool hasStaticBlockPosition = child.style()->hasStaticBlockPosition(isHorizo ntal); 1339 bool hasStaticBlockPosition = child.style()->hasStaticBlockPosition(isHorizo ntal);
1340 1340
1341 LayoutUnit logicalTop = logicalHeight(); 1341 LayoutUnit logicalTop = logicalHeight();
1342 updateStaticInlinePositionForChild(child, logicalTop); 1342 updateStaticInlinePositionForChild(child, logicalTop);
1343 1343
1344 if (!marginInfo.canCollapseWithMarginBefore()) { 1344 if (!marginInfo.canCollapseWithMarginBefore()) {
1345 // Positioned blocks don't collapse margins, so add the margin provided by 1345 // Positioned blocks don't collapse margins, so add the margin provided by
1346 // the container now. The child's own margin is added later when calcula ting its logical top. 1346 // the container now. The child's own margin is added later when calcula ting its logical top.
1347 LayoutUnit collapsedBeforePos = marginInfo.positiveMargin(); 1347 LayoutUnit collapsedBeforePos = marginInfo.positiveMargin();
1348 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin(); 1348 LayoutUnit collapsedBeforeNeg = marginInfo.negativeMargin();
1349 logicalTop += collapsedBeforePos - collapsedBeforeNeg; 1349 logicalTop += collapsedBeforePos - collapsedBeforeNeg;
1350 } 1350 }
1351 1351
1352 Layer* childLayer = child.layer(); 1352 Layer* childLayer = child.layer();
1353 if (childLayer->staticBlockPosition() != logicalTop) { 1353 if (childLayer->staticBlockPosition() != logicalTop) {
1354 childLayer->setStaticBlockPosition(logicalTop); 1354 childLayer->setStaticBlockPosition(logicalTop);
1355 if (hasStaticBlockPosition) 1355 if (hasStaticBlockPosition)
1356 child.setChildNeedsLayout(MarkOnlyThis); 1356 child.setChildNeedsLayout(MarkOnlyThis);
1357 } 1357 }
1358 } 1358 }
1359 1359
1360 LayoutUnit RenderBlockFlow::clearFloatsIfNeeded(RenderBox& child, MarginInfo& ma rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo s, bool childIsSelfCollapsing) 1360 LayoutUnit RenderBlockFlow::clearFloatsIfNeeded(LayoutBox& child, MarginInfo& ma rginInfo, LayoutUnit oldTopPosMargin, LayoutUnit oldTopNegMargin, LayoutUnit yPo s, bool childIsSelfCollapsing)
1361 { 1361 {
1362 LayoutUnit heightIncrease = getClearDelta(&child, yPos); 1362 LayoutUnit heightIncrease = getClearDelta(&child, yPos);
1363 if (!heightIncrease) 1363 if (!heightIncrease)
1364 return yPos; 1364 return yPos;
1365 1365
1366 if (childIsSelfCollapsing) { 1366 if (childIsSelfCollapsing) {
1367 bool childDiscardMargin = mustDiscardMarginBeforeForChild(child) || must DiscardMarginAfterForChild(child); 1367 bool childDiscardMargin = mustDiscardMarginBeforeForChild(child) || must DiscardMarginAfterForChild(child);
1368 1368
1369 // For self-collapsing blocks that clear, they can still collapse their 1369 // For self-collapsing blocks that clear, they can still collapse their
1370 // margins with following siblings. Reset the current margins to represe nt 1370 // margins with following siblings. Reset the current margins to represe nt
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1431
1432 if (marginInfo.hasMarginAfterQuirk() && !marginAfter()) { 1432 if (marginInfo.hasMarginAfterQuirk() && !marginAfter()) {
1433 // We have no bottom margin and our last child has a quirky margin. 1433 // We have no bottom margin and our last child has a quirky margin.
1434 // We will pick up this quirky margin and pass it through. 1434 // We will pick up this quirky margin and pass it through.
1435 // This deals with the <td><div><p> case. 1435 // This deals with the <td><div><p> case.
1436 setHasMarginAfterQuirk(true); 1436 setHasMarginAfterQuirk(true);
1437 } 1437 }
1438 } 1438 }
1439 } 1439 }
1440 1440
1441 void RenderBlockFlow::marginBeforeEstimateForChild(RenderBox& child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore, bool& discardMarginBefo re) const 1441 void RenderBlockFlow::marginBeforeEstimateForChild(LayoutBox& child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore, bool& discardMarginBefo re) const
1442 { 1442 {
1443 // Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky. 1443 // Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky.
1444 // Give up if the child specified -webkit-margin-collapse: separate that pre vents collapsing. 1444 // Give up if the child specified -webkit-margin-collapse: separate that pre vents collapsing.
1445 // FIXME: Use writing mode independent accessor for marginBeforeCollapse. 1445 // FIXME: Use writing mode independent accessor for marginBeforeCollapse.
1446 if ((document().inQuirksMode() && hasMarginBeforeQuirk(&child) && (isTableCe ll() || isBody())) || child.style()->marginBeforeCollapse() == MSEPARATE) 1446 if ((document().inQuirksMode() && hasMarginBeforeQuirk(&child) && (isTableCe ll() || isBody())) || child.style()->marginBeforeCollapse() == MSEPARATE)
1447 return; 1447 return;
1448 1448
1449 // The margins are discarded by a child that specified -webkit-margin-collap se: discard. 1449 // The margins are discarded by a child that specified -webkit-margin-collap se: discard.
1450 // FIXME: Use writing mode independent accessor for marginBeforeCollapse. 1450 // FIXME: Use writing mode independent accessor for marginBeforeCollapse.
1451 if (child.style()->marginBeforeCollapse() == MDISCARD) { 1451 if (child.style()->marginBeforeCollapse() == MDISCARD) {
(...skipping 11 matching lines...) Expand all
1463 return; 1463 return;
1464 1464
1465 RenderBlockFlow* childBlockFlow = toRenderBlockFlow(&child); 1465 RenderBlockFlow* childBlockFlow = toRenderBlockFlow(&child);
1466 if (childBlockFlow->childrenInline() || childBlockFlow->isWritingModeRoot()) 1466 if (childBlockFlow->childrenInline() || childBlockFlow->isWritingModeRoot())
1467 return; 1467 return;
1468 1468
1469 MarginInfo childMarginInfo(childBlockFlow, childBlockFlow->borderBefore() + childBlockFlow->paddingBefore(), childBlockFlow->borderAfter() + childBlockFlow- >paddingAfter()); 1469 MarginInfo childMarginInfo(childBlockFlow, childBlockFlow->borderBefore() + childBlockFlow->paddingBefore(), childBlockFlow->borderAfter() + childBlockFlow- >paddingAfter());
1470 if (!childMarginInfo.canCollapseMarginBeforeWithChildren()) 1470 if (!childMarginInfo.canCollapseMarginBeforeWithChildren())
1471 return; 1471 return;
1472 1472
1473 RenderBox* grandchildBox = childBlockFlow->firstChildBox(); 1473 LayoutBox* grandchildBox = childBlockFlow->firstChildBox();
1474 for ( ; grandchildBox; grandchildBox = grandchildBox->nextSiblingBox()) { 1474 for ( ; grandchildBox; grandchildBox = grandchildBox->nextSiblingBox()) {
1475 if (!grandchildBox->isFloatingOrOutOfFlowPositioned() && !grandchildBox- >isColumnSpanAll()) 1475 if (!grandchildBox->isFloatingOrOutOfFlowPositioned() && !grandchildBox- >isColumnSpanAll())
1476 break; 1476 break;
1477 } 1477 }
1478 1478
1479 if (!grandchildBox) 1479 if (!grandchildBox)
1480 return; 1480 return;
1481 1481
1482 // Make sure to update the block margins now for the grandchild box so that we're looking at current values. 1482 // Make sure to update the block margins now for the grandchild box so that we're looking at current values.
1483 if (grandchildBox->needsLayout()) { 1483 if (grandchildBox->needsLayout()) {
1484 grandchildBox->computeAndSetBlockDirectionMargins(this); 1484 grandchildBox->computeAndSetBlockDirectionMargins(this);
1485 if (grandchildBox->isRenderBlock()) { 1485 if (grandchildBox->isRenderBlock()) {
1486 RenderBlock* grandchildBlock = toRenderBlock(grandchildBox); 1486 RenderBlock* grandchildBlock = toRenderBlock(grandchildBox);
1487 grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style()->has MarginBeforeQuirk()); 1487 grandchildBlock->setHasMarginBeforeQuirk(grandchildBox->style()->has MarginBeforeQuirk());
1488 grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style()->hasM arginAfterQuirk()); 1488 grandchildBlock->setHasMarginAfterQuirk(grandchildBox->style()->hasM arginAfterQuirk());
1489 } 1489 }
1490 } 1490 }
1491 1491
1492 // If we have a 'clear' value but also have a margin we may not actually req uire clearance to move past any floats. 1492 // If we have a 'clear' value but also have a margin we may not actually req uire clearance to move past any floats.
1493 // If that's the case we want to be sure we estimate the correct position in cluding margins after any floats rather 1493 // If that's the case we want to be sure we estimate the correct position in cluding margins after any floats rather
1494 // than use 'clearance' later which could give us the wrong position. 1494 // than use 'clearance' later which could give us the wrong position.
1495 if (grandchildBox->style()->clear() != CNONE && childBlockFlow->marginBefore ForChild(*grandchildBox) == 0) 1495 if (grandchildBox->style()->clear() != CNONE && childBlockFlow->marginBefore ForChild(*grandchildBox) == 0)
1496 return; 1496 return;
1497 1497
1498 // Collapse the margin of the grandchild box with our own to produce an esti mate. 1498 // Collapse the margin of the grandchild box with our own to produce an esti mate.
1499 childBlockFlow->marginBeforeEstimateForChild(*grandchildBox, positiveMarginB efore, negativeMarginBefore, discardMarginBefore); 1499 childBlockFlow->marginBeforeEstimateForChild(*grandchildBox, positiveMarginB efore, negativeMarginBefore, discardMarginBefore);
1500 } 1500 }
1501 1501
1502 LayoutUnit RenderBlockFlow::estimateLogicalTopPosition(RenderBox& child, const M arginInfo& marginInfo, LayoutUnit& estimateWithoutPagination) 1502 LayoutUnit RenderBlockFlow::estimateLogicalTopPosition(LayoutBox& child, const M arginInfo& marginInfo, LayoutUnit& estimateWithoutPagination)
1503 { 1503 {
1504 // FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological 1504 // FIXME: We need to eliminate the estimation of vertical position, because when it's wrong we sometimes trigger a pathological
1505 // relayout if there are intruding floats. 1505 // relayout if there are intruding floats.
1506 LayoutUnit logicalTopEstimate = logicalHeight(); 1506 LayoutUnit logicalTopEstimate = logicalHeight();
1507 if (!marginInfo.canCollapseWithMarginBefore()) { 1507 if (!marginInfo.canCollapseWithMarginBefore()) {
1508 LayoutUnit positiveMarginBefore = 0; 1508 LayoutUnit positiveMarginBefore = 0;
1509 LayoutUnit negativeMarginBefore = 0; 1509 LayoutUnit negativeMarginBefore = 0;
1510 bool discardMarginBefore = false; 1510 bool discardMarginBefore = false;
1511 if (child.selfNeedsLayout()) { 1511 if (child.selfNeedsLayout()) {
1512 // Try to do a basic estimation of how the collapse is going to go. 1512 // Try to do a basic estimation of how the collapse is going to go.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 // height when computing the position of the float. This condition can be te sted 1572 // height when computing the position of the float. This condition can be te sted
1573 // for by simply calling canCollapseWithMarginBefore. See 1573 // for by simply calling canCollapseWithMarginBefore. See
1574 // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html fo r 1574 // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html fo r
1575 // an example of this scenario. 1575 // an example of this scenario.
1576 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? LayoutU nit() : marginInfo.margin(); 1576 LayoutUnit marginOffset = marginInfo.canCollapseWithMarginBefore() ? LayoutU nit() : marginInfo.margin();
1577 setLogicalHeight(logicalHeight() + marginOffset); 1577 setLogicalHeight(logicalHeight() + marginOffset);
1578 positionNewFloats(); 1578 positionNewFloats();
1579 setLogicalHeight(logicalHeight() - marginOffset); 1579 setLogicalHeight(logicalHeight() - marginOffset);
1580 } 1580 }
1581 1581
1582 void RenderBlockFlow::handleAfterSideOfBlock(RenderBox* lastChild, LayoutUnit be foreSide, LayoutUnit afterSide, MarginInfo& marginInfo) 1582 void RenderBlockFlow::handleAfterSideOfBlock(LayoutBox* lastChild, LayoutUnit be foreSide, LayoutUnit afterSide, MarginInfo& marginInfo)
1583 { 1583 {
1584 marginInfo.setAtAfterSideOfBlock(true); 1584 marginInfo.setAtAfterSideOfBlock(true);
1585 1585
1586 // If our last child was a self-collapsing block with clearance then our log ical height is flush with the 1586 // If our last child was a self-collapsing block with clearance then our log ical height is flush with the
1587 // bottom edge of the float that the child clears. The correct vertical posi tion for the margin-collapsing we want 1587 // bottom edge of the float that the child clears. The correct vertical posi tion for the margin-collapsing we want
1588 // to perform now is at the child's margin-top - so adjust our height to tha t position. 1588 // to perform now is at the child's margin-top - so adjust our height to tha t position.
1589 if (lastChild && lastChild->isRenderBlockFlow() && lastChild->isSelfCollapsi ngBlock()) 1589 if (lastChild && lastChild->isRenderBlockFlow() && lastChild->isSelfCollapsi ngBlock())
1590 setLogicalHeight(logicalHeight() - toRenderBlockFlow(lastChild)->marginO ffsetForSelfCollapsingBlock()); 1590 setLogicalHeight(logicalHeight() - toRenderBlockFlow(lastChild)->marginO ffsetForSelfCollapsingBlock());
1591 1591
1592 if (marginInfo.canCollapseMarginAfterWithChildren() && !marginInfo.canCollap seMarginAfterWithLastChild()) 1592 if (marginInfo.canCollapseMarginAfterWithChildren() && !marginInfo.canCollap seMarginAfterWithLastChild())
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 bool RenderBlockFlow::mustDiscardMarginBefore() const 1643 bool RenderBlockFlow::mustDiscardMarginBefore() const
1644 { 1644 {
1645 return style()->marginBeforeCollapse() == MDISCARD || (m_rareData && m_rareD ata->m_discardMarginBefore); 1645 return style()->marginBeforeCollapse() == MDISCARD || (m_rareData && m_rareD ata->m_discardMarginBefore);
1646 } 1646 }
1647 1647
1648 bool RenderBlockFlow::mustDiscardMarginAfter() const 1648 bool RenderBlockFlow::mustDiscardMarginAfter() const
1649 { 1649 {
1650 return style()->marginAfterCollapse() == MDISCARD || (m_rareData && m_rareDa ta->m_discardMarginAfter); 1650 return style()->marginAfterCollapse() == MDISCARD || (m_rareData && m_rareDa ta->m_discardMarginAfter);
1651 } 1651 }
1652 1652
1653 bool RenderBlockFlow::mustDiscardMarginBeforeForChild(const RenderBox& child) co nst 1653 bool RenderBlockFlow::mustDiscardMarginBeforeForChild(const LayoutBox& child) co nst
1654 { 1654 {
1655 ASSERT(!child.selfNeedsLayout()); 1655 ASSERT(!child.selfNeedsLayout());
1656 if (!child.isWritingModeRoot()) 1656 if (!child.isWritingModeRoot())
1657 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginBefore() : (child.style()->marginBeforeCollapse() == MDISCARD); 1657 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginBefore() : (child.style()->marginBeforeCollapse() == MDISCARD);
1658 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) 1658 if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
1659 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginAfter() : (child.style()->marginAfterCollapse() == MDISCARD); 1659 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginAfter() : (child.style()->marginAfterCollapse() == MDISCARD);
1660 1660
1661 // FIXME: We return false here because the implementation is not geometrical ly complete. We have values only for before/after, not start/end. 1661 // FIXME: We return false here because the implementation is not geometrical ly complete. We have values only for before/after, not start/end.
1662 // In case the boxes are perpendicular we assume the property is not specifi ed. 1662 // In case the boxes are perpendicular we assume the property is not specifi ed.
1663 return false; 1663 return false;
1664 } 1664 }
1665 1665
1666 bool RenderBlockFlow::mustDiscardMarginAfterForChild(const RenderBox& child) con st 1666 bool RenderBlockFlow::mustDiscardMarginAfterForChild(const LayoutBox& child) con st
1667 { 1667 {
1668 ASSERT(!child.selfNeedsLayout()); 1668 ASSERT(!child.selfNeedsLayout());
1669 if (!child.isWritingModeRoot()) 1669 if (!child.isWritingModeRoot())
1670 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginAfter() : (child.style()->marginAfterCollapse() == MDISCARD); 1670 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginAfter() : (child.style()->marginAfterCollapse() == MDISCARD);
1671 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) 1671 if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
1672 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginBefore() : (child.style()->marginBeforeCollapse() == MDISCARD); 1672 return child.isRenderBlockFlow() ? toRenderBlockFlow(&child)->mustDiscar dMarginBefore() : (child.style()->marginBeforeCollapse() == MDISCARD);
1673 1673
1674 // FIXME: See |mustDiscardMarginBeforeForChild| above. 1674 // FIXME: See |mustDiscardMarginBeforeForChild| above.
1675 return false; 1675 return false;
1676 } 1676 }
(...skipping 13 matching lines...) Expand all
1690 { 1690 {
1691 if (!m_rareData) { 1691 if (!m_rareData) {
1692 if (pos == RenderBlockFlowRareData::positiveMarginAfterDefault(this) && neg == RenderBlockFlowRareData::negativeMarginAfterDefault(this)) 1692 if (pos == RenderBlockFlowRareData::positiveMarginAfterDefault(this) && neg == RenderBlockFlowRareData::negativeMarginAfterDefault(this))
1693 return; 1693 return;
1694 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 1694 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
1695 } 1695 }
1696 m_rareData->m_margins.setPositiveMarginAfter(pos); 1696 m_rareData->m_margins.setPositiveMarginAfter(pos);
1697 m_rareData->m_margins.setNegativeMarginAfter(neg); 1697 m_rareData->m_margins.setNegativeMarginAfter(neg);
1698 } 1698 }
1699 1699
1700 bool RenderBlockFlow::mustSeparateMarginBeforeForChild(const RenderBox& child) c onst 1700 bool RenderBlockFlow::mustSeparateMarginBeforeForChild(const LayoutBox& child) c onst
1701 { 1701 {
1702 ASSERT(!child.selfNeedsLayout()); 1702 ASSERT(!child.selfNeedsLayout());
1703 const LayoutStyle& childStyle = child.styleRef(); 1703 const LayoutStyle& childStyle = child.styleRef();
1704 if (!child.isWritingModeRoot()) 1704 if (!child.isWritingModeRoot())
1705 return childStyle.marginBeforeCollapse() == MSEPARATE; 1705 return childStyle.marginBeforeCollapse() == MSEPARATE;
1706 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) 1706 if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
1707 return childStyle.marginAfterCollapse() == MSEPARATE; 1707 return childStyle.marginAfterCollapse() == MSEPARATE;
1708 1708
1709 // FIXME: See |mustDiscardMarginBeforeForChild| above. 1709 // FIXME: See |mustDiscardMarginBeforeForChild| above.
1710 return false; 1710 return false;
1711 } 1711 }
1712 1712
1713 bool RenderBlockFlow::mustSeparateMarginAfterForChild(const RenderBox& child) co nst 1713 bool RenderBlockFlow::mustSeparateMarginAfterForChild(const LayoutBox& child) co nst
1714 { 1714 {
1715 ASSERT(!child.selfNeedsLayout()); 1715 ASSERT(!child.selfNeedsLayout());
1716 const LayoutStyle& childStyle = child.styleRef(); 1716 const LayoutStyle& childStyle = child.styleRef();
1717 if (!child.isWritingModeRoot()) 1717 if (!child.isWritingModeRoot())
1718 return childStyle.marginAfterCollapse() == MSEPARATE; 1718 return childStyle.marginAfterCollapse() == MSEPARATE;
1719 if (child.isHorizontalWritingMode() == isHorizontalWritingMode()) 1719 if (child.isHorizontalWritingMode() == isHorizontalWritingMode())
1720 return childStyle.marginBeforeCollapse() == MSEPARATE; 1720 return childStyle.marginBeforeCollapse() == MSEPARATE;
1721 1721
1722 // FIXME: See |mustDiscardMarginBeforeForChild| above. 1722 // FIXME: See |mustDiscardMarginBeforeForChild| above.
1723 return false; 1723 return false;
1724 } 1724 }
1725 1725
1726 LayoutUnit RenderBlockFlow::applyBeforeBreak(RenderBox& child, LayoutUnit logica lOffset) 1726 LayoutUnit RenderBlockFlow::applyBeforeBreak(LayoutBox& child, LayoutUnit logica lOffset)
1727 { 1727 {
1728 // FIXME: Add page break checking here when we support printing. 1728 // FIXME: Add page break checking here when we support printing.
1729 LayoutFlowThread* flowThread = flowThreadContainingBlock(); 1729 LayoutFlowThread* flowThread = flowThreadContainingBlock();
1730 bool isInsideMulticolFlowThread = flowThread; 1730 bool isInsideMulticolFlowThread = flowThread;
1731 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns(); 1731 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns();
1732 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight(); // FIXME: Once columns can print we have to check this. 1732 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight(); // FIXME: Once columns can print we have to check this.
1733 bool checkBeforeAlways = (checkColumnBreaks && child.style()->columnBreakBef ore() == PBALWAYS) 1733 bool checkBeforeAlways = (checkColumnBreaks && child.style()->columnBreakBef ore() == PBALWAYS)
1734 || (checkPageBreaks && child.style()->pageBreakBefore() == PBALWAYS); 1734 || (checkPageBreaks && child.style()->pageBreakBefore() == PBALWAYS);
1735 if (checkBeforeAlways && inNormalFlow(&child)) { 1735 if (checkBeforeAlways && inNormalFlow(&child)) {
1736 if (checkColumnBreaks) { 1736 if (checkColumnBreaks) {
1737 if (isInsideMulticolFlowThread) { 1737 if (isInsideMulticolFlowThread) {
1738 LayoutUnit offsetBreakAdjustment = 0; 1738 LayoutUnit offsetBreakAdjustment = 0;
1739 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirst Page() + logicalOffset, &child, true, &offsetBreakAdjustment)) 1739 if (flowThread->addForcedRegionBreak(offsetFromLogicalTopOfFirst Page() + logicalOffset, &child, true, &offsetBreakAdjustment))
1740 return logicalOffset + offsetBreakAdjustment; 1740 return logicalOffset + offsetBreakAdjustment;
1741 } else { 1741 } else {
1742 view()->layoutState()->addForcedColumnBreak(child, logicalOffset ); 1742 view()->layoutState()->addForcedColumnBreak(child, logicalOffset );
1743 } 1743 }
1744 } 1744 }
1745 return nextPageLogicalTop(logicalOffset, IncludePageBoundary); 1745 return nextPageLogicalTop(logicalOffset, IncludePageBoundary);
1746 } 1746 }
1747 return logicalOffset; 1747 return logicalOffset;
1748 } 1748 }
1749 1749
1750 LayoutUnit RenderBlockFlow::applyAfterBreak(RenderBox& child, LayoutUnit logical Offset, MarginInfo& marginInfo) 1750 LayoutUnit RenderBlockFlow::applyAfterBreak(LayoutBox& child, LayoutUnit logical Offset, MarginInfo& marginInfo)
1751 { 1751 {
1752 // FIXME: Add page break checking here when we support printing. 1752 // FIXME: Add page break checking here when we support printing.
1753 LayoutFlowThread* flowThread = flowThreadContainingBlock(); 1753 LayoutFlowThread* flowThread = flowThreadContainingBlock();
1754 bool isInsideMulticolFlowThread = flowThread; 1754 bool isInsideMulticolFlowThread = flowThread;
1755 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns(); 1755 bool checkColumnBreaks = isInsideMulticolFlowThread || view()->layoutState() ->isPaginatingColumns();
1756 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight(); // FIXME: Once columns can print we have to check this. 1756 bool checkPageBreaks = !checkColumnBreaks && view()->layoutState()->pageLogi calHeight(); // FIXME: Once columns can print we have to check this.
1757 bool checkAfterAlways = (checkColumnBreaks && child.style()->columnBreakAfte r() == PBALWAYS) 1757 bool checkAfterAlways = (checkColumnBreaks && child.style()->columnBreakAfte r() == PBALWAYS)
1758 || (checkPageBreaks && child.style()->pageBreakAfter() == PBALWAYS); 1758 || (checkPageBreaks && child.style()->pageBreakAfter() == PBALWAYS);
1759 if (checkAfterAlways && inNormalFlow(&child)) { 1759 if (checkAfterAlways && inNormalFlow(&child)) {
1760 // So our margin doesn't participate in the next collapsing steps. 1760 // So our margin doesn't participate in the next collapsing steps.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 } 1804 }
1805 1805
1806 void RenderBlockFlow::deleteLineBoxTree() 1806 void RenderBlockFlow::deleteLineBoxTree()
1807 { 1807 {
1808 if (containsFloats()) 1808 if (containsFloats())
1809 m_floatingObjects->clearLineBoxTreePointers(); 1809 m_floatingObjects->clearLineBoxTreePointers();
1810 1810
1811 m_lineBoxes.deleteLineBoxTree(); 1811 m_lineBoxes.deleteLineBoxTree();
1812 } 1812 }
1813 1813
1814 void RenderBlockFlow::markAllDescendantsWithFloatsForLayout(RenderBox* floatToRe move, bool inLayout) 1814 void RenderBlockFlow::markAllDescendantsWithFloatsForLayout(LayoutBox* floatToRe move, bool inLayout)
1815 { 1815 {
1816 if (!everHadLayout() && !containsFloats()) 1816 if (!everHadLayout() && !containsFloats())
1817 return; 1817 return;
1818 1818
1819 if (m_descendantsWithFloatsMarkedForLayout && !floatToRemove) 1819 if (m_descendantsWithFloatsMarkedForLayout && !floatToRemove)
1820 return; 1820 return;
1821 m_descendantsWithFloatsMarkedForLayout |= !floatToRemove; 1821 m_descendantsWithFloatsMarkedForLayout |= !floatToRemove;
1822 1822
1823 MarkingBehavior markParents = inLayout ? MarkOnlyThis : MarkContainingBlockC hain; 1823 MarkingBehavior markParents = inLayout ? MarkOnlyThis : MarkContainingBlockC hain;
1824 setChildNeedsLayout(markParents); 1824 setChildNeedsLayout(markParents);
(...skipping 12 matching lines...) Expand all
1837 childBlock->setChildNeedsLayout(markParents); 1837 childBlock->setChildNeedsLayout(markParents);
1838 continue; 1838 continue;
1839 } 1839 }
1840 RenderBlockFlow* childBlockFlow = toRenderBlockFlow(child); 1840 RenderBlockFlow* childBlockFlow = toRenderBlockFlow(child);
1841 if ((floatToRemove ? childBlockFlow->containsFloat(floatToRemove) : childBlockFlow->containsFloats()) || childBlockFlow->shrinkToAvoidFloats()) 1841 if ((floatToRemove ? childBlockFlow->containsFloat(floatToRemove) : childBlockFlow->containsFloats()) || childBlockFlow->shrinkToAvoidFloats())
1842 childBlockFlow->markAllDescendantsWithFloatsForLayout(floatToRem ove, inLayout); 1842 childBlockFlow->markAllDescendantsWithFloatsForLayout(floatToRem ove, inLayout);
1843 } 1843 }
1844 } 1844 }
1845 } 1845 }
1846 1846
1847 void RenderBlockFlow::markSiblingsWithFloatsForLayout(RenderBox* floatToRemove) 1847 void RenderBlockFlow::markSiblingsWithFloatsForLayout(LayoutBox* floatToRemove)
1848 { 1848 {
1849 if (!m_floatingObjects) 1849 if (!m_floatingObjects)
1850 return; 1850 return;
1851 1851
1852 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1852 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1853 FloatingObjectSetIterator end = floatingObjectSet.end(); 1853 FloatingObjectSetIterator end = floatingObjectSet.end();
1854 1854
1855 for (LayoutObject* next = nextSibling(); next; next = next->nextSibling()) { 1855 for (LayoutObject* next = nextSibling(); next; next = next->nextSibling()) {
1856 if (!next->isRenderBlockFlow() || next->isFloatingOrOutOfFlowPositioned( ) || toRenderBlockFlow(next)->avoidsFloats()) 1856 if (!next->isRenderBlockFlow() || next->isFloatingOrOutOfFlowPositioned( ) || toRenderBlockFlow(next)->avoidsFloats())
1857 continue; 1857 continue;
1858 1858
1859 RenderBlockFlow* nextBlock = toRenderBlockFlow(next); 1859 RenderBlockFlow* nextBlock = toRenderBlockFlow(next);
1860 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) { 1860 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end ; ++it) {
1861 RenderBox* floatingBox = (*it)->renderer(); 1861 LayoutBox* floatingBox = (*it)->renderer();
1862 if (floatToRemove && floatingBox != floatToRemove) 1862 if (floatToRemove && floatingBox != floatToRemove)
1863 continue; 1863 continue;
1864 if (nextBlock->containsFloat(floatingBox)) 1864 if (nextBlock->containsFloat(floatingBox))
1865 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox); 1865 nextBlock->markAllDescendantsWithFloatsForLayout(floatingBox);
1866 } 1866 }
1867 } 1867 }
1868 } 1868 }
1869 1869
1870 LayoutUnit RenderBlockFlow::getClearDelta(RenderBox* child, LayoutUnit logicalTo p) 1870 LayoutUnit RenderBlockFlow::getClearDelta(LayoutBox* child, LayoutUnit logicalTo p)
1871 { 1871 {
1872 // There is no need to compute clearance if we have no floats. 1872 // There is no need to compute clearance if we have no floats.
1873 if (!containsFloats()) 1873 if (!containsFloats())
1874 return LayoutUnit(); 1874 return LayoutUnit();
1875 1875
1876 // At least one float is present. We need to perform the clearance computati on. 1876 // At least one float is present. We need to perform the clearance computati on.
1877 bool clearSet = child->style()->clear() != CNONE; 1877 bool clearSet = child->style()->clear() != CNONE;
1878 LayoutUnit logicalBottom = 0; 1878 LayoutUnit logicalBottom = 0;
1879 switch (child->style()->clear()) { 1879 switch (child->style()->clear()) {
1880 case CNONE: 1880 case CNONE:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 RenderBlockFlow* parentBlockFlow = this; 1954 RenderBlockFlow* parentBlockFlow = this;
1955 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 1955 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
1956 FloatingObjectSetIterator end = floatingObjectSet.end(); 1956 FloatingObjectSetIterator end = floatingObjectSet.end();
1957 1957
1958 for (LayoutObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) { 1958 for (LayoutObject* curr = parent(); curr && !curr->isRenderView(); curr = curr->parent()) {
1959 if (curr->isRenderBlockFlow()) { 1959 if (curr->isRenderBlockFlow()) {
1960 RenderBlockFlow* currBlock = toRenderBlockFlow(curr); 1960 RenderBlockFlow* currBlock = toRenderBlockFlow(curr);
1961 1961
1962 if (currBlock->hasOverhangingFloats()) { 1962 if (currBlock->hasOverhangingFloats()) {
1963 for (FloatingObjectSetIterator it = floatingObjectSet.begin( ); it != end; ++it) { 1963 for (FloatingObjectSetIterator it = floatingObjectSet.begin( ); it != end; ++it) {
1964 RenderBox* renderer = (*it)->renderer(); 1964 LayoutBox* renderer = (*it)->renderer();
1965 if (currBlock->hasOverhangingFloat(renderer)) { 1965 if (currBlock->hasOverhangingFloat(renderer)) {
1966 parentBlockFlow = currBlock; 1966 parentBlockFlow = currBlock;
1967 break; 1967 break;
1968 } 1968 }
1969 } 1969 }
1970 } 1970 }
1971 } 1971 }
1972 } 1972 }
1973 1973
1974 parentBlockFlow->markAllDescendantsWithFloatsForLayout(); 1974 parentBlockFlow->markAllDescendantsWithFloatsForLayout();
1975 parentBlockFlow->markSiblingsWithFloatsForLayout(); 1975 parentBlockFlow->markSiblingsWithFloatsForLayout();
1976 } 1976 }
1977 1977
1978 if (diff.needsFullLayout() || !oldStyle) 1978 if (diff.needsFullLayout() || !oldStyle)
1979 createOrDestroyMultiColumnFlowThreadIfNeeded(oldStyle); 1979 createOrDestroyMultiColumnFlowThreadIfNeeded(oldStyle);
1980 if (oldStyle) { 1980 if (oldStyle) {
1981 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { 1981 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
1982 if (!style()->columnRuleEquivalent(oldStyle)) { 1982 if (!style()->columnRuleEquivalent(oldStyle)) {
1983 // Column rules are painted by anonymous column set children of the multicol 1983 // Column rules are painted by anonymous column set children of the multicol
1984 // container. We need to notify them. 1984 // container. We need to notify them.
1985 flowThread->columnRuleStyleDidChange(); 1985 flowThread->columnRuleStyleDidChange();
1986 } 1986 }
1987 } 1987 }
1988 } 1988 }
1989 } 1989 }
1990 1990
1991 void RenderBlockFlow::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildre n, RenderBox& child) 1991 void RenderBlockFlow::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildre n, LayoutBox& child)
1992 { 1992 {
1993 if (child.isLayoutMultiColumnSpannerPlaceholder() && toLayoutMultiColumnSpan nerPlaceholder(child).rendererInFlowThread()->needsLayout()) { 1993 if (child.isLayoutMultiColumnSpannerPlaceholder() && toLayoutMultiColumnSpan nerPlaceholder(child).rendererInFlowThread()->needsLayout()) {
1994 // The containing block of a spanner is the multicol container (|this| b lock), but the spanner 1994 // The containing block of a spanner is the multicol container (|this| b lock), but the spanner
1995 // is laid out via its spanner set (|child|), so we need to make sure th at we enter it. 1995 // is laid out via its spanner set (|child|), so we need to make sure th at we enter it.
1996 child.setChildNeedsLayout(MarkOnlyThis); 1996 child.setChildNeedsLayout(MarkOnlyThis);
1997 } 1997 }
1998 RenderBlock::updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child); 1998 RenderBlock::updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child);
1999 } 1999 }
2000 2000
2001 void RenderBlockFlow::updateStaticInlinePositionForChild(RenderBox& child, Layou tUnit logicalTop) 2001 void RenderBlockFlow::updateStaticInlinePositionForChild(LayoutBox& child, Layou tUnit logicalTop)
2002 { 2002 {
2003 if (child.style()->isOriginalDisplayInlineType()) 2003 if (child.style()->isOriginalDisplayInlineType())
2004 setStaticInlinePositionForChild(child, startAlignedOffsetForLine(logical Top, false)); 2004 setStaticInlinePositionForChild(child, startAlignedOffsetForLine(logical Top, false));
2005 else 2005 else
2006 setStaticInlinePositionForChild(child, startOffsetForContent()); 2006 setStaticInlinePositionForChild(child, startOffsetForContent());
2007 } 2007 }
2008 2008
2009 void RenderBlockFlow::setStaticInlinePositionForChild(RenderBox& child, LayoutUn it inlinePosition) 2009 void RenderBlockFlow::setStaticInlinePositionForChild(LayoutBox& child, LayoutUn it inlinePosition)
2010 { 2010 {
2011 child.layer()->setStaticInlinePosition(inlinePosition); 2011 child.layer()->setStaticInlinePosition(inlinePosition);
2012 } 2012 }
2013 2013
2014 void RenderBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild ) 2014 void RenderBlockFlow::addChild(LayoutObject* newChild, LayoutObject* beforeChild )
2015 { 2015 {
2016 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) { 2016 if (LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread()) {
2017 if (beforeChild == flowThread) 2017 if (beforeChild == flowThread)
2018 beforeChild = flowThread->firstChild(); 2018 beforeChild = flowThread->firstChild();
2019 ASSERT(!beforeChild || beforeChild->isDescendantOf(flowThread)); 2019 ASSERT(!beforeChild || beforeChild->isDescendantOf(flowThread));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 FloatingObjectSetIterator end = floatingObjectSet.end(); 2076 FloatingObjectSetIterator end = floatingObjectSet.end();
2077 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) { 2077 for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++ it) {
2078 FloatingObject* floatingObject = it->get(); 2078 FloatingObject* floatingObject = it->get();
2079 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and 2079 // Only issue paint invaldiations for the object if it is overhanging, i s not in its own layer, and
2080 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter 2080 // is our responsibility to paint (m_shouldPaint is set). When paintAllD escendants is true, the latter
2081 // condition is replaced with being a descendant of us. 2081 // condition is replaced with being a descendant of us.
2082 if (logicalBottomForFloat(floatingObject) > logicalHeight() 2082 if (logicalBottomForFloat(floatingObject) > logicalHeight()
2083 && !floatingObject->renderer()->hasSelfPaintingLayer() 2083 && !floatingObject->renderer()->hasSelfPaintingLayer()
2084 && (floatingObject->shouldPaint() || (paintAllDescendants && floatin gObject->renderer()->isDescendantOf(this)))) { 2084 && (floatingObject->shouldPaint() || (paintAllDescendants && floatin gObject->renderer()->isDescendantOf(this)))) {
2085 2085
2086 RenderBox* floatingRenderer = floatingObject->renderer(); 2086 LayoutBox* floatingRenderer = floatingObject->renderer();
2087 floatingRenderer->setShouldDoFullPaintInvalidation(); 2087 floatingRenderer->setShouldDoFullPaintInvalidation();
2088 floatingRenderer->invalidatePaintForOverhangingFloats(false); 2088 floatingRenderer->invalidatePaintForOverhangingFloats(false);
2089 } 2089 }
2090 } 2090 }
2091 } 2091 }
2092 2092
2093 void RenderBlockFlow::invalidatePaintForOverflow() 2093 void RenderBlockFlow::invalidatePaintForOverflow()
2094 { 2094 {
2095 // FIXME: We could tighten up the left and right invalidation points if we l et layoutInlineChildren fill them in based off the particular lines 2095 // FIXME: We could tighten up the left and right invalidation points if we l et layoutInlineChildren fill them in based off the particular lines
2096 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca se either. 2096 // it had to lay out. We wouldn't need the hasOverflowClip() hack in that ca se either.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 break; 2179 break;
2180 case CBOTH: 2180 case CBOTH:
2181 newY = lowestFloatLogicalBottom(); 2181 newY = lowestFloatLogicalBottom();
2182 default: 2182 default:
2183 break; 2183 break;
2184 } 2184 }
2185 if (size().height() < newY) 2185 if (size().height() < newY)
2186 setLogicalHeight(newY); 2186 setLogicalHeight(newY);
2187 } 2187 }
2188 2188
2189 bool RenderBlockFlow::containsFloat(RenderBox* renderer) const 2189 bool RenderBlockFlow::containsFloat(LayoutBox* renderer) const
2190 { 2190 {
2191 return m_floatingObjects && m_floatingObjects->set().contains<FloatingObject HashTranslator>(renderer); 2191 return m_floatingObjects && m_floatingObjects->set().contains<FloatingObject HashTranslator>(renderer);
2192 } 2192 }
2193 2193
2194 void RenderBlockFlow::removeFloatingObjects() 2194 void RenderBlockFlow::removeFloatingObjects()
2195 { 2195 {
2196 if (!m_floatingObjects) 2196 if (!m_floatingObjects)
2197 return; 2197 return;
2198 2198
2199 markSiblingsWithFloatsForLayout(); 2199 markSiblingsWithFloatsForLayout();
2200 2200
2201 m_floatingObjects->clear(); 2201 m_floatingObjects->clear();
2202 } 2202 }
2203 2203
2204 LayoutPoint RenderBlockFlow::flipFloatForWritingModeForChild(const FloatingObjec t* child, const LayoutPoint& point) const 2204 LayoutPoint RenderBlockFlow::flipFloatForWritingModeForChild(const FloatingObjec t* child, const LayoutPoint& point) const
2205 { 2205 {
2206 if (!style()->isFlippedBlocksWritingMode()) 2206 if (!style()->isFlippedBlocksWritingMode())
2207 return point; 2207 return point;
2208 2208
2209 // This is similar to RenderBox::flipForWritingModeForChild. We have to subt ract out our left/top offsets twice, since 2209 // This is similar to LayoutBox::flipForWritingModeForChild. We have to subt ract out our left/top offsets twice, since
2210 // it's going to get added back in. We hide this complication here so that t he calling code looks normal for the unflipped 2210 // it's going to get added back in. We hide this complication here so that t he calling code looks normal for the unflipped
2211 // case. 2211 // case.
2212 if (isHorizontalWritingMode()) 2212 if (isHorizontalWritingMode())
2213 return LayoutPoint(point.x(), point.y() + size().height() - child->rende rer()->size().height() - 2 * yPositionForFloatIncludingMargin(child)); 2213 return LayoutPoint(point.x(), point.y() + size().height() - child->rende rer()->size().height() - 2 * yPositionForFloatIncludingMargin(child));
2214 return LayoutPoint(point.x() + size().width() - child->renderer()->size().wi dth() - 2 * xPositionForFloatIncludingMargin(child), point.y()); 2214 return LayoutPoint(point.x() + size().width() - child->renderer()->size().wi dth() - 2 * xPositionForFloatIncludingMargin(child), point.y());
2215 } 2215 }
2216 2216
2217 LayoutUnit RenderBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin g) const 2217 LayoutUnit RenderBlockFlow::logicalLeftOffsetForPositioningFloat(LayoutUnit logi calTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit* heightRemainin g) const
2218 { 2218 {
2219 LayoutUnit offset = fixedOffset; 2219 LayoutUnit offset = fixedOffset;
(...skipping 25 matching lines...) Expand all
2245 LayoutUnit right = offsetFromFloats; 2245 LayoutUnit right = offsetFromFloats;
2246 2246
2247 if (applyTextIndent && !style()->isLeftToRightDirection()) 2247 if (applyTextIndent && !style()->isLeftToRightDirection())
2248 right -= textIndentOffset(); 2248 right -= textIndentOffset();
2249 2249
2250 return right; 2250 return right;
2251 } 2251 }
2252 2252
2253 LayoutPoint RenderBlockFlow::computeLogicalLocationForFloat(const FloatingObject * floatingObject, LayoutUnit logicalTopOffset) const 2253 LayoutPoint RenderBlockFlow::computeLogicalLocationForFloat(const FloatingObject * floatingObject, LayoutUnit logicalTopOffset) const
2254 { 2254 {
2255 RenderBox* childBox = floatingObject->renderer(); 2255 LayoutBox* childBox = floatingObject->renderer();
2256 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa rt of left offset. 2256 LayoutUnit logicalLeftOffset = logicalLeftOffsetForContent(); // Constant pa rt of left offset.
2257 LayoutUnit logicalRightOffset; // Constant part of right offset. 2257 LayoutUnit logicalRightOffset; // Constant part of right offset.
2258 logicalRightOffset = logicalRightOffsetForContent(); 2258 logicalRightOffset = logicalRightOffsetForContent();
2259 2259
2260 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject) , logicalRightOffset - logicalLeftOffset); // The width we look for. 2260 LayoutUnit floatLogicalWidth = std::min(logicalWidthForFloat(floatingObject) , logicalRightOffset - logicalLeftOffset); // The width we look for.
2261 2261
2262 LayoutUnit floatLogicalLeft; 2262 LayoutUnit floatLogicalLeft;
2263 2263
2264 bool insideFlowThread = flowThreadContainingBlock(); 2264 bool insideFlowThread = flowThreadContainingBlock();
2265 2265
(...skipping 28 matching lines...) Expand all
2294 } 2294 }
2295 // Use the original width of the float here, since the local variable 2295 // Use the original width of the float here, since the local variable
2296 // |floatLogicalWidth| was capped to the available line width. See 2296 // |floatLogicalWidth| was capped to the available line width. See
2297 // fast/block/float/clamped-right-float.html. 2297 // fast/block/float/clamped-right-float.html.
2298 floatLogicalLeft -= logicalWidthForFloat(floatingObject); 2298 floatLogicalLeft -= logicalWidthForFloat(floatingObject);
2299 } 2299 }
2300 2300
2301 return LayoutPoint(floatLogicalLeft, logicalTopOffset); 2301 return LayoutPoint(floatLogicalLeft, logicalTopOffset);
2302 } 2302 }
2303 2303
2304 FloatingObject* RenderBlockFlow::insertFloatingObject(RenderBox& floatBox) 2304 FloatingObject* RenderBlockFlow::insertFloatingObject(LayoutBox& floatBox)
2305 { 2305 {
2306 ASSERT(floatBox.isFloating()); 2306 ASSERT(floatBox.isFloating());
2307 2307
2308 // Create the list of special objects if we don't aleady have one 2308 // Create the list of special objects if we don't aleady have one
2309 if (!m_floatingObjects) { 2309 if (!m_floatingObjects) {
2310 createFloatingObjects(); 2310 createFloatingObjects();
2311 } else { 2311 } else {
2312 // Don't insert the object again if it's already in the list 2312 // Don't insert the object again if it's already in the list
2313 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2313 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2314 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(&floatBox); 2314 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(&floatBox);
(...skipping 17 matching lines...) Expand all
2332 } else { 2332 } else {
2333 floatBox.updateLogicalWidth(); 2333 floatBox.updateLogicalWidth();
2334 floatBox.computeAndSetBlockDirectionMargins(this); 2334 floatBox.computeAndSetBlockDirectionMargins(this);
2335 } 2335 }
2336 2336
2337 setLogicalWidthForFloat(newObj.get(), logicalWidthForChild(floatBox) + margi nStartForChild(floatBox) + marginEndForChild(floatBox)); 2337 setLogicalWidthForFloat(newObj.get(), logicalWidthForChild(floatBox) + margi nStartForChild(floatBox) + marginEndForChild(floatBox));
2338 2338
2339 return m_floatingObjects->add(newObj.release()); 2339 return m_floatingObjects->add(newObj.release());
2340 } 2340 }
2341 2341
2342 void RenderBlockFlow::removeFloatingObject(RenderBox* floatBox) 2342 void RenderBlockFlow::removeFloatingObject(LayoutBox* floatBox)
2343 { 2343 {
2344 if (m_floatingObjects) { 2344 if (m_floatingObjects) {
2345 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2345 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2346 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(floatBox); 2346 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHash Translator>(floatBox);
2347 if (it != floatingObjectSet.end()) { 2347 if (it != floatingObjectSet.end()) {
2348 FloatingObject* floatingObject = it->get(); 2348 FloatingObject* floatingObject = it->get();
2349 if (childrenInline()) { 2349 if (childrenInline()) {
2350 LayoutUnit logicalTop = logicalTopForFloat(floatingObject); 2350 LayoutUnit logicalTop = logicalTopForFloat(floatingObject);
2351 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject) ; 2351 LayoutUnit logicalBottom = logicalBottomForFloat(floatingObject) ;
2352 2352
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 2427
2428 FloatingObjectSetIterator end = floatingObjectSet.end(); 2428 FloatingObjectSetIterator end = floatingObjectSet.end();
2429 // Now walk through the set of unpositioned floats and place them. 2429 // Now walk through the set of unpositioned floats and place them.
2430 for (; it != end; ++it) { 2430 for (; it != end; ++it) {
2431 FloatingObject* floatingObject = it->get(); 2431 FloatingObject* floatingObject = it->get();
2432 // The containing block is responsible for positioning floats, so if we have floats in our 2432 // The containing block is responsible for positioning floats, so if we have floats in our
2433 // list that come from somewhere else, do not attempt to position them. 2433 // list that come from somewhere else, do not attempt to position them.
2434 if (floatingObject->renderer()->containingBlock() != this) 2434 if (floatingObject->renderer()->containingBlock() != this)
2435 continue; 2435 continue;
2436 2436
2437 RenderBox* childBox = floatingObject->renderer(); 2437 LayoutBox* childBox = floatingObject->renderer();
2438 2438
2439 // FIXME Investigate if this can be removed. crbug.com/370006 2439 // FIXME Investigate if this can be removed. crbug.com/370006
2440 childBox->setMayNeedPaintInvalidation(); 2440 childBox->setMayNeedPaintInvalidation();
2441 2441
2442 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ? marginStartForChild(*childBox) : marginEndForChild(*childBox); 2442 LayoutUnit childLogicalLeftMargin = style()->isLeftToRightDirection() ? marginStartForChild(*childBox) : marginEndForChild(*childBox);
2443 if (childBox->style()->clear() & CLEFT) 2443 if (childBox->style()->clear() & CLEFT)
2444 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Left), logicalTop); 2444 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Left), logicalTop);
2445 if (childBox->style()->clear() & CRIGHT) 2445 if (childBox->style()->clear() & CRIGHT)
2446 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Right), logicalTop); 2446 logicalTop = std::max(lowestFloatLogicalBottom(FloatingObject::Float Right), logicalTop);
2447 2447
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 2497
2498 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo()) 2498 if (ShapeOutsideInfo* shapeOutside = childBox->shapeOutsideInfo())
2499 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox)); 2499 shapeOutside->setReferenceBoxLogicalSize(logicalSizeForChild(*childB ox));
2500 2500
2501 if (width) 2501 if (width)
2502 width->shrinkAvailableWidthForNewFloatIfNeeded(floatingObject); 2502 width->shrinkAvailableWidthForNewFloatIfNeeded(floatingObject);
2503 } 2503 }
2504 return true; 2504 return true;
2505 } 2505 }
2506 2506
2507 bool RenderBlockFlow::hasOverhangingFloat(RenderBox* renderer) 2507 bool RenderBlockFlow::hasOverhangingFloat(LayoutBox* renderer)
2508 { 2508 {
2509 if (!m_floatingObjects || hasColumns() || !parent()) 2509 if (!m_floatingObjects || hasColumns() || !parent())
2510 return false; 2510 return false;
2511 2511
2512 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set(); 2512 const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
2513 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(renderer); 2513 FloatingObjectSetIterator it = floatingObjectSet.find<FloatingObjectHashTran slator>(renderer);
2514 if (it == floatingObjectSet.end()) 2514 if (it == floatingObjectSet.end())
2515 return false; 2515 return false;
2516 2516
2517 return logicalBottomForFloat(it->get()) > logicalHeight(); 2517 return logicalBottomForFloat(it->get()) > logicalHeight();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 return selectionGaps(this, offsetFromPaintInvalidationContainer, LayoutSize( ), lastTop, lastLeft, lastRight); 2721 return selectionGaps(this, offsetFromPaintInvalidationContainer, LayoutSize( ), lastTop, lastLeft, lastRight);
2722 } 2722 }
2723 2723
2724 static void clipOutPositionedObjects(const PaintInfo& paintInfo, const LayoutPoi nt& offset, TrackedRendererListHashSet* positionedObjects) 2724 static void clipOutPositionedObjects(const PaintInfo& paintInfo, const LayoutPoi nt& offset, TrackedRendererListHashSet* positionedObjects)
2725 { 2725 {
2726 if (!positionedObjects) 2726 if (!positionedObjects)
2727 return; 2727 return;
2728 2728
2729 TrackedRendererListHashSet::const_iterator end = positionedObjects->end(); 2729 TrackedRendererListHashSet::const_iterator end = positionedObjects->end();
2730 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi n(); it != end; ++it) { 2730 for (TrackedRendererListHashSet::const_iterator it = positionedObjects->begi n(); it != end; ++it) {
2731 RenderBox* r = *it; 2731 LayoutBox* r = *it;
2732 ASSERT(paintInfo.context->clipRecorderStack()); 2732 ASSERT(paintInfo.context->clipRecorderStack());
2733 paintInfo.context->clipRecorderStack()->addClipRecorder(adoptPtr(new Cli pRecorder( 2733 paintInfo.context->clipRecorderStack()->addClipRecorder(adoptPtr(new Cli pRecorder(
2734 r->displayItemClient(), paintInfo.context, paintInfo.displayItemType ForClipping(), 2734 r->displayItemClient(), paintInfo.context, paintInfo.displayItemType ForClipping(),
2735 IntRect(flooredIntPoint(r->location() + offset), flooredIntSize(r->s ize())), SkRegion::kDifference_Op))); 2735 IntRect(flooredIntPoint(r->location() + offset), flooredIntSize(r->s ize())), SkRegion::kDifference_Op)));
2736 } 2736 }
2737 } 2737 }
2738 2738
2739 GapRects RenderBlockFlow::selectionGaps(const RenderBlock* rootBlock, const Layo utPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2739 GapRects RenderBlockFlow::selectionGaps(const RenderBlock* rootBlock, const Layo utPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2740 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const 2740 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2741 { 2741 {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 } 2862 }
2863 return gapRect; 2863 return gapRect;
2864 } 2864 }
2865 2865
2866 GapRects RenderBlockFlow::blockSelectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 2866 GapRects RenderBlockFlow::blockSelectionGaps(const RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
2867 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const 2867 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLog icalRight, const PaintInfo* paintInfo) const
2868 { 2868 {
2869 GapRects result; 2869 GapRects result;
2870 2870
2871 // Go ahead and jump right to the first block child that contains some selec ted objects. 2871 // Go ahead and jump right to the first block child that contains some selec ted objects.
2872 RenderBox* curr; 2872 LayoutBox* curr;
2873 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone ; curr = curr->nextSiblingBox()) { } 2873 for (curr = firstChildBox(); curr && curr->selectionState() == SelectionNone ; curr = curr->nextSiblingBox()) { }
2874 2874
2875 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne xtSiblingBox()) { 2875 for (bool sawSelectionEnd = false; curr && !sawSelectionEnd; curr = curr->ne xtSiblingBox()) {
2876 SelectionState childState = curr->selectionState(); 2876 SelectionState childState = curr->selectionState();
2877 if (childState == SelectionBoth || childState == SelectionEnd) 2877 if (childState == SelectionBoth || childState == SelectionEnd)
2878 sawSelectionEnd = true; 2878 sawSelectionEnd = true;
2879 2879
2880 if (curr->isFloatingOrOutOfFlowPositioned()) 2880 if (curr->isFloatingOrOutOfFlowPositioned())
2881 continue; // We must be a normal flow object in order to even be con sidered. 2881 continue; // We must be a normal flow object in order to even be con sidered.
2882 2882
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2979 if (!m_rareData) { 2979 if (!m_rareData) {
2980 if (!strut) 2980 if (!strut)
2981 return; 2981 return;
2982 m_rareData = adoptPtr(new RenderBlockFlowRareData(this)); 2982 m_rareData = adoptPtr(new RenderBlockFlowRareData(this));
2983 } 2983 }
2984 m_rareData->m_paginationStrut = strut; 2984 m_rareData->m_paginationStrut = strut;
2985 } 2985 }
2986 2986
2987 void RenderBlockFlow::positionSpannerDescendant(LayoutMultiColumnSpannerPlacehol der& child) 2987 void RenderBlockFlow::positionSpannerDescendant(LayoutMultiColumnSpannerPlacehol der& child)
2988 { 2988 {
2989 RenderBox& spanner = *child.rendererInFlowThread(); 2989 LayoutBox& spanner = *child.rendererInFlowThread();
2990 // FIXME: |spanner| is a descendant, but never a direct child, so the names here are bad, if 2990 // FIXME: |spanner| is a descendant, but never a direct child, so the names here are bad, if
2991 // nothing else. 2991 // nothing else.
2992 setLogicalTopForChild(spanner, child.logicalTop()); 2992 setLogicalTopForChild(spanner, child.logicalTop());
2993 determineLogicalLeftPositionForChild(spanner); 2993 determineLogicalLeftPositionForChild(spanner);
2994 } 2994 }
2995 2995
2996 bool RenderBlockFlow::avoidsFloats() const 2996 bool RenderBlockFlow::avoidsFloats() const
2997 { 2997 {
2998 // Floats can't intrude into our box if we have a non-auto column count or w idth. 2998 // Floats can't intrude into our box if we have a non-auto column count or w idth.
2999 // Note: we need to use RenderBox::avoidsFloats here since RenderBlock::avoi dsFloats is always true. 2999 // Note: we need to use LayoutBox::avoidsFloats here since RenderBlock::avoi dsFloats is always true.
3000 return RenderBox::avoidsFloats() || !style()->hasAutoColumnCount() || !style ()->hasAutoColumnWidth(); 3000 return LayoutBox::avoidsFloats() || !style()->hasAutoColumnCount() || !style ()->hasAutoColumnWidth();
3001 } 3001 }
3002 3002
3003 void RenderBlockFlow::moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, Lay outObject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool f ullRemoveInsert) 3003 void RenderBlockFlow::moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, Lay outObject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool f ullRemoveInsert)
3004 { 3004 {
3005 if (childrenInline()) 3005 if (childrenInline())
3006 deleteLineBoxTree(); 3006 deleteLineBoxTree();
3007 LayoutBoxModelObject::moveChildrenTo(toBoxModelObject, startChild, endChild, beforeChild, fullRemoveInsert); 3007 LayoutBoxModelObject::moveChildrenTo(toBoxModelObject, startChild, endChild, beforeChild, fullRemoveInsert);
3008 } 3008 }
3009 3009
3010 LayoutUnit RenderBlockFlow::logicalLeftSelectionOffset(const RenderBlock* rootBl ock, LayoutUnit position) const 3010 LayoutUnit RenderBlockFlow::logicalLeftSelectionOffset(const RenderBlock* rootBl ock, LayoutUnit position) const
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 FrameView* frameView = document().view(); 3134 FrameView* frameView = document().view();
3135 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3135 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3136 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3136 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3137 if (size().height() < visibleHeight) 3137 if (size().height() < visibleHeight)
3138 top += (visibleHeight - size().height()) / 2; 3138 top += (visibleHeight - size().height()) / 2;
3139 setY(top); 3139 setY(top);
3140 dialog->setCentered(top); 3140 dialog->setCentered(top);
3141 } 3141 }
3142 3142
3143 } // namespace blink 3143 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBlockFlow.h ('k') | Source/core/rendering/RenderBlockLineLayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698