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

Work around reversed word range in DocumentMarkerController::FirstMarkerAroundPosition

There are some crashes in the function due to legacy implemetation of
StartOfWord() creating invalid/legacy positions, which lead to reversed
word ranges.

This patch adds handling of reversed word ranges so that we don't crash,
before switching StartOfWord() to proper implementation.

Bug: 886589
Change-Id: I8ad988247c6e4ab4a4a7cf90675d7df5f326f56f
Reviewed-on: https://chromium-review.googlesource.com/c/1298018Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602474}
parent a2603add
......@@ -407,7 +407,13 @@ DocumentMarker* DocumentMarkerController::FirstMarkerAroundPosition(
const PositionInFlatTree end =
end_of_word_or_null.IsNotNull() ? end_of_word_or_null : position;
DCHECK_LE(start, end) << "|start| should be before |end|.";
if (start > end) {
// TODO(crbug.com/778507): We shouldn't reach here, but currently do due to
// legacy implementation of StartOfWord(). Rewriting StartOfWord() with
// TextOffsetMapping should fix it.
NOTREACHED() << "|start| should be before |end|.";
return nullptr;
}
const Node* const start_node = start.ComputeContainerNode();
const unsigned start_offset = start.ComputeOffsetInContainerNode();
......
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