OLD | NEW |
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 if (r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) { | 272 if (r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) { |
273 data.isSpeechInputEnabled = | 273 data.isSpeechInputEnabled = |
274 static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isSpeech
Enabled(); | 274 static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isSpeech
Enabled(); |
275 } | 275 } |
276 #endif | 276 #endif |
277 // When Chrome enables asynchronous spellchecking, its spellchecker adds
spelling markers to misspelled | 277 // When Chrome enables asynchronous spellchecking, its spellchecker adds
spelling markers to misspelled |
278 // words and attaches suggestions to these markers in the background. Th
erefore, when a user right-clicks | 278 // words and attaches suggestions to these markers in the background. Th
erefore, when a user right-clicks |
279 // a mouse on a word, Chrome just needs to find a spelling marker on the
word instread of spellchecking it. | 279 // a mouse on a word, Chrome just needs to find a spelling marker on the
word instread of spellchecking it. |
280 if (selectedFrame->settings() && selectedFrame->settings()->asynchronous
SpellCheckingEnabled()) { | 280 if (selectedFrame->settings() && selectedFrame->settings()->asynchronous
SpellCheckingEnabled()) { |
281 VisibleSelection selection = selectedFrame->selection()->selection()
; | 281 VisibleSelection selection = selectedFrame->selection()->selection()
; |
282 if (selection.isCaretOrRange()) { | 282 if (selection.isCaret()) { |
283 if (selection.isCaret()) | 283 selection.expandUsingGranularity(WordGranularity); |
284 selection.expandUsingGranularity(WordGranularity); | |
285 RefPtr<Range> range = selection.toNormalizedRange(); | 284 RefPtr<Range> range = selection.toNormalizedRange(); |
286 Vector<DocumentMarker*> markers = selectedFrame->document()->mar
kers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::G
rammar); | 285 Vector<DocumentMarker*> markers = selectedFrame->document()->mar
kers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::G
rammar); |
287 if (markers.size() == 1) { | 286 if (markers.size() == 1) { |
288 range->setStart(range->startContainer(), markers[0]->startOf
fset()); | 287 range->setStart(range->startContainer(), markers[0]->startOf
fset()); |
289 range->setEnd(range->endContainer(), markers[0]->endOffset()
); | 288 range->setEnd(range->endContainer(), markers[0]->endOffset()
); |
290 data.misspelledWord = range->text(); | 289 data.misspelledWord = range->text(); |
291 if (markers[0]->description().length()) { | 290 if (markers[0]->description().length()) { |
292 Vector<String> suggestions; | 291 Vector<String> suggestions; |
293 markers[0]->description().split('\n', suggestions); | 292 markers[0]->description().split('\n', suggestions); |
294 data.dictionarySuggestions = suggestions; | 293 data.dictionarySuggestions = suggestions; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 outputItems[i] = subItems[i]; | 389 outputItems[i] = subItems[i]; |
391 subMenuItems.swap(outputItems); | 390 subMenuItems.swap(outputItems); |
392 } | 391 } |
393 | 392 |
394 void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaul
tMenu, WebContextMenuData* data) | 393 void ContextMenuClientImpl::populateCustomMenuItems(WebCore::ContextMenu* defaul
tMenu, WebContextMenuData* data) |
395 { | 394 { |
396 populateSubMenuItems(defaultMenu->platformDescription(), data->customItems); | 395 populateSubMenuItems(defaultMenu->platformDescription(), data->customItems); |
397 } | 396 } |
398 | 397 |
399 } // namespace WebKit | 398 } // namespace WebKit |
OLD | NEW |