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

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

Issue 712553003: [New Multicolumn] Actual support for layout of column-span:all. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase master Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 537
538 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical Top) 538 void RenderBlockFlow::setLogicalTopForChild(RenderBox* child, LayoutUnit logical Top)
539 { 539 {
540 if (isHorizontalWritingMode()) { 540 if (isHorizontalWritingMode()) {
541 child->setY(logicalTop); 541 child->setY(logicalTop);
542 } else { 542 } else {
543 child->setX(logicalTop); 543 child->setX(logicalTop);
544 } 544 }
545 } 545 }
546 546
547 class ColumnSpannerLayoutScope {
548 public:
549 ColumnSpannerLayoutScope()
550 : m_spanner(0) { }
551
552 ~ColumnSpannerLayoutScope()
553 {
554 if (!m_spanner)
555 return;
556 m_spanner->flowThreadContainingBlock()->leaveColumnSpannerAfterLayout(m_ spanner, m_spanner->containingBlock()->logicalHeight());
557 }
558
559 LayoutUnit enterSpanner(RenderBox* spanner, SubtreeLayoutScope& layoutScope)
560 {
561 ASSERT(!m_spanner);
562 m_spanner = spanner;
563 return m_spanner->flowThreadContainingBlock()->enterColumnSpannerBeforeL ayout(m_spanner, m_spanner->containingBlock()->logicalHeight(), layoutScope);
564 }
565
566 private:
567 RenderBox* m_spanner;
568 };
569
547 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom) 570 void RenderBlockFlow::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom)
548 { 571 {
549 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); 572 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore();
550 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); 573 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();
551 574
575 SubtreeLayoutScope layoutScope(*child);
576
577 ColumnSpannerLayoutScope columnSpannerLayoutScope;
578 if (child->isColumnSpanAll()) {
579 LayoutUnit adjustment = columnSpannerLayoutScope.enterSpanner(child, lay outScope);
580 // A spanner needs to start at an exact column boundary inside the flow thread, so that it
581 // doesn't bleed into a preceding column. That's what the adjustment is about.
582 setLogicalHeight(logicalHeight() + adjustment);
583 }
584
552 // The child is a normal flow object. Compute the margins we will use for co llapsing now. 585 // The child is a normal flow object. Compute the margins we will use for co llapsing now.
553 child->computeAndSetBlockDirectionMargins(this); 586 child->computeAndSetBlockDirectionMargins(this);
554 587
555 // Try to guess our correct logical top position. In most cases this guess w ill 588 // Try to guess our correct logical top position. In most cases this guess w ill
556 // be correct. Only if we're wrong (when we compute the real logical top pos ition) 589 // be correct. Only if we're wrong (when we compute the real logical top pos ition)
557 // will we have to potentially relayout. 590 // will we have to potentially relayout.
558 LayoutUnit estimateWithoutPagination; 591 LayoutUnit estimateWithoutPagination;
559 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination); 592 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination);
560 593
561 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves. 594 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves.
(...skipping 21 matching lines...) Expand all
583 markDescendantsWithFloats = true; 616 markDescendantsWithFloats = true;
584 } 617 }
585 618
586 if (childRenderBlockFlow) { 619 if (childRenderBlockFlow) {
587 if (markDescendantsWithFloats) 620 if (markDescendantsWithFloats)
588 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout(); 621 childRenderBlockFlow->markAllDescendantsWithFloatsForLayout();
589 if (!child->isWritingModeRoot()) 622 if (!child->isWritingModeRoot())
590 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom()); 623 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol dLogicalTop + childRenderBlockFlow->lowestFloatLogicalBottom());
591 } 624 }
592 625
593 SubtreeLayoutScope layoutScope(*child);
594 if (!child->needsLayout()) 626 if (!child->needsLayout())
595 child->markForPaginationRelayoutIfNeeded(layoutScope); 627 child->markForPaginationRelayoutIfNeeded(layoutScope);
596 628
597 bool childNeededLayout = child->needsLayout(); 629 bool childNeededLayout = child->needsLayout();
598 if (childNeededLayout) 630 if (childNeededLayout)
599 child->layout(); 631 child->layout();
600 632
601 // Cache if we are at the top of the block right now. 633 // Cache if we are at the top of the block right now.
602 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); 634 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock();
603 bool childIsSelfCollapsing = child->isSelfCollapsingBlock(); 635 bool childIsSelfCollapsing = child->isSelfCollapsingBlock();
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 marginInfo.clearMargin(); 1320 marginInfo.clearMargin();
1289 } 1321 }
1290 1322
1291 if (marginInfo.margin()) 1323 if (marginInfo.margin())
1292 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child)); 1324 marginInfo.setHasMarginAfterQuirk(hasMarginAfterQuirk(child));
1293 } 1325 }
1294 1326
1295 // If margins would pull us past the top of the next page, then we need to p ull back and pretend like the margins 1327 // If margins would pull us past the top of the next page, then we need to p ull back and pretend like the margins
1296 // collapsed into the page edge. 1328 // collapsed into the page edge.
1297 LayoutState* layoutState = view()->layoutState(); 1329 LayoutState* layoutState = view()->layoutState();
1298 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTop > beforeCollapseLogicalTop) { 1330 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTop > beforeCollapseLogicalTop && !child->isColumnSpanAll()) {
Julien - ping for review 2014/11/17 23:47:11 It seems like we should just make column spanning
mstensho (USE GERRIT) 2014/11/18 13:29:26 They already do create a new block formatting cont
Julien - ping for review 2014/11/19 17:54:34 I missed that you actually changed the function in
mstensho (USE GERRIT) 2014/11/21 15:39:24 This code here is about the top margin. Being a BF
1299 LayoutUnit oldLogicalTop = logicalTop; 1331 LayoutUnit oldLogicalTop = logicalTop;
1300 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic alTop)); 1332 logicalTop = std::min(logicalTop, nextPageLogicalTop(beforeCollapseLogic alTop));
1301 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop)); 1333 setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
1302 } 1334 }
1303 1335
1304 if (previousBlockFlow) { 1336 if (previousBlockFlow) {
1305 // If |child| is a self-collapsing block it may have collapsed into a pr evious sibling and although it hasn't reduced the height of the parent yet 1337 // If |child| is a self-collapsing block it may have collapsed into a pr evious sibling and although it hasn't reduced the height of the parent yet
1306 // any floats from the parent will now overhang. 1338 // any floats from the parent will now overhang.
1307 LayoutUnit oldLogicalHeight = logicalHeight(); 1339 LayoutUnit oldLogicalHeight = logicalHeight();
1308 setLogicalHeight(logicalTop); 1340 setLogicalHeight(logicalTop);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 } 1536 }
1505 1537
1506 // Collapse the result with our current margins. 1538 // Collapse the result with our current margins.
1507 if (!discardMarginBefore) 1539 if (!discardMarginBefore)
1508 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore); 1540 logicalTopEstimate += std::max(marginInfo.positiveMargin(), positive MarginBefore) - std::max(marginInfo.negativeMargin(), negativeMarginBefore);
1509 } 1541 }
1510 1542
1511 // Adjust logicalTopEstimate down to the next page if the margins are so lar ge that we don't fit on the current 1543 // Adjust logicalTopEstimate down to the next page if the margins are so lar ge that we don't fit on the current
1512 // page. 1544 // page.
1513 LayoutState* layoutState = view()->layoutState(); 1545 LayoutState* layoutState = view()->layoutState();
1514 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTopEstimate > logicalHeight()) 1546 if (layoutState->isPaginated() && layoutState->pageLogicalHeight() && logica lTopEstimate > logicalHeight() && !child->isColumnSpanAll())
mstensho (USE GERRIT) 2014/11/21 15:39:24 I'll remove this for now. No test covers it. See p
1515 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log icalHeight())); 1547 logicalTopEstimate = std::min(logicalTopEstimate, nextPageLogicalTop(log icalHeight()));
1516 1548
1517 logicalTopEstimate += getClearDelta(child, logicalTopEstimate); 1549 logicalTopEstimate += getClearDelta(child, logicalTopEstimate);
1518 1550
1519 estimateWithoutPagination = logicalTopEstimate; 1551 estimateWithoutPagination = logicalTopEstimate;
1520 1552
1521 if (layoutState->isPaginated()) { 1553 if (layoutState->isPaginated()) {
1522 // If the object has a page or column break value of "before", then we s hould shift to the top of the next page. 1554 // If the object has a page or column break value of "before", then we s hould shift to the top of the next page.
1523 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate); 1555 logicalTopEstimate = applyBeforeBreak(child, logicalTopEstimate);
1524 1556
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 FrameView* frameView = document().view(); 2876 FrameView* frameView = document().view();
2845 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 2877 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
2846 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 2878 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
2847 if (height() < visibleHeight) 2879 if (height() < visibleHeight)
2848 top += (visibleHeight - height()) / 2; 2880 top += (visibleHeight - height()) / 2;
2849 setY(top); 2881 setY(top);
2850 dialog->setCentered(top); 2882 dialog->setCentered(top);
2851 } 2883 }
2852 2884
2853 } // namespace blink 2885 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698