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

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

Issue 2525033002: Deprecate NGPhysicalConstraintSpace (Closed)
Patch Set: update TestExpectations Created 4 years 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
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_node.h" 5 #include "core/layout/ng/ng_block_node.h"
6 6
7 #include "core/layout/LayoutBlockFlow.h" 7 #include "core/layout/LayoutBlockFlow.h"
8 #include "core/layout/api/LineLayoutAPIShim.h" 8 #include "core/layout/api/LineLayoutAPIShim.h"
9 #include "core/layout/line/InlineIterator.h" 9 #include "core/layout/line/InlineIterator.h"
10 #include "core/layout/ng/layout_ng_block_flow.h" 10 #include "core/layout/ng/layout_ng_block_flow.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 90 }
91 DCHECK(!layout_coordinator_) 91 DCHECK(!layout_coordinator_)
92 << "Can't interleave Layout and ComputeMinAndMaxContentSizes"; 92 << "Can't interleave Layout and ComputeMinAndMaxContentSizes";
93 if (!minmax_algorithm_) { 93 if (!minmax_algorithm_) {
94 NGConstraintSpaceBuilder builder( 94 NGConstraintSpaceBuilder builder(
95 FromPlatformWritingMode(Style()->getWritingMode())); 95 FromPlatformWritingMode(Style()->getWritingMode()));
96 96
97 builder.SetAvailableSize(NGLogicalSize(LayoutUnit(), LayoutUnit())); 97 builder.SetAvailableSize(NGLogicalSize(LayoutUnit(), LayoutUnit()));
98 builder.SetPercentageResolutionSize( 98 builder.SetPercentageResolutionSize(
99 NGLogicalSize(LayoutUnit(), LayoutUnit())); 99 NGLogicalSize(LayoutUnit(), LayoutUnit()));
100 // TODO(layoutng): Use builder.ToConstraintSpace.ToLogicalConstraintSpace 100 // TODO(layoutng): Use builder.ToConstraintSpace.ToLogicalConstraintSpace
cbiesinger 2016/12/01 21:11:37 This TODO can be removed now.
Gleb Lanbin 2016/12/05 17:46:53 done http://crrev.com/2557463002
101 // once 101 // once
102 // that's available. 102 // that's available.
103 NGConstraintSpace* constraint_space = new NGConstraintSpace( 103 NGConstraintSpace* constraint_space =
104 FromPlatformWritingMode(Style()->getWritingMode()), 104 NGConstraintSpaceBuilder(
105 Style()->direction(), builder.ToConstraintSpace()); 105 FromPlatformWritingMode(Style()->getWritingMode()))
106 .SetTextDirection(Style()->direction())
107 .ToConstraintSpace();
106 108
107 minmax_algorithm_ = new NGBlockLayoutAlgorithm( 109 minmax_algorithm_ = new NGBlockLayoutAlgorithm(
108 Style(), toNGBlockNode(FirstChild()), constraint_space); 110 Style(), toNGBlockNode(FirstChild()), constraint_space);
109 } 111 }
110 // TODO(cbiesinger): For orthogonal children, we need to always synthesize. 112 // TODO(cbiesinger): For orthogonal children, we need to always synthesize.
111 NGLayoutAlgorithm::MinAndMaxState state = 113 NGLayoutAlgorithm::MinAndMaxState state =
112 minmax_algorithm_->ComputeMinAndMaxContentSizes(sizes); 114 minmax_algorithm_->ComputeMinAndMaxContentSizes(sizes);
113 if (state == NGLayoutAlgorithm::kSuccess) 115 if (state == NGLayoutAlgorithm::kSuccess)
114 return true; 116 return true;
115 if (state == NGLayoutAlgorithm::kPending) 117 if (state == NGLayoutAlgorithm::kPending)
116 return false; 118 return false;
117 DCHECK_EQ(state, NGLayoutAlgorithm::kNotImplemented); 119 DCHECK_EQ(state, NGLayoutAlgorithm::kNotImplemented);
118 120
119 // TODO(cbiesinger): Replace the loops below with a state machine like in 121 // TODO(cbiesinger): Replace the loops below with a state machine like in
120 // Layout. 122 // Layout.
121 123
122 // Have to synthesize this value. 124 // Have to synthesize this value.
123 NGPhysicalFragmentBase* physical_fragment; 125 NGPhysicalFragmentBase* physical_fragment;
124 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) 126 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr))
125 continue; 127 continue;
126 NGFragment* fragment = new NGFragment( 128 NGFragment* fragment = new NGFragment(
127 FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(), 129 FromPlatformWritingMode(Style()->getWritingMode()), Style()->direction(),
128 toNGPhysicalFragment(physical_fragment)); 130 toNGPhysicalFragment(physical_fragment));
129 131
130 sizes->min_content = fragment->InlineOverflow(); 132 sizes->min_content = fragment->InlineOverflow();
131 133
132 // Now, redo with infinite space for max_content 134 // Now, redo with infinite space for max_content
133 NGConstraintSpaceBuilder builder(
134 FromPlatformWritingMode(Style()->getWritingMode()));
135 builder.SetAvailableSize(NGLogicalSize(LayoutUnit::max(), LayoutUnit()));
136 builder.SetPercentageResolutionSize(
137 NGLogicalSize(LayoutUnit(), LayoutUnit()));
138 NGConstraintSpace* constraint_space = 135 NGConstraintSpace* constraint_space =
139 new NGConstraintSpace(FromPlatformWritingMode(Style()->getWritingMode()), 136 NGConstraintSpaceBuilder(
140 Style()->direction(), builder.ToConstraintSpace()); 137 FromPlatformWritingMode(Style()->getWritingMode()))
138 .SetTextDirection(Style()->direction())
139 .SetAvailableSize({LayoutUnit::max(), LayoutUnit()})
140 .SetPercentageResolutionSize({LayoutUnit(), LayoutUnit()})
141 .ToConstraintSpace();
141 142
142 minmax_algorithm_ = new NGBlockLayoutAlgorithm( 143 minmax_algorithm_ = new NGBlockLayoutAlgorithm(
143 Style(), toNGBlockNode(FirstChild()), constraint_space); 144 Style(), toNGBlockNode(FirstChild()), constraint_space);
144 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr)) 145 while (!minmax_algorithm_->Layout(nullptr, &physical_fragment, nullptr))
145 continue; 146 continue;
146 147
147 fragment = new NGFragment(FromPlatformWritingMode(Style()->getWritingMode()), 148 fragment = new NGFragment(FromPlatformWritingMode(Style()->getWritingMode()),
148 Style()->direction(), 149 Style()->direction(),
149 toNGPhysicalFragment(physical_fragment)); 150 toNGPhysicalFragment(physical_fragment));
150 sizes->max_content = fragment->InlineOverflow(); 151 sizes->max_content = fragment->InlineOverflow();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 .SetBlockSize(layout_box_->logicalHeight()) 315 .SetBlockSize(layout_box_->logicalHeight())
315 .SetDirection(layout_box_->styleRef().direction()) 316 .SetDirection(layout_box_->styleRef().direction())
316 .SetWritingMode( 317 .SetWritingMode(
317 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode())) 318 FromPlatformWritingMode(layout_box_->styleRef().getWritingMode()))
318 .SetInlineOverflow(overflow.width()) 319 .SetInlineOverflow(overflow.width())
319 .SetBlockOverflow(overflow.height()); 320 .SetBlockOverflow(overflow.height());
320 return builder.ToFragment(); 321 return builder.ToFragment();
321 } 322 }
322 323
323 } // namespace blink 324 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698