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

Side by Side 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: Use modern CSS terms, rather than old XSL terms, for box sides 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "core/layout/ng/ng_block_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/layout/LayoutBox.h" 7 #include "core/layout/LayoutBox.h"
8 #include "core/layout/ng/ng_constraint_space.h" 8 #include "core/layout/ng/ng_constraint_space.h"
9 #include "core/layout/ng/ng_fragment_builder.h" 9 #include "core/layout/ng/ng_fragment_builder.h"
10 #include "core/layout/ng/ng_fragment.h" 10 #include "core/layout/ng/ng_fragment.h"
(...skipping 29 matching lines...) Expand all
40 case kStateInit: { 40 case kStateInit: {
41 LayoutUnit inline_size = 41 LayoutUnit inline_size =
42 computeInlineSizeForFragment(*constraint_space, *style_); 42 computeInlineSizeForFragment(*constraint_space, *style_);
43 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of 43 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of
44 // -1? 44 // -1?
45 LayoutUnit block_size = computeBlockSizeForFragment( 45 LayoutUnit block_size = computeBlockSizeForFragment(
46 *constraint_space, *style_, LayoutUnit(-1)); 46 *constraint_space, *style_, LayoutUnit(-1));
47 constraint_space_for_children_ = 47 constraint_space_for_children_ =
48 new NGConstraintSpace(*constraint_space, NGLogicalOffset(), 48 new NGConstraintSpace(*constraint_space, NGLogicalOffset(),
49 NGLogicalSize(inline_size, block_size)); 49 NGLogicalSize(inline_size, block_size));
50 content_size_ = LayoutUnit(); 50 content_size_ =
51 computeBorderAndPaddingBlockStart(*constraint_space, *style_);
51 52
52 builder_ = new NGFragmentBuilder(NGPhysicalFragmentBase::FragmentBox); 53 builder_ = new NGFragmentBuilder(NGPhysicalFragmentBase::FragmentBox);
53 builder_->SetInlineSize(inline_size).SetBlockSize(block_size); 54 builder_->SetInlineSize(inline_size).SetBlockSize(block_size);
54 current_child_ = first_child_; 55 current_child_ = first_child_;
55 state_ = kStateChildLayout; 56 state_ = kStateChildLayout;
56 return false; 57 return false;
57 } 58 }
58 case kStateChildLayout: { 59 case kStateChildLayout: {
59 if (current_child_) { 60 if (current_child_) {
60 NGFragment* fragment; 61 NGFragment* fragment;
61 if (!current_child_->Layout(constraint_space_for_children_, &fragment)) 62 if (!current_child_->Layout(constraint_space_for_children_, &fragment))
62 return false; 63 return false;
63 NGBoxStrut child_margins = computeMargins( 64 NGBoxStrut child_margins = computeMargins(
64 *constraint_space_for_children_, *current_child_->Style()); 65 *constraint_space_for_children_, *current_child_->Style());
65 66
66 LayoutUnit margin_block_start = 67 LayoutUnit margin_block_start =
67 CollapseMargins(child_margins, fragment->MarginStrut()); 68 CollapseMargins(child_margins, fragment->MarginStrut());
68 69
70 // TODO(layout-ng): This is probably something we shouldn't calculate
71 // over and over again for each child.
72 LayoutUnit content_inline_start_edge =
73 computeBorderAndPaddingInlineStart(*constraint_space, *style_);
74
69 // TODO(layout-ng): Support auto margins 75 // TODO(layout-ng): Support auto margins
70 builder_->AddChild(fragment, 76 builder_->AddChild(fragment,
71 NGLogicalOffset(child_margins.inline_start, 77 NGLogicalOffset(content_inline_start_edge +
78 child_margins.inline_start,
72 content_size_ + margin_block_start)); 79 content_size_ + margin_block_start));
73 80
74 content_size_ += fragment->BlockSize() + margin_block_start; 81 content_size_ += fragment->BlockSize() + margin_block_start;
75 max_inline_size_ = 82 max_inline_size_ =
76 std::max(max_inline_size_, 83 std::max(max_inline_size_,
77 fragment->InlineSize() + child_margins.InlineSum()); 84 fragment->InlineSize() + child_margins.InlineSum());
78 current_child_ = current_child_->NextSibling(); 85 current_child_ = current_child_->NextSibling();
79 if (current_child_) 86 if (current_child_)
80 return false; 87 return false;
81 } 88 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 margin_block_start = ComputeCollapsedMarginBlockStart( 128 margin_block_start = ComputeCollapsedMarginBlockStart(
122 prev_child_margin_strut_, curr_margin_strut); 129 prev_child_margin_strut_, curr_margin_strut);
123 130
124 prev_child_margin_strut_ = curr_margin_strut; 131 prev_child_margin_strut_ = curr_margin_strut;
125 // TODO(layout-ng): support other Margin Collapsing use cases, 132 // TODO(layout-ng): support other Margin Collapsing use cases,
126 // i.e. support 0 height elements etc. 133 // i.e. support 0 height elements etc.
127 return margin_block_start; 134 return margin_block_start;
128 } 135 }
129 136
130 } // namespace blink 137 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | 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