Commit b6f6b015 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Make FrameSelection::Contains return false for null VisibleSelection in DOM tree

This is a workaround for crbug.com/845849.

In some buggy cases, we get ComputeVisibleSelectionInFlatTree() returning
non-null, but ComputeVisibleSelectionInDOMTree() returning null. This
makes FrameSelection::Contains() return true erroneously.

As we don't have a fix to the inconsistency, this patch adds a
workaround that, we call ComputeVisibleSelectionInDOMTree() first to
set the cached VisibleSelections to null also for flat tree, so that
the following computation does not work on a non-null VS in flat tree
erroneously.

Bug: 845849
Change-Id: I7255d8224b8b6e29d479dd635e2c4ee99b366fc1
Reviewed-on: https://chromium-review.googlesource.com/1072924Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561775}
parent c8cb9f20
......@@ -554,6 +554,14 @@ bool FrameSelection::Contains(const LayoutPoint& point) {
if (!GetDocument().GetLayoutView())
return false;
// This is a workaround of the issue that we sometimes get null from
// ComputeVisibleSelectionInDOMTree(), but non-null from flat tree.
// By running this, in case we get null, we also set the cached result in flat
// tree into null, so that this function can return false correctly.
// See crbug.com/846527 for details.
// TODO(editing-dev): Fix the inconsistency and then remove this call.
ComputeVisibleSelectionInDOMTree();
// Treat a collapsed selection like no selection.
const VisibleSelectionInFlatTree& visible_selection =
ComputeVisibleSelectionInFlatTree();
......
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