Changeset 141519 in webkit
- Timestamp:
- Jan 31, 2013 6:05:18 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141514 r141519 1 2013-01-31 Rouslan Solomakhin <rouslan@chromium.org> 2 3 [Chromium] Expect spellcheck to select multi-word misspelling on context click 4 https://bugs.webkit.org/show_bug.cgi?id=108509 5 6 Reviewed by Tony Chang. 7 8 * editing/spelling/spelling-exactly-selected-multiple-words.html: Check spelling suggestion for multi-word misspelling. 9 * editing/spelling/spelling-should-select-multiple-words.html: Check spelling suggestion for multi-word misspelling. 10 * editing/spelling/spelling-exactly-selected-multiple-words-expected.txt: 11 * editing/spelling/spelling-should-select-multiple-words-expected.txt: 12 * platform/chromium/TestExpectations: Expect spellcheck to select multi-word misspelling on context click 13 1 14 2013-01-31 Christopher Cameron <ccameron@chromium.org> 2 15 -
trunk/LayoutTests/editing/spelling/spelling-exactly-selected-multiple-words-expected.txt
r141354 r141519 9 9 PASS spellingMarkerRange.toString() is "upper case" 10 10 PASS window.getSelection().toString() is "upper case" 11 PASS contextMenuElements[contextMenuElements.length - 1] is "uppercase" 11 12 PASS successfullyParsed is true 12 13 -
trunk/LayoutTests/editing/spelling/spelling-exactly-selected-multiple-words.html
r141354 r141519 40 40 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case"); 41 41 shouldBeEqualToString("window.getSelection().toString()", "upper case"); 42 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "uppercase"); 42 43 }); 43 44 -
trunk/LayoutTests/editing/spelling/spelling-should-select-multiple-words-expected.txt
r141354 r141519 8 8 PASS spellingMarkerRange.toString() is "upper case" 9 9 PASS window.getSelection().toString() is "upper case" 10 PASS contextMenuElements[contextMenuElements.length - 1] is "uppercase" 10 11 PASS successfullyParsed is true 11 12 -
trunk/LayoutTests/editing/spelling/spelling-should-select-multiple-words.html
r141354 r141519 31 31 shouldBeEqualToString("spellingMarkerRange.toString()", "upper case"); 32 32 shouldBeEqualToString("window.getSelection().toString()", "upper case"); 33 shouldBeEqualToString("contextMenuElements[contextMenuElements.length - 1]", "uppercase"); 33 34 }); 34 35 -
trunk/LayoutTests/platform/chromium/TestExpectations
r141479 r141519 4358 4358 webkit.org/b/108370 editing/spelling/spelling-double-clicked-word.html [ Failure ] 4359 4359 webkit.org/b/108370 editing/spelling/spelling-double-clicked-word-with-underscores.html [ Failure ] 4360 webkit.org/b/108370 editing/spelling/spelling-should-select-multiple-words.html [ Failure ]4361 4360 webkit.org/b/108370 editing/spelling/spelling-with-punctuation-selection.html [ Failure ] 4362 4361 webkit.org/b/108370 editing/spelling/spelling-with-underscore-selection.html [ Failure ] -
trunk/Source/WebKit/chromium/ChangeLog
r141496 r141519 1 2013-01-31 Rouslan Solomakhin <rouslan@chromium.org> 2 3 [Chromium] Select multi-word misspelling on context click 4 https://bugs.webkit.org/show_bug.cgi?id=108509 5 6 Reviewed by Tony Chang. 7 8 * src/ContextMenuClientImpl.cpp: 9 (WebKit): 10 (WebKit::selectMisspellingAsync): Added utility function to get the misspelling for asynchronous spellcheck. 11 (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): Select multi-word misspelling on context click. 12 1 13 2013-01-31 Florin Malita <fmalita@chromium.org> 2 14 -
trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp
r138216 r141519 41 41 #include "Editor.h" 42 42 #include "EventHandler.h" 43 #include "ExceptionCodePlaceholder.h" 43 44 #include "FrameLoader.h" 44 45 #include "FrameView.h" … … 103 104 104 105 // Helper function to get misspelled word on which context menu 105 // is to be evolked. This function also sets the word on which context menu106 // has been evoked to be the selected word, as required. This function changes106 // is to be invoked. This function also sets the word on which context menu 107 // has been invoked to be the selected word, as required. This function changes 107 108 // the selection only when there were no selected characters on OS X. 108 109 static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame) … … 142 143 #endif 143 144 return misspelledWord; 145 } 146 147 static String selectMisspellingAsync(Frame* selectedFrame, Vector<DocumentMarker*>& markers) 148 { 149 VisibleSelection selection = selectedFrame->selection()->selection(); 150 if (!selection.isCaretOrRange()) 151 return String(); 152 153 // Caret and range selections always return valid normalized ranges. 154 RefPtr<Range> selectionRange = selection.toNormalizedRange(); 155 markers.append(selectedFrame->document()->markers()->markersInRange(selectionRange.get(), DocumentMarker::Spelling | DocumentMarker::Grammar)); 156 if (markers.size() != 1) 157 return String(); 158 159 // Cloning a range fails only for invalid ranges. 160 RefPtr<Range> markerRange = selectionRange->cloneRange(ASSERT_NO_EXCEPTION); 161 markerRange->setStart(markerRange->startContainer(), markers[0]->startOffset()); 162 markerRange->setEnd(markerRange->endContainer(), markers[0]->endOffset()); 163 if (selection.isCaret()) { 164 selection = VisibleSelection(markerRange.get()); 165 selectedFrame->selection()->setSelection(selection, WordGranularity); 166 selectionRange = selection.toNormalizedRange(); 167 } 168 169 if (!WebCore::areRangesEqual(markerRange.get(), selectionRange.get())) 170 return String(); 171 172 return markerRange->text(); 144 173 } 145 174 … … 275 304 // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled 276 305 // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks 277 // a mouse on a word, Chrome just needs to find a spelling marker on the word inst read of spellchecking it.306 // a mouse on a word, Chrome just needs to find a spelling marker on the word instead of spellchecking it. 278 307 if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) { 279 VisibleSelection selection = selectedFrame->selection()->selection(); 280 bool shouldUpdateSelection = false; 281 if (selection.isCaretOrRange()) { 282 if (selection.isCaret()) { 283 selection.expandUsingGranularity(WordGranularity); 284 shouldUpdateSelection = true; 285 } 286 RefPtr<Range> range = selection.toNormalizedRange(); 287 Vector<DocumentMarker*> markers = selectedFrame->document()->markers()->markersInRange(range.get(), DocumentMarker::Spelling | DocumentMarker::Grammar); 288 if (markers.size() == 1) { 289 if (markers[0]->startOffset() != static_cast<unsigned>(range->startOffset()) || markers[0]->endOffset() != static_cast<unsigned>(range->endOffset())) 290 markers.clear(); 291 } 292 if (markers.size() == 1) { 293 range->setStart(range->startContainer(), markers[0]->startOffset()); 294 range->setEnd(range->endContainer(), markers[0]->endOffset()); 295 data.misspelledWord = range->text(); 296 if (markers[0]->description().length()) { 297 Vector<String> suggestions; 298 markers[0]->description().split('\n', suggestions); 299 data.dictionarySuggestions = suggestions; 300 } else if (m_webView->spellCheckClient()) { 301 int misspelledOffset, misspelledLength; 302 m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); 303 } 304 selection = VisibleSelection(range.get()); 305 if (shouldUpdateSelection && selectedFrame->selection()->shouldChangeSelection(selection)) 306 selectedFrame->selection()->setSelection(selection, WordGranularity); 307 } 308 Vector<DocumentMarker*> markers; 309 data.misspelledWord = selectMisspellingAsync(selectedFrame, markers); 310 if (markers.size() == 1 && markers[0]->description().length()) { 311 Vector<String> suggestions; 312 markers[0]->description().split('\n', suggestions); 313 data.dictionarySuggestions = suggestions; 314 } else if (m_webView->spellCheckClient()) { 315 int misspelledOffset, misspelledLength; 316 m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); 308 317 } 309 318 } else { -
trunk/Tools/ChangeLog
r141515 r141519 1 2013-01-31 Rouslan Solomakhin <rouslan@chromium.org> 2 3 [Chromium] Suggest 'uppercase' for multi-word misspelling 'upper case' 4 https://bugs.webkit.org/show_bug.cgi?id=108509 5 6 Reviewed by Tony Chang. 7 8 * DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp: 9 (append): Added utility function to append WebString to WebVector. 10 (MockSpellCheck::fillSuggestionList): Suggest 'uppercase' for misspelling 'upper case'. 11 1 12 2013-01-31 David Farler <dfarler@apple.com> 2 13 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/MockSpellCheck.cpp
r141478 r141519 37 37 38 38 using namespace WebKit; 39 40 static void append(WebVector<WebString>* data, const WebString& item) 41 { 42 WebVector<WebString> result(data->size() + 1); 43 for (size_t i = 0; i < data->size(); ++i) 44 result[i] = (*data)[i]; 45 result[data->size()] = item; 46 data->swap(result); 47 } 39 48 40 49 MockSpellCheck::MockSpellCheck() … … 108 117 void MockSpellCheck::fillSuggestionList(const WebString& word, WebVector<WebString>* suggestions) 109 118 { 110 if (word == WebString::fromUTF8("wellcome")) { 111 WebVector<WebString> result(suggestions->size() + 1); 112 for (size_t i = 0; i < suggestions->size(); ++i) 113 result[i] = (*suggestions)[i]; 114 result[suggestions->size()] = WebString::fromUTF8("welcome"); 115 suggestions->swap(result); 116 } 119 if (word == WebString::fromUTF8("wellcome")) 120 append(suggestions, WebString::fromUTF8("welcome")); 121 else if (word == WebString::fromUTF8("upper case")) 122 append(suggestions, WebString::fromUTF8("uppercase")); 117 123 } 118 124
Note: See TracChangeset
for help on using the changeset viewer.