Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2857173003: Remove DocumentMarkerController::MarkersInRange() (Closed)
Patch Set: Fix WebFrameTest.cpp Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
index 71a48a56cc62fbfd9098153f1efa18d809a453f9..390ea155cee6ba45703c2c2ddcf9ad02dc8f9a2e 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -802,17 +802,44 @@ void SpellChecker::ReplaceMisspelledRange(const String& text) {
.ToNormalizedEphemeralRange();
if (caret_range.IsNull())
return;
- DocumentMarkerVector markers =
- GetFrame().GetDocument()->Markers().MarkersInRange(
- caret_range, DocumentMarker::MisspellingMarkers());
- if (markers.size() < 1 ||
- markers[0]->StartOffset() >= markers[0]->EndOffset())
+
+ Node* caret_start_container =
+ caret_range.StartPosition().ComputeContainerNode();
+ const unsigned caret_start_offset =
+ caret_range.StartPosition().ComputeOffsetInContainerNode();
+ Node* caret_end_container = caret_range.EndPosition().ComputeContainerNode();
+ const unsigned caret_end_offset =
+ caret_range.EndPosition().ComputeOffsetInContainerNode();
+
+ Node* found_marker_anchor_node = nullptr;
+ const DocumentMarker* found_marker = nullptr;
+ for (Node& node : caret_range.Nodes()) {
Xiaocheng 2017/05/10 22:54:22 Since we do not plan to support the case where a m
rlanday 2017/05/10 23:17:57 I don't think that's correct; the misspelling coul
Xiaocheng 2017/05/10 23:23:42 1. caret_range has been adjusted by ToNormalizedEp
rlanday 2017/05/10 23:25:43 Ah, OK, I'll change it
+ if (found_marker)
+ break;
+
+ const DocumentMarkerVector& markers_in_node =
+ GetFrame().GetDocument()->Markers().MarkersFor(
+ &node, DocumentMarker::MisspellingMarkers());
+ for (DocumentMarker* marker : markers_in_node) {
+ if (&node == caret_start_container &&
+ marker->EndOffset() <= caret_start_offset)
+ continue;
+ if (&node == caret_end_container &&
+ marker->StartOffset() >= caret_end_offset)
+ continue;
+
+ found_marker_anchor_node = &node;
+ found_marker = markers_in_node[0];
+ break;
+ }
+ }
+
+ if (!found_marker)
return;
+
EphemeralRange marker_range = EphemeralRange(
- Position(caret_range.StartPosition().ComputeContainerNode(),
Xiaocheng 2017/05/10 22:54:22 Note that the existing code doesn't work if the st
- markers[0]->StartOffset()),
- Position(caret_range.EndPosition().ComputeContainerNode(),
- markers[0]->EndOffset()));
+ Position(found_marker_anchor_node, found_marker->StartOffset()),
+ Position(found_marker_anchor_node, found_marker->EndOffset()));
if (marker_range.IsNull())
return;

Powered by Google App Engine
This is Rietveld 408576698