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

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

Issue 2714803002: [LayoutNG] Allow block-flow layout to be fragmented using new approach. (Closed)
Patch Set: address comments. Created 3 years, 9 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 layout_box_(nullptr), 79 layout_box_(nullptr),
80 style_(style) { 80 style_(style) {
81 DCHECK(style_); 81 DCHECK(style_);
82 } 82 }
83 83
84 // Need an explicit destructor in the .cc file, or the MSWIN compiler will 84 // Need an explicit destructor in the .cc file, or the MSWIN compiler will
85 // produce an error when attempting to generate a default one, if the .h file is 85 // produce an error when attempting to generate a default one, if the .h file is
86 // included from a compilation unit that lacks the ComputedStyle definition. 86 // included from a compilation unit that lacks the ComputedStyle definition.
87 NGBlockNode::~NGBlockNode() {} 87 NGBlockNode::~NGBlockNode() {}
88 88
89 RefPtr<NGLayoutResult> NGBlockNode::Layout( 89 RefPtr<NGLayoutResult> NGBlockNode::Layout(NGConstraintSpace* constraint_space,
90 NGConstraintSpace* constraint_space) { 90 NGBreakToken* break_token) {
91 // Use the old layout code and synthesize a fragment. 91 // Use the old layout code and synthesize a fragment.
92 if (!CanUseNewLayout()) { 92 if (!CanUseNewLayout()) {
93 DCHECK(layout_box_); 93 DCHECK(layout_box_);
94 layout_result_ = RunOldLayout(*constraint_space); 94 layout_result_ = RunOldLayout(*constraint_space);
95 return layout_result_; 95 return layout_result_;
96 } 96 }
97 97
98 layout_result_ = 98 layout_result_ = NGBlockLayoutAlgorithm(this, constraint_space,
99 NGBlockLayoutAlgorithm(this, constraint_space, CurrentBreakToken()) 99 toNGBlockBreakToken(break_token))
100 .Layout(); 100 .Layout();
101 101
102 CopyFragmentDataToLayoutBox(*constraint_space); 102 CopyFragmentDataToLayoutBox(*constraint_space);
103 return layout_result_; 103 return layout_result_;
104 } 104 }
105 105
106 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() { 106 MinAndMaxContentSizes NGBlockNode::ComputeMinAndMaxContentSizes() {
107 MinAndMaxContentSizes sizes; 107 MinAndMaxContentSizes sizes;
108 if (!CanUseNewLayout()) { 108 if (!CanUseNewLayout()) {
109 DCHECK(layout_box_); 109 DCHECK(layout_box_);
110 // TODO(layout-ng): This could be somewhat optimized by directly calling 110 // TODO(layout-ng): This could be somewhat optimized by directly calling
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 void NGBlockNode::SetNextSibling(NGLayoutInputNode* sibling) { 202 void NGBlockNode::SetNextSibling(NGLayoutInputNode* sibling) {
203 next_sibling_ = sibling; 203 next_sibling_ = sibling;
204 } 204 }
205 205
206 void NGBlockNode::SetFirstChild(NGLayoutInputNode* child) { 206 void NGBlockNode::SetFirstChild(NGLayoutInputNode* child) {
207 first_child_ = child; 207 first_child_ = child;
208 } 208 }
209 209
210 NGBreakToken* NGBlockNode::CurrentBreakToken() const {
211 return layout_result_ ? layout_result_->PhysicalFragment()->BreakToken()
212 : nullptr;
213 }
214
215 DEFINE_TRACE(NGBlockNode) { 210 DEFINE_TRACE(NGBlockNode) {
216 visitor->trace(next_sibling_); 211 visitor->trace(next_sibling_);
217 visitor->trace(first_child_); 212 visitor->trace(first_child_);
218 NGLayoutInputNode::trace(visitor); 213 NGLayoutInputNode::trace(visitor);
219 } 214 }
220 215
221 bool NGBlockNode::CanUseNewLayout() { 216 bool NGBlockNode::CanUseNewLayout() {
222 if (!layout_box_) 217 if (!layout_box_)
223 return true; 218 return true;
224 if (!layout_box_->isLayoutBlockFlow()) 219 if (!layout_box_->isLayoutBlockFlow())
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 // Save static position for legacy AbsPos layout. 364 // Save static position for legacy AbsPos layout.
370 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 365 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
371 DCHECK(layout_box_); 366 DCHECK(layout_box_);
372 DCHECK(layout_box_->isOutOfFlowPositioned()); 367 DCHECK(layout_box_->isOutOfFlowPositioned());
373 DCHECK(layout_box_->layer()); 368 DCHECK(layout_box_->layer());
374 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 369 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
375 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 370 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
376 } 371 }
377 372
378 } // namespace blink 373 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698