Commit 80e94bcf authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[FragmentItem] Fix resolved direction for box items

This patch fixes resolved direction for box items. Before
this patch, it was set to the opposite direction.

Bug: 982194
Change-Id: I1fcdd0c15fa453ac8a25ba6cc81769022cbfd2f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880895
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709767}
parent b840580e
...@@ -39,16 +39,15 @@ NGFragmentItem::NGFragmentItem(const NGPhysicalLineBoxFragment& line, ...@@ -39,16 +39,15 @@ NGFragmentItem::NGFragmentItem(const NGPhysicalLineBoxFragment& line,
text_direction_(static_cast<unsigned>(line.BaseDirection())) {} text_direction_(static_cast<unsigned>(line.BaseDirection())) {}
NGFragmentItem::NGFragmentItem(const NGPhysicalBoxFragment& box, NGFragmentItem::NGFragmentItem(const NGPhysicalBoxFragment& box,
wtf_size_t item_count) wtf_size_t item_count,
TextDirection resolved_direction)
: layout_object_(box.GetLayoutObject()), : layout_object_(box.GetLayoutObject()),
box_({&box, item_count}), box_({&box, item_count}),
rect_({PhysicalOffset(), box.Size()}), rect_({PhysicalOffset(), box.Size()}),
type_(kBox), type_(kBox),
style_variant_(static_cast<unsigned>(box.StyleVariant())), style_variant_(static_cast<unsigned>(box.StyleVariant())),
is_hidden_for_paint_(false), is_hidden_for_paint_(false),
// TODO(yosin): We should have |textDirection| parameter from text_direction_(static_cast<unsigned>(resolved_direction)) {}
// |NGLineBoxFragmentBuilder::Child::BidiLevel()|
text_direction_(box.IsAtomicInline() && IsLtr(box.ResolvedDirection())) {}
NGFragmentItem::~NGFragmentItem() { NGFragmentItem::~NGFragmentItem() {
switch (Type()) { switch (Type()) {
......
...@@ -62,7 +62,9 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient { ...@@ -62,7 +62,9 @@ class CORE_EXPORT NGFragmentItem : public DisplayItemClient {
// TODO(kojii): Should be able to create without once creating fragments. // TODO(kojii): Should be able to create without once creating fragments.
NGFragmentItem(const NGPhysicalTextFragment& text); NGFragmentItem(const NGPhysicalTextFragment& text);
NGFragmentItem(const NGPhysicalBoxFragment& box, wtf_size_t item_count); NGFragmentItem(const NGPhysicalBoxFragment& box,
wtf_size_t item_count,
TextDirection resolved_direction);
NGFragmentItem(const NGPhysicalLineBoxFragment& line, wtf_size_t item_count); NGFragmentItem(const NGPhysicalLineBoxFragment& line, wtf_size_t item_count);
~NGFragmentItem() final; ~NGFragmentItem() final;
......
...@@ -85,7 +85,9 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) { ...@@ -85,7 +85,9 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) {
if (!has_floating_descendants_for_paint_ && box.IsFloating()) if (!has_floating_descendants_for_paint_ && box.IsFloating())
has_floating_descendants_for_paint_ = true; has_floating_descendants_for_paint_ = true;
items_.push_back(std::make_unique<NGFragmentItem>(box, 1)); DCHECK(child.HasBidiLevel());
items_.push_back(std::make_unique<NGFragmentItem>(
box, 1, DirectionFromLevel(child.bidi_level)));
offsets_.push_back(child.offset); offsets_.push_back(child.offset);
++child_iter; ++child_iter;
continue; continue;
...@@ -112,8 +114,9 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) { ...@@ -112,8 +114,9 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) {
wtf_size_t item_count = items_.size() - box_start_index; wtf_size_t item_count = items_.size() - box_start_index;
// Create an item for the start of the box. // Create an item for the start of the box.
items_[box_start_index] = DCHECK(child.HasBidiLevel());
std::make_unique<NGFragmentItem>(box, item_count); items_[box_start_index] = std::make_unique<NGFragmentItem>(
box, item_count, DirectionFromLevel(child.bidi_level));
continue; continue;
} }
...@@ -127,7 +130,11 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) { ...@@ -127,7 +130,11 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) {
void NGFragmentItemsBuilder::AddListMarker( void NGFragmentItemsBuilder::AddListMarker(
const NGPhysicalBoxFragment& marker_fragment, const NGPhysicalBoxFragment& marker_fragment,
const LogicalOffset& offset) { const LogicalOffset& offset) {
items_.push_back(std::make_unique<NGFragmentItem>(marker_fragment, 1)); // Resolved direction matters only for inline items, and outside list markers
// are not inline.
const TextDirection resolved_direction = TextDirection::kLtr;
items_.push_back(
std::make_unique<NGFragmentItem>(marker_fragment, 1, resolved_direction));
offsets_.push_back(offset); offsets_.push_back(offset);
} }
......
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