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

Unified Diff: third_party/WebKit/Source/web/ContextMenuClientImpl.cpp

Issue 2857173003: Remove DocumentMarkerController::MarkersInRange() (Closed)
Patch Set: Remove MarkersInRange() 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/web/ContextMenuClientImpl.cpp
diff --git a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
index f5151fa215c236921294a946d95afa6d4661da0d..2fac29bf0389c9f704e94483f0b9be784d614039 100644
--- a/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
+++ b/third_party/WebKit/Source/web/ContextMenuClientImpl.cpp
@@ -112,23 +112,36 @@ static String SelectMisspellingAsync(LocalFrame* selected_frame,
return String();
// Caret and range selections always return valid normalized ranges.
- Range* selection_range = CreateRange(selection.ToNormalizedEphemeralRange());
- DocumentMarkerVector markers =
- selected_frame->GetDocument()->Markers().MarkersInRange(
- EphemeralRange(selection_range),
- DocumentMarker::MisspellingMarkers());
- if (markers.size() != 1)
+ const EphemeralRange& selection_range =
+ selection.ToNormalizedEphemeralRange();
+
+ Node* found_marker_anchor_node = nullptr;
+ const DocumentMarker* found_marker = nullptr;
+ for (Node& node : selection_range.Nodes()) {
+ const DocumentMarkerVector& markers_in_node =
+ selected_frame->GetDocument()->Markers().MarkersFor(
+ &node, DocumentMarker::MisspellingMarkers());
+ if (!markers_in_node.IsEmpty()) {
+ found_marker_anchor_node = &node;
+ found_marker = markers_in_node[0];
+ break;
+ }
+ }
+
+ if (!found_marker)
return String();
- description = markers[0]->Description();
- // Cloning a range fails only for invalid ranges.
- Range* marker_range = selection_range->cloneRange();
- marker_range->setStart(marker_range->startContainer(),
- markers[0]->StartOffset());
- marker_range->setEnd(marker_range->endContainer(), markers[0]->EndOffset());
+ description = found_marker->Description();
+
+ Range* marker_range =
+ Range::Create(*selected_frame->GetDocument(), found_marker_anchor_node,
+ found_marker->StartOffset(), found_marker_anchor_node,
+ found_marker->EndOffset());
if (marker_range->GetText().StripWhiteSpace(&IsWhiteSpaceOrPunctuation) !=
- selection_range->GetText().StripWhiteSpace(&IsWhiteSpaceOrPunctuation))
+ CreateRange(selection_range)
+ ->GetText()
+ .StripWhiteSpace(&IsWhiteSpaceOrPunctuation))
return String();
return marker_range->GetText();

Powered by Google App Engine
This is Rietveld 408576698