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

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

Issue 2816933003: Use Layout Opportunity Iterator to position new FC blocks. (Closed)
Patch Set: Created 3 years, 8 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NGBlockLayoutAlgorithm_h 5 #ifndef NGBlockLayoutAlgorithm_h
6 #define NGBlockLayoutAlgorithm_h 6 #define NGBlockLayoutAlgorithm_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/geometry/ng_margin_strut.h" 9 #include "core/layout/ng/geometry/ng_margin_strut.h"
10 #include "core/layout/ng/ng_block_break_token.h" 10 #include "core/layout/ng/ng_block_break_token.h"
11 #include "core/layout/ng/ng_block_node.h" 11 #include "core/layout/ng/ng_block_node.h"
12 #include "core/layout/ng/ng_box_fragment.h"
12 #include "core/layout/ng/ng_constraint_space_builder.h" 13 #include "core/layout/ng/ng_constraint_space_builder.h"
13 #include "core/layout/ng/ng_layout_algorithm.h" 14 #include "core/layout/ng/ng_layout_algorithm.h"
14 #include "platform/wtf/RefPtr.h" 15 #include "platform/wtf/RefPtr.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 class NGConstraintSpace; 19 class NGConstraintSpace;
19 class NGLayoutResult; 20 class NGLayoutResult;
20 21
21 // Updates the fragment's BFC offset if it's not already set. 22 // Updates the fragment's BFC offset if it's not already set.
(...skipping 16 matching lines...) Expand all
38 NGBlockBreakToken* break_token = nullptr); 39 NGBlockBreakToken* break_token = nullptr);
39 40
40 Optional<MinMaxContentSize> ComputeMinMaxContentSize() const override; 41 Optional<MinMaxContentSize> ComputeMinMaxContentSize() const override;
41 virtual RefPtr<NGLayoutResult> Layout() override; 42 virtual RefPtr<NGLayoutResult> Layout() override;
42 43
43 private: 44 private:
44 NGBoxStrut CalculateMargins(NGLayoutInputNode* child, 45 NGBoxStrut CalculateMargins(NGLayoutInputNode* child,
45 const NGConstraintSpace& space); 46 const NGConstraintSpace& space);
46 47
47 // Creates a new constraint space for the current child. 48 // Creates a new constraint space for the current child.
48 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(NGLayoutInputNode*); 49 RefPtr<NGConstraintSpace> CreateConstraintSpaceForChild(
49 void PrepareChildLayout(NGLayoutInputNode*); 50 const NGLogicalOffset& child_bfc_offset,
50 void FinishChildLayout(NGLayoutInputNode*, 51 NGLayoutInputNode*);
51 NGConstraintSpace*, 52 NGLogicalOffset PrepareChildLayout(NGLayoutInputNode*);
52 RefPtr<NGLayoutResult>); 53
54 void FinishChildLayout(const NGConstraintSpace*, NGLayoutResult*);
55
56 void FinishFloatChildLayout(const ComputedStyle&,
57 const NGConstraintSpace&,
58 const NGLayoutResult*);
53 59
54 // Final adjustments before fragment creation. We need to prevent the 60 // Final adjustments before fragment creation. We need to prevent the
55 // fragment from crossing fragmentainer boundaries, and rather create a break 61 // fragment from crossing fragmentainer boundaries, and rather create a break
56 // token if we're out of space. 62 // token if we're out of space.
57 void FinalizeForFragmentation(); 63 void FinalizeForFragmentation();
58 64
59 // Calculates logical offset for the current fragment using either 65 // Calculates logical offset for the current fragment using either
60 // {@code content_size_} when the fragment doesn't know it's offset 66 // {@code content_size_} when the fragment doesn't know it's offset
61 // or {@code known_fragment_offset} if the fragment knows it's offset 67 // or {@code known_fragment_offset} if the fragment knows it's offset
62 // @return Fragment's offset relative to the fragment's parent. 68 // @return Fragment's offset relative to the fragment's parent.
63 NGLogicalOffset CalculateLogicalOffset( 69 NGLogicalOffset CalculateLogicalOffset(
64 const WTF::Optional<NGLogicalOffset>& known_fragment_offset); 70 const WTF::Optional<NGLogicalOffset>& known_fragment_offset);
65 71
72 // Positions the fragment that establishes a new formatting context.
73 NGLogicalOffset PositionNewFc(const NGBoxFragment&,
74 const NGConstraintSpace* child_space);
75
76 // Positions the fragment that knows its BFC offset.
77 NGLogicalOffset PositionWithBfcOffset(const NGBoxFragment&);
78
79 // Positions using the parent BFC offset.
80 // Fragment doesn't know its offset but we can still calculate its BFC
81 // position because the parent fragment's BFC is known.
82 // Example:
83 // BFC Offset is known here because of the padding.
84 // <div style="padding: 1px">
85 // <div id="empty-div" style="margins: 1px"></div>
86 NGLogicalOffset PositionWithParentBfc();
87
66 NGConstraintSpaceBuilder space_builder_; 88 NGConstraintSpaceBuilder space_builder_;
67 89
68 NGBoxStrut border_and_padding_; 90 NGBoxStrut border_and_padding_;
69 LayoutUnit content_size_; 91 LayoutUnit content_size_;
70 LayoutUnit max_inline_size_; 92 LayoutUnit max_inline_size_;
71 // MarginStrut for the previous child. 93 // MarginStrut for the previous child.
72 NGMarginStrut curr_margin_strut_; 94 NGMarginStrut curr_margin_strut_;
73 NGLogicalOffset curr_bfc_offset_; 95 NGLogicalOffset curr_bfc_offset_;
74 NGBoxStrut curr_child_margins_; 96 NGBoxStrut curr_child_margins_;
75 }; 97 };
76 98
77 } // namespace blink 99 } // namespace blink
78 100
79 #endif // NGBlockLayoutAlgorithm_h 101 #endif // NGBlockLayoutAlgorithm_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698