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_inline_layout_algorithm.cc

Issue 2648253005: Cleanup: remove state variables from inline_algorithm (Closed)
Patch Set: Created 3 years, 10 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 18 matching lines...) Expand all
29 break_token_(break_token) { 29 break_token_(break_token) {
30 DCHECK(style_); 30 DCHECK(style_);
31 } 31 }
32 32
33 NGPhysicalFragment* NGInlineLayoutAlgorithm::Layout() { 33 NGPhysicalFragment* NGInlineLayoutAlgorithm::Layout() {
34 // TODO(kojii): Implement sizing and child constraint spaces. Share common 34 // TODO(kojii): Implement sizing and child constraint spaces. Share common
35 // logic with NGBlockLayoutAlgorithm using composition. 35 // logic with NGBlockLayoutAlgorithm using composition.
36 builder_ = new NGFragmentBuilder(NGPhysicalFragment::kFragmentBox); 36 builder_ = new NGFragmentBuilder(NGPhysicalFragment::kFragmentBox);
37 builder_->SetWritingMode(constraint_space_->WritingMode()); 37 builder_->SetWritingMode(constraint_space_->WritingMode());
38 builder_->SetDirection(constraint_space_->Direction()); 38 builder_->SetDirection(constraint_space_->Direction());
39 current_child_ = first_child_; 39 NGInlineNode* current_child = first_child_;
40 40 Member<NGLineBuilder> line_builder;
ikilpatrick 2017/01/23 23:21:36 my newlines /o\!
atotic 2017/01/23 23:31:21 done. newline is back.
41 // TODO(kojii): Since line_builder_ is bound to NGLayoutInlineItem 41 // TODO(kojii): Since line_builder_ is bound to NGLayoutInlineItem
42 // in current_child_, changing the current_child_ needs more work. 42 // in current_child, changing the current_child needs more work.
43 if (current_child_) { 43 if (current_child) {
44 space_for_current_child_ = CreateConstraintSpaceForCurrentChild(); 44 Member<NGConstraintSpace> space_for_current_child =
45 line_builder_ = new NGLineBuilder(current_child_, space_for_current_child_); 45 CreateConstraintSpaceForCurrentChild(*current_child);
46 current_child_->LayoutInline(space_for_current_child_, line_builder_); 46 line_builder = new NGLineBuilder(current_child, space_for_current_child);
47 current_child->LayoutInline(space_for_current_child, line_builder);
47 } 48 }
48 49 line_builder->CreateFragments(builder_);
49 line_builder_->CreateFragments(builder_);
50 NGPhysicalFragment* fragment = builder_->ToBoxFragment(); 50 NGPhysicalFragment* fragment = builder_->ToBoxFragment();
51 line_builder_->CopyFragmentDataToLayoutBlockFlow(); 51 line_builder->CopyFragmentDataToLayoutBlockFlow();
52 return fragment; 52 return fragment;
53 } 53 }
54 54
55 NGConstraintSpace* 55 NGConstraintSpace*
56 NGInlineLayoutAlgorithm::CreateConstraintSpaceForCurrentChild() const { 56 NGInlineLayoutAlgorithm::CreateConstraintSpaceForCurrentChild(
57 DCHECK(current_child_); 57 const NGInlineNode& current_child) const {
58 // TODO(kojii): Implement child constraint space. 58 // TODO(kojii): Implement child constraint space.
59 NGConstraintSpace* child_space = 59 NGConstraintSpace* child_space =
60 NGConstraintSpaceBuilder(constraint_space_->WritingMode()) 60 NGConstraintSpaceBuilder(constraint_space_->WritingMode())
61 .SetTextDirection(constraint_space_->Direction()) 61 .SetTextDirection(constraint_space_->Direction())
62 .ToConstraintSpace(); 62 .ToConstraintSpace();
63 return child_space; 63 return child_space;
64 } 64 }
65 65
66 DEFINE_TRACE(NGInlineLayoutAlgorithm) { 66 DEFINE_TRACE(NGInlineLayoutAlgorithm) {
67 NGLayoutAlgorithm::trace(visitor); 67 NGLayoutAlgorithm::trace(visitor);
68 visitor->trace(first_child_); 68 visitor->trace(first_child_);
69 visitor->trace(constraint_space_); 69 visitor->trace(constraint_space_);
70 visitor->trace(break_token_); 70 visitor->trace(break_token_);
71 visitor->trace(builder_); 71 visitor->trace(builder_);
72 visitor->trace(space_for_current_child_);
73 visitor->trace(current_child_);
74 visitor->trace(line_builder_);
75 } 72 }
76 73
77 } // namespace blink 74 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698