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

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

Issue 2745973002: [LayoutNG] Implement atomic inlines for LayoutNGInline (Closed)
Patch Set: Resolved merge conflicts Created 3 years, 9 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_node.h" 5 #include "core/layout/ng/ng_inline_node.h"
6 6
7 #include "core/layout/LayoutBlockFlow.h" 7 #include "core/layout/LayoutBlockFlow.h"
8 #include "core/layout/LayoutObject.h" 8 #include "core/layout/LayoutObject.h"
9 #include "core/layout/LayoutText.h" 9 #include "core/layout/LayoutText.h"
10 #include "core/layout/ng/ng_bidi_paragraph.h" 10 #include "core/layout/ng/ng_bidi_paragraph.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return InlineSize(start_offset_, end_offset_); 212 return InlineSize(start_offset_, end_offset_);
213 } 213 }
214 214
215 LayoutUnit NGLayoutInlineItem::InlineSize(unsigned start, unsigned end) const { 215 LayoutUnit NGLayoutInlineItem::InlineSize(unsigned start, unsigned end) const {
216 DCHECK(start >= StartOffset() && start <= end && end <= EndOffset()); 216 DCHECK(start >= StartOffset() && start <= end && end <= EndOffset());
217 217
218 if (start == end) 218 if (start == end)
219 return LayoutUnit(); 219 return LayoutUnit();
220 220
221 if (!style_ || !shape_result_) { 221 if (!style_ || !shape_result_) {
222 // Bidi controls do not have widths. 222 DCHECK(start == start_offset_ && end == end_offset_);
223 // TODO(kojii): Atomic inline not supported yet. 223 DCHECK(!IsAtomicInlineLevel()) << "Use NGLineBuilder::InlineSize";
224 DCHECK(!layout_object_ ||
225 layout_object_->isFloatingOrOutOfFlowPositioned());
226 // Bidi controls and out-of-flow objects do not have in-flow widths.
224 return LayoutUnit(); 227 return LayoutUnit();
225 } 228 }
226 229
227 if (start == start_offset_ && end == end_offset_) 230 if (start == start_offset_ && end == end_offset_)
228 return LayoutUnit(shape_result_->width()); 231 return LayoutUnit(shape_result_->width());
229 232
230 return LayoutUnit(ShapeResultBuffer::getCharacterRange( 233 return LayoutUnit(ShapeResultBuffer::getCharacterRange(
231 shape_result_, Direction(), shape_result_->width(), 234 shape_result_, Direction(), shape_result_->width(),
232 start - StartOffset(), end - StartOffset()) 235 start - StartOffset(), end - StartOffset())
233 .width()); 236 .width());
234 } 237 }
235 238
236 void NGLayoutInlineItem::GetFallbackFonts( 239 void NGLayoutInlineItem::GetFallbackFonts(
237 HashSet<const SimpleFontData*>* fallback_fonts, 240 HashSet<const SimpleFontData*>* fallback_fonts,
238 unsigned start, 241 unsigned start,
239 unsigned end) const { 242 unsigned end) const {
240 DCHECK(start >= StartOffset() && start <= end && end <= EndOffset()); 243 DCHECK(start >= StartOffset() && start <= end && end <= EndOffset());
241 244
242 // TODO(kojii): Implement |start| and |end|. 245 // TODO(kojii): Implement |start| and |end|.
243 shape_result_->fallbackFonts(fallback_fonts); 246 shape_result_->fallbackFonts(fallback_fonts);
244 } 247 }
245 248
246 void NGInlineNode::ShapeText() { 249 void NGInlineNode::ShapeText() {
247 // TODO(eae): Add support for shaping latin-1 text? 250 // TODO(eae): Add support for shaping latin-1 text?
248 text_content_.ensure16Bit(); 251 text_content_.ensure16Bit();
249 252
250 // Shape each item with the full context of the entire node. 253 // Shape each item with the full context of the entire node.
251 HarfBuzzShaper shaper(text_content_.characters16(), text_content_.length()); 254 HarfBuzzShaper shaper(text_content_.characters16(), text_content_.length());
252 for (auto& item : items_) { 255 for (auto& item : items_) {
253 // Skip object replacement characters and bidi control characters. 256 // Skip non-text items; e.g., bidi controls, atomic inlines, out-of-flow
257 // objects.
254 if (!item.style_) 258 if (!item.style_)
255 continue; 259 continue;
256 260
257 item.shape_result_ = shaper.shape(&item.Style()->font(), item.Direction(), 261 item.shape_result_ = shaper.shape(&item.Style()->font(), item.Direction(),
258 item.StartOffset(), item.EndOffset()); 262 item.StartOffset(), item.EndOffset());
259 } 263 }
260 } 264 }
261 265
262 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace*, NGBreakToken*) { 266 RefPtr<NGLayoutResult> NGInlineNode::Layout(NGConstraintSpace*, NGBreakToken*) {
263 ASSERT_NOT_REACHED(); 267 ASSERT_NOT_REACHED();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 .SetAvailableSize({LayoutUnit(), NGSizeIndefinite}) 302 .SetAvailableSize({LayoutUnit(), NGSizeIndefinite})
299 .ToConstraintSpace(writing_mode); 303 .ToConstraintSpace(writing_mode);
300 NGLineBuilder line_builder(this, constraint_space.get(), nullptr); 304 NGLineBuilder line_builder(this, constraint_space.get(), nullptr);
301 Layout(&line_builder); 305 Layout(&line_builder);
302 MinMaxContentSize sizes; 306 MinMaxContentSize sizes;
303 sizes.min_content = line_builder.MaxInlineSize(); 307 sizes.min_content = line_builder.MaxInlineSize();
304 308
305 // max-content is the width without any line wrapping. 309 // max-content is the width without any line wrapping.
306 // TODO(kojii): Implement hard breaks (<br> etc.) to break. 310 // TODO(kojii): Implement hard breaks (<br> etc.) to break.
307 for (const auto& item : items_) 311 for (const auto& item : items_)
308 sizes.max_content += item.InlineSize(); 312 sizes.max_content += line_builder.InlineSize(item);
309 313
310 return sizes; 314 return sizes;
311 } 315 }
312 316
313 NGLayoutInputNode* NGInlineNode::NextSibling() { 317 NGLayoutInputNode* NGInlineNode::NextSibling() {
314 if (!IsPrepareLayoutFinished()) 318 if (!IsPrepareLayoutFinished())
315 PrepareLayout(); 319 PrepareLayout();
316 return next_sibling_; 320 return next_sibling_;
317 } 321 }
318 322
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 Vector<NGLayoutInlineItem>* items, 368 Vector<NGLayoutInlineItem>* items,
365 unsigned start_index, 369 unsigned start_index,
366 unsigned end_index) 370 unsigned end_index)
367 : start_item_(&(*items)[start_index]), 371 : start_item_(&(*items)[start_index]),
368 size_(end_index - start_index), 372 size_(end_index - start_index),
369 start_index_(start_index) { 373 start_index_(start_index) {
370 RELEASE_ASSERT(start_index <= end_index && end_index <= items->size()); 374 RELEASE_ASSERT(start_index <= end_index && end_index <= items->size());
371 } 375 }
372 376
373 } // namespace blink 377 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698