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

Unified Diff: third_party/WebKit/Source/core/page/ContextMenuClient.cpp

Issue 2966223003: [SelectMisspellingAsync #1] Move SelectMisspellingAsync() from ContextMenuClient.cpp to SpellChecker (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/page/ContextMenuClient.cpp
diff --git a/third_party/WebKit/Source/core/page/ContextMenuClient.cpp b/third_party/WebKit/Source/core/page/ContextMenuClient.cpp
index 63c57f1f7075f749ac2be5bc7202240df8acd31d..9f87cba674fb345d002b86468b3a57afed5c9422 100644
--- a/third_party/WebKit/Source/core/page/ContextMenuClient.cpp
+++ b/third_party/WebKit/Source/core/page/ContextMenuClient.cpp
@@ -103,41 +103,6 @@ static WebURL UrlFromFrame(LocalFrame* frame) {
return WebURL();
}
-static bool IsWhiteSpaceOrPunctuation(UChar c) {
- return IsSpaceOrNewline(c) || WTF::Unicode::IsPunct(c);
-}
-
-static String SelectMisspellingAsync(LocalFrame* selected_frame,
- String& description) {
- const Optional<std::pair<Node*, SpellCheckMarker*>>& node_and_marker =
- selected_frame->GetSpellChecker().GetSpellCheckMarkerUnderSelection();
- if (!node_and_marker)
- return String();
-
- Node* const marker_node = node_and_marker.value().first;
- const SpellCheckMarker* const marker = node_and_marker.value().second;
- description = marker->Description();
-
- Range* const marker_range =
- Range::Create(*selected_frame->GetDocument(), marker_node,
- marker->StartOffset(), marker_node, marker->EndOffset());
-
- VisibleSelection selection =
- selected_frame->Selection().ComputeVisibleSelectionInDOMTree();
- // Caret and range selections (one of which we must have since we found a
- // marker) always return valid normalized ranges.
- const EphemeralRange& selection_range =
- selection.ToNormalizedEphemeralRange();
-
- if (marker_range->GetText().StripWhiteSpace(&IsWhiteSpaceOrPunctuation) !=
- CreateRange(selection_range)
- ->GetText()
- .StripWhiteSpace(&IsWhiteSpaceOrPunctuation))
- return String();
-
- return marker_range->GetText();
-}
-
// static
int ContextMenuClient::ComputeEditFlags(Document& selected_document,
Editor& editor) {
@@ -396,7 +361,8 @@ bool ContextMenuClient::ShowContextMenu(const ContextMenu* default_menu,
// user right-clicks a mouse on a word, Chrome just needs to find a
// spelling marker on the word instead of spellchecking it.
String description;
- data.misspelled_word = SelectMisspellingAsync(selected_frame, description);
+ data.misspelled_word =
+ selected_frame->GetSpellChecker().SelectMisspellingAsync(description);
if (description.length()) {
Vector<String> suggestions;
description.Split('\n', suggestions);

Powered by Google App Engine
This is Rietveld 408576698