| 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 LayoutUnit logicalTopAfterPagination = std::max(logicalTopWithContentStrut,
std::max(logicalTopAfterForcedBreak, logicalTopAfterUnsplittable)); | 709 LayoutUnit logicalTopAfterPagination = std::max(logicalTopWithContentStrut,
std::max(logicalTopAfterForcedBreak, logicalTopAfterUnsplittable)); |
| 710 LayoutUnit newLogicalTop = logicalTop; | 710 LayoutUnit newLogicalTop = logicalTop; |
| 711 if (LayoutUnit paginationStrut = logicalTopAfterPagination - logicalTop) { | 711 if (LayoutUnit paginationStrut = logicalTopAfterPagination - logicalTop) { |
| 712 ASSERT(paginationStrut > 0); | 712 ASSERT(paginationStrut > 0); |
| 713 // We are willing to propagate out to our parent block as long as we wer
e at the top of the block prior | 713 // We are willing to propagate out to our parent block as long as we wer
e at the top of the block prior |
| 714 // to collapsing our margins, and as long as we didn't clear or move as
a result of other pagination. | 714 // to collapsing our margins, and as long as we didn't clear or move as
a result of other pagination. |
| 715 if (atBeforeSideOfBlock && logicalTopAfterForcedBreak == logicalTop && a
llowsPaginationStrut()) { | 715 if (atBeforeSideOfBlock && logicalTopAfterForcedBreak == logicalTop && a
llowsPaginationStrut()) { |
| 716 // FIXME: Should really check if we're exceeding the page height bef
ore propagating the strut, but we don't | 716 // FIXME: Should really check if we're exceeding the page height bef
ore propagating the strut, but we don't |
| 717 // have all the information to do so (the strut only has the remaini
ng amount to push). Gecko gets this wrong too | 717 // have all the information to do so (the strut only has the remaini
ng amount to push). Gecko gets this wrong too |
| 718 // and pushes to the next page anyway, so not too concerned about it
. | 718 // and pushes to the next page anyway, so not too concerned about it
. |
| 719 paginationStrut += logicalTop; | 719 paginationStrut += logicalTop + marginBeforeIfFloating(); |
| 720 if (isFloating()) | |
| 721 paginationStrut += marginBefore(); // Floats' margins do not col
lapse with page or column boundaries. | |
| 722 setPaginationStrutPropagatedFromChild(paginationStrut); | 720 setPaginationStrutPropagatedFromChild(paginationStrut); |
| 723 if (childBlockFlow) | 721 if (childBlockFlow) |
| 724 childBlockFlow->setPaginationStrutPropagatedFromChild(LayoutUnit
()); | 722 childBlockFlow->setPaginationStrutPropagatedFromChild(LayoutUnit
()); |
| 725 } else { | 723 } else { |
| 726 child.setPaginationStrut(paginationStrut); | 724 child.setPaginationStrut(paginationStrut); |
| 727 newLogicalTop += paginationStrut; | 725 newLogicalTop += paginationStrut; |
| 728 } | 726 } |
| 729 } | 727 } |
| 730 | 728 |
| 731 paginatedContentWasLaidOut(newLogicalTop); | 729 paginatedContentWasLaidOut(newLogicalTop); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 755 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, lin
eLogicalOffset); | 753 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, lin
eLogicalOffset); |
| 756 LayoutUnit pageLogicalHeightAtNewOffset = block.pageLogicalHeightForOffs
et(lineLogicalOffset + remainingLogicalHeight); | 754 LayoutUnit pageLogicalHeightAtNewOffset = block.pageLogicalHeightForOffs
et(lineLogicalOffset + remainingLogicalHeight); |
| 757 // It's rather pointless to break before the block if the current line i
sn't going to | 755 // It's rather pointless to break before the block if the current line i
sn't going to |
| 758 // fit in the same column or page, so check that as well. | 756 // fit in the same column or page, so check that as well. |
| 759 if (totalLogicalHeight <= pageLogicalHeightAtNewOffset) | 757 if (totalLogicalHeight <= pageLogicalHeightAtNewOffset) |
| 760 wantsStrutOnBlock = true; | 758 wantsStrutOnBlock = true; |
| 761 } | 759 } |
| 762 return wantsStrutOnBlock && block.allowsPaginationStrut(); | 760 return wantsStrutOnBlock && block.allowsPaginationStrut(); |
| 763 } | 761 } |
| 764 | 762 |
| 765 static LayoutUnit calculateStrutForPropagation(const LayoutBlockFlow& blockFlow,
LayoutUnit lineLogicalOffset) | |
| 766 { | |
| 767 LayoutUnit paginationStrut = std::max<LayoutUnit>(LayoutUnit(), lineLogicalO
ffset); | |
| 768 if (blockFlow.isFloating()) | |
| 769 paginationStrut += blockFlow.marginBefore(); // Floats' margins do not c
ollapse with page or column boundaries. | |
| 770 return paginationStrut; | |
| 771 } | |
| 772 | |
| 773 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La
youtUnit& delta) | 763 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La
youtUnit& delta) |
| 774 { | 764 { |
| 775 // TODO(mstensho): Pay attention to line overflow. It should be painted in t
he same column as | 765 // TODO(mstensho): Pay attention to line overflow. It should be painted in t
he same column as |
| 776 // the rest of the line, possibly overflowing the column. We currently only
allow overflow above | 766 // the rest of the line, possibly overflowing the column. We currently only
allow overflow above |
| 777 // the first column. We clip at all other column boundaries, and that's how
it has to be for | 767 // the first column. We clip at all other column boundaries, and that's how
it has to be for |
| 778 // now. The paint we have to do when a column has overflow has to be special
. We need to exclude | 768 // now. The paint we have to do when a column has overflow has to be special
. We need to exclude |
| 779 // content that paints in a previous column (and content that paints in the
following column). | 769 // content that paints in a previous column (and content that paints in the
following column). |
| 780 // | 770 // |
| 781 // FIXME: Another problem with simply moving lines is that the available lin
e width may change (because of floats). | 771 // FIXME: Another problem with simply moving lines is that the available lin
e width may change (because of floats). |
| 782 // Technically if the location we move the line to has a different line widt
h than our old position, then we need to dirty the | 772 // Technically if the location we move the line to has a different line widt
h than our old position, then we need to dirty the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 806 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { | 796 if (shouldBreakAtLineToAvoidWidow() && lineBreakToAvoidWidow() == lineIn
dex) { |
| 807 clearShouldBreakAtLineToAvoidWidow(); | 797 clearShouldBreakAtLineToAvoidWidow(); |
| 808 setDidBreakAtLineToAvoidWidow(); | 798 setDidBreakAtLineToAvoidWidow(); |
| 809 } | 799 } |
| 810 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, rema
iningLogicalHeight)) { | 800 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, rema
iningLogicalHeight)) { |
| 811 // Note that when setting the strut on a block, it may be propagated
to parent blocks | 801 // Note that when setting the strut on a block, it may be propagated
to parent blocks |
| 812 // later on, if a block's logical top is flush with that of its pare
nt. We don't want | 802 // later on, if a block's logical top is flush with that of its pare
nt. We don't want |
| 813 // content-less portions (struts) at the beginning of a block before
a break, if it can | 803 // content-less portions (struts) at the beginning of a block before
a break, if it can |
| 814 // be avoided. After all, that's the reason for setting struts on bl
ocks and not lines | 804 // be avoided. After all, that's the reason for setting struts on bl
ocks and not lines |
| 815 // in the first place. | 805 // in the first place. |
| 816 setPaginationStrutPropagatedFromChild(calculateStrutForPropagation(*
this, remainingLogicalHeight + logicalOffset)); | 806 LayoutUnit strut = remainingLogicalHeight + logicalOffset + marginBe
foreIfFloating(); |
| 807 setPaginationStrutPropagatedFromChild(strut); |
| 817 } else { | 808 } else { |
| 818 logicalOffset += remainingLogicalHeight; | 809 logicalOffset += remainingLogicalHeight; |
| 819 delta += remainingLogicalHeight; | 810 delta += remainingLogicalHeight; |
| 820 lineBox.setPaginationStrut(remainingLogicalHeight); | 811 lineBox.setPaginationStrut(remainingLogicalHeight); |
| 821 lineBox.setIsFirstAfterPageBreak(true); | 812 lineBox.setIsFirstAfterPageBreak(true); |
| 822 } | 813 } |
| 823 } else if (remainingLogicalHeight == pageLogicalHeight) { | 814 } else if (remainingLogicalHeight == pageLogicalHeight) { |
| 824 // We're at the very top of a page or column. | 815 // We're at the very top of a page or column. |
| 825 if (lineBox != firstRootBox()) | 816 if (lineBox != firstRootBox()) |
| 826 lineBox.setIsFirstAfterPageBreak(true); | 817 lineBox.setIsFirstAfterPageBreak(true); |
| 827 // If this is the first line in the block, and the block has a top borde
r, padding, or (in | 818 // If this is the first line in the block, and the block has a top borde
r, padding, or (in |
| 828 // case it's a float) margin, we may want to set a strut on the block, s
o that everything | 819 // case it's a float) margin, we may want to set a strut on the block, s
o that everything |
| 829 // ends up in the next column or page. Setting a strut on the block is a
lso important when | 820 // ends up in the next column or page. Setting a strut on the block is a
lso important when |
| 830 // it comes to satisfying orphan requirements. | 821 // it comes to satisfying orphan requirements. |
| 831 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, rema
iningLogicalHeight)) | 822 if (shouldSetStrutOnBlock(*this, lineBox, logicalOffset, lineIndex, rema
iningLogicalHeight)) { |
| 832 setPaginationStrutPropagatedFromChild(calculateStrutForPropagation(*
this, logicalOffset)); | 823 LayoutUnit strut = logicalOffset + marginBeforeIfFloating(); |
| 824 setPaginationStrutPropagatedFromChild(strut); |
| 825 } |
| 833 } else if (lineBox == firstRootBox() && allowsPaginationStrut()) { | 826 } else if (lineBox == firstRootBox() && allowsPaginationStrut()) { |
| 834 // This is the first line in the block. The block may still start in the
previous column or | 827 // This is the first line in the block. The block may still start in the
previous column or |
| 835 // page, and if that's the case, attempt to pull it over to where this l
ine is, so that we | 828 // page, and if that's the case, attempt to pull it over to where this l
ine is, so that we |
| 836 // don't split the top border, padding, or (in case it's a float) margin
. | 829 // don't split the top border, padding, or (in case it's a float) margin
. |
| 837 LayoutUnit totalLogicalOffset = logicalOffset; | 830 LayoutUnit totalLogicalOffset = logicalOffset + marginBeforeIfFloating()
; |
| 838 if (isFloating()) | |
| 839 totalLogicalOffset += marginBefore(); // Floats' margins do not coll
apse with page or column boundaries. | |
| 840 LayoutUnit strut = remainingLogicalHeight + totalLogicalOffset - pageLog
icalHeight; | 831 LayoutUnit strut = remainingLogicalHeight + totalLogicalOffset - pageLog
icalHeight; |
| 841 if (strut > 0) { | 832 if (strut > 0) { |
| 842 // The block starts in a previous column or page. Set a strut on the
block if there's | 833 // The block starts in a previous column or page. Set a strut on the
block if there's |
| 843 // room for the top border, padding and (if it's a float) margin and
the line in one | 834 // room for the top border, padding and (if it's a float) margin and
the line in one |
| 844 // column or page. | 835 // column or page. |
| 845 if (totalLogicalOffset + lineHeight <= pageLogicalHeight) | 836 if (totalLogicalOffset + lineHeight <= pageLogicalHeight) |
| 846 setPaginationStrutPropagatedFromChild(strut); | 837 setPaginationStrutPropagatedFromChild(strut); |
| 847 } | 838 } |
| 848 } | 839 } |
| 849 | 840 |
| (...skipping 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2925 // fully pushed to the next outer fragmentainer, instead of taking up un
usable space in the | 2916 // fully pushed to the next outer fragmentainer, instead of taking up un
usable space in the |
| 2926 // previous one. But currently we have no mechanism in place to handle t
his. | 2917 // previous one. But currently we have no mechanism in place to handle t
his. |
| 2927 return false; | 2918 return false; |
| 2928 } | 2919 } |
| 2929 LayoutBlock* containingBlock = this->containingBlock(); | 2920 LayoutBlock* containingBlock = this->containingBlock(); |
| 2930 return containingBlock && containingBlock->isLayoutBlockFlow(); | 2921 return containingBlock && containingBlock->isLayoutBlockFlow(); |
| 2931 } | 2922 } |
| 2932 | 2923 |
| 2933 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) | 2924 void LayoutBlockFlow::setPaginationStrutPropagatedFromChild(LayoutUnit strut) |
| 2934 { | 2925 { |
| 2926 strut = std::max(strut, LayoutUnit()); |
| 2935 if (!m_rareData) { | 2927 if (!m_rareData) { |
| 2936 if (!strut) | 2928 if (!strut) |
| 2937 return; | 2929 return; |
| 2938 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 2930 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); |
| 2939 } | 2931 } |
| 2940 m_rareData->m_paginationStrutPropagatedFromChild = strut; | 2932 m_rareData->m_paginationStrutPropagatedFromChild = strut; |
| 2941 } | 2933 } |
| 2942 | 2934 |
| 2943 void LayoutBlockFlow::positionSpannerDescendant(LayoutMultiColumnSpannerPlacehol
der& child) | 2935 void LayoutBlockFlow::positionSpannerDescendant(LayoutMultiColumnSpannerPlacehol
der& child) |
| 2944 { | 2936 { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3105 FrameView* frameView = document().view(); | 3097 FrameView* frameView = document().view(); |
| 3106 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3098 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
| 3107 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3099 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
| 3108 if (size().height() < visibleHeight) | 3100 if (size().height() < visibleHeight) |
| 3109 top += (visibleHeight - size().height()) / 2; | 3101 top += (visibleHeight - size().height()) / 2; |
| 3110 setY(top); | 3102 setY(top); |
| 3111 dialog->setCentered(top); | 3103 dialog->setCentered(top); |
| 3112 } | 3104 } |
| 3113 | 3105 |
| 3114 } // namespace blink | 3106 } // namespace blink |
| OLD | NEW |