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 or a table | |
2906 // (which would be the case for table cell or table caption)). The reason fo r this limitation is | |
Julien - ping for review
2015/10/05 17:33:05
or a grid
mstensho (USE GERRIT)
2015/10/05 19:51:32
Done.
| |
2907 // simply that LayoutBlockFlow child layout code is the only place where we pick up the struts | |
2908 // and handle them. We handle floats and regular in-flow children, and that' s all. We could | |
2909 // handle this in other layout modes as well (and even for out-of-flow child ren), but currently | |
2910 // we don't. | |
Julien - ping for review
2015/10/05 17:33:05
TODO(mstensho)?
mstensho (USE GERRIT)
2015/10/05 19:51:32
Done.
| |
2911 if (isOutOfFlowPositioned()) | |
2912 return false; | |
2913 LayoutBlock* containingBlock = this->containingBlock(); | |
2914 return containingBlock && containingBlock->isLayoutBlockFlow(); | |
2915 } | |
2916 | |
2912 void LayoutBlockFlow::setPaginationStrut(LayoutUnit strut) | 2917 void LayoutBlockFlow::setPaginationStrut(LayoutUnit strut) |
2913 { | 2918 { |
2914 if (!m_rareData) { | 2919 if (!m_rareData) { |
2915 if (!strut) | 2920 if (!strut) |
2916 return; | 2921 return; |
2917 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); | 2922 m_rareData = adoptPtr(new LayoutBlockFlowRareData(this)); |
2918 } | 2923 } |
2919 m_rareData->m_paginationStrut = strut; | 2924 m_rareData->m_paginationStrut = strut; |
2920 } | 2925 } |
2921 | 2926 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3084 FrameView* frameView = document().view(); | 3089 FrameView* frameView = document().view(); |
3085 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); | 3090 LayoutUnit top = (style()->position() == FixedPosition) ? 0 : frameView->scr ollOffset().height(); |
3086 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); | 3091 int visibleHeight = frameView->visibleContentRect(IncludeScrollbars).height( ); |
3087 if (size().height() < visibleHeight) | 3092 if (size().height() < visibleHeight) |
3088 top += (visibleHeight - size().height()) / 2; | 3093 top += (visibleHeight - size().height()) / 2; |
3089 setY(top); | 3094 setY(top); |
3090 dialog->setCentered(top); | 3095 dialog->setCentered(top); |
3091 } | 3096 } |
3092 | 3097 |
3093 } // namespace blink | 3098 } // namespace blink |
OLD | NEW |