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

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

Issue 2270983002: [layoutng] Add an NGFragmentBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove SwapChildren Created 4 years, 4 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.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
index 178dd138478ca0dd7f576c76c9319eded546f6bf..b354a614d13a5a354f63268cb99dae151c7f330c 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
@@ -6,6 +6,7 @@
#include "core/layout/LayoutBox.h"
#include "core/layout/ng/ng_constraint_space.h"
+#include "core/layout/ng/ng_fragment_builder.h"
#include "core/layout/ng/ng_fragment.h"
#include "core/layout/ng/ng_length_utils.h"
#include "core/layout/ng/ng_margin_strut.h"
@@ -29,28 +30,31 @@ NGFragment* NGBlockLayoutAlgorithm::layout(
NGConstraintSpace constraint_space_for_children(
constraintSpace, NGLogicalSize(inlineSize, blockSize));
- HeapVector<Member<const NGFragmentBase>> childFragments;
+ NGFragmentBuilder builder(NGFragmentBase::FragmentBox);
+ builder.SetInlineSize(inlineSize).SetBlockSize(blockSize);
+
LayoutUnit contentSize;
for (NGBox box : m_boxIterator) {
NGBoxMargins childMargins =
computeMargins(constraint_space_for_children, *box.style());
NGFragment* fragment = box.layout(constraint_space_for_children);
// TODO(layout-ng): Support auto margins
- fragment->setOffset(childMargins.inlineStart,
+ fragment->SetOffset(childMargins.inlineStart,
contentSize + childMargins.blockStart);
box.positionUpdated(*fragment);
- contentSize += fragment->blockSize() + childMargins.blockSum();
- childFragments.append(fragment);
+ contentSize += fragment->BlockSize() + childMargins.blockSum();
+ builder.AddChild(fragment);
}
// Recompute the block-axis size now that we know our content size.
blockSize =
computeBlockSizeForFragment(constraintSpace, *m_style, contentSize);
- NGFragment* returnFragment =
- new NGFragment(inlineSize, blockSize, inlineSize, blockSize,
- HorizontalTopBottom, LeftToRight);
- returnFragment->swapChildren(childFragments);
- return returnFragment;
+ // TODO(layout-ng): Compute correct inline overflow (block overflow should be
+ // correct)
+ builder.SetBlockSize(blockSize)
+ .SetInlineOverflow(inlineSize)
+ .SetBlockOverflow(contentSize);
+ return builder.ToFragment();
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/core.gypi ('k') | third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698