Commit 6a93bb17 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Fix 'unicode-bidi: plaintext' handling in ComputeInlineBoxPosition

Existing code performs bidi adjustment for 'unicode-bidi: plaintext' only
for the right edge of InlineBoxes. This patch makes it handle both edges
to allow caret to appear at the left edge.

This patch also makes the bidi adjustment code symmetric for left and
right edge handling, so that we can de-duplicate in future refactoring.

Bug: 828657, 771398
Change-Id: I3fd22280327c7186fcfddfb0ba1bb13c4a5dfeff
Reviewed-on: https://chromium-review.googlesource.com/994389Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547987}
parent 59deb360
......@@ -162,6 +162,9 @@ InlineBoxPosition AdjustInlineBoxPositionForTextDirectionInternal(
if (inline_box->Direction() == primary_direction)
return AdjustInlineBoxPositionForPrimaryDirection(inline_box, caret_offset);
if (unicode_bidi == UnicodeBidi::kPlaintext)
return InlineBoxPosition(inline_box, caret_offset);
const unsigned char level = inline_box->BidiLevel();
if (caret_offset == inline_box->CaretLeftmostOffset()) {
InlineBox* const prev_box = inline_box->PrevLeafChildIgnoringLineBreak();
......@@ -183,9 +186,6 @@ InlineBoxPosition AdjustInlineBoxPositionForTextDirectionInternal(
return InlineBoxPosition(result_box, result_box->CaretLeftmostOffset());
}
if (unicode_bidi == UnicodeBidi::kPlaintext)
return InlineBoxPosition(inline_box, inline_box->CaretRightmostOffset());
InlineBox* const next_box = inline_box->NextLeafChildIgnoringLineBreak();
if (!next_box || next_box->BidiLevel() < level) {
// Right edge of a secondary run. Set to the left edge of the entire
......
......@@ -915,4 +915,15 @@ TEST_P(ParameterizedLocalCaretRectTest, AfterLineBreakInPreBlockRTLLineRTL) {
position_rect);
EXPECT_EQ(LayoutRect(299, 10, 1, 10), visible_position_rect);
};
TEST_P(ParameterizedLocalCaretRectTest,
UnicodeBidiPlaintextWithDifferentBlockDirection) {
LoadAhem();
InsertStyleElement("div { font: 10px/10px Ahem; unicode-bidi: plaintext }");
const Position position = SetCaretTextToBody("<div dir='rtl'>|abc</div>");
const LayoutRect caret_rect =
LocalCaretRectOfPosition(PositionWithAffinity(position)).rect;
EXPECT_EQ(LayoutRect(0, 0, 1, 10), caret_rect);
}
} // namespace blink
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