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

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

Issue 2649583002: [LayoutNG] Remove the ng_layout_coordinator and temporary LayoutSync method. (Closed)
Patch Set: rebase v2 Created 3 years, 11 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_inline_layout_algorithm.h" 5 #include "core/layout/ng/ng_inline_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.h" 10 #include "core/layout/ng/ng_fragment.h"
(...skipping 12 matching lines...) Expand all
23 NGConstraintSpace* constraint_space, 23 NGConstraintSpace* constraint_space,
24 NGBreakToken* break_token) 24 NGBreakToken* break_token)
25 : NGLayoutAlgorithm(kInlineLayoutAlgorithm), 25 : NGLayoutAlgorithm(kInlineLayoutAlgorithm),
26 style_(style), 26 style_(style),
27 first_child_(first_child), 27 first_child_(first_child),
28 constraint_space_(constraint_space), 28 constraint_space_(constraint_space),
29 break_token_(break_token) { 29 break_token_(break_token) {
30 DCHECK(style_); 30 DCHECK(style_);
31 } 31 }
32 32
33 NGLayoutStatus NGInlineLayoutAlgorithm::Layout( 33 NGPhysicalFragment* NGInlineLayoutAlgorithm::Layout() {
34 NGPhysicalFragment*,
35 NGPhysicalFragment** fragment_out,
36 NGLayoutAlgorithm**) {
37 // TODO(kojii): Implement sizing and child constraint spaces. Share common 34 // TODO(kojii): Implement sizing and child constraint spaces. Share common
38 // logic with NGBlockLayoutAlgorithm using composition. 35 // logic with NGBlockLayoutAlgorithm using composition.
39 builder_ = new NGFragmentBuilder(NGPhysicalFragment::kFragmentBox); 36 builder_ = new NGFragmentBuilder(NGPhysicalFragment::kFragmentBox);
40 builder_->SetWritingMode(constraint_space_->WritingMode()); 37 builder_->SetWritingMode(constraint_space_->WritingMode());
41 builder_->SetDirection(constraint_space_->Direction()); 38 builder_->SetDirection(constraint_space_->Direction());
42 current_child_ = first_child_; 39 current_child_ = first_child_;
43 40
44 // TODO(kojii): Since line_builder_ is bound to NGLayoutInlineItem 41 // TODO(kojii): Since line_builder_ is bound to NGLayoutInlineItem
45 // in current_child_, changing the current_child_ needs more work. 42 // in current_child_, changing the current_child_ needs more work.
46 if (current_child_) { 43 if (current_child_) {
47 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); 44 space_for_current_child_ = CreateConstraintSpaceForCurrentChild();
48 line_builder_ = new NGLineBuilder(current_child_, space_for_current_child_); 45 line_builder_ = new NGLineBuilder(current_child_, space_for_current_child_);
49 46
50 while (!LayoutCurrentChild()) 47 while (!LayoutCurrentChild())
51 continue; 48 continue;
52 } 49 }
53 50
54 line_builder_->CreateFragments(builder_); 51 line_builder_->CreateFragments(builder_);
55 *fragment_out = builder_->ToBoxFragment(); 52 NGPhysicalFragment* fragment = builder_->ToBoxFragment();
56 line_builder_->CopyFragmentDataToLayoutBlockFlow(); 53 line_builder_->CopyFragmentDataToLayoutBlockFlow();
57 state_ = kStateInit; 54 return fragment;
58 return kNewFragment;
59 } 55 }
60 56
61 bool NGInlineLayoutAlgorithm::LayoutCurrentChild() { 57 bool NGInlineLayoutAlgorithm::LayoutCurrentChild() {
62 return current_child_->LayoutInline(space_for_current_child_, line_builder_); 58 return current_child_->LayoutInline(space_for_current_child_, line_builder_);
63 } 59 }
64 60
65 NGConstraintSpace* 61 NGConstraintSpace*
66 NGInlineLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { 62 NGInlineLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const {
67 DCHECK(current_child_); 63 DCHECK(current_child_);
68 // TODO(kojii): Implement child constraint space. 64 // TODO(kojii): Implement child constraint space.
69 NGConstraintSpace* child_space = 65 NGConstraintSpace* child_space =
70 NGConstraintSpaceBuilder(constraint_space_->WritingMode()) 66 NGConstraintSpaceBuilder(constraint_space_->WritingMode())
71 .SetTextDirection(constraint_space_->Direction()) 67 .SetTextDirection(constraint_space_->Direction())
72 .ToConstraintSpace(); 68 .ToConstraintSpace();
73 return child_space; 69 return child_space;
74 } 70 }
75 71
76 DEFINE_TRACE(NGInlineLayoutAlgorithm) { 72 DEFINE_TRACE(NGInlineLayoutAlgorithm) {
77 NGLayoutAlgorithm::trace(visitor); 73 NGLayoutAlgorithm::trace(visitor);
78 visitor->trace(first_child_); 74 visitor->trace(first_child_);
79 visitor->trace(constraint_space_); 75 visitor->trace(constraint_space_);
80 visitor->trace(break_token_); 76 visitor->trace(break_token_);
81 visitor->trace(builder_); 77 visitor->trace(builder_);
82 visitor->trace(space_for_current_child_); 78 visitor->trace(space_for_current_child_);
83 visitor->trace(current_child_); 79 visitor->trace(current_child_);
84 visitor->trace(line_builder_); 80 visitor->trace(line_builder_);
85 } 81 }
86 82
87 } // namespace blink 83 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698