Chromium Code Reviews| 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 7a59b4d5bd7f3b946578348d56c6e7f6b3f8b20f..a09357334b11c55b9f9ca6e96edc491764ab7af4 100644 |
| --- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
| +++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
| @@ -908,11 +908,11 @@ SpellChecker::GetSpellCheckMarkerTouchingSelection() { |
| return Optional<std::pair<Node*, SpellCheckMarker*>>(); |
| } |
| -String SpellChecker::SelectMisspellingAsync(String& description) { |
| +Optional<std::pair<String, String>> SpellChecker::SelectMisspellingAsync() { |
| VisibleSelection selection = |
| GetFrame().Selection().ComputeVisibleSelectionInDOMTree(); |
| if (selection.IsNone()) |
| - return String(); |
| + return Optional<std::pair<String, String>>(); |
|
yosin_UTC9
2017/07/20 01:00:54
I think we write |return {};|
Could you try this t
rlanday
2017/07/20 21:14:27
I am simplifying the implementation of this method
rlanday
2017/07/20 23:37:07
I've updated this CL to return {}
|
| // Caret and range selections always return valid normalized ranges. |
| const EphemeralRange& selection_range = |
| @@ -926,7 +926,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 Optional<std::pair<String, String>>(); |
| const unsigned selection_start_offset = |
| selection_range.StartPosition().ComputeOffsetInContainerNode(); |
| @@ -944,11 +944,9 @@ String SpellChecker::SelectMisspellingAsync(String& description) { |
| marker->EndOffset() > selection_start_offset; |
| }); |
| if (marker_it == markers_in_node.end()) |
| - return String(); |
| + return Optional<std::pair<String, String>>(); |
| const SpellCheckMarker* const found_marker = ToSpellCheckMarker(*marker_it); |
| - description = found_marker->Description(); |
| - |
| Range* const marker_range = |
| Range::Create(*GetFrame().GetDocument(), selection_start_container, |
| found_marker->StartOffset(), selection_start_container, |
| @@ -958,9 +956,9 @@ String SpellChecker::SelectMisspellingAsync(String& description) { |
| CreateRange(selection_range) |
| ->GetText() |
| .StripWhiteSpace(&IsWhiteSpaceOrPunctuation)) |
| - return String(); |
| + return Optional<std::pair<String, String>>(); |
| - return marker_range->GetText(); |
| + return std::make_pair(marker_range->GetText(), found_marker->Description()); |
| } |
| void SpellChecker::ReplaceMisspelledRange(const String& text) { |