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

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

Issue 2910133002: [LayoutNG] Handle empty inlines and border edges (Closed)
Patch Set: Rebase Created 3 years, 6 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/inline/ng_inline_layout_algorithm.h" 5 #include "core/layout/ng/inline/ng_inline_layout_algorithm.h"
6 6
7 #include "core/layout/ng/inline/ng_bidi_paragraph.h" 7 #include "core/layout/ng/inline/ng_bidi_paragraph.h"
8 #include "core/layout/ng/inline/ng_inline_break_token.h" 8 #include "core/layout/ng/inline/ng_inline_break_token.h"
9 #include "core/layout/ng/inline/ng_inline_node.h" 9 #include "core/layout/ng/inline/ng_inline_node.h"
10 #include "core/layout/ng/inline/ng_line_box_fragment.h" 10 #include "core/layout/ng/inline/ng_line_box_fragment.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 item_result.end_offset); 252 item_result.end_offset);
253 line_box.AddChild(std::move(text_fragment), {position, box->text_top}); 253 line_box.AddChild(std::move(text_fragment), {position, box->text_top});
254 } else if (item.Type() == NGInlineItem::kOpenTag) { 254 } else if (item.Type() == NGInlineItem::kOpenTag) {
255 box = box_states_.OnOpenTag(item, &line_box); 255 box = box_states_.OnOpenTag(item, &line_box);
256 // Compute text metrics for all inline boxes since even empty inlines 256 // Compute text metrics for all inline boxes since even empty inlines
257 // influence the line height. 257 // influence the line height.
258 // https://drafts.csswg.org/css2/visudet.html#line-height 258 // https://drafts.csswg.org/css2/visudet.html#line-height
259 box->ComputeTextMetrics(*item.Style(), baseline_type_); 259 box->ComputeTextMetrics(*item.Style(), baseline_type_);
260 text_builder.SetDirection(box->style->Direction()); 260 text_builder.SetDirection(box->style->Direction());
261 // TODO(kojii): We may need more conditions to create box fragments. 261 // TODO(kojii): We may need more conditions to create box fragments.
262 if (item.Style()->HasBoxDecorationBackground()) { 262 if (item.Style()->HasBoxDecorationBackground())
263 // TODO(kojii): These are once computed in NGLineBreaker. Should copy to 263 box->SetNeedsBoxFragment(item, item_result, position);
264 // NGInlineItemResult to reuse here.
265 NGBoxStrut borders = ComputeBorders(*constraint_space_, *item.Style());
266 NGBoxStrut paddings = ComputePadding(*constraint_space_, *item.Style());
267 // TODO(kojii): Set paint edges.
268 box->SetNeedsBoxFragment(position,
269 borders.block_start + paddings.block_start,
270 borders.BlockSum() + paddings.BlockSum());
271 }
272 } else if (item.Type() == NGInlineItem::kCloseTag) { 264 } else if (item.Type() == NGInlineItem::kCloseTag) {
273 position += item_result.inline_size; 265 position += item_result.inline_size;
274 box = box_states_.OnCloseTag(item, &line_box, box, baseline_type_, 266 if (box->needs_box_fragment)
275 position); 267 box->SetLineRightForBoxFragment(item, item_result, position);
268 box = box_states_.OnCloseTag(item, &line_box, box, baseline_type_);
276 continue; 269 continue;
277 } else if (item.Type() == NGInlineItem::kAtomicInline) { 270 } else if (item.Type() == NGInlineItem::kAtomicInline) {
278 box = PlaceAtomicInline(item, &item_result, position, &line_box, 271 box = PlaceAtomicInline(item, &item_result, position, &line_box,
279 &text_builder); 272 &text_builder);
280 } else if (item.Type() == NGInlineItem::kOutOfFlowPositioned) { 273 } else if (item.Type() == NGInlineItem::kOutOfFlowPositioned) {
281 // TODO(layout-dev): Report the correct static position for the out of 274 // TODO(layout-dev): Report the correct static position for the out of
282 // flow descendant. We can't do this here yet as it doesn't know the 275 // flow descendant. We can't do this here yet as it doesn't know the
283 // size of the line box. 276 // size of the line box.
284 container_builder_.AddOutOfFlowDescendant( 277 container_builder_.AddOutOfFlowDescendant(
285 // Absolute positioning blockifies the box's display type. 278 // Absolute positioning blockifies the box's display type.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // |fragment| directly. Currently |CopyFragmentDataToLayoutBlockFlow| 373 // |fragment| directly. Currently |CopyFragmentDataToLayoutBlockFlow|
381 // requires a text fragment. 374 // requires a text fragment.
382 text_builder->SetDirection(item.Style()->Direction()); 375 text_builder->SetDirection(item.Style()->Direction());
383 text_builder->SetSize({fragment.InlineSize(), block_size}); 376 text_builder->SetSize({fragment.InlineSize(), block_size});
384 LayoutUnit line_top = item_result->margins.block_start - metrics.ascent; 377 LayoutUnit line_top = item_result->margins.block_start - metrics.ascent;
385 RefPtr<NGPhysicalTextFragment> text_fragment = text_builder->ToTextFragment( 378 RefPtr<NGPhysicalTextFragment> text_fragment = text_builder->ToTextFragment(
386 item_result->item_index, item_result->start_offset, 379 item_result->item_index, item_result->start_offset,
387 item_result->end_offset); 380 item_result->end_offset);
388 line_box->AddChild(std::move(text_fragment), {position, line_top}); 381 line_box->AddChild(std::move(text_fragment), {position, line_top});
389 382
390 return box_states_.OnCloseTag(item, line_box, box, baseline_type_, 383 return box_states_.OnCloseTag(item, line_box, box, baseline_type_);
391 LayoutUnit(0));
392 } 384 }
393 385
394 void NGInlineLayoutAlgorithm::ApplyTextAlign(LayoutUnit* line_left, 386 void NGInlineLayoutAlgorithm::ApplyTextAlign(LayoutUnit* line_left,
395 LayoutUnit inline_size, 387 LayoutUnit inline_size,
396 LayoutUnit available_width) { 388 LayoutUnit available_width) {
397 // TODO(kojii): Implement text-align-last. 389 // TODO(kojii): Implement text-align-last.
398 ETextAlign text_align = LineStyle().GetTextAlign(); 390 ETextAlign text_align = LineStyle().GetTextAlign();
399 switch (text_align) { 391 switch (text_align) {
400 case ETextAlign::kRight: 392 case ETextAlign::kRight:
401 case ETextAlign::kWebkitRight: 393 case ETextAlign::kWebkitRight:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // Margin struts shouldn't need to be passed through like this once we've 447 // Margin struts shouldn't need to be passed through like this once we've
456 // removed LayoutInline splitting. 448 // removed LayoutInline splitting.
457 if (!container_builder_.BfcOffset()) { 449 if (!container_builder_.BfcOffset()) {
458 container_builder_.SetEndMarginStrut(ConstraintSpace().MarginStrut()); 450 container_builder_.SetEndMarginStrut(ConstraintSpace().MarginStrut());
459 } 451 }
460 452
461 return container_builder_.ToBoxFragment(); 453 return container_builder_.ToBoxFragment();
462 } 454 }
463 455
464 } // namespace blink 456 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698