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

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

Issue 2281763002: [layoutng] Move and rename NGBoxMargins to NGBoxStrut (Closed)
Patch Set: 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_length_utils.h » ('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"
11 #include "core/layout/ng/ng_length_utils.h" 11 #include "core/layout/ng/ng_length_utils.h"
12 #include "core/layout/ng/ng_margin_strut.h"
13 #include "core/style/ComputedStyle.h" 12 #include "core/style/ComputedStyle.h"
14 #include "platform/LengthFunctions.h" 13 #include "platform/LengthFunctions.h"
15 14
16 namespace blink { 15 namespace blink {
17 16
18 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm( 17 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
19 PassRefPtr<const ComputedStyle> style, 18 PassRefPtr<const ComputedStyle> style,
20 NGBoxIterator box_iterator) 19 NGBoxIterator box_iterator)
21 : m_style(style), m_boxIterator(box_iterator) {} 20 : m_style(style), m_boxIterator(box_iterator) {}
22 21
23 NGFragment* NGBlockLayoutAlgorithm::layout( 22 NGFragment* NGBlockLayoutAlgorithm::layout(
24 const NGConstraintSpace& constraint_space) { 23 const NGConstraintSpace& constraint_space) {
25 LayoutUnit inline_size = 24 LayoutUnit inline_size =
26 computeInlineSizeForFragment(constraint_space, *m_style); 25 computeInlineSizeForFragment(constraint_space, *m_style);
27 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of -1? 26 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of -1?
28 LayoutUnit block_size = 27 LayoutUnit block_size =
29 computeBlockSizeForFragment(constraint_space, *m_style, LayoutUnit(-1)); 28 computeBlockSizeForFragment(constraint_space, *m_style, LayoutUnit(-1));
30 NGConstraintSpace constraint_space_for_children( 29 NGConstraintSpace constraint_space_for_children(
31 constraint_space, NGLogicalSize(inline_size, block_size)); 30 constraint_space, NGLogicalSize(inline_size, block_size));
32 31
33 NGFragmentBuilder builder(NGFragmentBase::FragmentBox); 32 NGFragmentBuilder builder(NGFragmentBase::FragmentBox);
34 builder.SetInlineSize(inline_size).SetBlockSize(block_size); 33 builder.SetInlineSize(inline_size).SetBlockSize(block_size);
35 34
36 LayoutUnit content_size; 35 LayoutUnit content_size;
37 for (NGBox box : m_boxIterator) { 36 for (NGBox box : m_boxIterator) {
38 NGBoxMargins child_margins = 37 NGBoxStrut child_margins =
39 computeMargins(constraint_space_for_children, *box.style()); 38 computeMargins(constraint_space_for_children, *box.style());
40 NGFragment* fragment = box.layout(constraint_space_for_children); 39 NGFragment* fragment = box.layout(constraint_space_for_children);
41 // TODO(layout-ng): Support auto margins 40 // TODO(layout-ng): Support auto margins
42 fragment->SetOffset(child_margins.inline_start, 41 fragment->SetOffset(child_margins.inline_start,
43 content_size + child_margins.block_start); 42 content_size + child_margins.block_start);
44 box.positionUpdated(*fragment); 43 box.positionUpdated(*fragment);
45 content_size += fragment->BlockSize() + child_margins.BlockSum(); 44 content_size += fragment->BlockSize() + child_margins.BlockSum();
46 builder.AddChild(fragment); 45 builder.AddChild(fragment);
47 } 46 }
48 47
49 // Recompute the block-axis size now that we know our content size. 48 // Recompute the block-axis size now that we know our content size.
50 block_size = 49 block_size =
51 computeBlockSizeForFragment(constraint_space, *m_style, content_size); 50 computeBlockSizeForFragment(constraint_space, *m_style, content_size);
52 // TODO(layout-ng): Compute correct inline overflow (block overflow should be 51 // TODO(layout-ng): Compute correct inline overflow (block overflow should be
53 // correct) 52 // correct)
54 builder.SetBlockSize(block_size) 53 builder.SetBlockSize(block_size)
55 .SetInlineOverflow(inline_size) 54 .SetInlineOverflow(inline_size)
56 .SetBlockOverflow(content_size); 55 .SetBlockOverflow(content_size);
57 return builder.ToFragment(); 56 return builder.ToFragment();
58 } 57 }
59 58
60 } // namespace blink 59 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_length_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698