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

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

Issue 2467803002: Revert of Use NGLogicalRect instead of NGExclusion for exclusions. (Closed)
Patch Set: Created 4 years, 1 month 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_constraint_space.h" 7 #include "core/layout/ng/ng_constraint_space.h"
8 #include "core/layout/ng/ng_constraint_space_builder.h" 8 #include "core/layout/ng/ng_constraint_space_builder.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"
(...skipping 10 matching lines...) Expand all
21 const NGMarginStrut& prev_margin_strut, 21 const NGMarginStrut& prev_margin_strut,
22 const NGMarginStrut& curr_margin_strut) { 22 const NGMarginStrut& curr_margin_strut) {
23 return std::max(prev_margin_strut.margin_block_end, 23 return std::max(prev_margin_strut.margin_block_end,
24 curr_margin_strut.margin_block_start) - 24 curr_margin_strut.margin_block_start) -
25 std::max(prev_margin_strut.negative_margin_block_end.abs(), 25 std::max(prev_margin_strut.negative_margin_block_end.abs(),
26 curr_margin_strut.negative_margin_block_start.abs()); 26 curr_margin_strut.negative_margin_block_start.abs());
27 } 27 }
28 28
29 // Creates an exclusion from the fragment that will be placed in the provided 29 // Creates an exclusion from the fragment that will be placed in the provided
30 // layout opportunity. 30 // layout opportunity.
31 NGLogicalRect CreateExclusion(const NGFragment& fragment, 31 NGExclusion* CreateExclusion(const NGFragment& fragment,
32 const NGLayoutOpportunity& opportunity, 32 const NGLayoutOpportunity& opportunity,
33 LayoutUnit float_offset, 33 LayoutUnit float_offset,
34 NGBoxStrut margins) { 34 NGBoxStrut margins) {
35 NGLogicalRect exclusion; 35 LayoutUnit exclusion_top = opportunity.offset.block_offset;
36 exclusion.offset = opportunity.offset;
37 exclusion.offset.inline_offset += float_offset;
38 36
39 exclusion.size.inline_size = fragment.InlineSize(); 37 LayoutUnit exclusion_left = opportunity.offset.inline_offset;
40 exclusion.size.block_size = fragment.BlockSize(); 38 exclusion_left += float_offset;
39
40 LayoutUnit exclusion_bottom = exclusion_top + fragment.BlockSize();
41 LayoutUnit exclusion_right = exclusion_left + fragment.InlineSize();
41 42
42 // Adjust to child's margin. 43 // Adjust to child's margin.
43 exclusion.size.block_size += margins.BlockSum(); 44 exclusion_bottom += margins.BlockSum();
44 exclusion.size.inline_size += margins.InlineSum(); 45 exclusion_right += margins.InlineSum();
45 46
46 return exclusion; 47 return new NGExclusion(exclusion_top, exclusion_right, exclusion_bottom,
48 exclusion_left);
47 } 49 }
48 50
49 // Finds a layout opportunity for the fragment. 51 // Finds a layout opportunity for the fragment.
50 // It iterates over all layout opportunities in the constraint space and returns 52 // It iterates over all layout opportunities in the constraint space and returns
51 // the first layout opportunity that is wider than the fragment or returns the 53 // the first layout opportunity that is wider than the fragment or returns the
52 // last one which is always the widest. 54 // last one which is always the widest.
53 // 55 //
54 // @param space Constraint space that is used to find layout opportunity for 56 // @param space Constraint space that is used to find layout opportunity for
55 // the fragment. 57 // the fragment.
56 // @param fragment Fragment that needs to be placed. 58 // @param fragment Fragment that needs to be placed.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 FindLayoutOpportunityForFragment(constraint_space_, fragment, margins); 354 FindLayoutOpportunityForFragment(constraint_space_, fragment, margins);
353 DCHECK(!opportunity.IsEmpty()) << "Opportunity is empty but it shouldn't be"; 355 DCHECK(!opportunity.IsEmpty()) << "Opportunity is empty but it shouldn't be";
354 356
355 // Calculate the float offset if needed. 357 // Calculate the float offset if needed.
356 LayoutUnit float_offset; 358 LayoutUnit float_offset;
357 if (current_child_->Style()->floating() == EFloat::Right) { 359 if (current_child_->Style()->floating() == EFloat::Right) {
358 float_offset = opportunity.size.inline_size - fragment.InlineSize(); 360 float_offset = opportunity.size.inline_size - fragment.InlineSize();
359 } 361 }
360 362
361 // Add the float as an exclusion. 363 // Add the float as an exclusion.
362 const NGLogicalRect exclusion = 364 const NGExclusion* exclusion =
363 CreateExclusion(fragment, opportunity, float_offset, margins); 365 CreateExclusion(fragment, opportunity, float_offset, margins);
364 constraint_space_->AddExclusion(exclusion); 366 constraint_space_->AddExclusion(exclusion);
365 367
366 return CalculateLogicalOffsetForOpportunity(opportunity, border_and_padding_, 368 return CalculateLogicalOffsetForOpportunity(opportunity, border_and_padding_,
367 float_offset, margins); 369 float_offset, margins);
368 } 370 }
369 371
370 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) { 372 void NGBlockLayoutAlgorithm::UpdateMarginStrut(const NGMarginStrut& from) {
371 if (!is_fragment_margin_strut_block_start_updated_) { 373 if (!is_fragment_margin_strut_block_start_updated_) {
372 builder_->SetMarginStrutBlockStart(from); 374 builder_->SetMarginStrutBlockStart(from);
373 is_fragment_margin_strut_block_start_updated_ = true; 375 is_fragment_margin_strut_block_start_updated_ = true;
374 } 376 }
375 builder_->SetMarginStrutBlockEnd(from); 377 builder_->SetMarginStrutBlockEnd(from);
376 } 378 }
377 379
378 DEFINE_TRACE(NGBlockLayoutAlgorithm) { 380 DEFINE_TRACE(NGBlockLayoutAlgorithm) {
379 NGLayoutAlgorithm::trace(visitor); 381 NGLayoutAlgorithm::trace(visitor);
380 visitor->trace(first_child_); 382 visitor->trace(first_child_);
381 visitor->trace(constraint_space_); 383 visitor->trace(constraint_space_);
382 visitor->trace(builder_); 384 visitor->trace(builder_);
383 visitor->trace(space_builder_); 385 visitor->trace(space_builder_);
384 visitor->trace(space_for_current_child_); 386 visitor->trace(space_for_current_child_);
385 visitor->trace(current_child_); 387 visitor->trace(current_child_);
386 } 388 }
387 389
388 } // namespace blink 390 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/BUILD.gn ('k') | 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