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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1769483002: Class A fragmentainer break points also exist between zero-height blocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Regression fixed: missed a class C break opportunity. Updated the documentation. Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 bool LayoutBlockFlow::s_canPropagateFloatIntoSibling = false; 63 bool LayoutBlockFlow::s_canPropagateFloatIntoSibling = false;
64 64
65 struct SameSizeAsMarginInfo { 65 struct SameSizeAsMarginInfo {
66 uint16_t bitfields; 66 uint16_t bitfields;
67 LayoutUnit margins[2]; 67 LayoutUnit margins[2];
68 }; 68 };
69 69
70 static_assert(sizeof(LayoutBlockFlow::MarginValues) == sizeof(LayoutUnit[4]), "M arginValues should stay small"); 70 static_assert(sizeof(LayoutBlockFlow::MarginValues) == sizeof(LayoutUnit[4]), "M arginValues should stay small");
71 71
72 // Caches all our current margin collapsing state.
72 class MarginInfo { 73 class MarginInfo {
73 // Collapsing flags for whether we can collapse our margins with our childre n's margins. 74 // Collapsing flags for whether we can collapse our margins with our childre n's margins.
74 bool m_canCollapseWithChildren : 1; 75 bool m_canCollapseWithChildren : 1;
75 bool m_canCollapseMarginBeforeWithChildren : 1; 76 bool m_canCollapseMarginBeforeWithChildren : 1;
76 bool m_canCollapseMarginAfterWithChildren : 1; 77 bool m_canCollapseMarginAfterWithChildren : 1;
77 bool m_canCollapseMarginAfterWithLastChild: 1; 78 bool m_canCollapseMarginAfterWithLastChild: 1;
78 79
79 // Whether or not we are a quirky container, i.e., do we collapse away top a nd bottom 80 // Whether or not we are a quirky container, i.e., do we collapse away top a nd bottom
80 // margins in our container. Table cells and the body are the common example s. We 81 // margins in our container. Table cells and the body are the common example s. We
81 // also have a custom style property for Safari RSS to deal with TypePad blo g articles. 82 // also have a custom style property for Safari RSS to deal with TypePad blo g articles.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; } 148 bool hasMarginBeforeQuirk() const { return m_hasMarginBeforeQuirk; }
148 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; } 149 bool hasMarginAfterQuirk() const { return m_hasMarginAfterQuirk; }
149 LayoutUnit positiveMargin() const { return m_positiveMargin; } 150 LayoutUnit positiveMargin() const { return m_positiveMargin; }
150 LayoutUnit negativeMargin() const { return m_negativeMargin; } 151 LayoutUnit negativeMargin() const { return m_negativeMargin; }
151 bool discardMargin() const { return m_discardMargin; } 152 bool discardMargin() const { return m_discardMargin; }
152 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; } 153 LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; }
153 void setLastChildIsSelfCollapsingBlockWithClearance(bool value) { m_lastChil dIsSelfCollapsingBlockWithClearance = value; } 154 void setLastChildIsSelfCollapsingBlockWithClearance(bool value) { m_lastChil dIsSelfCollapsingBlockWithClearance = value; }
154 bool lastChildIsSelfCollapsingBlockWithClearance() const { return m_lastChil dIsSelfCollapsingBlockWithClearance; } 155 bool lastChildIsSelfCollapsingBlockWithClearance() const { return m_lastChil dIsSelfCollapsingBlockWithClearance; }
155 }; 156 };
156 157
158 // Some features, such as floats, margin collapsing and fragmentation, require s ome knowledge about
159 // things that happened when laying out previous block child siblings. Only look ing at the object
160 // currently being laid out isn't always enough.
161 class BlockChildrenLayoutInfo {
leviw_travelin_and_unemployed 2016/03/10 21:23:59 I'm in love with context objects in layout and hap
mstensho (USE GERRIT) 2016/03/11 10:18:49 Soon there'll be even moar context! :)
162 public:
163 BlockChildrenLayoutInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeEdge, L ayoutUnit afterEdge)
164 : m_marginInfo(blockFlow, beforeEdge, afterEdge)
165 , m_isAtFirstInFlowChild(true) { }
166
167 const MarginInfo& marginInfo() const { return m_marginInfo; }
168 MarginInfo& marginInfo() { return m_marginInfo; }
169 LayoutUnit& previousFloatLogicalBottom() { return m_previousFloatLogicalBott om; }
170
171 bool isAtFirstInFlowChild() const { return m_isAtFirstInFlowChild; }
172 void clearIsAtFirstInFlowChild() { m_isAtFirstInFlowChild = false; }
173
174 private:
175 MarginInfo m_marginInfo;
176 LayoutUnit m_previousFloatLogicalBottom;
177 bool m_isAtFirstInFlowChild;
178 };
179
157 LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node) 180 LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node)
158 : LayoutBlock(node) 181 : LayoutBlock(node)
159 { 182 {
160 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInf o should stay small"); 183 static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInf o should stay small");
161 setChildrenInline(true); 184 setChildrenInline(true);
162 } 185 }
163 186
164 LayoutBlockFlow::~LayoutBlockFlow() 187 LayoutBlockFlow::~LayoutBlockFlow()
165 { 188 {
166 } 189 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // If an element might be affected by the presence of floats, then alway s mark it for 539 // If an element might be affected by the presence of floats, then alway s mark it for
517 // layout. 540 // layout.
518 if (std::max(previousFloatLogicalBottom, lowestFloatLogicalBottom()) > n ewLogicalTop) 541 if (std::max(previousFloatLogicalBottom, lowestFloatLogicalBottom()) > n ewLogicalTop)
519 markDescendantsWithFloats = true; 542 markDescendantsWithFloats = true;
520 } 543 }
521 544
522 if (markDescendantsWithFloats) 545 if (markDescendantsWithFloats)
523 child.markAllDescendantsWithFloatsForLayout(); 546 child.markAllDescendantsWithFloatsForLayout();
524 } 547 }
525 548
526 bool LayoutBlockFlow::positionAndLayoutOnceIfNeeded(LayoutBox& child, LayoutUnit newLogicalTop, LayoutUnit& previousFloatLogicalBottom) 549 bool LayoutBlockFlow::positionAndLayoutOnceIfNeeded(LayoutBox& child, LayoutUnit newLogicalTop, BlockChildrenLayoutInfo& layoutInfo)
527 { 550 {
528 if (child.isLayoutBlockFlow()) { 551 if (child.isLayoutBlockFlow()) {
552 LayoutUnit& previousFloatLogicalBottom = layoutInfo.previousFloatLogical Bottom();
529 LayoutBlockFlow& childBlockFlow = toLayoutBlockFlow(child); 553 LayoutBlockFlow& childBlockFlow = toLayoutBlockFlow(child);
530 if (childBlockFlow.containsFloats() || containsFloats()) 554 if (childBlockFlow.containsFloats() || containsFloats())
531 markDescendantsWithFloatsForLayoutIfNeeded(childBlockFlow, newLogica lTop, previousFloatLogicalBottom); 555 markDescendantsWithFloatsForLayoutIfNeeded(childBlockFlow, newLogica lTop, previousFloatLogicalBottom);
532 556
533 // TODO(mstensho): A writing mode root is one thing, but we should be ab le to skip anything 557 // TODO(mstensho): A writing mode root is one thing, but we should be ab le to skip anything
534 // that establishes a new block formatting context here. Their floats do n't affect us. 558 // that establishes a new block formatting context here. Their floats do n't affect us.
535 if (!childBlockFlow.isWritingModeRoot()) 559 if (!childBlockFlow.isWritingModeRoot())
536 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ch ildBlockFlow.logicalTop() + childBlockFlow.lowestFloatLogicalBottom()); 560 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ch ildBlockFlow.logicalTop() + childBlockFlow.lowestFloatLogicalBottom());
537 } 561 }
538 562
(...skipping 10 matching lines...) Expand all
549 child.markForPaginationRelayoutIfNeeded(layoutScope); 573 child.markForPaginationRelayoutIfNeeded(layoutScope);
550 } 574 }
551 } 575 }
552 576
553 if (!child.needsLayout()) 577 if (!child.needsLayout())
554 return false; 578 return false;
555 child.layout(); 579 child.layout();
556 return true; 580 return true;
557 } 581 }
558 582
559 void LayoutBlockFlow::layoutBlockChild(LayoutBox& child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom) 583 void LayoutBlockFlow::layoutBlockChild(LayoutBox& child, BlockChildrenLayoutInfo & layoutInfo)
560 { 584 {
585 MarginInfo& marginInfo = layoutInfo.marginInfo();
561 LayoutBlockFlow* childLayoutBlockFlow = child.isLayoutBlockFlow() ? toLayout BlockFlow(&child) : nullptr; 586 LayoutBlockFlow* childLayoutBlockFlow = child.isLayoutBlockFlow() ? toLayout BlockFlow(&child) : nullptr;
562 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); 587 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore();
563 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); 588 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();
564 589
565 // The child is a normal flow object. Compute the margins we will use for co llapsing now. 590 // The child is a normal flow object. Compute the margins we will use for co llapsing now.
566 child.computeAndSetBlockDirectionMargins(this); 591 child.computeAndSetBlockDirectionMargins(this);
567 592
568 // Try to guess our correct logical top position. In most cases this guess w ill 593 // Try to guess our correct logical top position. In most cases this guess w ill
569 // be correct. Only if we're wrong (when we compute the real logical top pos ition) 594 // be correct. Only if we're wrong (when we compute the real logical top pos ition)
570 // will we have to potentially relayout. 595 // will we have to potentially relayout.
571 LayoutUnit estimateWithoutPagination; 596 LayoutUnit estimateWithoutPagination;
572 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination); 597 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination);
573 598
574 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves. 599 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves.
575 LayoutRect oldRect = child.frameRect(); 600 LayoutRect oldRect = child.frameRect();
576 601
577 // Use the estimated block position and lay out the child if needed. After c hild layout, when 602 // Use the estimated block position and lay out the child if needed. After c hild layout, when
578 // we have enough information to perform proper margin collapsing, float cle aring and 603 // we have enough information to perform proper margin collapsing, float cle aring and
579 // pagination, we may have to reposition and lay out again if the estimate w as wrong. 604 // pagination, we may have to reposition and lay out again if the estimate w as wrong.
580 bool childNeededLayout = positionAndLayoutOnceIfNeeded(child, logicalTopEsti mate, previousFloatLogicalBottom); 605 bool childNeededLayout = positionAndLayoutOnceIfNeeded(child, logicalTopEsti mate, layoutInfo);
581 606
582 // Cache if we are at the top of the block right now. 607 // Cache if we are at the top of the block right now.
583 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); 608 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock();
584 bool childIsSelfCollapsing = child.isSelfCollapsingBlock(); 609 bool childIsSelfCollapsing = child.isSelfCollapsingBlock();
585 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child); 610 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child);
586 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); 611 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child);
587 612
588 // Now determine the correct ypos based off examination of collapsing margin 613 // Now determine the correct ypos based off examination of collapsing margin
589 // values. 614 // values.
590 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childI sSelfCollapsing, childDiscardMarginBefore, childDiscardMarginAfter); 615 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childI sSelfCollapsing, childDiscardMarginBefore, childDiscardMarginAfter);
591 616
592 // Now check for clear. 617 // Now check for clear.
593 bool childDiscardMargin = childDiscardMarginBefore || childDiscardMarginAfte r; 618 bool childDiscardMargin = childDiscardMarginBefore || childDiscardMarginAfte r;
594 LayoutUnit newLogicalTop = clearFloatsIfNeeded(child, marginInfo, oldPosMarg inBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsing, chil dDiscardMargin); 619 LayoutUnit newLogicalTop = clearFloatsIfNeeded(child, marginInfo, oldPosMarg inBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsing, chil dDiscardMargin);
595 620
596 // Now check for pagination. 621 // Now check for pagination.
597 bool paginated = view()->layoutState()->isPaginated(); 622 bool paginated = view()->layoutState()->isPaginated();
598 if (paginated) { 623 if (paginated) {
599 if (estimateWithoutPagination != newLogicalTop) { 624 if (estimateWithoutPagination != newLogicalTop) {
600 // We got a new position due to clearance or margin collapsing. Befo re we attempt to 625 // We got a new position due to clearance or margin collapsing. Befo re we attempt to
601 // paginate (which may result in the position changing again), let's try again at the 626 // paginate (which may result in the position changing again), let's try again at the
602 // new position (since a new position may result in a new logical he ight). 627 // new position (since a new position may result in a new logical he ight).
603 positionAndLayoutOnceIfNeeded(child, newLogicalTop, previousFloatLog icalBottom); 628 positionAndLayoutOnceIfNeeded(child, newLogicalTop, layoutInfo);
604 } 629 }
605 630
606 newLogicalTop = adjustBlockChildForPagination(newLogicalTop, child, atBe foreSideOfBlock && logicalTopBeforeClear == newLogicalTop); 631 newLogicalTop = adjustBlockChildForPagination(newLogicalTop, child, layo utInfo, atBeforeSideOfBlock && logicalTopBeforeClear == newLogicalTop);
607 } 632 }
608 633
609 // Clearance, margin collapsing or pagination may have given us a new logica l top, in which 634 // Clearance, margin collapsing or pagination may have given us a new logica l top, in which
610 // case we may have to reposition and possibly relayout as well. If we deter mined during child 635 // case we may have to reposition and possibly relayout as well. If we deter mined during child
611 // layout that we need to insert a break to honor widows, we also need to re layout. 636 // layout that we need to insert a break to honor widows, we also need to re layout.
612 if (newLogicalTop != logicalTopEstimate 637 if (newLogicalTop != logicalTopEstimate
613 || child.needsLayout() 638 || child.needsLayout()
614 || (paginated && childLayoutBlockFlow && childLayoutBlockFlow->shouldBre akAtLineToAvoidWidow())) { 639 || (paginated && childLayoutBlockFlow && childLayoutBlockFlow->shouldBre akAtLineToAvoidWidow())) {
615 positionAndLayoutOnceIfNeeded(child, newLogicalTop, previousFloatLogical Bottom); 640 positionAndLayoutOnceIfNeeded(child, newLogicalTop, layoutInfo);
616 } 641 }
617 642
618 // If we previously encountered a self-collapsing sibling of this child that had clearance then 643 // If we previously encountered a self-collapsing sibling of this child that had clearance then
619 // we set this bit to ensure we would not collapse the child's margins, and those of any subsequent 644 // we set this bit to ensure we would not collapse the child's margins, and those of any subsequent
620 // self-collapsing siblings, with our parent. If this child is not self-coll apsing then it can 645 // self-collapsing siblings, with our parent. If this child is not self-coll apsing then it can
621 // collapse its margins with the parent so reset the bit. 646 // collapse its margins with the parent so reset the bit.
622 if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollaps ing) 647 if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollaps ing)
623 marginInfo.setCanCollapseMarginAfterWithLastChild(true); 648 marginInfo.setCanCollapseMarginAfterWithLastChild(true);
624 649
625 // We are no longer at the top of the block if we encounter a non-empty chil d. 650 // We are no longer at the top of the block if we encounter a non-empty chil d.
(...skipping 29 matching lines...) Expand all
655 if (newHeight != size().height()) 680 if (newHeight != size().height())
656 setLogicalHeight(newHeight); 681 setLogicalHeight(newHeight);
657 } 682 }
658 683
659 if (child.isLayoutMultiColumnSpannerPlaceholder()) { 684 if (child.isLayoutMultiColumnSpannerPlaceholder()) {
660 // The actual column-span:all element is positioned by this placeholder child. 685 // The actual column-span:all element is positioned by this placeholder child.
661 positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child)); 686 positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child));
662 } 687 }
663 } 688 }
664 689
665 LayoutUnit LayoutBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTop, LayoutBox& child, bool atBeforeSideOfBlock) 690 LayoutUnit LayoutBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTop, LayoutBox& child, BlockChildrenLayoutInfo& layoutInfo, bool atBeforeSideOfBlock )
666 { 691 {
667 LayoutBlockFlow* childBlockFlow = child.isLayoutBlockFlow() ? toLayoutBlockF low(&child) : 0; 692 LayoutBlockFlow* childBlockFlow = child.isLayoutBlockFlow() ? toLayoutBlockF low(&child) : 0;
668 693
669 // Calculate the pagination strut for this child. A strut may come from thre e sources: 694 // Calculate the pagination strut for this child. A strut may come from thre e sources:
670 // 1. The first piece of content inside the child doesn't fit in the current page or column 695 // 1. The first piece of content inside the child doesn't fit in the current page or column
671 // 2. A forced break before the child 696 // 2. A forced break before the child
672 // 3. The child itself is unsplittable and doesn't fit in the current page o r column. 697 // 3. The child itself is unsplittable and doesn't fit in the current page o r column.
673 // 698 //
674 // No matter which source, if we need to insert a strut, it should always ta ke us to the exact 699 // No matter which source, if we need to insert a strut, it should always ta ke us to the exact
675 // top of a page or column further ahead, or be zero. 700 // top of a page or column further ahead, or be zero.
(...skipping 13 matching lines...) Expand all
689 714
690 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. 715 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
691 LayoutUnit logicalTopAfterUnsplittable = adjustForUnsplittableChild(child, l ogicalTop); 716 LayoutUnit logicalTopAfterUnsplittable = adjustForUnsplittableChild(child, l ogicalTop);
692 717
693 // Pick the largest offset. Tall unsplittable content may take us to a page or column further 718 // Pick the largest offset. Tall unsplittable content may take us to a page or column further
694 // ahead than the next one. 719 // ahead than the next one.
695 LayoutUnit logicalTopAfterPagination = std::max(logicalTopWithContentStrut, std::max(logicalTopAfterForcedBreak, logicalTopAfterUnsplittable)); 720 LayoutUnit logicalTopAfterPagination = std::max(logicalTopWithContentStrut, std::max(logicalTopAfterForcedBreak, logicalTopAfterUnsplittable));
696 LayoutUnit newLogicalTop = logicalTop; 721 LayoutUnit newLogicalTop = logicalTop;
697 if (LayoutUnit paginationStrut = logicalTopAfterPagination - logicalTop) { 722 if (LayoutUnit paginationStrut = logicalTopAfterPagination - logicalTop) {
698 ASSERT(paginationStrut > 0); 723 ASSERT(paginationStrut > 0);
699 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior 724 // If we're not at the first in-flow child, there's a class A break poin t before the child. If we *are* at the
leviw_travelin_and_unemployed 2016/03/10 21:23:59 I kind of hate these class names. Can we link to t
mstensho (USE GERRIT) 2016/03/11 10:18:49 Done.
700 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination. 725 // first in-flow child, but the child isn't flush with the content edge of its container, due to e.g. clearance,
701 if (atBeforeSideOfBlock && logicalTopAfterForcedBreak == logicalTop && a llowsPaginationStrut()) { 726 // there's a class C break point before the child. Otherwise we should p ropagate the strut to our parent block,
727 // and attempt to break there instead.
728 if (layoutInfo.isAtFirstInFlowChild() && atBeforeSideOfBlock && logicalT opAfterForcedBreak == logicalTop && allowsPaginationStrut()) {
702 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't 729 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't
703 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too 730 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too
704 // and pushes to the next page anyway, so not too concerned about it . 731 // and pushes to the next page anyway, so not too concerned about it .
705 paginationStrut += logicalTop + marginBeforeIfFloating(); 732 paginationStrut += logicalTop + marginBeforeIfFloating();
706 setPaginationStrutPropagatedFromChild(paginationStrut); 733 setPaginationStrutPropagatedFromChild(paginationStrut);
707 if (childBlockFlow) 734 if (childBlockFlow)
708 childBlockFlow->setPaginationStrutPropagatedFromChild(LayoutUnit ()); 735 childBlockFlow->setPaginationStrutPropagatedFromChild(LayoutUnit ());
709 } else { 736 } else {
710 child.setPaginationStrut(paginationStrut); 737 child.setPaginationStrut(paginationStrut);
711 newLogicalTop += paginationStrut; 738 newLogicalTop += paginationStrut;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 if (!oldIntrudingFloatSet.isEmpty()) 1016 if (!oldIntrudingFloatSet.isEmpty())
990 markAllDescendantsWithFloatsForLayout(); 1017 markAllDescendantsWithFloatsForLayout();
991 } 1018 }
992 } 1019 }
993 } 1020 }
994 1021
995 void LayoutBlockFlow::layoutBlockChildren(bool relayoutChildren, SubtreeLayoutSc ope& layoutScope, LayoutUnit beforeEdge, LayoutUnit afterEdge) 1022 void LayoutBlockFlow::layoutBlockChildren(bool relayoutChildren, SubtreeLayoutSc ope& layoutScope, LayoutUnit beforeEdge, LayoutUnit afterEdge)
996 { 1023 {
997 dirtyForLayoutFromPercentageHeightDescendants(layoutScope); 1024 dirtyForLayoutFromPercentageHeightDescendants(layoutScope);
998 1025
999 // The margin struct caches all our current margin collapsing state. The com pact struct caches state when we encounter compacts, 1026 BlockChildrenLayoutInfo layoutInfo(this, beforeEdge, afterEdge);
1000 MarginInfo marginInfo(this, beforeEdge, afterEdge); 1027 MarginInfo& marginInfo = layoutInfo.marginInfo();
1001 1028
1002 // Fieldsets need to find their legend and position it inside the border of the object. 1029 // Fieldsets need to find their legend and position it inside the border of the object.
1003 // The legend then gets skipped during normal layout. The same is true for r uby text. 1030 // The legend then gets skipped during normal layout. The same is true for r uby text.
1004 // It doesn't get included in the normal layout process but is instead skipp ed. 1031 // It doesn't get included in the normal layout process but is instead skipp ed.
1005 LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren, layoutScope); 1032 LayoutObject* childToExclude = layoutSpecialExcludedChild(relayoutChildren, layoutScope);
1006 1033
1007 LayoutUnit previousFloatLogicalBottom;
1008
1009 LayoutBox* next = firstChildBox(); 1034 LayoutBox* next = firstChildBox();
1010 LayoutBox* lastNormalFlowChild = nullptr; 1035 LayoutBox* lastNormalFlowChild = nullptr;
1011 1036
1012 while (next) { 1037 while (next) {
1013 LayoutBox* child = next; 1038 LayoutBox* child = next;
1014 next = child->nextSiblingBox(); 1039 next = child->nextSiblingBox();
1015 1040
1016 child->setMayNeedPaintInvalidation(); 1041 child->setMayNeedPaintInvalidation();
1017 1042
1018 if (childToExclude == child) 1043 if (childToExclude == child)
(...skipping 18 matching lines...) Expand all
1037 // first we apply the pending margin, so that it's taken into consid eration and doesn't 1062 // first we apply the pending margin, so that it's taken into consid eration and doesn't
1038 // end up on the other side of the spanner. 1063 // end up on the other side of the spanner.
1039 setLogicalHeight(logicalHeight() + marginInfo.margin()); 1064 setLogicalHeight(logicalHeight() + marginInfo.margin());
1040 marginInfo.clearMargin(); 1065 marginInfo.clearMargin();
1041 1066
1042 child->spannerPlaceholder()->flowThread()->skipColumnSpanner(child, offsetFromLogicalTopOfFirstPage() + logicalHeight()); 1067 child->spannerPlaceholder()->flowThread()->skipColumnSpanner(child, offsetFromLogicalTopOfFirstPage() + logicalHeight());
1043 continue; 1068 continue;
1044 } 1069 }
1045 1070
1046 // Lay out the child. 1071 // Lay out the child.
1047 layoutBlockChild(*child, marginInfo, previousFloatLogicalBottom); 1072 layoutBlockChild(*child, layoutInfo);
1073 layoutInfo.clearIsAtFirstInFlowChild();
1048 lastNormalFlowChild = child; 1074 lastNormalFlowChild = child;
1049 } 1075 }
1050 1076
1051 // Now do the handling of the bottom of the block, adding in our bottom bord er/padding and 1077 // Now do the handling of the bottom of the block, adding in our bottom bord er/padding and
1052 // determining the correct collapsed bottom margin information. 1078 // determining the correct collapsed bottom margin information.
1053 handleAfterSideOfBlock(lastNormalFlowChild, beforeEdge, afterEdge, marginInf o); 1079 handleAfterSideOfBlock(lastNormalFlowChild, beforeEdge, afterEdge, marginInf o);
1054 } 1080 }
1055 1081
1056 // Our MarginInfo state used when laying out block children. 1082 // Our MarginInfo state used when laying out block children.
1057 MarginInfo::MarginInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeBorderPaddin g, LayoutUnit afterBorderPadding) 1083 MarginInfo::MarginInfo(LayoutBlockFlow* blockFlow, LayoutUnit beforeBorderPaddin g, LayoutUnit afterBorderPadding)
(...skipping 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 // FIXME: Glyph overflow will get lost in this case, but not really a big de al. 2931 // FIXME: Glyph overflow will get lost in this case, but not really a big de al.
2906 GlyphOverflowAndFallbackFontsMap textBoxDataMap; 2932 GlyphOverflowAndFallbackFontsMap textBoxDataMap;
2907 for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); it != lineBoxes.end(); ++it) { 2933 for (ListHashSet<RootInlineBox*>::const_iterator it = lineBoxes.begin(); it != lineBoxes.end(); ++it) {
2908 RootInlineBox* box = *it; 2934 RootInlineBox* box = *it;
2909 box->computeOverflow(box->lineTop(), box->lineBottom(), textBoxDataMap); 2935 box->computeOverflow(box->lineTop(), box->lineBottom(), textBoxDataMap);
2910 } 2936 }
2911 return childrenOverflowChanged; 2937 return childrenOverflowChanged;
2912 } 2938 }
2913 2939
2914 } // namespace blink 2940 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698