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

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

Issue 2456973002: [LayoutNG] Move ng_block_layout_algorithm to use constraint space builder. (Closed)
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h
index cb44a4c7c4e5040f8a39dd0e1159950f62420b47..4b455f7cdefcad0458618cd55a58d4fb2b459041 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.h
@@ -15,6 +15,7 @@ namespace blink {
class ComputedStyle;
class NGConstraintSpace;
+class NGConstraintSpaceBuilder;
Gleb Lanbin 2016/10/27 22:30:06 can we just include a header here instead of using
ikilpatrick 2016/10/28 00:16:28 Done.
cbiesinger 2016/10/28 18:58:56 That sucks that they changed the style guide like
class NGPhysicalFragment;
// A class for general block layout (e.g. a <div> with no special style).
@@ -25,31 +26,27 @@ class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm {
// @param style Style reference of the block that is being laid out.
// @param first_child Our first child; the algorithm will use its NextSibling
// method to access all the children.
- NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>, NGBox* first_child);
-
- // Actual layout implementation. Lays out the children in sequence within the
- // constraints given by the NGConstraintSpace. Returns a fragment with the
- // resulting layout information.
- // This function can not be const because for interruptible layout, we have
- // to be able to store state information.
- // Returns true when done; when this function returns false, it has to be
- // called again. The out parameter will only be set when this function
- // returns true. The same constraint space has to be passed each time.
- bool Layout(const NGConstraintSpace*, NGPhysicalFragment**) override;
+ // @param space The constraint space which the algorithm should generate a
+ // fragment within.
+ NGBlockLayoutAlgorithm(PassRefPtr<const ComputedStyle>,
+ NGBox* first_child,
+ NGConstraintSpace* space);
+
+ bool Layout(NGPhysicalFragment**) override;
DECLARE_VIRTUAL_TRACE();
private:
+ bool LayoutCurrentChild();
+
// Computes collapsed margins for 2 adjoining blocks and updates the resultant
// fragment's MarginStrut if needed.
// See https://www.w3.org/TR/CSS2/box.html#collapsing-margins
//
- // @param space Constraint space for the block.
// @param child_margins Margins information for the current child.
// @param fragment Current child's fragment.
// @return NGBoxStrut with margins block start/end.
- NGBoxStrut CollapseMargins(const NGConstraintSpace& space,
- const NGBoxStrut& child_margins,
+ NGBoxStrut CollapseMargins(const NGBoxStrut& child_margins,
const NGFragment& fragment);
// Calculates position of the in-flow block-level fragment that needs to be
@@ -57,11 +54,9 @@ class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm {
//
// @param fragment Fragment that needs to be placed.
// @param child_margins Margins information for the current child fragment.
- // @param space Constraint space for the block.
// @return Position of the fragment in the parent's constraint space.
NGLogicalOffset PositionFragment(const NGFragment& fragment,
- const NGBoxStrut& child_margins,
- const NGConstraintSpace& space);
+ const NGBoxStrut& child_margins);
// Calculates position of the float fragment that needs to be
// positioned relative to the current fragment that is being built.
@@ -79,19 +74,27 @@ class CORE_EXPORT NGBlockLayoutAlgorithm : public NGLayoutAlgorithm {
// keeps updating block-end (on every non-zero height child).
void UpdateMarginStrut(const NGMarginStrut& from);
- bool LayoutCurrentChild(const NGConstraintSpace*);
+ // Creates a new constraint space for the current child. Should be called
+ // prior to performing layout on the next child.
+ //
+ // @return The constraint space for the child.
+ NGConstraintSpace* CreateConstraintSpaceForCurrentChild();
// Read-only Getters.
const ComputedStyle& Style() const { return *style_; }
- RefPtr<const ComputedStyle> style_;
- Member<NGBox> first_child_;
-
enum State { kStateInit, kStateChildLayout, kStateFinalize };
State state_;
+
+ RefPtr<const ComputedStyle> style_;
+
+ Member<NGBox> first_child_;
+ Member<NGConstraintSpace> constraint_space_;
Member<NGFragmentBuilder> builder_;
- Member<NGConstraintSpace> constraint_space_for_children_;
+ Member<NGConstraintSpaceBuilder> space_builder_;
+ Member<NGConstraintSpace> space_for_current_child_;
Member<NGBox> current_child_;
+
NGBoxStrut border_and_padding_;
LayoutUnit content_size_;
LayoutUnit max_inline_size_;

Powered by Google App Engine
This is Rietveld 408576698