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

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

Issue 2978823002: [SelectMiss...Async #2] Change ContextMenuClient::SelectMisspellingAsync() to return pair of strings (Closed)
Patch Set: Rebase Created 3 years, 5 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 c279e5a3433bf1eb4657d5ec6037c7502d5aede7..5d3f1ac4187db1ed521da9a47178a5d77c28feda 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -838,7 +838,7 @@ SpellChecker::GetSpellCheckMarkerUnderSelection() {
const VisibleSelection& selection =
GetFrame().Selection().ComputeVisibleSelectionInDOMTree();
if (selection.IsNone())
- return Optional<std::pair<Node*, SpellCheckMarker*>>();
+ return {};
// Caret and range selections always return valid normalized ranges.
const EphemeralRange& selection_range = FirstEphemeralRangeOf(selection);
@@ -866,16 +866,16 @@ SpellChecker::GetSpellCheckMarkerUnderSelection() {
ToText(*selection_start_container), selection_start_offset,
selection_end_offset, DocumentMarker::MisspellingMarkers());
if (!marker)
- return Optional<std::pair<Node*, SpellCheckMarker*>>();
+ return {};
return std::make_pair(selection_start_container, ToSpellCheckMarker(marker));
}
-String SpellChecker::SelectMisspellingAsync(String& description) {
+std::pair<String, String> SpellChecker::SelectMisspellingAsync() {
VisibleSelection selection =
GetFrame().Selection().ComputeVisibleSelectionInDOMTree();
if (selection.IsNone())
- return String();
+ return {};
// Caret and range selections always return valid normalized ranges.
const EphemeralRange& selection_range =
@@ -889,7 +889,7 @@ String SpellChecker::SelectMisspellingAsync(String& description) {
// We don't currently support the case where a misspelling spans multiple
// nodes. See crbug.com/720065
if (selection_start_container != selection_end_container)
- return String();
+ return {};
const unsigned selection_start_offset =
selection_range.StartPosition().ComputeOffsetInContainerNode();
@@ -907,10 +907,9 @@ String SpellChecker::SelectMisspellingAsync(String& description) {
marker->EndOffset() > selection_start_offset;
});
if (marker_it == markers_in_node.end())
- return String();
+ return {};
const SpellCheckMarker* const found_marker = ToSpellCheckMarker(*marker_it);
- description = found_marker->Description();
Range* const marker_range =
Range::Create(*GetFrame().GetDocument(), selection_start_container,
@@ -921,9 +920,9 @@ String SpellChecker::SelectMisspellingAsync(String& description) {
CreateRange(selection_range)
->GetText()
.StripWhiteSpace(&IsWhiteSpaceOrPunctuation))
- return String();
+ return {};
- return marker_range->GetText();
+ return std::make_pair(marker_range->GetText(), found_marker->Description());
}
void SpellChecker::ReplaceMisspelledRange(const String& text) {

Powered by Google App Engine
This is Rietveld 408576698