Chromium Code Reviews| 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/LayoutTableRow.h" | |
|
mstensho (USE GERRIT)
2016/02/26 13:29:59
No need for this, I hope.
| |
| 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) |
| 724 { | 725 { |
| 726 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTopWit hLeading(); | |
|
mstensho (USE GERRIT)
2016/02/26 13:29:59
Maybe you meant to revert these changes, now that
| |
| 727 LayoutUnit totalLogicalHeight = lineHeight + lineLogicalOffset.clampNegative ToZero(); | |
| 728 | |
| 729 | |
| 725 bool wantsStrutOnBlock = false; | 730 bool wantsStrutOnBlock = false; |
| 726 if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineInde x) { | 731 // We avoid letting table cells straddle a page boundary unless the cell is taller than the page. |
| 732 if (block.isTableCell() && totalLogicalHeight <= pageLogicalHeight) { | |
| 733 wantsStrutOnBlock = true; | |
| 734 } 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 | 735 // Not enough orphans here. Push the entire block to the next column / p age as an |
| 728 // attempt to better satisfy the orphans requirement. | 736 // attempt to better satisfy the orphans requirement. |
| 729 wantsStrutOnBlock = true; | 737 wantsStrutOnBlock = true; |
| 730 } else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.bor derAndPaddingBefore()) { | 738 } 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 | 739 // 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 | 740 // 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 | 741 // 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 | 742 // 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 | 743 // 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. | 744 // fits nicely where it is. |
| 737 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTo pWithLeading(); | |
| 738 LayoutUnit totalLogicalHeight = lineHeight + lineLogicalOffset.clampNega tiveToZero(); | |
| 739 // It's rather pointless to break before the block if the current line i sn't going to | 745 // It's rather pointless to break before the block if the current line i sn't going to |
| 740 // fit in the same column or page, so check that as well. | 746 // fit in the same column or page, so check that as well. |
| 741 if (totalLogicalHeight <= pageLogicalHeight) | 747 if (totalLogicalHeight <= pageLogicalHeight) |
| 742 wantsStrutOnBlock = true; | 748 wantsStrutOnBlock = true; |
| 743 } | 749 } |
| 744 return wantsStrutOnBlock && block.allowsPaginationStrut(); | 750 return wantsStrutOnBlock && block.allowsPaginationStrut(); |
| 745 } | 751 } |
| 746 | 752 |
| 747 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La youtUnit& delta) | 753 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La youtUnit& delta) |
| 748 { | 754 { |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2671 if (isOutOfFlowPositioned()) | 2677 if (isOutOfFlowPositioned()) |
| 2672 return false; | 2678 return false; |
| 2673 if (isLayoutFlowThread()) { | 2679 if (isLayoutFlowThread()) { |
| 2674 // Don't let the strut escape the fragmentation context and get lost. | 2680 // 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 | 2681 // 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 | 2682 // 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 | 2683 // 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. | 2684 // previous one. But currently we have no mechanism in place to handle t his. |
| 2679 return false; | 2685 return false; |
| 2680 } | 2686 } |
| 2687 if (isTableCell()) | |
| 2688 return true; | |
| 2689 | |
| 2681 LayoutBlock* containingBlock = this->containingBlock(); | 2690 LayoutBlock* containingBlock = this->containingBlock(); |
| 2682 return containingBlock && containingBlock->isLayoutBlockFlow(); | 2691 return containingBlock && containingBlock->isLayoutBlockFlow(); |
| 2683 } | 2692 } |
| 2684 | 2693 |
| 2685 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) | 2694 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) |
| 2686 { | 2695 { |
| 2687 strut = std::max(strut, LayoutUnit()); | 2696 strut = std::max(strut, LayoutUnit()); |
| 2688 if (!m_rareData) { | 2697 if (!m_rareData) { |
| 2689 if (!strut) | 2698 if (!strut) |
| 2690 return; | 2699 return; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2858 FrameView* frameView = document().view(); | 2867 FrameView* frameView = document().view(); |
| 2859 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); | 2868 LayoutUnit top = LayoutUnit((style()->position() == FixedPosition) ? 0 : fra meView->scrollOffset().height()); |
| 2860 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 2869 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
| 2861 if (size().height() < visibleHeight) | 2870 if (size().height() < visibleHeight) |
| 2862 top += (visibleHeight - size().height()) / 2; | 2871 top += (visibleHeight - size().height()) / 2; |
| 2863 setY(top); | 2872 setY(top); |
| 2864 dialog->setCentered(top); | 2873 dialog->setCentered(top); |
| 2865 } | 2874 } |
| 2866 | 2875 |
| 2867 } // namespace blink | 2876 } // namespace blink |
| OLD | NEW |