OLD | NEW |
---|---|
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 23 matching lines...) Expand all Loading... | |
34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
37 #include "core/html/HTMLDialogElement.h" | 37 #include "core/html/HTMLDialogElement.h" |
38 #include "core/layout/HitTestLocation.h" | 38 #include "core/layout/HitTestLocation.h" |
39 #include "core/layout/LayoutAnalyzer.h" | 39 #include "core/layout/LayoutAnalyzer.h" |
40 #include "core/layout/LayoutFlowThread.h" | 40 #include "core/layout/LayoutFlowThread.h" |
41 #include "core/layout/LayoutMultiColumnFlowThread.h" | 41 #include "core/layout/LayoutMultiColumnFlowThread.h" |
42 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 42 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
43 #include "core/layout/LayoutPagedFlowThread.h" | 43 #include "core/layout/LayoutPagedFlowThread.h" |
44 #include "core/layout/LayoutTableCell.h" | |
44 #include "core/layout/LayoutText.h" | 45 #include "core/layout/LayoutText.h" |
45 #include "core/layout/LayoutView.h" | 46 #include "core/layout/LayoutView.h" |
46 #include "core/layout/TextAutosizer.h" | 47 #include "core/layout/TextAutosizer.h" |
47 #include "core/layout/api/SelectionState.h" | 48 #include "core/layout/api/SelectionState.h" |
48 #include "core/layout/line/LineBreaker.h" | 49 #include "core/layout/line/LineBreaker.h" |
49 #include "core/layout/line/LineWidth.h" | 50 #include "core/layout/line/LineWidth.h" |
50 #include "core/layout/shapes/ShapeOutsideInfo.h" | 51 #include "core/layout/shapes/ShapeOutsideInfo.h" |
51 #include "core/paint/BlockFlowPainter.h" | 52 #include "core/paint/BlockFlowPainter.h" |
52 #include "core/paint/ClipScope.h" | 53 #include "core/paint/ClipScope.h" |
53 #include "core/paint/LayoutObjectDrawingRecorder.h" | 54 #include "core/paint/LayoutObjectDrawingRecorder.h" |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 | 714 |
714 paginatedContentWasLaidOut(newLogicalTop + child.logicalHeight()); | 715 paginatedContentWasLaidOut(newLogicalTop + child.logicalHeight()); |
715 | 716 |
716 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. | 717 // Similar to how we apply clearance. Go ahead and boost height() to be the place where we're going to position the child. |
717 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop)); | 718 setLogicalHeight(logicalHeight() + (newLogicalTop - logicalTop)); |
718 | 719 |
719 // Return the final adjusted logical top. | 720 // Return the final adjusted logical top. |
720 return newLogicalTop; | 721 return newLogicalTop; |
721 } | 722 } |
722 | 723 |
723 static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInline Box& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogica lHeight) | 724 static bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInline Box& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit pageLogica lHeight, LayoutUnit remainingLogicalHeight) |
724 { | 725 { |
725 bool wantsStrutOnBlock = false; | 726 bool wantsStrutOnBlock = false; |
726 if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineInde x) { | 727 // We avoid letting table cells straddle a page boundary unless the cell is taller than the page. |
728 if (block.isTableCell() && toLayoutTableCell(block).table()->vBorderSpacing( ) + block.logicalHeight() + remainingLogicalHeight < pageLogicalHeight) { | |
mstensho (USE GERRIT)
2016/02/29 09:46:47
I'm sorry, but this just looks like a hack. While
| |
729 wantsStrutOnBlock = true; | |
730 } else if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= l ineIndex) { | |
727 // Not enough orphans here. Push the entire block to the next column / p age as an | 731 // Not enough orphans here. Push the entire block to the next column / p age as an |
728 // attempt to better satisfy the orphans requirement. | 732 // attempt to better satisfy the orphans requirement. |
729 wantsStrutOnBlock = true; | 733 wantsStrutOnBlock = true; |
730 } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.bor derAndPaddingBefore()) { | 734 } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.bor derAndPaddingBefore()) { |
731 // This is the first line in the block. We can take the whole block with us to the next page | 735 // This is the first line in the block. We can take the whole block with us to the next page |
732 // or column, rather than keeping a content-less portion of it in the pr evious one. Only do | 736 // or column, rather than keeping a content-less portion of it in the pr evious one. Only do |
733 // this if the line is flush with the content edge of the block, though. If it isn't, it | 737 // this if the line is flush with the content edge of the block, though. If it isn't, it |
734 // means that the line was pushed downwards by preceding floats that did n't fit beside the | 738 // means that the line was pushed downwards by preceding floats that did n't fit beside the |
735 // line, and we don't want to move all that, since it has already been e stablished that it | 739 // line, and we don't want to move all that, since it has already been e stablished that it |
736 // fits nicely where it is. | 740 // fits nicely where it is. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
782 return; | 786 return; |
783 } | 787 } |
784 | 788 |
785 // We need to insert a break now, either because there's no room for the line in the | 789 // We need to insert a break now, either because there's no room for the line in the |
786 // current column / page, or because we have determined that we need a b reak to satisfy | 790 // current column / page, or because we have determined that we need a b reak to satisfy |
787 // widow requirements. | 791 // widow requirements. |
788 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { | 792 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn dex) { |
789 clearShouldBreakAtLineToAvoidWidow(); | 793 clearShouldBreakAtLineToAvoidWidow(); |
790 setDidBreakAtLineToAvoidWidow(); | 794 setDidBreakAtLineToAvoidWidow(); |
791 } | 795 } |
792 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page LogicalHeight)) { | 796 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page LogicalHeight, remainingLogicalHeight)) { |
793 // Note that when setting the strut on a block, it may be propagated to parent blocks | 797 // Note that when setting the strut on a block, it may be propagated to parent blocks |
794 // later on, if a block's logical top is flush with that of its pare nt. We don't want | 798 // later on, if a block's logical top is flush with that of its pare nt. We don't want |
795 // content-less portions (struts) at the beginning of a block before a break, if it can | 799 // content-less portions (struts) at the beginning of a block before a break, if it can |
796 // be avoided. After all, that's the reason for setting struts on bl ocks and not lines | 800 // be avoided. After all, that's the reason for setting struts on bl ocks and not lines |
797 // in the first place. | 801 // in the first place. |
798 LayoutUnit strut = paginationStrut + logicalOffset + marginBeforeIfF loating(); | 802 LayoutUnit strut = paginationStrut + logicalOffset + marginBeforeIfF loating(); |
799 setPaginationStrutPropagatedFromChild(strut); | 803 setPaginationStrutPropagatedFromChild(strut); |
800 } else { | 804 } else { |
801 delta += paginationStrut; | 805 delta += paginationStrut; |
802 lineBox.setPaginationStrut(paginationStrut); | 806 lineBox.setPaginationStrut(paginationStrut); |
803 lineBox.setIsFirstAfterPageBreak(true); | 807 lineBox.setIsFirstAfterPageBreak(true); |
804 } | 808 } |
805 return; | 809 return; |
806 } | 810 } |
807 | 811 |
808 if (remainingLogicalHeight == pageLogicalHeight) { | 812 if (remainingLogicalHeight == pageLogicalHeight) { |
809 // We're at the very top of a page or column. | 813 // We're at the very top of a page or column. |
810 if (lineBox != firstRootBox()) | 814 if (lineBox != firstRootBox()) |
811 lineBox.setIsFirstAfterPageBreak(true); | 815 lineBox.setIsFirstAfterPageBreak(true); |
812 // If this is the first line in the block, and the block has a top borde r, padding, or (in | 816 // If this is the first line in the block, and the block has a top borde r, padding, or (in |
813 // case it's a float) margin, we may want to set a strut on the block, s o that everything | 817 // case it's a float) margin, we may want to set a strut on the block, s o that everything |
814 // ends up in the next column or page. Setting a strut on the block is a lso important when | 818 // ends up in the next column or page. Setting a strut on the block is a lso important when |
815 // it comes to satisfying orphan requirements. | 819 // it comes to satisfying orphan requirements. |
816 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page LogicalHeight)) { | 820 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, page LogicalHeight, remainingLogicalHeight)) { |
817 LayoutUnit strut = logicalOffset + marginBeforeIfFloating(); | 821 LayoutUnit strut = logicalOffset + marginBeforeIfFloating(); |
818 setPaginationStrutPropagatedFromChild(strut); | 822 setPaginationStrutPropagatedFromChild(strut); |
819 } | 823 } |
820 } else if (lineBox == firstRootBox() && allowsPaginationStrut()) { | 824 } else if (lineBox == firstRootBox() && allowsPaginationStrut()) { |
821 // This is the first line in the block. The block may still start in the previous column or | 825 // This is the first line in the block. The block may still start in the previous column or |
822 // page, and if that's the case, attempt to pull it over to where this l ine is, so that we | 826 // page, and if that's the case, attempt to pull it over to where this l ine is, so that we |
823 // don't split the top border, padding, or (in case it's a float) margin . | 827 // don't split the top border, padding, or (in case it's a float) margin . |
824 LayoutUnit totalLogicalOffset = logicalOffset + marginBeforeIfFloating() ; | 828 LayoutUnit totalLogicalOffset = logicalOffset + marginBeforeIfFloating() ; |
825 LayoutUnit strut = remainingLogicalHeight + totalLogicalOffset - pageLog icalHeight; | 829 LayoutUnit strut = remainingLogicalHeight + totalLogicalOffset - pageLog icalHeight; |
826 if (strut > 0) { | 830 if (strut > 0) { |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2671 if (isOutOfFlowPositioned()) | 2675 if (isOutOfFlowPositioned()) |
2672 return false; | 2676 return false; |
2673 if (isLayoutFlowThread()) { | 2677 if (isLayoutFlowThread()) { |
2674 // Don't let the strut escape the fragmentation context and get lost. | 2678 // Don't let the strut escape the fragmentation context and get lost. |
2675 // TODO(mstensho): If we're in a nested fragmentation context, we should ideally convert | 2679 // TODO(mstensho): If we're in a nested fragmentation context, we should ideally convert |
2676 // and propagate the strut to the outer fragmentation context, so that t he inner one is | 2680 // and propagate the strut to the outer fragmentation context, so that t he inner one is |
2677 // fully pushed to the next outer fragmentainer, instead of taking up un usable space in the | 2681 // fully pushed to the next outer fragmentainer, instead of taking up un usable space in the |
2678 // previous one. But currently we have no mechanism in place to handle t his. | 2682 // previous one. But currently we have no mechanism in place to handle t his. |
2679 return false; | 2683 return false; |
2680 } | 2684 } |
2685 if (isTableCell()) | |
2686 return true; | |
2687 | |
2681 LayoutBlock* containingBlock = this->containingBlock(); | 2688 LayoutBlock* containingBlock = this->containingBlock(); |
2682 return containingBlock && containingBlock->isLayoutBlockFlow(); | 2689 return containingBlock && containingBlock->isLayoutBlockFlow(); |
2683 } | 2690 } |
2684 | 2691 |
2685 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) | 2692 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) |
2686 { | 2693 { |
2687 strut = std::max(strut, LayoutUnit()); | 2694 strut = std::max(strut, LayoutUnit()); |
2688 if (!m_rareData) { | 2695 if (!m_rareData) { |
2689 if (!strut) | 2696 if (!strut) |
2690 return; | 2697 return; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2858 FrameView* frameView = document().view(); | 2865 FrameView* frameView = document().view(); |
2859 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); | 2866 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); |
2860 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 2867 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
2861 if (size().height() < visibleHeight) | 2868 if (size().height() < visibleHeight) |
2862 top += (visibleHeight - size().height()) / 2; | 2869 top += (visibleHeight - size().height()) / 2; |
2863 setY(top); | 2870 setY(top); |
2864 dialog->setCentered(top); | 2871 dialog->setCentered(top); |
2865 } | 2872 } |
2866 | 2873 |
2867 } // namespace blink | 2874 } // namespace blink |
OLD | NEW |