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

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

Issue 2664383003: [LayoutNG] Make NGBlockNode return a const style reference. (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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_out_of_flow_layout_part.h" 5 #include "core/layout/ng/ng_out_of_flow_layout_part.h"
6 6
7 #include "core/layout/ng/ng_absolute_utils.h" 7 #include "core/layout/ng/ng_absolute_utils.h"
8 #include "core/layout/ng/ng_block_node.h" 8 #include "core/layout/ng/ng_block_node.h"
9 #include "core/layout/ng/ng_box_fragment.h" 9 #include "core/layout/ng/ng_box_fragment.h"
10 #include "core/layout/ng/ng_constraint_space_builder.h" 10 #include "core/layout/ng/ng_constraint_space_builder.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 container_builder_->GetAndClearOutOfFlowDescendantCandidates( 68 container_builder_->GetAndClearOutOfFlowDescendantCandidates(
69 &out_of_flow_candidates, &out_of_flow_candidate_positions); 69 &out_of_flow_candidates, &out_of_flow_candidate_positions);
70 70
71 size_t position_index = 0; 71 size_t position_index = 0;
72 72
73 for (auto& descendant : out_of_flow_candidates) { 73 for (auto& descendant : out_of_flow_candidates) {
74 NGStaticPosition static_position = 74 NGStaticPosition static_position =
75 out_of_flow_candidate_positions[position_index++]; 75 out_of_flow_candidate_positions[position_index++];
76 76
77 if (IsContainingBlockForAbsoluteDescendant(container_style_, 77 if (IsContainingBlockForAbsoluteDescendant(container_style_,
78 *descendant->Style())) { 78 descendant->Style())) {
79 NGLogicalOffset offset; 79 NGLogicalOffset offset;
80 NGFragment* fragment = 80 NGFragment* fragment =
81 LayoutDescendant(*descendant, static_position, &offset); 81 LayoutDescendant(*descendant, static_position, &offset);
82 // TODO(atotic) Need to adjust size of overflow rect per spec. 82 // TODO(atotic) Need to adjust size of overflow rect per spec.
83 container_builder_->AddChild(fragment, offset); 83 container_builder_->AddChild(fragment, offset);
84 } else { 84 } else {
85 container_builder_->AddOutOfFlowDescendant(descendant, static_position); 85 container_builder_->AddOutOfFlowDescendant(descendant, static_position);
86 } 86 }
87 } 87 }
88 } 88 }
89 89
90 NGFragment* NGOutOfFlowLayoutPart::LayoutDescendant( 90 NGFragment* NGOutOfFlowLayoutPart::LayoutDescendant(
91 NGBlockNode& descendant, 91 NGBlockNode& descendant,
92 NGStaticPosition static_position, 92 NGStaticPosition static_position,
93 NGLogicalOffset* offset) { 93 NGLogicalOffset* offset) {
94 // Adjust the static_position origin. The static_position coordinate origin is 94 // Adjust the static_position origin. The static_position coordinate origin is
95 // relative to the container's border box, ng_absolute_utils expects it to be 95 // relative to the container's border box, ng_absolute_utils expects it to be
96 // relative to the container's padding box. 96 // relative to the container's padding box.
97 static_position.offset -= container_border_physical_offset_; 97 static_position.offset -= container_border_physical_offset_;
98 98
99 NGFragment* fragment = nullptr; 99 NGFragment* fragment = nullptr;
100 Optional<MinAndMaxContentSizes> inline_estimate; 100 Optional<MinAndMaxContentSizes> inline_estimate;
101 Optional<LayoutUnit> block_estimate; 101 Optional<LayoutUnit> block_estimate;
102 102
103 if (AbsoluteNeedsChildInlineSize(*descendant.Style())) { 103 if (AbsoluteNeedsChildInlineSize(descendant.Style())) {
104 inline_estimate = descendant.ComputeMinAndMaxContentSizes(); 104 inline_estimate = descendant.ComputeMinAndMaxContentSizes();
105 } 105 }
106 106
107 NGAbsolutePhysicalPosition node_position = 107 NGAbsolutePhysicalPosition node_position =
108 ComputePartialAbsoluteWithChildInlineSize( 108 ComputePartialAbsoluteWithChildInlineSize(
109 *container_space_, *descendant.Style(), static_position, 109 *container_space_, descendant.Style(), static_position,
110 inline_estimate); 110 inline_estimate);
111 111
112 if (AbsoluteNeedsChildBlockSize(*descendant.Style())) { 112 if (AbsoluteNeedsChildBlockSize(descendant.Style())) {
113 fragment = GenerateFragment(descendant, block_estimate, node_position); 113 fragment = GenerateFragment(descendant, block_estimate, node_position);
114 block_estimate = fragment->BlockSize(); 114 block_estimate = fragment->BlockSize();
115 } 115 }
116 116
117 ComputeFullAbsoluteWithChildBlockSize(*container_space_, *descendant.Style(), 117 ComputeFullAbsoluteWithChildBlockSize(*container_space_, descendant.Style(),
118 static_position, block_estimate, 118 static_position, block_estimate,
119 &node_position); 119 &node_position);
120 120
121 // Skip this step if we produced a fragment when estimating the block size. 121 // Skip this step if we produced a fragment when estimating the block size.
122 if (!fragment) { 122 if (!fragment) {
123 block_estimate = 123 block_estimate =
124 node_position.size.ConvertToLogical(container_space_->WritingMode()) 124 node_position.size.ConvertToLogical(container_space_->WritingMode())
125 .block_size; 125 .block_size;
126 fragment = GenerateFragment(descendant, block_estimate, node_position); 126 fragment = GenerateFragment(descendant, block_estimate, node_position);
127 } 127 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 NGPhysicalFragment* fragment = descendant.Layout(space); 168 NGPhysicalFragment* fragment = descendant.Layout(space);
169 169
170 // TODO(ikilpatrick): the writing mode switching here looks wrong. 170 // TODO(ikilpatrick): the writing mode switching here looks wrong.
171 return new NGBoxFragment(container_space_->WritingMode(), 171 return new NGBoxFragment(container_space_->WritingMode(),
172 container_space_->Direction(), 172 container_space_->Direction(),
173 toNGPhysicalBoxFragment(fragment)); 173 toNGPhysicalBoxFragment(fragment));
174 } 174 }
175 175
176 } // namespace blink 176 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698