Commit 5376bde3 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Don't optimize NGInlineNode::SetTextWithOffset() when text content contains bidi control codes

This patch changes |NGInlineNode::SetTextWithOffset()| not to reuse existing
data because we can't figure out insert position of bidi control codes
before/after editing.

Example: For <pre><b dir=ltr>\nXYZ</b></pre>, we have
  \u2066\u2069\n\u2066XYZ\u2069
after removing "\n", we have
  \u2066XYZ\u2069

Bug: 1039143
Change-Id: Iba443f0228bece9e8b08fc8f49d827565073d159
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1991037
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729669}
parent ccc82369
......@@ -153,6 +153,21 @@ TEST_F(LayoutNGTextTest, SetTextWithOffsetDeleteRTL2) {
GetItemsAsString(*text.GetLayoutObject()));
}
// http://crbug.com/1039143
TEST_F(LayoutNGTextTest, SetTextWithOffsetDeleteWithBidiControl) {
if (!RuntimeEnabledFeatures::LayoutNGEnabled())
return;
// In text content, we have bidi control codes:
// U+2066 U+2069 \n U+2066 abc U+2066
SetBodyInnerHTML(u"<pre><b id=target dir=ltr>\nabc</b></pre>");
Text& text = To<Text>(*GetElementById("target")->firstChild());
text.deleteData(0, 1, ASSERT_NO_EXCEPTION); // remove "\n"
EXPECT_EQ("LayoutText has NeedsCollectInlines",
GetItemsAsString(*text.GetLayoutObject()));
}
TEST_F(LayoutNGTextTest, SetTextWithOffsetInsert) {
if (!RuntimeEnabledFeatures::LayoutNGEnabled())
return;
......
......@@ -528,6 +528,11 @@ class NGInlineNodeDataEditor final {
if (layout_text_.StyleRef().TextSecurity() != ETextSecurity::kNone)
return nullptr;
// It is hard to figure differences of bidi control codes before/after
// editing. See http://crbug.com/1039143
if (layout_text_.HasBidiControlInlineItems())
return nullptr;
// Note: We should compute offset mapping before calling
// |LayoutBlockFlow::TakeNGInlineNodeData()|
const NGOffsetMapping* const offset_mapping =
......
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