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

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

Issue 1315353005: Avoid duplicated code in LayoutBlockChild::layoutBlockChild(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 void LayoutBlockFlow::setLogicalTopForChild(LayoutBox& child, LayoutUnit logical Top) 500 void LayoutBlockFlow::setLogicalTopForChild(LayoutBox& child, LayoutUnit logical Top)
501 { 501 {
502 if (isHorizontalWritingMode()) { 502 if (isHorizontalWritingMode()) {
503 child.setY(logicalTop); 503 child.setY(logicalTop);
504 } else { 504 } else {
505 child.setX(logicalTop); 505 child.setX(logicalTop);
506 } 506 }
507 } 507 }
508 508
509 void LayoutBlockFlow::markDescendantsWithFloatsForLayoutIfNeeded(LayoutBlockFlow & child, LayoutUnit newLogicalTop, LayoutUnit previousFloatLogicalBottom)
510 {
511 // TODO(mstensho): rework the code to return early when no need for marking, instead of this |markDescendantsWithFloats| flag.
Julien - ping for review 2015/09/04 17:40:10 s/when no need for marking/when there is no need f
mstensho (USE GERRIT) 2015/09/04 18:31:49 It is done.
512 bool markDescendantsWithFloats = false;
513 if (newLogicalTop != child.logicalTop() && !child.avoidsFloats() && child.co ntainsFloats()) {
514 markDescendantsWithFloats = true;
515 } else if (UNLIKELY(newLogicalTop.mightBeSaturated())) {
516 // The logical top might be saturated for very large elements. Comparing with the old
517 // logical top might then yield a false negative, as adding and removing margins, borders
518 // etc. from a saturated number might yield incorrect results. If this i s the case, always
519 // mark for layout.
520 markDescendantsWithFloats = true;
521 } else if (!child.avoidsFloats() || child.shrinkToAvoidFloats()) {
522 // If an element might be affected by the presence of floats, then alway s mark it for
523 // layout.
524 if (std::max(previousFloatLogicalBottom, lowestFloatLogicalBottom()) > n ewLogicalTop)
525 markDescendantsWithFloats = true;
526 }
527
528 if (markDescendantsWithFloats)
529 child.markAllDescendantsWithFloatsForLayout();
530 }
531
532 bool LayoutBlockFlow::positionAndLayoutOnceIfNeeded(LayoutBox& child, LayoutUnit newLogicalTop, LayoutUnit& previousFloatLogicalBottom)
533 {
534 if (child.isLayoutBlockFlow()) {
535 LayoutBlockFlow& childBlockFlow = toLayoutBlockFlow(child);
536 if (childBlockFlow.containsFloats() || containsFloats())
537 markDescendantsWithFloatsForLayoutIfNeeded(childBlockFlow, newLogica lTop, previousFloatLogicalBottom);
538
539 // TODO(mstensho): A writing mode root is one thing, but we should be ab le to skip anything
540 // that establishes a new block formatting context here. Their floats do n't affect us.
541 if (!childBlockFlow.isWritingModeRoot())
542 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ch ildBlockFlow.logicalTop() + childBlockFlow.lowestFloatLogicalBottom());
543 }
544
545 LayoutUnit oldLogicalTop = logicalTopForChild(child);
546 setLogicalTopForChild(child, newLogicalTop);
547
548 SubtreeLayoutScope layoutScope(child);
549 if (!child.needsLayout()) {
550 if (newLogicalTop != oldLogicalTop && child.shrinkToAvoidFloats()) {
551 // The child's width is affected by adjacent floats. When the child shifts to clear an
552 // item, its width can change (because it has more available width).
553 layoutScope.setChildNeedsLayout(&child);
554 } else {
555 child.markForPaginationRelayoutIfNeeded(layoutScope);
556 }
557 }
558
559 if (!child.needsLayout())
560 return false;
561 child.layout();
562 return true;
563 }
564
509 void LayoutBlockFlow::layoutBlockChild(LayoutBox& child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom) 565 void LayoutBlockFlow::layoutBlockChild(LayoutBox& child, MarginInfo& marginInfo, LayoutUnit& previousFloatLogicalBottom)
510 { 566 {
511 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore(); 567 LayoutUnit oldPosMarginBefore = maxPositiveMarginBefore();
512 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore(); 568 LayoutUnit oldNegMarginBefore = maxNegativeMarginBefore();
513 569
514 // The child is a normal flow object. Compute the margins we will use for co llapsing now. 570 // The child is a normal flow object. Compute the margins we will use for co llapsing now.
515 child.computeAndSetBlockDirectionMargins(this); 571 child.computeAndSetBlockDirectionMargins(this);
516 572
517 // Try to guess our correct logical top position. In most cases this guess w ill 573 // Try to guess our correct logical top position. In most cases this guess w ill
518 // be correct. Only if we're wrong (when we compute the real logical top pos ition) 574 // be correct. Only if we're wrong (when we compute the real logical top pos ition)
519 // will we have to potentially relayout. 575 // will we have to potentially relayout.
520 LayoutUnit estimateWithoutPagination; 576 LayoutUnit estimateWithoutPagination;
521 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination); 577 LayoutUnit logicalTopEstimate = estimateLogicalTopPosition(child, marginInfo , estimateWithoutPagination);
522 578
523 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves. 579 // Cache our old rect so that we can dirty the proper paint invalidation rec ts if the child moves.
524 LayoutRect oldRect = child.frameRect(); 580 LayoutRect oldRect = child.frameRect();
525 LayoutUnit oldLogicalTop = logicalTopForChild(child);
526
527 // Go ahead and position the child as though it didn't collapse with the top .
Julien - ping for review 2015/09/04 17:40:10 I liked this comment as it explained an assumption
mstensho (USE GERRIT) 2015/09/04 18:31:49 But is / was it even true? Not sure which "top" we
mstensho (USE GERRIT) 2015/09/07 08:03:38 OK, I put a new comment here that I believe is mor
528 setLogicalTopForChild(child, logicalTopEstimate);
529 581
530 LayoutBlockFlow* childLayoutBlockFlow = child.isLayoutBlockFlow() ? toLayout BlockFlow(&child) : 0; 582 LayoutBlockFlow* childLayoutBlockFlow = child.isLayoutBlockFlow() ? toLayout BlockFlow(&child) : 0;
531 bool markDescendantsWithFloats = false; 583 bool childNeededLayout = positionAndLayoutOnceIfNeeded(child, logicalTopEsti mate, previousFloatLogicalBottom);
532 if (logicalTopEstimate != oldLogicalTop && childLayoutBlockFlow && !childLay outBlockFlow->avoidsFloats() && childLayoutBlockFlow->containsFloats()) {
533 markDescendantsWithFloats = true;
534 } else if (UNLIKELY(logicalTopEstimate.mightBeSaturated())) {
535 // logicalTopEstimate, returned by estimateLogicalTopPosition, might be saturated for
536 // very large elements. If it does the comparison with oldLogicalTop mig ht yield a
537 // false negative as adding and removing margins, borders etc from a sat urated number
538 // might yield incorrect results. If this is the case always mark for la yout.
539 markDescendantsWithFloats = true;
540 } else if (!child.avoidsFloats() || child.shrinkToAvoidFloats()) {
541 // If an element might be affected by the presence of floats, then alway s mark it for
542 // layout.
543 LayoutUnit fb = std::max(previousFloatLogicalBottom, lowestFloatLogicalB ottom());
544 if (fb > logicalTopEstimate)
545 markDescendantsWithFloats = true;
546 }
547
548 if (childLayoutBlockFlow) {
549 if (markDescendantsWithFloats)
550 childLayoutBlockFlow->markAllDescendantsWithFloatsForLayout();
551 if (!child.isWritingModeRoot())
552 previousFloatLogicalBottom = std::max(previousFloatLogicalBottom, ol dLogicalTop + childLayoutBlockFlow->lowestFloatLogicalBottom());
553 }
554
555 SubtreeLayoutScope layoutScope(child);
556 if (!child.needsLayout())
557 child.markForPaginationRelayoutIfNeeded(layoutScope);
558
559 bool childNeededLayout = child.needsLayout();
560 if (childNeededLayout)
561 child.layout();
562 584
563 // Cache if we are at the top of the block right now. 585 // Cache if we are at the top of the block right now.
564 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock(); 586 bool atBeforeSideOfBlock = marginInfo.atBeforeSideOfBlock();
565 bool childIsSelfCollapsing = child.isSelfCollapsingBlock(); 587 bool childIsSelfCollapsing = child.isSelfCollapsingBlock();
566 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child); 588 bool childDiscardMarginBefore = mustDiscardMarginBeforeForChild(child);
567 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child); 589 bool childDiscardMarginAfter = mustDiscardMarginAfterForChild(child);
568 590
569 // Now determine the correct ypos based off examination of collapsing margin 591 // Now determine the correct ypos based off examination of collapsing margin
570 // values. 592 // values.
571 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childI sSelfCollapsing, childDiscardMarginBefore, childDiscardMarginAfter); 593 LayoutUnit logicalTopBeforeClear = collapseMargins(child, marginInfo, childI sSelfCollapsing, childDiscardMarginBefore, childDiscardMarginAfter);
572 594
573 // Now check for clear. 595 // Now check for clear.
574 bool childDiscardMargin = childDiscardMarginBefore || childDiscardMarginAfte r; 596 bool childDiscardMargin = childDiscardMarginBefore || childDiscardMarginAfte r;
575 LayoutUnit logicalTopAfterClear = clearFloatsIfNeeded(child, marginInfo, old PosMarginBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsin g, childDiscardMargin); 597 LayoutUnit newLogicalTop = clearFloatsIfNeeded(child, marginInfo, oldPosMarg inBefore, oldNegMarginBefore, logicalTopBeforeClear, childIsSelfCollapsing, chil dDiscardMargin);
576 598
599 // Now check for pagination.
577 bool paginated = view()->layoutState()->isPaginated(); 600 bool paginated = view()->layoutState()->isPaginated();
578 if (paginated) { 601 if (paginated) {
579 logicalTopAfterClear = adjustBlockChildForPagination(logicalTopAfterClea r, estimateWithoutPagination, child, 602 if (estimateWithoutPagination != newLogicalTop) {
580 atBeforeSideOfBlock && logicalTopBeforeClear == logicalTopAfterClear ); 603 // We got a new position due to clearance or margin collapsing. Befo re we attempt to
604 // paginate (which may result in the position changing again), let's try again at the
605 // new position (since a new position may result in a new logical he ight).
606 positionAndLayoutOnceIfNeeded(child, newLogicalTop, previousFloatLog icalBottom);
607 }
608
609 newLogicalTop = adjustBlockChildForPagination(newLogicalTop, child, atBe foreSideOfBlock && logicalTopBeforeClear == newLogicalTop);
581 } 610 }
582 611
583 setLogicalTopForChild(child, logicalTopAfterClear); 612 // Clearance, margin collapsing or pagination may have given us a new logica l top, in which
584 613 // case we may have to reposition and possibly relayout as well. If we deter mined during child
585 // Now we have a final top position. See if it really does end up being diff erent from our estimate. 614 // layout that we need to insert a break to honor widows, we also need to re layout.
586 // clearFloatsIfNeeded can also mark the child as needing a layout even thou gh we didn't move. This happens 615 if (newLogicalTop != logicalTopEstimate
587 // when collapseMargins dynamically adds overhanging floats because of a chi ld with negative margins. 616 || child.needsLayout()
588 if (logicalTopAfterClear != logicalTopEstimate || child.needsLayout() || (pa ginated && childLayoutBlockFlow && childLayoutBlockFlow->shouldBreakAtLineToAvoi dWidow())) { 617 || (paginated && childLayoutBlockFlow && childLayoutBlockFlow->shouldBre akAtLineToAvoidWidow())) {
589 SubtreeLayoutScope layoutScope(child); 618 positionAndLayoutOnceIfNeeded(child, newLogicalTop, previousFloatLogical Bottom);
590 if (child.shrinkToAvoidFloats()) {
591 // The child's width depends on the line width.
592 // When the child shifts to clear an item, its width can
593 // change (because it has more available line width).
594 // So go ahead and mark the item as dirty.
595 layoutScope.setChildNeedsLayout(&child);
596 }
597
598 if (childLayoutBlockFlow && !childLayoutBlockFlow->avoidsFloats() && chi ldLayoutBlockFlow->containsFloats())
599 childLayoutBlockFlow->markAllDescendantsWithFloatsForLayout();
600
601 if (!child.needsLayout())
602 child.markForPaginationRelayoutIfNeeded(layoutScope);
603
604 // Our guess was wrong. Make the child lay itself out again.
605 child.layoutIfNeeded();
606 } 619 }
607 620
608 // If we previously encountered a self-collapsing sibling of this child that had clearance then 621 // If we previously encountered a self-collapsing sibling of this child that had clearance then
609 // we set this bit to ensure we would not collapse the child's margins, and those of any subsequent 622 // we set this bit to ensure we would not collapse the child's margins, and those of any subsequent
610 // self-collapsing siblings, with our parent. If this child is not self-coll apsing then it can 623 // self-collapsing siblings, with our parent. If this child is not self-coll apsing then it can
611 // collapse its margins with the parent so reset the bit. 624 // collapse its margins with the parent so reset the bit.
612 if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollaps ing) 625 if (!marginInfo.canCollapseMarginAfterWithLastChild() && !childIsSelfCollaps ing)
613 marginInfo.setCanCollapseMarginAfterWithLastChild(true); 626 marginInfo.setCanCollapseMarginAfterWithLastChild(true);
614 627
615 // We are no longer at the top of the block if we encounter a non-empty chil d. 628 // We are no longer at the top of the block if we encounter a non-empty chil d.
(...skipping 29 matching lines...) Expand all
645 if (newHeight != size().height()) 658 if (newHeight != size().height())
646 setLogicalHeight(newHeight); 659 setLogicalHeight(newHeight);
647 } 660 }
648 661
649 if (child.isLayoutMultiColumnSpannerPlaceholder()) { 662 if (child.isLayoutMultiColumnSpannerPlaceholder()) {
650 // The actual column-span:all element is positioned by this placeholder child. 663 // The actual column-span:all element is positioned by this placeholder child.
651 positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child)); 664 positionSpannerDescendant(toLayoutMultiColumnSpannerPlaceholder(child));
652 } 665 }
653 } 666 }
654 667
655 LayoutUnit LayoutBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTopA fterClear, LayoutUnit estimateWithoutPagination, LayoutBox& child, bool atBefore SideOfBlock) 668 LayoutUnit LayoutBlockFlow::adjustBlockChildForPagination(LayoutUnit logicalTop, LayoutBox& child, bool atBeforeSideOfBlock)
656 { 669 {
657 LayoutBlockFlow* childBlockFlow = child.isLayoutBlockFlow() ? toLayoutBlockF low(&child) : 0; 670 LayoutBlockFlow* childBlockFlow = child.isLayoutBlockFlow() ? toLayoutBlockF low(&child) : 0;
658 671
659 if (estimateWithoutPagination != logicalTopAfterClear) {
660 // Our guess prior to pagination movement was wrong. Before we attempt t o paginate, let's try again at the new
661 // position.
662 setLogicalHeight(logicalTopAfterClear);
663 setLogicalTopForChild(child, logicalTopAfterClear);
664
665 if (child.shrinkToAvoidFloats()) {
666 // The child's width depends on the line width.
667 // When the child shifts to clear an item, its width can
668 // change (because it has more available line width).
669 // So go ahead and mark the item as dirty.
670 child.setChildNeedsLayout(MarkOnlyThis);
671 }
672
673 SubtreeLayoutScope layoutScope(child);
674
675 if (childBlockFlow) {
676 if (!childBlockFlow->avoidsFloats() && childBlockFlow->containsFloat s())
677 childBlockFlow->markAllDescendantsWithFloatsForLayout();
678 if (!child.needsLayout())
679 child.markForPaginationRelayoutIfNeeded(layoutScope);
680 }
681
682 // Our guess was wrong. Make the child lay itself out again.
683 child.layoutIfNeeded();
684 }
685
686 LayoutUnit oldTop = logicalTopAfterClear;
687
688 // If the object has a page or column break value of "before", then we shoul d shift to the top of the next page. 672 // If the object has a page or column break value of "before", then we shoul d shift to the top of the next page.
689 LayoutUnit result = applyBeforeBreak(child, logicalTopAfterClear); 673 LayoutUnit newLogicalTop = applyBeforeBreak(child, logicalTop);
690 674
691 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one. 675 // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
692 LayoutUnit logicalTopBeforeUnsplittableAdjustment = result; 676 LayoutUnit logicalTopBeforeUnsplittableAdjustment = newLogicalTop;
693 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChil d(child, result); 677 LayoutUnit logicalTopAfterUnsplittableAdjustment = adjustForUnsplittableChil d(child, newLogicalTop);
694 678
695 LayoutUnit paginationStrut = 0; 679 LayoutUnit paginationStrut = 0;
696 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustme nt - logicalTopBeforeUnsplittableAdjustment; 680 LayoutUnit unsplittableAdjustmentDelta = logicalTopAfterUnsplittableAdjustme nt - logicalTopBeforeUnsplittableAdjustment;
697 LayoutUnit childLogicalHeight = child.logicalHeight(); 681 LayoutUnit childLogicalHeight = child.logicalHeight();
698 if (unsplittableAdjustmentDelta) { 682 if (unsplittableAdjustmentDelta) {
699 setPageBreak(result, childLogicalHeight - unsplittableAdjustmentDelta); 683 setPageBreak(newLogicalTop, childLogicalHeight - unsplittableAdjustmentD elta);
700 paginationStrut = unsplittableAdjustmentDelta; 684 paginationStrut = unsplittableAdjustmentDelta;
701 } else if (childBlockFlow && childBlockFlow->paginationStrut()) { 685 } else if (childBlockFlow && childBlockFlow->paginationStrut()) {
702 paginationStrut = childBlockFlow->paginationStrut(); 686 paginationStrut = childBlockFlow->paginationStrut();
703 } 687 }
704 688
705 if (paginationStrut) { 689 if (paginationStrut) {
706 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior 690 // We are willing to propagate out to our parent block as long as we wer e at the top of the block prior
707 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination. 691 // to collapsing our margins, and as long as we didn't clear or move as a result of other pagination.
708 if (atBeforeSideOfBlock && oldTop == result && !isOutOfFlowPositioned() && !isTableCell()) { 692 if (atBeforeSideOfBlock && logicalTop == newLogicalTop && !isOutOfFlowPo sitioned() && !isTableCell()) {
709 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't 693 // FIXME: Should really check if we're exceeding the page height bef ore propagating the strut, but we don't
710 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too 694 // have all the information to do so (the strut only has the remaini ng amount to push). Gecko gets this wrong too
711 // and pushes to the next page anyway, so not too concerned about it . 695 // and pushes to the next page anyway, so not too concerned about it .
712 setPaginationStrut(result + paginationStrut); 696 setPaginationStrut(logicalTop + paginationStrut);
713 if (childBlockFlow) 697 if (childBlockFlow)
714 childBlockFlow->setPaginationStrut(0); 698 childBlockFlow->setPaginationStrut(0);
715 } else { 699 } else {
716 result += paginationStrut; 700 newLogicalTop += paginationStrut;
717 } 701 }
718 } 702 }
719 703
720 if (!unsplittableAdjustmentDelta) { 704 if (!unsplittableAdjustmentDelta) {
721 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(result)) { 705 if (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(newLogical Top)) {
722 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff set(result, AssociateWithLatterPage); 706 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOff set(newLogicalTop, AssociateWithLatterPage);
723 LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeig ht; 707 LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeig ht;
724 if (spaceShortage > 0) { 708 if (spaceShortage > 0) {
725 // If the child crosses a column boundary, report a break, in ca se nothing inside it 709 // If the child crosses a column boundary, report a break, in ca se nothing inside it
726 // has already done so. The column balancer needs to know how mu ch it has to stretch 710 // has already done so. The column balancer needs to know how mu ch it has to stretch
727 // the columns to make more content fit. If no breaks are report ed (but do occur), 711 // the columns to make more content fit. If no breaks are report ed (but do occur),
728 // the balancer will have no clue. Only measure the space after the last column 712 // the balancer will have no clue. Only measure the space after the last column
729 // boundary, in case it crosses more than one. 713 // boundary, in case it crosses more than one.
730 LayoutUnit spaceShortageInLastColumn = intMod(spaceShortage, pag eLogicalHeight); 714 LayoutUnit spaceShortageInLastColumn = intMod(spaceShortage, pag eLogicalHeight);
731 setPageBreak(result, spaceShortageInLastColumn ? spaceShortageIn LastColumn : spaceShortage); 715 setPageBreak(newLogicalTop, spaceShortageInLastColumn ? spaceSho rtageInLastColumn : spaceShortage);
732 } else if (remainingLogicalHeight == pageLogicalHeight && offsetFrom LogicalTopOfFirstPage() + child.logicalTop()) { 716 } else if (remainingLogicalHeight == pageLogicalHeight && offsetFrom LogicalTopOfFirstPage() + child.logicalTop()) {
733 // We're at the very top of a page or column, and it's not the f irst one. This child 717 // We're at the very top of a page or column, and it's not the f irst one. This child
734 // may turn out to be the smallest piece of content that causes a page break, so we 718 // may turn out to be the smallest piece of content that causes a page break, so we
735 // need to report it. 719 // need to report it.
736 setPageBreak(result, childLogicalHeight); 720 setPageBreak(newLogicalTop, childLogicalHeight);
737 } 721 }
738 } 722 }
739 } 723 }
740 724
741 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. 725 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child.
742 setLogicalHeight(logicalHeight() + (result - oldTop)); 726 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop));
743 727
744 // Return the final adjusted logical top. 728 // Return the final adjusted logical top.
745 return result; 729 return newLogicalTop;
746 } 730 }
747 731
748 static inline LayoutUnit calculateMinimumPageHeight(const ComputedStyle& style, const RootInlineBox& lastLine) 732 static inline LayoutUnit calculateMinimumPageHeight(const ComputedStyle& style, const RootInlineBox& lastLine)
749 { 733 {
750 // We may require a certain minimum number of lines per page in order to sat isfy 734 // We may require a certain minimum number of lines per page in order to sat isfy
751 // orphans and widows, and that may affect the minimum page height. 735 // orphans and widows, and that may affect the minimum page height.
752 unsigned lineCount = std::max<unsigned>(style.hasAutoOrphans() ? 1 : style.o rphans(), style.widows()); 736 unsigned lineCount = std::max<unsigned>(style.hasAutoOrphans() ? 1 : style.o rphans(), style.widows());
753 const RootInlineBox* firstLine = &lastLine; 737 const RootInlineBox* firstLine = &lastLine;
754 for (unsigned i = 1; i < lineCount && firstLine->prevRootBox(); i++) 738 for (unsigned i = 1; i < lineCount && firstLine->prevRootBox(); i++)
755 firstLine = firstLine->prevRootBox(); 739 firstLine = firstLine->prevRootBox();
(...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 FrameView* frameView = document().view(); 3054 FrameView* frameView = document().view();
3071 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); 3055 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height();
3072 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); 3056 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( );
3073 if (size().height() < visibleHeight) 3057 if (size().height() < visibleHeight)
3074 top += (visibleHeight - size().height()) / 2; 3058 top += (visibleHeight - size().height()) / 2;
3075 setY(top); 3059 setY(top);
3076 dialog->setCentered(top); 3060 dialog->setCentered(top);
3077 } 3061 }
3078 3062
3079 } // namespace blink 3063 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698