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

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

Issue 2325073002: [LayoutNG] Handle border and padding when sizing a block and when placing its children. (Closed)
Patch Set: Add unit test. 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 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 ae4722e5639624aede739e87e0b97c50998941fa..3607bcd5b5e342b6d8286ec16c162014ae9c01f4 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
@@ -47,7 +47,7 @@ bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space,
constraint_space_for_children_ =
new NGConstraintSpace(*constraint_space, NGLogicalOffset(),
NGLogicalSize(inline_size, block_size));
- content_size_ = LayoutUnit();
+ content_size_ = computeBorderAndPaddingBefore(*constraint_space, *style_);
builder_ = new NGFragmentBuilder(NGPhysicalFragmentBase::FragmentBox);
builder_->SetInlineSize(inline_size).SetBlockSize(block_size);
@@ -66,10 +66,16 @@ bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space,
LayoutUnit margin_block_start =
CollapseMargins(child_margins, fragment->MarginStrut());
+ // TODO(layout-ng): This is probably something we shouldn't calculate
+ // over and over again for each child.
+ LayoutUnit content_start_edge =
+ computeBorderAndPaddingStart(*constraint_space, *style_);
+
// TODO(layout-ng): Support auto margins
- builder_->AddChild(fragment,
- NGLogicalOffset(child_margins.inline_start,
- content_size_ + margin_block_start));
+ builder_->AddChild(
+ fragment,
+ NGLogicalOffset(content_start_edge + child_margins.inline_start,
+ content_size_ + margin_block_start));
content_size_ += fragment->BlockSize() + margin_block_start;
max_inline_size_ =

Powered by Google App Engine
This is Rietveld 408576698