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

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

Issue 2692403003: [LayoutNG] Make NGBlockLayoutAlgorithm accept a NGBlockNode. (Closed)
Patch Set: comments! 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_line_builder.h" 5 #include "core/layout/ng/ng_line_builder.h"
6 6
7 #include "core/layout/BidiRun.h" 7 #include "core/layout/BidiRun.h"
8 #include "core/layout/LayoutBlockFlow.h" 8 #include "core/layout/LayoutBlockFlow.h"
9 #include "core/layout/line/LineInfo.h" 9 #include "core/layout/line/LineInfo.h"
10 #include "core/layout/line/RootInlineBox.h" 10 #include "core/layout/line/RootInlineBox.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 line_item_chunks.push_back( 124 line_item_chunks.push_back(
125 LineItemChunk{i, start_offset, end_offset, 125 LineItemChunk{i, start_offset, end_offset,
126 item.InlineSize(start_offset, end_offset)}); 126 item.InlineSize(start_offset, end_offset)});
127 start_offset = end_offset; 127 start_offset = end_offset;
128 } 128 }
129 129
130 if (inline_box_->IsBidiEnabled()) 130 if (inline_box_->IsBidiEnabled())
131 BidiReorder(&line_item_chunks); 131 BidiReorder(&line_item_chunks);
132 132
133 NGFragmentBuilder text_builder(NGPhysicalFragment::kFragmentText, 133 NGFragmentBuilder text_builder(NGPhysicalFragment::kFragmentText,
134 inline_box_->GetLayoutObject()); 134 inline_box_);
135 text_builder.SetWritingMode(constraint_space_->WritingMode()); 135 text_builder.SetWritingMode(constraint_space_->WritingMode());
136 LayoutUnit inline_offset; 136 LayoutUnit inline_offset;
137 for (const auto& line_item_chunk : line_item_chunks) { 137 for (const auto& line_item_chunk : line_item_chunks) {
138 const NGLayoutInlineItem& item = items[line_item_chunk.index]; 138 const NGLayoutInlineItem& item = items[line_item_chunk.index];
139 // Skip bidi controls. 139 // Skip bidi controls.
140 if (!item.GetLayoutObject()) 140 if (!item.GetLayoutObject())
141 continue; 141 continue;
142 const ComputedStyle* style = item.Style(); 142 const ComputedStyle* style = item.Style();
143 // TODO(kojii): Handling atomic inline needs more thoughts. 143 // TODO(kojii): Handling atomic inline needs more thoughts.
144 if (!style) 144 if (!style)
145 style = item.GetLayoutObject()->style(); 145 style = item.GetLayoutObject()->style();
146 146
147 // TODO(kojii): The block size for a text fragment isn't clear, revisit when 147 // TODO(kojii): The block size for a text fragment isn't clear, revisit when
148 // we implement line box layout. 148 // we implement line box layout.
149 text_builder.SetInlineSize(line_item_chunk.inline_size) 149 text_builder.SetInlineSize(line_item_chunk.inline_size)
150 .SetInlineOverflow(line_item_chunk.inline_size); 150 .SetInlineOverflow(line_item_chunk.inline_size);
151 151
152 // The direction of a fragment is the CSS direction to resolve logical 152 // The direction of a fragment is the CSS direction to resolve logical
153 // properties, not the resolved bidi direction. 153 // properties, not the resolved bidi direction.
154 TextDirection css_direction = style->direction(); 154 TextDirection css_direction = style->direction();
155 text_builder.SetDirection(css_direction); 155 text_builder.SetDirection(css_direction);
156 RefPtr<NGPhysicalTextFragment> text_fragment = text_builder.ToTextFragment( 156 RefPtr<NGPhysicalTextFragment> text_fragment = text_builder.ToTextFragment(
157 inline_box_, line_item_chunk.index, line_item_chunk.start_offset, 157 line_item_chunk.index, line_item_chunk.start_offset,
158 line_item_chunk.end_offset); 158 line_item_chunk.end_offset);
159 159
160 fragments_.push_back(std::move(text_fragment)); 160 fragments_.push_back(std::move(text_fragment));
161 offsets_.push_back(NGLogicalOffset(inline_offset, content_size_)); 161 offsets_.push_back(NGLogicalOffset(inline_offset, content_size_));
162 inline_offset += line_item_chunk.inline_size; 162 inline_offset += line_item_chunk.inline_size;
163 } 163 }
164 DCHECK_EQ(fragments_.size(), offsets_.size()); 164 DCHECK_EQ(fragments_.size(), offsets_.size());
165 165
166 if (!fragments_.isEmpty()) { 166 if (!fragments_.isEmpty()) {
167 line_box_data_list_.grow(line_box_data_list_.size() + 1); 167 line_box_data_list_.grow(line_box_data_list_.size() + 1);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 fragments_for_bidi_runs.clear(); 310 fragments_for_bidi_runs.clear();
311 } 311 }
312 } 312 }
313 313
314 DEFINE_TRACE(NGLineBuilder) { 314 DEFINE_TRACE(NGLineBuilder) {
315 visitor->trace(inline_box_); 315 visitor->trace(inline_box_);
316 visitor->trace(constraint_space_); 316 visitor->trace(constraint_space_);
317 } 317 }
318 318
319 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698