Commit 0f7573ec authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix ComputeFragmentOffsetOnLine

This patch changes |NGInlineBoxFragmentPainterBase::
ComputeFragmentOffsetOnLine| to support |NGFragmentItem|. It
used |NGPaintFragment|, but did not crash when it was null.

Fixes e.g., fast/inline/inline-box-background.html

Bug: 982194
Change-Id: I99abff4e4a2319151870d1283681d1d957c6d3e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1993363Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729879}
parent 125ae871
...@@ -178,22 +178,34 @@ void NGInlineBoxFragmentPainterBase::ComputeFragmentOffsetOnLine( ...@@ -178,22 +178,34 @@ void NGInlineBoxFragmentPainterBase::ComputeFragmentOffsetOnLine(
LayoutUnit* offset_on_line, LayoutUnit* offset_on_line,
LayoutUnit* total_width) const { LayoutUnit* total_width) const {
WritingMode writing_mode = inline_box_fragment_.Style().GetWritingMode(); WritingMode writing_mode = inline_box_fragment_.Style().GetWritingMode();
NGPaintFragment::FragmentRange fragments = NGInlineCursor cursor;
inline_box_paint_fragment_->InlineFragmentsFor( DCHECK(inline_box_fragment_.GetLayoutObject());
inline_box_fragment_.GetLayoutObject()); cursor.MoveTo(*inline_box_fragment_.GetLayoutObject());
LayoutUnit before; LayoutUnit before;
LayoutUnit after; LayoutUnit after;
bool before_self = true; bool before_self = true;
for (auto iter = fragments.begin(); iter != fragments.end(); ++iter) { for (; cursor; cursor.MoveToNextForSameLayoutObject()) {
if (*iter == inline_box_paint_fragment_) { if (inline_box_paint_fragment_) {
before_self = false; DCHECK(cursor.CurrentPaintFragment());
continue; if (cursor.CurrentPaintFragment() == inline_box_paint_fragment_) {
before_self = false;
continue;
}
} else {
DCHECK(inline_box_item_);
DCHECK(cursor.CurrentItem());
if (cursor.CurrentItem() == inline_box_item_) {
before_self = false;
continue;
}
} }
const NGPhysicalBoxFragment* box_fragment = cursor.CurrentBoxFragment();
DCHECK(box_fragment);
if (before_self) if (before_self)
before += NGFragment(writing_mode, iter->PhysicalFragment()).InlineSize(); before += NGFragment(writing_mode, *box_fragment).InlineSize();
else else
after += NGFragment(writing_mode, iter->PhysicalFragment()).InlineSize(); after += NGFragment(writing_mode, *box_fragment).InlineSize();
} }
NGFragment logical_fragment(writing_mode, inline_box_fragment_); NGFragment logical_fragment(writing_mode, inline_box_fragment_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment