Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.h

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

Powered by Google App Engine
This is Rietveld 408576698