Commit 954a7e79 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix bidi-reordering not to break inline box nesting

This patch fixes bidi-reordering to compute children of
inline boxes correctly. r728439 <crrev.com/c/1980663> broke
the computation when two inline boxes are adjacent without any
text/spaces between them,

Bug: 1040884
Change-Id: I0368a94b3b2d4cabd62bd82e1114fcadabf81acc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000399
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731860}
parent 12a2fb8d
......@@ -371,19 +371,23 @@ void NGInlineLayoutStateStack::PrepareForReorder(
DCHECK((*line_box)[box_data.fragment_start].IsPlaceholder());
for (unsigned i = box_data.fragment_start; i < box_data.fragment_end; i++) {
NGLineBoxFragmentBuilder::Child& child = (*line_box)[i];
if (!child.box_data_index)
unsigned child_box_data_index = child.box_data_index;
if (!child_box_data_index) {
child.box_data_index = box_data_index;
}
continue;
}
// When boxes are nested, placeholders have indexes to which box it should be
// added. Copy them to BoxData.
for (BoxData& box_data : box_data_list_) {
if (!box_data.fragment_start)
continue;
const NGLineBoxFragmentBuilder::Child& parent =
(*line_box)[box_data.fragment_start - 1];
box_data.parent_box_data_index = parent.box_data_index;
// This |box_data| has child boxes. Set up |parent_box_data_index| to
// represent the box nesting structure.
while (child_box_data_index != box_data_index) {
BoxData* child_box_data = &box_data_list_[child_box_data_index - 1];
child_box_data_index = child_box_data->parent_box_data_index;
if (!child_box_data_index) {
child_box_data->parent_box_data_index = box_data_index;
break;
}
}
}
}
}
......
<!DOCTYPE html>
<style>
.container {
width: 300px;
background: pink;
}
div {
margin-bottom: 10px;
text-align: right;
}
.purple {
border: purple solid 5px;
}
.orange {
background: orange;
}
</style>
<body>
<div class="container">
<div>
<span class="purple">inspect</span><span class="orange">pause</span>
</div>
<div>
<span class="purple">inspect</span> <span class="orange">pause</span>
</div
<div>
<span class="purple">inspect<span class="orange">pause</span></span>
</div>
</div>
</body>
<!DOCTYPE html>
<title>CSS Test: Bidi reordering with inline boxes</title>
<link rel="match" href="bidi-span-003-ref.html">
<link rel="help" href="https://drafts.csswg.org/css2/visuren.html#direction">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<style>
.container {
width: 300px;
background: pink;
}
div {
margin-bottom: 10px;
}
.purple {
border: purple solid 5px;
}
.orange {
background: orange;
}
</style>
<body>
<div class="container">
<div dir=rtl>
<span class="purple">inspect</span><span class="orange">pause</span>
</div>
<div dir=rtl>
<span class="purple">inspect</span> <span class="orange">pause</span>
</div>
<div dir=rtl>
<span class="purple">inspect<span class="orange">pause</span></span>
</div>
</div>
</body>
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