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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 if (unsplittableAdjustmentDelta) { | 698 if (unsplittableAdjustmentDelta) { |
699 setPageBreak(newLogicalTop, childLogicalHeight - unsplittableAdjustmentD
elta); | 699 setPageBreak(newLogicalTop, childLogicalHeight - unsplittableAdjustmentD
elta); |
700 paginationStrut = unsplittableAdjustmentDelta; | 700 paginationStrut = unsplittableAdjustmentDelta; |
701 } else if (childBlockFlow && childBlockFlow->paginationStrut()) { | 701 } else if (childBlockFlow && childBlockFlow->paginationStrut()) { |
702 paginationStrut = childBlockFlow->paginationStrut(); | 702 paginationStrut = childBlockFlow->paginationStrut(); |
703 } | 703 } |
704 | 704 |
705 if (paginationStrut) { | 705 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 | 706 // 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. | 707 // to collapsing our margins, and as long as we didn't clear or move as
a result of other pagination. |
708 if (atBeforeSideOfBlock && logicalTop == newLogicalTop && !isOutOfFlowPo
sitioned() && !isTableCell()) { | 708 if (atBeforeSideOfBlock && logicalTop == newLogicalTop && allowsPaginati
onStrut()) { |
709 // FIXME: Should really check if we're exceeding the page height bef
ore propagating the strut, but we don't | 709 // 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 | 710 // 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
. | 711 // and pushes to the next page anyway, so not too concerned about it
. |
712 paginationStrut += logicalTop; | 712 paginationStrut += logicalTop; |
713 if (isFloating()) | 713 if (isFloating()) |
714 paginationStrut += marginBefore(); // Floats' margins do not col
lapse with page or column boundaries. | 714 paginationStrut += marginBefore(); // Floats' margins do not col
lapse with page or column boundaries. |
715 setPaginationStrut(paginationStrut); | 715 setPaginationStrut(paginationStrut); |
716 if (childBlockFlow) | 716 if (childBlockFlow) |
717 childBlockFlow->setPaginationStrut(0); | 717 childBlockFlow->setPaginationStrut(0); |
718 } else { | 718 } else { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 // line, and we don't want to move all that, since it has already been e
stablished that it | 774 // line, and we don't want to move all that, since it has already been e
stablished that it |
775 // fits nicely where it is. | 775 // fits nicely where it is. |
776 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTo
pWithLeading(); | 776 LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTo
pWithLeading(); |
777 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, lin
eLogicalOffset); | 777 LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, lin
eLogicalOffset); |
778 LayoutUnit pageLogicalHeightAtNewOffset = block.pageLogicalHeightForOffs
et(lineLogicalOffset + remainingLogicalHeight); | 778 LayoutUnit pageLogicalHeightAtNewOffset = block.pageLogicalHeightForOffs
et(lineLogicalOffset + remainingLogicalHeight); |
779 // It's rather pointless to break before the block if the current line i
sn't going to | 779 // It's rather pointless to break before the block if the current line i
sn't going to |
780 // fit in the same column or page, so check that as well. | 780 // fit in the same column or page, so check that as well. |
781 if (totalLogicalHeight < pageLogicalHeightAtNewOffset) | 781 if (totalLogicalHeight < pageLogicalHeightAtNewOffset) |
782 wantsStrutOnBlock = true; | 782 wantsStrutOnBlock = true; |
783 } | 783 } |
784 // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a f
lexbox or a table | 784 return wantsStrutOnBlock && block.allowsPaginationStrut(); |
785 // (which would be the case for table cell or table caption)). The reason fo
r this limitation is | |
786 // simply that LayoutBlockFlow child layout code is the only place where we
pick up the struts | |
787 // and handle them. We handle floats and regular in-flow children, and that'
s all. We could | |
788 // handle this in other layout modes as well (and even for out-of-flow child
ren), but currently | |
789 // we don't. | |
790 if (!wantsStrutOnBlock || block.isOutOfFlowPositioned()) | |
791 return false; | |
792 LayoutBlock* containingBlock = block.containingBlock(); | |
793 return containingBlock && containingBlock->isLayoutBlockFlow(); | |
794 } | 785 } |
795 | 786 |
796 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La
youtUnit& delta) | 787 void LayoutBlockFlow::adjustLinePositionForPagination(RootInlineBox& lineBox, La
youtUnit& delta) |
797 { | 788 { |
798 // TODO(mstensho): Pay attention to line overflow. It should be painted in t
he same column as | 789 // TODO(mstensho): Pay attention to line overflow. It should be painted in t
he same column as |
799 // the rest of the line, possibly overflowing the column. We currently only
allow overflow above | 790 // the rest of the line, possibly overflowing the column. We currently only
allow overflow above |
800 // the first column. We clip at all other column boundaries, and that's how
it has to be for | 791 // the first column. We clip at all other column boundaries, and that's how
it has to be for |
801 // now. The paint we have to do when a column has overflow has to be special
. We need to exclude | 792 // now. The paint we have to do when a column has overflow has to be special
. We need to exclude |
802 // content that paints in a previous column (and content that paints in the
following column). | 793 // content that paints in a previous column (and content that paints in the
following column). |
803 // | 794 // |
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2902 { | 2893 { |
2903 bool ltr = style()->isLeftToRightDirection(); | 2894 bool ltr = style()->isLeftToRightDirection(); |
2904 leftGap = (state == SelectionInside) | 2895 leftGap = (state == SelectionInside) |
2905 || (state == SelectionEnd && ltr) | 2896 || (state == SelectionEnd && ltr) |
2906 || (state == SelectionStart && !ltr); | 2897 || (state == SelectionStart && !ltr); |
2907 rightGap = (state == SelectionInside) | 2898 rightGap = (state == SelectionInside) |
2908 || (state == SelectionStart && ltr) | 2899 || (state == SelectionStart && ltr) |
2909 || (state == SelectionEnd && !ltr); | 2900 || (state == SelectionEnd && !ltr); |
2910 } | 2901 } |
2911 | 2902 |
| 2903 bool LayoutBlockFlow::allowsPaginationStrut() const |
| 2904 { |
| 2905 // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a f
lexbox, grid, or a |
| 2906 // table (the latter being the case for table cell or table caption)). The r
eason for this |
| 2907 // limitation is simply that LayoutBlockFlow child layout code is the only p
lace where we pick |
| 2908 // up the struts and handle them. We handle floats and regular in-flow child
ren, and that's |
| 2909 // all. We could handle this in other layout modes as well (and even for out
-of-flow children), |
| 2910 // but currently we don't. |
| 2911 // TODO(mstensho): But we *should*. |
| 2912 if (isOutOfFlowPositioned()) |
| 2913 return false; |
| 2914 LayoutBlock* containingBlock = this->containingBlock(); |
| 2915 return containingBlock && containingBlock->isLayoutBlockFlow(); |
| 2916 } |
| 2917 |
2912 void LayoutBlockFlow::setPaginationStrut(LayoutUnit strut) | 2918 void LayoutBlockFlow::setPaginationStrut(LayoutUnit strut) |
2913 { | 2919 { |
2914 if (!m_rareData) { | 2920 if (!m_rareData) { |
2915 if (!strut) | 2921 if (!strut) |
2916 return; | 2922 return; |
2917 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 2923 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); |
2918 } | 2924 } |
2919 m_rareData->m_paginationStrut = strut; | 2925 m_rareData->m_paginationStrut = strut; |
2920 } | 2926 } |
2921 | 2927 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3084 FrameView* frameView = document().view(); | 3090 FrameView* frameView = document().view(); |
3085 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); | 3091 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr
ollOffset().height(); |
3086 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); | 3092 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height(
); |
3087 if (size().height() < visibleHeight) | 3093 if (size().height() < visibleHeight) |
3088 top += (visibleHeight - size().height()) / 2; | 3094 top += (visibleHeight - size().height()) / 2; |
3089 setY(top); | 3095 setY(top); |
3090 dialog->setCentered(top); | 3096 dialog->setCentered(top); |
3091 } | 3097 } |
3092 | 3098 |
3093 } // namespace blink | 3099 } // namespace blink |
OLD | NEW |