Index: third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc |
index d99a083a6a3f9d68818c176646be1dbe5b9c46a6..c21d8465966dab85366ad4ea8ab9bf9861cb8155 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_layout_algorithm.cc |
@@ -440,7 +440,7 @@ bool NGInlineLayoutAlgorithm::PlaceItems( |
box->ComputeTextMetrics(*item.Style(), baseline_type_); |
continue; |
} else if (item.Type() == NGInlineItem::kCloseTag) { |
- box = box_states_.OnCloseTag(item, &line_box, box); |
+ box = box_states_.OnCloseTag(item, &line_box, box, baseline_type_); |
continue; |
} else if (item.Type() == NGInlineItem::kAtomicInline) { |
line_top = PlaceAtomicInline(item, &line_box, box, &text_builder); |
@@ -476,7 +476,7 @@ bool NGInlineLayoutAlgorithm::PlaceItems( |
return true; // The line was empty. |
} |
- box_states_.OnEndPlaceItems(&line_box); |
+ box_states_.OnEndPlaceItems(&line_box, baseline_type_); |
// The baselines are always placed at pixel boundaries. Not doing so results |
// in incorrect layout of text decorations, most notably underlines. |
@@ -509,7 +509,7 @@ bool NGInlineLayoutAlgorithm::PlaceItems( |
line_box.SetInlineSize(inline_size); |
container_builder_.AddChild( |
line_box.ToLineBoxFragment(), |
- {LayoutUnit(), baseline + box_states_.LineBoxState().text_top}); |
+ {LayoutUnit(), baseline - box_states_.LineBoxState().metrics.ascent}); |
max_inline_size_ = std::max(max_inline_size_, inline_size); |
content_size_ = line_bottom; |
@@ -521,11 +521,17 @@ LayoutUnit NGInlineLayoutAlgorithm::PlaceAtomicInline( |
NGLineBoxFragmentBuilder* line_box, |
NGInlineBoxState* state, |
NGTextFragmentBuilder* text_builder) { |
+ // For replaced elements, inline-block elements, and inline-table elements, |
+ // the height is the height of their margin box. |
+ // https://drafts.csswg.org/css2/visudet.html#line-height |
NGBoxFragment fragment( |
ConstraintSpace().WritingMode(), |
ToNGPhysicalBoxFragment(LayoutItem(item)->PhysicalFragment().Get())); |
- // TODO(kojii): Margin and border in block progression not implemented yet. |
- LayoutUnit block_size = fragment.BlockSize(); |
+ DCHECK(item.Style()); |
+ NGBoxStrut margins = ComputeMargins(ConstraintSpace(), *item.Style(), |
+ ConstraintSpace().WritingMode(), |
+ item.Style()->Direction()); |
+ LayoutUnit block_size = fragment.BlockSize() + margins.BlockSum(); |
// TODO(kojii): Try to eliminate the wrapping text fragment and use the |
// |fragment| directly. Currently |CopyFragmentDataToLayoutBlockFlow| |
@@ -546,7 +552,7 @@ LayoutUnit NGInlineLayoutAlgorithm::PlaceAtomicInline( |
// TODO(kojii): Figure out what to do with OOF in NGLayoutResult. |
// Floats are ok because atomic inlines are BFC? |
- return -metrics.ascent; |
+ return -(metrics.ascent - margins.block_start); |
} |
void NGInlineLayoutAlgorithm::FindNextLayoutOpportunity() { |