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

Side by Side Diff: third_party/WebKit/Source/core/page/ContextMenuClient.cpp

Issue 2978823002: [SelectMiss...Async #2] Change ContextMenuClient::SelectMisspellingAsync() to return pair of strings (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 353 }
354 } 354 }
355 355
356 if (r.IsContentEditable()) { 356 if (r.IsContentEditable()) {
357 data.is_editable = true; 357 data.is_editable = true;
358 358
359 // Spellchecker adds spelling markers to misspelled words and attaches 359 // Spellchecker adds spelling markers to misspelled words and attaches
360 // suggestions to these markers in the background. Therefore, when a 360 // suggestions to these markers in the background. Therefore, when a
361 // user right-clicks a mouse on a word, Chrome just needs to find a 361 // user right-clicks a mouse on a word, Chrome just needs to find a
362 // spelling marker on the word instead of spellchecking it. 362 // spelling marker on the word instead of spellchecking it.
363 String description; 363 Optional<std::pair<String, String>> misspelled_word_and_description =
364 data.misspelled_word = 364 selected_frame->GetSpellChecker().SelectMisspellingAsync();
365 selected_frame->GetSpellChecker().SelectMisspellingAsync(description); 365 data.misspelled_word = misspelled_word_and_description
yosin_UTC9 2017/07/20 01:00:54 Because both |data.misspell_word| and |description
366 ? misspelled_word_and_description.value().first
367 : String();
368 const String& description =
369 misspelled_word_and_description
370 ? misspelled_word_and_description.value().second
371 : String();
366 if (description.length()) { 372 if (description.length()) {
367 Vector<String> suggestions; 373 Vector<String> suggestions;
368 description.Split('\n', suggestions); 374 description.Split('\n', suggestions);
369 data.dictionary_suggestions = suggestions; 375 data.dictionary_suggestions = suggestions;
370 } else if (selected_web_frame->TextCheckClient()) { 376 } else if (selected_web_frame->TextCheckClient()) {
371 int misspelled_offset, misspelled_length; 377 int misspelled_offset, misspelled_length;
372 selected_web_frame->TextCheckClient()->CheckSpelling( 378 selected_web_frame->TextCheckClient()->CheckSpelling(
373 data.misspelled_word, misspelled_offset, misspelled_length, 379 data.misspelled_word, misspelled_offset, misspelled_length,
374 &data.dictionary_suggestions); 380 &data.dictionary_suggestions);
375 } 381 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 output_items[i] = sub_items[i]; 514 output_items[i] = sub_items[i];
509 sub_menu_items.Swap(output_items); 515 sub_menu_items.Swap(output_items);
510 } 516 }
511 517
512 void ContextMenuClient::PopulateCustomMenuItems(const ContextMenu* default_menu, 518 void ContextMenuClient::PopulateCustomMenuItems(const ContextMenu* default_menu,
513 WebContextMenuData* data) { 519 WebContextMenuData* data) {
514 PopulateSubMenuItems(default_menu->Items(), data->custom_items); 520 PopulateSubMenuItems(default_menu->Items(), data->custom_items);
515 } 521 }
516 522
517 } // namespace blink 523 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698