Commit 565c4156 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Workaround to avoid crashing in FrameSelection::SelectedText()

This patch introduces workaround to check invalid selection for avoiding crash
in |ComputeRangeForSerialization()| called by |FrameSelection::SelectedText()|.

When selection is none, both selection base and extent should be null. However,
we have invalid selection, one of base and extent is null, by some reasons.


Background: 
Bug: 1019152
Change-Id: I38717ede505eebb9c59229d5d2e14d75b50f24a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891819
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711162}
parent e8564ac4
...@@ -920,9 +920,17 @@ void FrameSelection::SetFocusedNodeIfNeeded() { ...@@ -920,9 +920,17 @@ void FrameSelection::SetFocusedNodeIfNeeded() {
} }
static EphemeralRangeInFlatTree ComputeRangeForSerialization( static EphemeralRangeInFlatTree ComputeRangeForSerialization(
const SelectionInDOMTree& selection) { const SelectionInDOMTree& selection_in_dom_tree) {
const EphemeralRangeInFlatTree& range = const SelectionInFlatTree& selection =
ConvertToSelectionInFlatTree(selection).ComputeRange(); ConvertToSelectionInFlatTree(selection_in_dom_tree);
// TODO(crbug.com/1019152): Once we know the root cause of having
// seleciton with |base.IsNull() != extent.IsNull()|, we should get rid of
// this if-statement.
if (selection.Base().IsNull() || selection.Extent().IsNull()) {
DCHECK(selection.IsNone());
return EphemeralRangeInFlatTree();
}
const EphemeralRangeInFlatTree& range = selection.ComputeRange();
const PositionInFlatTree& start = const PositionInFlatTree& start =
CreateVisiblePosition(range.StartPosition()).DeepEquivalent(); CreateVisiblePosition(range.StartPosition()).DeepEquivalent();
const PositionInFlatTree& end = const PositionInFlatTree& end =
......
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