Commit 585308f4 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

[NGFragmentItem] Fix hit test on left edge of RTL inline element

This patch changes |NGInlineCursor::PositionForPointInInlineBox()| to call
|NGInlineCursor::PositionForPoint()| for |closest_child_after| like it does
fro |closest_child_before| to make hit test on left edge of RTL inline element
to pass the test[1].

This patch also changes |NGFragmentItem::PositionForPointInText()| to avoid
calculating position for items of |IsGeneratedText()|, e.g. ::before/::after.

This is follow-up of the CL[2] which introduces calling |PositionForPoint()|
for |closest_child_before|.

[1] editing/selection/caret-at-bidi-boundary.html
[2] http://crrev.com/c/2104812 [NGFragmentItem] Fix hit test on
position:relative inline element

Bug: 707656
Change-Id: I8aca51af66a7d1885b7b7c2627cd7f4131b37c47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2282721
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786076}
parent db4e961e
...@@ -561,6 +561,8 @@ PositionWithAffinity NGFragmentItem::PositionForPointInText( ...@@ -561,6 +561,8 @@ PositionWithAffinity NGFragmentItem::PositionForPointInText(
const NGInlineCursor& cursor) const { const NGInlineCursor& cursor) const {
DCHECK_EQ(Type(), kText); DCHECK_EQ(Type(), kText);
DCHECK_EQ(cursor.CurrentItem(), this); DCHECK_EQ(cursor.CurrentItem(), this);
if (IsGeneratedText())
return PositionWithAffinity();
const unsigned text_offset = TextOffsetForPoint(point, cursor.Items()); const unsigned text_offset = TextOffsetForPoint(point, cursor.Items());
const NGCaretPosition unadjusted_position{ const NGCaretPosition unadjusted_position{
cursor, NGCaretPositionType::kAtTextOffset, text_offset}; cursor, NGCaretPositionType::kAtTextOffset, text_offset};
......
...@@ -869,8 +869,15 @@ PositionWithAffinity NGInlineCursor::PositionForPointInInlineBox( ...@@ -869,8 +869,15 @@ PositionWithAffinity NGInlineCursor::PositionForPointInInlineBox(
if (const PositionWithAffinity child_position = if (const PositionWithAffinity child_position =
descendants.PositionForPointInChild(point)) descendants.PositionForPointInChild(point))
return child_position; return child_position;
// TODO(yosin): we should do like "closest_child_before" once we have a if (closest_child_after->BoxFragment()) {
// case. // Hit test at left of "12"[1] and after "cd"[2] reache here.
// "<span dir="rtl">12<b>&#x05E7;&#x05D0;43</b></span>ab"
// [1] "editing/selection/caret-at-bidi-boundary.html"
// [2] HitTestingTest.PseudoElementAfter
if (const PositionWithAffinity child_position =
descendants.PositionForPointInInlineBox(point))
return child_position;
}
} }
if (closest_child_before) { if (closest_child_before) {
...@@ -881,7 +888,9 @@ PositionWithAffinity NGInlineCursor::PositionForPointInInlineBox( ...@@ -881,7 +888,9 @@ PositionWithAffinity NGInlineCursor::PositionForPointInInlineBox(
if (closest_child_before->BoxFragment()) { if (closest_child_before->BoxFragment()) {
// LayoutViewHitTest.HitTestHorizontal "Top-right corner (outside) of div" // LayoutViewHitTest.HitTestHorizontal "Top-right corner (outside) of div"
// reach here. // reach here.
return descendants.PositionForPointInInlineBox(point); if (const PositionWithAffinity child_position =
descendants.PositionForPointInInlineBox(point))
return child_position;
} }
} }
......
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