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

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

Issue 2266313002: [layoutng] Create a more correct constraint space for children (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_constraint_space.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.h" 9 #include "core/layout/ng/ng_fragment.h"
10 #include "core/layout/ng/ng_length_utils.h" 10 #include "core/layout/ng/ng_length_utils.h"
11 #include "core/layout/ng/ng_margin_strut.h" 11 #include "core/layout/ng/ng_margin_strut.h"
12 #include "core/style/ComputedStyle.h" 12 #include "core/style/ComputedStyle.h"
13 #include "platform/LengthFunctions.h" 13 #include "platform/LengthFunctions.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm( 17 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
18 PassRefPtr<const ComputedStyle> style, 18 PassRefPtr<const ComputedStyle> style,
19 NGBoxIterator boxIterator) 19 NGBoxIterator boxIterator)
20 : m_style(style), m_boxIterator(boxIterator) {} 20 : m_style(style), m_boxIterator(boxIterator) {}
21 21
22 NGFragment* NGBlockLayoutAlgorithm::layout( 22 NGFragment* NGBlockLayoutAlgorithm::layout(
23 const NGConstraintSpace& constraintSpace) { 23 const NGConstraintSpace& constraintSpace) {
24 LayoutUnit inlineSize = 24 LayoutUnit inlineSize =
25 computeInlineSizeForFragment(constraintSpace, *m_style); 25 computeInlineSizeForFragment(constraintSpace, *m_style);
26 // TODO(layout-ng): For quirks mode, should we pass blockSize instead of -1?
eae 2016/08/23 16:54:09 Might make sense to have a NGQuirksModeBlockLayout
27 LayoutUnit blockSize =
28 computeBlockSizeForFragment(constraintSpace, *m_style, LayoutUnit(-1));
29 NGConstraintSpace constraint_space_for_children(
30 constraintSpace, NGLogicalSize(inlineSize, blockSize));
26 31
27 HeapVector<Member<const NGFragmentBase>> childFragments; 32 HeapVector<Member<const NGFragmentBase>> childFragments;
28 LayoutUnit contentSize; 33 LayoutUnit contentSize;
29 for (NGBox box : m_boxIterator) { 34 for (NGBox box : m_boxIterator) {
30 NGBoxMargins childMargins = computeMargins(constraintSpace, *box.style()); 35 NGBoxMargins childMargins =
31 NGFragment* fragment = box.layout(constraintSpace); 36 computeMargins(constraint_space_for_children, *box.style());
37 NGFragment* fragment = box.layout(constraint_space_for_children);
32 // TODO(layout-ng): Support auto margins 38 // TODO(layout-ng): Support auto margins
33 fragment->setOffset(childMargins.inlineStart, 39 fragment->setOffset(childMargins.inlineStart,
34 contentSize + childMargins.blockStart); 40 contentSize + childMargins.blockStart);
35 box.positionUpdated(*fragment); 41 box.positionUpdated(*fragment);
36 contentSize += fragment->blockSize() + childMargins.blockSum(); 42 contentSize += fragment->blockSize() + childMargins.blockSum();
37 childFragments.append(fragment); 43 childFragments.append(fragment);
38 } 44 }
39 45
40 LayoutUnit blockSize = 46 // Recompute the block-axis size now that we know our content size.
47 blockSize =
41 computeBlockSizeForFragment(constraintSpace, *m_style, contentSize); 48 computeBlockSizeForFragment(constraintSpace, *m_style, contentSize);
42 NGFragment* returnFragment = 49 NGFragment* returnFragment =
43 new NGFragment(inlineSize, blockSize, inlineSize, blockSize, 50 new NGFragment(inlineSize, blockSize, inlineSize, blockSize,
44 HorizontalTopBottom, LeftToRight); 51 HorizontalTopBottom, LeftToRight);
45 returnFragment->swapChildren(childFragments); 52 returnFragment->swapChildren(childFragments);
46 return returnFragment; 53 return returnFragment;
47 } 54 }
48 55
49 } // namespace blink 56 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_constraint_space.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698