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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.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_layout_algorithm.h" 5 #include "core/layout/ng/ng_block_layout_algorithm.h"
6 6
7 #include "core/layout/ng/ng_break_token.h" 7 #include "core/layout/ng/ng_break_token.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_constraint_space_builder.h" 9 #include "core/layout/ng/ng_constraint_space_builder.h"
10 #include "core/layout/ng/ng_fragment_base.h" 10 #include "core/layout/ng/ng_fragment_base.h"
(...skipping 11 matching lines...) Expand all
22 22
23 // Adjusts content's offset to CSS "clear" property. 23 // Adjusts content's offset to CSS "clear" property.
24 // TODO(glebl): Support margin collapsing edge cases, e.g. margin collapsing 24 // TODO(glebl): Support margin collapsing edge cases, e.g. margin collapsing
25 // should not occur if "clear" is applied to non-floating blocks. 25 // should not occur if "clear" is applied to non-floating blocks.
26 // TODO(layout-ng): the call to AdjustToClearance should be moved to 26 // TODO(layout-ng): the call to AdjustToClearance should be moved to
27 // CreateConstraintSpaceForChild once ConstraintSpaceBuilder is sharing the 27 // CreateConstraintSpaceForChild once ConstraintSpaceBuilder is sharing the
28 // exclusion information between constraint spaces. 28 // exclusion information between constraint spaces.
29 void AdjustToClearance(const NGConstraintSpace& space, 29 void AdjustToClearance(const NGConstraintSpace& space,
30 const ComputedStyle& style, 30 const ComputedStyle& style,
31 LayoutUnit* content_size) { 31 LayoutUnit* content_size) {
32 const NGExclusion* right_exclusion = space.LastRightFloatExclusion(); 32 const NGExclusion* right_exclusion = space.Exclusions()->last_right_float;
33 const NGExclusion* left_exclusion = space.LastLeftFloatExclusion(); 33 const NGExclusion* left_exclusion = space.Exclusions()->last_left_float;
34 34
35 // Calculates Left/Right block end offset from left/right float exclusions or 35 // Calculates Left/Right block end offset from left/right float exclusions or
36 // use the default content offset position. 36 // use the default content offset position.
37 LayoutUnit left_block_end_offset = 37 LayoutUnit left_block_end_offset =
38 left_exclusion ? left_exclusion->rect.BlockEndOffset() : *content_size; 38 left_exclusion ? left_exclusion->rect.BlockEndOffset() : *content_size;
39 LayoutUnit right_block_end_offset = 39 LayoutUnit right_block_end_offset =
40 right_exclusion ? right_exclusion->rect.BlockEndOffset() : *content_size; 40 right_exclusion ? right_exclusion->rect.BlockEndOffset() : *content_size;
41 41
42 switch (style.clear()) { 42 switch (style.clear()) {
43 case EClear::ClearNone: 43 case EClear::ClearNone:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // -1? 211 // -1?
212 LayoutUnit block_size = ComputeBlockSizeForFragment( 212 LayoutUnit block_size = ComputeBlockSizeForFragment(
213 ConstraintSpace(), Style(), NGSizeIndefinite); 213 ConstraintSpace(), Style(), NGSizeIndefinite);
214 LayoutUnit adjusted_block_size(block_size); 214 LayoutUnit adjusted_block_size(block_size);
215 // Our calculated block-axis size may be indefinite at this point. 215 // Our calculated block-axis size may be indefinite at this point.
216 // If so, just leave the size as NGSizeIndefinite instead of subtracting 216 // If so, just leave the size as NGSizeIndefinite instead of subtracting
217 // borders and padding. 217 // borders and padding.
218 if (adjusted_block_size != NGSizeIndefinite) 218 if (adjusted_block_size != NGSizeIndefinite)
219 adjusted_block_size -= border_and_padding_.BlockSum(); 219 adjusted_block_size -= border_and_padding_.BlockSum();
220 220
221 space_builder_ = 221 space_builder_ = new NGConstraintSpaceBuilder(constraint_space_);
222 new NGConstraintSpaceBuilder(constraint_space_->WritingMode());
223 if (Style().specifiesColumns()) { 222 if (Style().specifiesColumns()) {
224 space_builder_->SetFragmentationType(kFragmentColumn); 223 space_builder_->SetFragmentationType(kFragmentColumn);
225 adjusted_inline_size = 224 adjusted_inline_size =
226 ResolveUsedColumnInlineSize(adjusted_inline_size, Style()); 225 ResolveUsedColumnInlineSize(adjusted_inline_size, Style());
227 } 226 }
228 space_builder_->SetAvailableSize( 227 space_builder_->SetAvailableSize(
229 NGLogicalSize(adjusted_inline_size, adjusted_block_size)); 228 NGLogicalSize(adjusted_inline_size, adjusted_block_size));
230 space_builder_->SetPercentageResolutionSize( 229 space_builder_->SetPercentageResolutionSize(
231 NGLogicalSize(adjusted_inline_size, adjusted_block_size)); 230 NGLogicalSize(adjusted_inline_size, adjusted_block_size));
232 231
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 421 }
423 builder_->SetMarginStrutBlockEnd(from); 422 builder_->SetMarginStrutBlockEnd(from);
424 } 423 }
425 424
426 NGConstraintSpace* 425 NGConstraintSpace*
427 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { 426 NGBlockLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const {
428 DCHECK(current_child_); 427 DCHECK(current_child_);
429 space_builder_->SetIsNewFormattingContext( 428 space_builder_->SetIsNewFormattingContext(
430 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(), 429 IsNewFormattingContextForInFlowBlockLevelChild(ConstraintSpace(),
431 CurrentChildStyle())); 430 CurrentChildStyle()));
432 NGConstraintSpace* child_space = new NGConstraintSpace( 431 NGConstraintSpace* child_space = space_builder_->ToConstraintSpace();
433 constraint_space_->WritingMode(), constraint_space_->Direction(),
434 space_builder_->ToConstraintSpace());
435 432
436 // TODO(layout-ng): Set offset through the space builder. 433 // TODO(layout-ng): Set offset through the space builder.
437 child_space->SetOffset( 434 child_space->SetOffset(
438 NGLogicalOffset(border_and_padding_.inline_start, content_size_)); 435 NGLogicalOffset(border_and_padding_.inline_start, content_size_));
439
440 // TODO(layout-ng): avoid copying here. A child and parent constraint spaces
441 // should share the same backing space.
442 for (const auto& exclusion : constraint_space_->Exclusions()) {
443 child_space->AddExclusion(*exclusion.get());
444 }
445 return child_space; 436 return child_space;
446 } 437 }
447 438
448 DEFINE_TRACE(NGBlockLayoutAlgorithm) { 439 DEFINE_TRACE(NGBlockLayoutAlgorithm) {
449 NGLayoutAlgorithm::trace(visitor); 440 NGLayoutAlgorithm::trace(visitor);
450 visitor->trace(first_child_); 441 visitor->trace(first_child_);
451 visitor->trace(constraint_space_); 442 visitor->trace(constraint_space_);
452 visitor->trace(break_token_); 443 visitor->trace(break_token_);
453 visitor->trace(builder_); 444 visitor->trace(builder_);
454 visitor->trace(space_builder_); 445 visitor->trace(space_builder_);
455 visitor->trace(space_for_current_child_); 446 visitor->trace(space_for_current_child_);
456 visitor->trace(current_child_); 447 visitor->trace(current_child_);
457 } 448 }
458 449
459 } // namespace blink 450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698