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

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

Issue 2284983002: [layoutng] Implement state machine for async layout (Closed)
Patch Set: NOTREACHED, also fix the windows compile error Created 4 years, 3 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/ng_box.h" 9 #include "core/layout/ng/ng_box.h"
10 #include "core/layout/ng/ng_box_iterator.h" 10 #include "core/layout/ng/ng_fragment_builder.h"
11 #include "core/layout/ng/ng_layout_algorithm.h" 11 #include "core/layout/ng/ng_layout_algorithm.h"
12 #include "wtf/RefPtr.h" 12 #include "wtf/RefPtr.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class ComputedStyle; 16 class ComputedStyle;
17 class NGConstraintSpace; 17 class NGConstraintSpace;
18 class NGFragment; 18 class NGFragment;
19 19
20 // A class for general block layout (e.g. a <div> with no special style). 20 // A class for general block layout (e.g. a <div> with no special style).
21 // Lays out the children in sequence. 21 // Lays out the children in sequence.
22 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm { 22 class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm {
23 public: 23 public:
24 // Default constructor. 24 // Default constructor.
25 // @param style Style reference of the block that is being laid out. 25 // @param style Style reference of the block that is being laid out.
26 // @param boxIterator Iterator for the block's children. 26 // @param first_child Our first child; the algorithm will use its NextSibling
27 NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, NGBoxIterator); 27 // method to access all the children.
28 NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, NGBox* first_child);
28 29
29 // Actual layout implementation. Lays out the children in sequence within the 30 // Actual layout implementation. Lays out the children in sequence within the
30 // constraints given by the NGConstraintSpace. Returns a fragment with the 31 // constraints given by the NGConstraintSpace. Returns a fragment with the
31 // resulting layout information. 32 // resulting layout information.
32 // This function can not be const because for interruptible layout, we have 33 // This function can not be const because for interruptible layout, we have
33 // to be able to store state information. 34 // to be able to store state information.
34 // Returns true when done; when this function returns false, it has to be 35 // Returns true when done; when this function returns false, it has to be
35 // called again. The out parameter will only be set when this function 36 // called again. The out parameter will only be set when this function
36 // returns true. The same constraint space has to be passed each time. 37 // returns true. The same constraint space has to be passed each time.
37 bool Layout(const NGConstraintSpace*, NGFragment**) override; 38 bool Layout(const NGConstraintSpace*, NGFragment**) override;
38 39
40 DEFINE_INLINE_VIRTUAL_TRACE() {
41 NGLayoutAlgorithm::trace(visitor);
42 visitor->trace(first_child_);
43 visitor->trace(builder_);
44 visitor->trace(constraint_space_for_children_);
45 visitor->trace(current_child_);
46 }
47
39 private: 48 private:
40 RefPtr<const ComputedStyle> style_; 49 RefPtr<const ComputedStyle> style_;
41 NGBoxIterator box_iterator_; 50 Member<NGBox> first_child_;
51
52 enum State { kStateInit, kStateChildLayout, kStateFinalize };
53 State state_;
54 Member<NGFragmentBuilder> builder_;
55 Member<NGConstraintSpace> constraint_space_for_children_;
56 Member<NGBox> current_child_;
57 LayoutUnit content_size_;
58 LayoutUnit max_inline_size_;
42 }; 59 };
43 60
44 } // namespace blink 61 } // namespace blink
45 62
46 #endif // NGBlockLayoutAlgorithm_h 63 #endif // NGBlockLayoutAlgorithm_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698