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

[LayoutNG] Fix PDI/PDF not to affect line breaking

This patch fixes PDI/PDF before spaces not to suppress the
line breaking opportunity at the space. For example, before
this fix, `<bdo dir=ltr>a</bdo> b` could not break between
"a" and "b".

PDI and PDF are injected by the `unicode-bidi` property, or
elements that imply the `unicode-bidi` property such as
`<bdi>`, `<bdo>`, or any elements with `dir` attributes.

Bug: 989094
Change-Id: I2128774e2b062ecb86880812c54d46299a19a18a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1735146
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683881}
parent c5304aed
...@@ -1133,8 +1133,16 @@ void NGLineBreaker::HandleBidiControlItem(const NGInlineItem& item, ...@@ -1133,8 +1133,16 @@ void NGLineBreaker::HandleBidiControlItem(const NGInlineItem& item,
if (!item_results->IsEmpty()) { if (!item_results->IsEmpty()) {
NGInlineItemResult* item_result = AddItem(item, line_info); NGInlineItemResult* item_result = AddItem(item, line_info);
NGInlineItemResult* last = &(*item_results)[item_results->size() - 2]; NGInlineItemResult* last = &(*item_results)[item_results->size() - 2];
item_result->can_break_after = last->can_break_after; // Honor the last |can_break_after| if it's true, in case it was
last->can_break_after = false; // artificially set to true for break-after-space.
if (last->can_break_after) {
item_result->can_break_after = last->can_break_after;
last->can_break_after = false;
} else {
// Otherwise compute from the text. |LazyLineBreakIterator| knows how to
// break around bidi control characters.
ComputeCanBreakAfter(item_result, auto_wrap_, break_iterator_);
}
} else { } else {
AddItem(item, line_info); AddItem(item, line_info);
} }
......
<!DOCTYPE html>
<title>Test implicit bidi controls do not affect line breaking</title>
<link rel="help" href="https://drafts.csswg.org/css-writing-modes-3/#unicode-bidi">
<link rel="author" title="Koji Ishii" href="mailto:kojii@chromium.org">
<style>
html {
font-size: 10px;
line-height: 1;
}
.isolate {
unicode-bidi: isolate;
}
.embed {
unicode-bidi: embed;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id=log></div>
<div id="container">
<div style="width: 4ch" data-expected-height="20">
<span class="isolate" dir="ltr">00</span> <span class="isolate" dir="ltr">00</span>
</div>
<div style="width: 4ch" data-expected-height="20">
<span class="embed" dir="ltr">00</span> <span class="embed" dir="ltr">00</span>
</div>
<div style="width: 4ch" data-expected-height="20">
<span dir="ltr">00</span> <span dir="ltr">00</span>
</div>
<div style="width: 4ch" data-expected-height="20">
<bdi dir="ltr">00</bdi> <bdi dir="ltr">00</bdi>
</div>
<div style="width: 4ch" data-expected-height="20">
<bdo dir="ltr">00</bdo> <bdo dir="ltr">00</bdo>
</div>
<div style="width: 4ch" data-expected-height="20">
<span class="isolate" dir="ltr">00 </span><span class="isolate" dir="ltr">00</span>
</div>
<div style="width: 4ch" data-expected-height="20">
<span class="embed" dir="ltr">00 </span><span class="embed" dir="ltr">00</span>
</div>
</div>
<script>
run();
function run() {
for (let node of document.getElementById('container').children) {
test(() => {
assert_approx_equals(node.offsetHeight, 20, 1);
}, node.innerHTML);
}
}
</script>
</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