Commit bf2bcb36 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Invalidate inline items when direction is changed

Following CL:986982 that optimizes re-layout for inline by
re-using previous items, this patch invalidates the re-use
when the resolved direction is changed.

The resolved direction is an input to HarfBuzzShaper that
such items need to be reshaped.

This patch is on top of another invalidation fix CL:1056647
to avoid conflict in FlagExpectations.

Bug: 636993
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Ic5fd81985db1aa0f05762fda63430d96a632ea89
Reviewed-on: https://chromium-review.googlesource.com/1056648
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558373}
parent 83b500c1
......@@ -25,7 +25,6 @@ crbug.com/811429 inspector-protocol/layout-fonts/cross-platform-cbdt-sbix-cff2.j
crbug.com/636993 accessibility/removed-continuation-element-causes-crash.html [ Crash ]
crbug.com/636993 fast/css/first-letter-removed-added.html [ Crash ]
crbug.com/591099 fast/css/getComputedStyle/getComputedStyle-resolved-values.html [ Crash ]
crbug.com/636993 fast/dynamic/unicode-bidi.html [ Failure ]
crbug.com/594672 fast/events/updateLayoutForHitTest.html [ Crash Failure ]
crbug.com/594672 virtual/mouseevent_fractional/fast/events/updateLayoutForHitTest.html [ Crash Failure ]
......
......@@ -122,6 +122,13 @@ const char* NGInlineItem::NGInlineItemTypeToString(int val) const {
return kNGInlineItemTypeStrings[val];
}
void NGInlineItem::SetBidiLevel(UBiDiLevel level) {
// Invalidate ShapeResult because it depends on the resolved direction.
if (DirectionFromLevel(level) != DirectionFromLevel(bidi_level_))
shape_result_ = nullptr;
bidi_level_ = level;
}
// Set bidi level to a list of NGInlineItem from |index| to the item that ends
// with |end_offset|.
// If |end_offset| is mid of an item, the item is split to ensure each item has
......@@ -136,14 +143,14 @@ unsigned NGInlineItem::SetBidiLevel(Vector<NGInlineItem>& items,
unsigned end_offset,
UBiDiLevel level) {
for (; items[index].end_offset_ < end_offset; index++)
items[index].bidi_level_ = level;
items[index].bidi_level_ = level;
items[index].SetBidiLevel(level);
items[index].SetBidiLevel(level);
if (items[index].end_offset_ == end_offset) {
// Let close items have the same bidi-level as the previous item.
while (index + 1 < items.size() &&
items[index + 1].Type() == NGInlineItem::kCloseTag) {
items[++index].bidi_level_ = level;
items[++index].SetBidiLevel(level);
}
} else {
Split(items, index, end_offset);
......@@ -175,11 +182,10 @@ void NGInlineItem::Split(Vector<NGInlineItem>& items,
unsigned offset) {
DCHECK_GT(offset, items[index].start_offset_);
DCHECK_LT(offset, items[index].end_offset_);
items[index].shape_result_ = nullptr;
items.insert(index + 1, items[index]);
items[index].end_offset_ = offset;
items[index].shape_result_ = nullptr;
items[index + 1].start_offset_ = offset;
items[index + 1].shape_result_ = nullptr;
}
void NGInlineItem::SetOffset(unsigned start, unsigned end) {
......
......@@ -132,6 +132,7 @@ class CORE_EXPORT NGInlineItem {
bool EndMayCollapse() const { return end_may_collapse_; }
static void Split(Vector<NGInlineItem>&, unsigned index, unsigned offset);
void SetBidiLevel(UBiDiLevel);
static unsigned SetBidiLevel(Vector<NGInlineItem>&,
unsigned index,
unsigned end_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