Commit 3c092b03 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Replace |PositionForPoint| with |GetPosition|

This patch replaces two usages of |LayoutObject::PositionForPoint|
with |HitTestResult::GetPosition| because the former does not
support NG block fragmentation.

There are some minor differences in the behavior. But
according to yosin@, using |InnerPossiblyPseudoNode| instead
of |InnerNode| is most likely more correct.

Bug: 829028
Change-Id: I6fda4161f60e2cafb78c12370484bf464331a5f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2535530
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827152}
parent 6d12f2d8
......@@ -628,13 +628,8 @@ bool FrameSelection::Contains(const PhysicalOffset& point) {
HitTestLocation location(point);
HitTestResult result(request, location);
GetDocument().GetLayoutView()->HitTest(location, result);
Node* inner_node = result.InnerNode();
if (!inner_node || !inner_node->GetLayoutObject())
return false;
const PositionInFlatTreeWithAffinity pos_with_affinity =
FromPositionInDOMTree<EditingInFlatTreeStrategy>(
inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint()));
FromPositionInDOMTree<EditingInFlatTreeStrategy>(result.GetPosition());
if (pos_with_affinity.IsNull())
return false;
......
......@@ -1193,11 +1193,7 @@ void SelectionController::HandleGestureTwoFingerTap(
}
static bool HitTestResultIsMisspelled(const HitTestResult& result) {
Node* inner_node = result.InnerPossiblyPseudoNode();
if (!inner_node || !inner_node->GetLayoutObject())
return false;
PositionWithAffinity pos_with_affinity =
inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint());
PositionWithAffinity pos_with_affinity = result.GetPosition();
if (pos_with_affinity.IsNull())
return false;
// TODO(xiaochengh): Don't use |ParentAnchoredEquivalent()|.
......@@ -1205,8 +1201,9 @@ static bool HitTestResultIsMisspelled(const HitTestResult& result) {
pos_with_affinity.GetPosition().ParentAnchoredEquivalent();
if (!SpellChecker::IsSpellCheckingEnabledAt(marker_position))
return false;
return SpellCheckMarkerAtPosition(inner_node->GetDocument().Markers(),
ToPositionInFlatTree(marker_position));
return SpellCheckMarkerAtPosition(
result.InnerPossiblyPseudoNode()->GetDocument().Markers(),
ToPositionInFlatTree(marker_position));
}
template <typename MouseEventObject>
......
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