Commit 8be76dce authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Minor simplification of IsFirstForNode

This patch sipmlifies |IsFirstForNode| for
|NGInlineItemResult| by using all information in it.

This was originally addded in r754815
<crrev.com/c/2111158>.

Bug: 1043787
Change-Id: I3acccd6fd7f53f7eeff955025397216680565850
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2152336
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759760}
parent e98b5e8d
......@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_INLINE_ITEM_RESULT_H_
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_box_strut.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_item.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_text_fragment.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h"
#include "third_party/blink/renderer/core/layout/ng/ng_positioned_float.h"
......@@ -36,6 +37,14 @@ struct CORE_EXPORT NGInlineItemResult {
return end_offset - start_offset;
}
// Return true if the fragment to be generated for the specified item is going
// to be the first fragment for the node.
bool IsFirstForNode() const {
DCHECK(item->Type() == NGInlineItem::kText ||
item->Type() == NGInlineItem::kControl);
return item->IsFirstForNode() && start_offset == item->StartOffset();
}
LayoutUnit HyphenInlineSize() const {
return hyphen_shape_result->SnappedWidth().ClampNegativeToZero();
}
......
......@@ -238,7 +238,7 @@ void NGInlineLayoutAlgorithm::CreateLine(
item.GetLayoutObject()->IsLayoutNGListItem());
DCHECK(item_result.shape_result);
text_builder.SetIsFirstForNode(IsFirstForNode(item, BreakToken()));
text_builder.SetIsFirstForNode(item_result.IsFirstForNode());
if (UNLIKELY(quirks_mode_))
box->EnsureTextMetrics(*item.Style(), baseline_type_);
......@@ -446,7 +446,7 @@ void NGInlineLayoutAlgorithm::PlaceControlItem(const NGInlineItem& item,
NGTextFragmentBuilder text_builder(ConstraintSpace().GetWritingMode());
text_builder.SetItem(type, line_info.ItemsData(), item_result,
box->text_height);
text_builder.SetIsFirstForNode(IsFirstForNode(item, BreakToken()));
text_builder.SetIsFirstForNode(item_result->IsFirstForNode());
line_box_.AddChild(text_builder.ToTextFragment(), box->text_top,
item_result->inline_size, item.BidiLevel());
}
......
......@@ -47,14 +47,6 @@ inline bool IsResumingLayout(const NGBlockBreakToken* token) {
return token && !token->IsBreakBefore();
}
// Return true if the fragment to be generated for the specified item is going
// to be the first fragment for the node.
inline bool IsFirstForNode(const NGInlineItem& item,
const NGInlineBreakToken* token) {
return item.IsFirstForNode() &&
(!token || item.StartOffset() >= token->TextOffset());
}
// Calculate the final "break-between" value at a class A or C breakpoint. This
// is the combination of all break-before and break-after values that met at the
// breakpoint.
......
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