OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003-2013 Apple Inc. All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * Copyright (C) 2013 Google Inc. All rights reserved. | 7 * Copyright (C) 2013 Google Inc. All rights reserved. |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions are | 10 * modification, are permitted provided that the following conditions are |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return static_cast<RootInlineBox*>(lastLineBox()); | 156 return static_cast<RootInlineBox*>(lastLineBox()); |
157 } | 157 } |
158 | 158 |
159 LayoutUnit logicalLeftSelectionOffset(const LayoutBlock* rootBlock, | 159 LayoutUnit logicalLeftSelectionOffset(const LayoutBlock* rootBlock, |
160 LayoutUnit position) const override; | 160 LayoutUnit position) const override; |
161 LayoutUnit logicalRightSelectionOffset(const LayoutBlock* rootBlock, | 161 LayoutUnit logicalRightSelectionOffset(const LayoutBlock* rootBlock, |
162 LayoutUnit position) const override; | 162 LayoutUnit position) const override; |
163 | 163 |
164 RootInlineBox* createAndAppendRootInlineBox(); | 164 RootInlineBox* createAndAppendRootInlineBox(); |
165 | 165 |
166 // Return the number of lines in *this* block flow. Does not recurse into | 166 // Return the number of lines in *this* block flow. Does not recurse into bloc
k flow children. |
167 // block flow children. | 167 // Will start counting from the first line, and stop counting right after |sto
pRootInlineBox|, |
168 // Will start counting from the first line, and stop counting right after | 168 // if specified. |
169 // |stopRootInlineBox|, if specified. | |
170 int lineCount(const RootInlineBox* stopRootInlineBox = nullptr) const; | 169 int lineCount(const RootInlineBox* stopRootInlineBox = nullptr) const; |
171 | 170 |
172 int firstLineBoxBaseline() const override; | 171 int firstLineBoxBaseline() const override; |
173 int inlineBlockBaseline(LineDirectionMode) const override; | 172 int inlineBlockBaseline(LineDirectionMode) const override; |
174 | 173 |
175 void removeFloatingObjectsFromDescendants(); | 174 void removeFloatingObjectsFromDescendants(); |
176 void markAllDescendantsWithFloatsForLayout(LayoutBox* floatToRemove = nullptr, | 175 void markAllDescendantsWithFloatsForLayout(LayoutBox* floatToRemove = nullptr, |
177 bool inLayout = true); | 176 bool inLayout = true); |
178 void markSiblingsWithFloatsForLayout(LayoutBox* floatToRemove = nullptr); | 177 void markSiblingsWithFloatsForLayout(LayoutBox* floatToRemove = nullptr); |
179 | 178 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 LayoutMultiColumnFlowThread* multiColumnFlowThread() const { | 271 LayoutMultiColumnFlowThread* multiColumnFlowThread() const { |
273 return m_rareData ? m_rareData->m_multiColumnFlowThread : 0; | 272 return m_rareData ? m_rareData->m_multiColumnFlowThread : 0; |
274 } | 273 } |
275 void resetMultiColumnFlowThread() { | 274 void resetMultiColumnFlowThread() { |
276 if (m_rareData) | 275 if (m_rareData) |
277 m_rareData->m_multiColumnFlowThread = nullptr; | 276 m_rareData->m_multiColumnFlowThread = nullptr; |
278 } | 277 } |
279 | 278 |
280 void addOverflowFromInlineChildren(); | 279 void addOverflowFromInlineChildren(); |
281 | 280 |
282 // FIXME: This should be const to avoid a const_cast, but can modify child | 281 // FIXME: This should be const to avoid a const_cast, but can modify child dir
ty bits and LayoutTextCombine |
283 // dirty bits and LayoutTextCombine. | |
284 void computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidth, | 282 void computeInlinePreferredLogicalWidths(LayoutUnit& minLogicalWidth, |
285 LayoutUnit& maxLogicalWidth); | 283 LayoutUnit& maxLogicalWidth); |
286 | 284 |
287 bool allowsPaginationStrut() const; | 285 bool allowsPaginationStrut() const; |
288 // Pagination strut caused by the first line or child block inside this | 286 // Pagination strut caused by the first line or child block inside this block-
level object. |
289 // block-level object. | |
290 // | 287 // |
291 // When the first piece of content (first child block or line) inside an | 288 // When the first piece of content (first child block or line) inside an objec
t wants to insert |
292 // object wants to insert a soft page or column break, rather than setting a | 289 // a soft page or column break, rather than setting a pagination strut on itse
lf it normally |
293 // pagination strut on itself it normally propagates the strut to its | 290 // propagates the strut to its containing block (|this|), as long as our imple
mentation can |
294 // containing block (|this|), as long as our implementation can handle it. | 291 // handle it. The idea is that we want to push the entire object to the next p
age or column |
295 // The idea is that we want to push the entire object to the next page or | 292 // along with the child content that caused the break, instead of leaving unus
able space at the |
296 // column along with the child content that caused the break, instead of | 293 // beginning of the object at the end of one column or page and just push the
first line or |
297 // leaving unusable space at the beginning of the object at the end of one | 294 // block to the next column or page. That would waste space in the container f
or no good |
298 // column or page and just push the first line or block to the next column or | 295 // reason, and it would also be a spec violation, since there is no break oppo
rtunity defined |
299 // page. That would waste space in the container for no good reason, and it | 296 // between the content logical top of an object and its first child or line (o
nly *between* |
300 // would also be a spec violation, since there is no break opportunity defined | 297 // blocks or lines). |
301 // between the content logical top of an object and its first child or line | |
302 // (only *between* blocks or lines). | |
303 LayoutUnit paginationStrutPropagatedFromChild() const { | 298 LayoutUnit paginationStrutPropagatedFromChild() const { |
304 return m_rareData ? m_rareData->m_paginationStrutPropagatedFromChild | 299 return m_rareData ? m_rareData->m_paginationStrutPropagatedFromChild |
305 : LayoutUnit(); | 300 : LayoutUnit(); |
306 } | 301 } |
307 void setPaginationStrutPropagatedFromChild(LayoutUnit); | 302 void setPaginationStrutPropagatedFromChild(LayoutUnit); |
308 | 303 |
309 void positionSpannerDescendant(LayoutMultiColumnSpannerPlaceholder& child); | 304 void positionSpannerDescendant(LayoutMultiColumnSpannerPlaceholder& child); |
310 | 305 |
311 bool avoidsFloats() const override; | 306 bool avoidsFloats() const override; |
312 | 307 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 LayoutUnit afterEdge); | 456 LayoutUnit afterEdge); |
462 | 457 |
463 void markDescendantsWithFloatsForLayoutIfNeeded( | 458 void markDescendantsWithFloatsForLayoutIfNeeded( |
464 LayoutBlockFlow& child, | 459 LayoutBlockFlow& child, |
465 LayoutUnit newLogicalTop, | 460 LayoutUnit newLogicalTop, |
466 LayoutUnit previousFloatLogicalBottom); | 461 LayoutUnit previousFloatLogicalBottom); |
467 bool positionAndLayoutOnceIfNeeded(LayoutBox& child, | 462 bool positionAndLayoutOnceIfNeeded(LayoutBox& child, |
468 LayoutUnit newLogicalTop, | 463 LayoutUnit newLogicalTop, |
469 BlockChildrenLayoutInfo&); | 464 BlockChildrenLayoutInfo&); |
470 | 465 |
471 // Handle breaking policy before the child, and insert a forced break in front | 466 // Handle breaking policy before the child, and insert a forced break in front
of it if needed. |
472 // of it if needed. | |
473 void insertForcedBreakBeforeChildIfNeeded(LayoutBox& child, | 467 void insertForcedBreakBeforeChildIfNeeded(LayoutBox& child, |
474 BlockChildrenLayoutInfo&); | 468 BlockChildrenLayoutInfo&); |
475 | 469 |
476 void layoutBlockChild(LayoutBox& child, BlockChildrenLayoutInfo&); | 470 void layoutBlockChild(LayoutBox& child, BlockChildrenLayoutInfo&); |
477 void adjustPositionedBlock(LayoutBox& child, const BlockChildrenLayoutInfo&); | 471 void adjustPositionedBlock(LayoutBox& child, const BlockChildrenLayoutInfo&); |
478 void adjustFloatingBlock(const MarginInfo&); | 472 void adjustFloatingBlock(const MarginInfo&); |
479 | 473 |
480 LayoutPoint computeLogicalLocationForFloat(const FloatingObject&, | 474 LayoutPoint computeLogicalLocationForFloat(const FloatingObject&, |
481 LayoutUnit logicalTopOffset) const; | 475 LayoutUnit logicalTopOffset) const; |
482 | 476 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 bool isPagedOverflow(const ComputedStyle&); | 528 bool isPagedOverflow(const ComputedStyle&); |
535 | 529 |
536 enum FlowThreadType { NoFlowThread, MultiColumnFlowThread, PagedFlowThread }; | 530 enum FlowThreadType { NoFlowThread, MultiColumnFlowThread, PagedFlowThread }; |
537 | 531 |
538 FlowThreadType getFlowThreadType(const ComputedStyle&); | 532 FlowThreadType getFlowThreadType(const ComputedStyle&); |
539 | 533 |
540 LayoutMultiColumnFlowThread* createMultiColumnFlowThread(FlowThreadType); | 534 LayoutMultiColumnFlowThread* createMultiColumnFlowThread(FlowThreadType); |
541 void createOrDestroyMultiColumnFlowThreadIfNeeded( | 535 void createOrDestroyMultiColumnFlowThreadIfNeeded( |
542 const ComputedStyle* oldStyle); | 536 const ComputedStyle* oldStyle); |
543 | 537 |
544 // Merge children of |siblingThatMayBeDeleted| into this object if possible, | 538 // Merge children of |siblingThatMayBeDeleted| into this object if possible, a
nd delete |
545 // and delete |siblingThatMayBeDeleted|. Returns true if we were able to | 539 // |siblingThatMayBeDeleted|. Returns true if we were able to merge. In that c
ase, |
546 // merge. In that case, |siblingThatMayBeDeleted| will be dead. We'll only be | 540 // |siblingThatMayBeDeleted| will be dead. We'll only be able to merge if both
blocks are |
547 // able to merge if both blocks are anonymous. | 541 // anonymous. |
548 bool mergeSiblingContiguousAnonymousBlock( | 542 bool mergeSiblingContiguousAnonymousBlock( |
549 LayoutBlockFlow* siblingThatMayBeDeleted); | 543 LayoutBlockFlow* siblingThatMayBeDeleted); |
550 | 544 |
551 // Reparent subsequent or preceding adjacent floating or out-of-flow siblings | 545 // Reparent subsequent or preceding adjacent floating or out-of-flow siblings
into this object. |
552 // into this object. | |
553 void reparentSubsequentFloatingOrOutOfFlowSiblings(); | 546 void reparentSubsequentFloatingOrOutOfFlowSiblings(); |
554 void reparentPrecedingFloatingOrOutOfFlowSiblings(); | 547 void reparentPrecedingFloatingOrOutOfFlowSiblings(); |
555 | 548 |
556 void makeChildrenInlineIfPossible(); | 549 void makeChildrenInlineIfPossible(); |
557 | 550 |
558 void makeChildrenNonInline(LayoutObject* insertionPoint = nullptr); | 551 void makeChildrenNonInline(LayoutObject* insertionPoint = nullptr); |
559 void childBecameNonInline(LayoutObject* child) final; | 552 void childBecameNonInline(LayoutObject* child) final; |
560 | 553 |
561 void updateLogicalWidthForAlignment(const ETextAlign&, | 554 void updateLogicalWidthForAlignment(const ETextAlign&, |
562 const RootInlineBox*, | 555 const RootInlineBox*, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const; | 741 virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const; |
749 | 742 |
750 private: | 743 private: |
751 LayoutUnit collapsedMarginBefore() const final { | 744 LayoutUnit collapsedMarginBefore() const final { |
752 return maxPositiveMarginBefore() - maxNegativeMarginBefore(); | 745 return maxPositiveMarginBefore() - maxNegativeMarginBefore(); |
753 } | 746 } |
754 LayoutUnit collapsedMarginAfter() const final { | 747 LayoutUnit collapsedMarginAfter() const final { |
755 return maxPositiveMarginAfter() - maxNegativeMarginAfter(); | 748 return maxPositiveMarginAfter() - maxNegativeMarginAfter(); |
756 } | 749 } |
757 | 750 |
758 // Floats' margins do not collapse with page or column boundaries, and we | 751 // Floats' margins do not collapse with page or column boundaries, and we ther
efore need to |
759 // therefore need to treat them specially in some cases. | 752 // treat them specially in some cases. |
760 LayoutUnit marginBeforeIfFloating() const { | 753 LayoutUnit marginBeforeIfFloating() const { |
761 return isFloating() ? marginBefore() : LayoutUnit(); | 754 return isFloating() ? marginBefore() : LayoutUnit(); |
762 } | 755 } |
763 | 756 |
764 LayoutUnit collapseMargins(LayoutBox& child, | 757 LayoutUnit collapseMargins(LayoutBox& child, |
765 MarginInfo&, | 758 MarginInfo&, |
766 bool childIsSelfCollapsing, | 759 bool childIsSelfCollapsing, |
767 bool childDiscardMarginBefore, | 760 bool childDiscardMarginBefore, |
768 bool childDiscardMarginAfter); | 761 bool childDiscardMarginAfter); |
769 LayoutUnit clearFloatsIfNeeded(LayoutBox& child, | 762 LayoutUnit clearFloatsIfNeeded(LayoutBox& child, |
770 MarginInfo&, | 763 MarginInfo&, |
771 LayoutUnit oldTopPosMargin, | 764 LayoutUnit oldTopPosMargin, |
772 LayoutUnit oldTopNegMargin, | 765 LayoutUnit oldTopNegMargin, |
773 LayoutUnit yPos, | 766 LayoutUnit yPos, |
774 bool childIsSelfCollapsing, | 767 bool childIsSelfCollapsing, |
775 bool childDiscardMargin); | 768 bool childDiscardMargin); |
776 LayoutUnit estimateLogicalTopPosition(LayoutBox& child, | 769 LayoutUnit estimateLogicalTopPosition(LayoutBox& child, |
777 const BlockChildrenLayoutInfo&, | 770 const BlockChildrenLayoutInfo&, |
778 LayoutUnit& estimateWithoutPagination); | 771 LayoutUnit& estimateWithoutPagination); |
779 void marginBeforeEstimateForChild(LayoutBox&, | 772 void marginBeforeEstimateForChild(LayoutBox&, |
780 LayoutUnit&, | 773 LayoutUnit&, |
781 LayoutUnit&, | 774 LayoutUnit&, |
782 bool&) const; | 775 bool&) const; |
783 void handleAfterSideOfBlock(LayoutBox* lastChild, | 776 void handleAfterSideOfBlock(LayoutBox* lastChild, |
784 LayoutUnit top, | 777 LayoutUnit top, |
785 LayoutUnit bottom, | 778 LayoutUnit bottom, |
786 MarginInfo&); | 779 MarginInfo&); |
787 void setCollapsedBottomMargin(const MarginInfo&); | 780 void setCollapsedBottomMargin(const MarginInfo&); |
788 | 781 |
789 // Apply any forced fragmentainer break that's set on the current class A | 782 // Apply any forced fragmentainer break that's set on the current class A brea
k point. |
790 // break point. | |
791 LayoutUnit applyForcedBreak(LayoutUnit logicalOffset, EBreak); | 783 LayoutUnit applyForcedBreak(LayoutUnit logicalOffset, EBreak); |
792 | 784 |
793 void setBreakBefore(EBreak); | 785 void setBreakBefore(EBreak); |
794 void setBreakAfter(EBreak); | 786 void setBreakAfter(EBreak); |
795 EBreak breakBefore() const override; | 787 EBreak breakBefore() const override; |
796 EBreak breakAfter() const override; | 788 EBreak breakAfter() const override; |
797 | 789 |
798 LayoutUnit adjustBlockChildForPagination(LayoutUnit logicalTop, | 790 LayoutUnit adjustBlockChildForPagination(LayoutUnit logicalTop, |
799 LayoutBox& child, | 791 LayoutBox& child, |
800 BlockChildrenLayoutInfo&, | 792 BlockChildrenLayoutInfo&, |
801 bool atBeforeSideOfBlock); | 793 bool atBeforeSideOfBlock); |
802 // Computes a deltaOffset value that put a line at the top of the next page if | 794 // Computes a deltaOffset value that put a line at the top of the next page if
it doesn't fit on the current page. |
803 // it doesn't fit on the current page. | |
804 void adjustLinePositionForPagination(RootInlineBox&, LayoutUnit& deltaOffset); | 795 void adjustLinePositionForPagination(RootInlineBox&, LayoutUnit& deltaOffset); |
805 // If the child is unsplittable and can't fit on the current page, return the | 796 // If the child is unsplittable and can't fit on the current page, return the
top of the next page/column. |
806 // top of the next page/column. | |
807 LayoutUnit adjustForUnsplittableChild(LayoutBox&, | 797 LayoutUnit adjustForUnsplittableChild(LayoutBox&, |
808 LayoutUnit logicalOffset) const; | 798 LayoutUnit logicalOffset) const; |
809 | 799 |
810 // Used to store state between styleWillChange and styleDidChange | 800 // Used to store state between styleWillChange and styleDidChange |
811 static bool s_canPropagateFloatIntoSibling; | 801 static bool s_canPropagateFloatIntoSibling; |
812 | 802 |
813 LineBoxList m_lineBoxes; // All of the root line boxes created for this block | 803 LineBoxList |
814 // flow. For example, <div>Hello<br>world.</div> | 804 m_lineBoxes; // All of the root line boxes created for this block flow.
For example, <div>Hello<br>world.</div> will have two total lines for the <div>. |
815 // will have two total lines for the <div>. | |
816 | 805 |
817 LayoutBlockFlowRareData& ensureRareData(); | 806 LayoutBlockFlowRareData& ensureRareData(); |
818 | 807 |
819 bool isSelfCollapsingBlock() const override; | 808 bool isSelfCollapsingBlock() const override; |
820 bool checkIfIsSelfCollapsingBlock() const; | 809 bool checkIfIsSelfCollapsingBlock() const; |
821 | 810 |
822 protected: | 811 protected: |
823 std::unique_ptr<LayoutBlockFlowRareData> m_rareData; | 812 std::unique_ptr<LayoutBlockFlowRareData> m_rareData; |
824 std::unique_ptr<FloatingObjects> m_floatingObjects; | 813 std::unique_ptr<FloatingObjects> m_floatingObjects; |
825 | 814 |
826 friend class MarginInfo; | 815 friend class MarginInfo; |
827 friend class LineWidth; // needs to know FloatingObject | 816 friend class LineWidth; // needs to know FloatingObject |
828 | 817 |
829 // LayoutRubyBase objects need to be able to split and merge, moving their | 818 // LayoutRubyBase objects need to be able to split and merge, moving their chi
ldren around |
830 // children around (calling makeChildrenNonInline). | 819 // (calling makeChildrenNonInline). |
831 // TODO(mstensho): Try to get rid of this friendship. | 820 // TODO(mstensho): Try to get rid of this friendship. |
832 friend class LayoutRubyBase; | 821 friend class LayoutRubyBase; |
833 | 822 |
834 // FIXME-BLOCKFLOW: These methods have implementations in | 823 // FIXME-BLOCKFLOW: These methods have implementations in |
835 // LayoutBlockFlowLine. They should be moved to the proper header once the | 824 // LayoutBlockFlowLine. They should be moved to the proper header once the |
836 // line layout code is separated from LayoutBlock and LayoutBlockFlow. | 825 // line layout code is separated from LayoutBlock and LayoutBlockFlow. |
837 // START METHODS DEFINED IN LayoutBlockFlowLine | 826 // START METHODS DEFINED IN LayoutBlockFlowLine |
838 private: | 827 private: |
839 InlineFlowBox* createLineBoxes(LineLayoutItem, | 828 InlineFlowBox* createLineBoxes(LineLayoutItem, |
840 const LineInfo&, | 829 const LineInfo&, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); | 891 bool checkPaginationAndFloatsAtEndLine(LineLayoutState&); |
903 bool matchedEndLine(LineLayoutState&, | 892 bool matchedEndLine(LineLayoutState&, |
904 const InlineBidiResolver&, | 893 const InlineBidiResolver&, |
905 const InlineIterator& endLineStart, | 894 const InlineIterator& endLineStart, |
906 const BidiStatus& endLineStatus); | 895 const BidiStatus& endLineStatus); |
907 void deleteEllipsisLineBoxes(); | 896 void deleteEllipsisLineBoxes(); |
908 void checkLinesForTextOverflow(); | 897 void checkLinesForTextOverflow(); |
909 void markLinesDirtyInBlockRange(LayoutUnit logicalTop, | 898 void markLinesDirtyInBlockRange(LayoutUnit logicalTop, |
910 LayoutUnit logicalBottom, | 899 LayoutUnit logicalBottom, |
911 RootInlineBox* highest = nullptr); | 900 RootInlineBox* highest = nullptr); |
912 // Positions new floats and also adjust all floats encountered on the line if | 901 // Positions new floats and also adjust all floats encountered on the line if
any of them |
913 // any of them have to move to the next page/column. | 902 // have to move to the next page/column. |
914 void positionDialog(); | 903 void positionDialog(); |
915 | 904 |
916 // END METHODS DEFINED IN LayoutBlockFlowLine | 905 // END METHODS DEFINED IN LayoutBlockFlowLine |
917 }; | 906 }; |
918 | 907 |
919 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlockFlow, isLayoutBlockFlow()); | 908 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlockFlow, isLayoutBlockFlow()); |
920 | 909 |
921 } // namespace blink | 910 } // namespace blink |
922 | 911 |
923 #endif // LayoutBlockFlow_h | 912 #endif // LayoutBlockFlow_h |
OLD | NEW |