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

Side by Side Diff: Source/core/editing/SpellChecker.cpp

Issue 576073003: Removal of more temporary Range objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix build; accidentally removed .get() call Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/DOMSelection.cpp ('k') | Source/core/editing/TextCheckingHelper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection) 163 void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection)
164 { 164 {
165 // The basic approach is to search in two phases - from the selection end to the end of the doc, and 165 // The basic approach is to search in two phases - from the selection end to the end of the doc, and
166 // then we wrap and search from the doc start to (approximately) where we st arted. 166 // then we wrap and search from the doc start to (approximately) where we st arted.
167 167
168 // Start at the end of the selection, search to edge of document. Starting a t the selection end makes 168 // Start at the end of the selection, search to edge of document. Starting a t the selection end makes
169 // repeated "check spelling" commands work. 169 // repeated "check spelling" commands work.
170 VisibleSelection selection(m_frame.selection().selection()); 170 VisibleSelection selection(m_frame.selection().selection());
171 RefPtrWillBeRawPtr<Range> spellingSearchRange(rangeOfContents(m_frame.docume nt())); 171 Position spellingSearchStart, spellingSearchEnd;
172 Range::selectNodeContents(m_frame.document(), spellingSearchStart, spellingS earchEnd);
172 173
173 bool startedWithSelection = false; 174 bool startedWithSelection = false;
174 if (selection.start().deprecatedNode()) { 175 if (selection.start().deprecatedNode()) {
175 startedWithSelection = true; 176 startedWithSelection = true;
176 if (startBeforeSelection) { 177 if (startBeforeSelection) {
177 VisiblePosition start(selection.visibleStart()); 178 VisiblePosition start(selection.visibleStart());
178 // We match AppKit's rule: Start 1 character before the selection. 179 // We match AppKit's rule: Start 1 character before the selection.
179 VisiblePosition oneBeforeStart = start.previous(); 180 VisiblePosition oneBeforeStart = start.previous();
180 setStart(spellingSearchRange.get(), oneBeforeStart.isNotNull() ? one BeforeStart : start); 181 spellingSearchStart = (oneBeforeStart.isNotNull() ? oneBeforeStart : start).toParentAnchoredPosition();
181 } else { 182 } else {
182 setStart(spellingSearchRange.get(), selection.visibleEnd()); 183 spellingSearchStart = selection.visibleEnd().toParentAnchoredPositio n();
183 } 184 }
184 } 185 }
185 186
186 Position position = spellingSearchRange->startPosition(); 187 Position position = spellingSearchStart;
187 if (!isEditablePosition(position)) { 188 if (!isEditablePosition(position)) {
188 // This shouldn't happen in very often because the Spelling menu items a ren't enabled unless the 189 // This shouldn't happen in very often because the Spelling menu items a ren't enabled unless the
189 // selection is editable. 190 // selection is editable.
190 // This can happen in Mail for a mix of non-editable and editable conten t (like Stationary), 191 // This can happen in Mail for a mix of non-editable and editable conten t (like Stationary),
191 // when spell checking the whole document before sending the message. 192 // when spell checking the whole document before sending the message.
192 // In that case the document might not be editable, but there are editab le pockets that need to be spell checked. 193 // In that case the document might not be editable, but there are editab le pockets that need to be spell checked.
193 194
194 position = firstEditableVisiblePositionAfterPositionInRoot(position, m_f rame.document()->documentElement()).deepEquivalent(); 195 position = firstEditableVisiblePositionAfterPositionInRoot(position, m_f rame.document()->documentElement()).deepEquivalent();
195 if (position.isNull()) 196 if (position.isNull())
196 return; 197 return;
197 198
198 Position rangeCompliantPosition = position.parentAnchoredEquivalent(); 199 spellingSearchStart = position.parentAnchoredEquivalent();
199 spellingSearchRange->setStart(rangeCompliantPosition.deprecatedNode(), r angeCompliantPosition.deprecatedEditingOffset(), IGNORE_EXCEPTION);
200 startedWithSelection = false; // won't need to wrap 200 startedWithSelection = false; // won't need to wrap
201 } 201 }
202 202
203 // topNode defines the whole range we want to operate on 203 // topNode defines the whole range we want to operate on
204 ContainerNode* topNode = highestEditableRoot(position); 204 ContainerNode* topNode = highestEditableRoot(position);
205 // FIXME: lastOffsetForEditing() is wrong here if editingIgnoresContent(high estEditableRoot()) returns true (e.g. a <table>) 205 // FIXME: lastOffsetForEditing() is wrong here if editingIgnoresContent(high estEditableRoot()) returns true (e.g. a <table>)
206 spellingSearchRange->setEnd(topNode, lastOffsetForEditing(topNode), IGNORE_E XCEPTION); 206 spellingSearchEnd = createLegacyEditingPosition(topNode, lastOffsetForEditin g(topNode));
207 207
208 // If spellingSearchRange starts in the middle of a word, advance to the nex t word so we start checking 208 // If spellingSearchRange starts in the middle of a word, advance to the nex t word so we start checking
209 // at a word boundary. Going back by one char and then forward by a word doe s the trick. 209 // at a word boundary. Going back by one char and then forward by a word doe s the trick.
210 if (startedWithSelection) { 210 if (startedWithSelection) {
211 VisiblePosition oneBeforeStart = startVisiblePosition(spellingSearchRang e.get(), DOWNSTREAM).previous(); 211 VisiblePosition oneBeforeStart = VisiblePosition(spellingSearchStart, DOWNST REAM).previous();
212 if (oneBeforeStart.isNotNull()) 212 if (oneBeforeStart.isNotNull())
213 setStart(spellingSearchRange.get(), endOfWord(oneBeforeStart)); 213 spellingSearchStart = endOfWord(oneBeforeStart).toParentAnchoredPosi tion();
214 // else we were already at the start of the editable node 214 // else we were already at the start of the editable node
215 } 215 }
216 216
217 if (spellingSearchRange->collapsed()) 217 if (spellingSearchStart == spellingSearchEnd)
218 return; // nothing to search in 218 return; // nothing to search in
219 219
220 // We go to the end of our first range instead of the start of it, just to b e sure 220 // We go to the end of our first range instead of the start of it, just to b e sure
221 // we don't get foiled by any word boundary problems at the start. It means we might 221 // we don't get foiled by any word boundary problems at the start. It means we might
222 // do a tiny bit more searching. 222 // do a tiny bit more searching.
223 Node* searchEndNodeAfterWrap = spellingSearchRange->endContainer(); 223 Node* searchEndNodeAfterWrap = spellingSearchEnd.containerNode();
224 int searchEndOffsetAfterWrap = spellingSearchRange->endOffset(); 224 int searchEndOffsetAfterWrap = spellingSearchEnd.offsetInContainerNode();
225 225
226 int misspellingOffset = 0; 226 int misspellingOffset = 0;
227 GrammarDetail grammarDetail; 227 GrammarDetail grammarDetail;
228 int grammarPhraseOffset = 0; 228 int grammarPhraseOffset = 0;
229 RefPtrWillBeRawPtr<Range> grammarSearchRange = nullptr; 229 Position grammarSearchStart, grammarSearchEnd;
230 String badGrammarPhrase; 230 String badGrammarPhrase;
231 String misspelledWord; 231 String misspelledWord;
232 232
233 bool isSpelling = true; 233 bool isSpelling = true;
234 int foundOffset = 0; 234 int foundOffset = 0;
235 String foundItem; 235 String foundItem;
236 RefPtrWillBeRawPtr<Range> firstMisspellingRange = nullptr; 236 RefPtrWillBeRawPtr<Range> firstMisspellingRange = nullptr;
237 if (unifiedTextCheckerEnabled()) { 237 if (unifiedTextCheckerEnabled()) {
238 grammarSearchRange = spellingSearchRange->cloneRange(); 238 grammarSearchStart = spellingSearchStart;
239 foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchRange ).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, found Offset, grammarDetail); 239 grammarSearchEnd = spellingSearchEnd;
240 foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchStart , spellingSearchEnd).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabled() , isSpelling, foundOffset, grammarDetail);
240 if (isSpelling) { 241 if (isSpelling) {
241 misspelledWord = foundItem; 242 misspelledWord = foundItem;
242 misspellingOffset = foundOffset; 243 misspellingOffset = foundOffset;
243 } else { 244 } else {
244 badGrammarPhrase = foundItem; 245 badGrammarPhrase = foundItem;
245 grammarPhraseOffset = foundOffset; 246 grammarPhraseOffset = foundOffset;
246 } 247 }
247 } else { 248 } else {
248 misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSearch Range).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange); 249 misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSearch Start, spellingSearchEnd).findFirstMisspelling(misspellingOffset, false, firstMi sspellingRange);
249 grammarSearchRange = spellingSearchRange->cloneRange(); 250 grammarSearchStart = spellingSearchStart;
251 grammarSearchEnd = spellingSearchEnd;
250 if (!misspelledWord.isEmpty()) { 252 if (!misspelledWord.isEmpty()) {
251 // Stop looking at start of next misspelled word 253 // Stop looking at start of next misspelled word
252 CharacterIterator chars(grammarSearchRange.get()); 254 CharacterIterator chars(grammarSearchStart, grammarSearchEnd);
253 chars.advance(misspellingOffset); 255 chars.advance(misspellingOffset);
254 grammarSearchRange->setEnd(chars.startContainer(), chars.startOffset (), IGNORE_EXCEPTION); 256 grammarSearchEnd = chars.startPosition();
255 } 257 }
256 258
257 if (isGrammarCheckingEnabled()) 259 if (isGrammarCheckingEnabled())
258 badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), grammarS earchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false); 260 badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), grammarS earchStart, grammarSearchEnd).findFirstBadGrammar(grammarDetail, grammarPhraseOf fset, false);
259 } 261 }
260 262
261 // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the 263 // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the
262 // block rather than at a selection). 264 // block rather than at a selection).
263 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) { 265 if (startedWithSelection && !misspelledWord && !badGrammarPhrase) {
264 spellingSearchRange->setStart(topNode, 0, IGNORE_EXCEPTION); 266 spellingSearchStart = createLegacyEditingPosition(topNode, 0);
265 // going until the end of the very first chunk we tested is far enough 267 // going until the end of the very first chunk we tested is far enough
266 spellingSearchRange->setEnd(searchEndNodeAfterWrap, searchEndOffsetAfter Wrap, IGNORE_EXCEPTION); 268 spellingSearchEnd = createLegacyEditingPosition(searchEndNodeAfterWrap, searchEndOffsetAfterWrap);
267 269
268 if (unifiedTextCheckerEnabled()) { 270 if (unifiedTextCheckerEnabled()) {
269 grammarSearchRange = spellingSearchRange->cloneRange(); 271 grammarSearchStart = spellingSearchStart;
270 foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchR ange).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabled(), isSpelling, f oundOffset, grammarDetail); 272 grammarSearchEnd = spellingSearchEnd;
273 foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchS tart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(isGrammarCheckingEnabl ed(), isSpelling, foundOffset, grammarDetail);
271 if (isSpelling) { 274 if (isSpelling) {
272 misspelledWord = foundItem; 275 misspelledWord = foundItem;
273 misspellingOffset = foundOffset; 276 misspellingOffset = foundOffset;
274 } else { 277 } else {
275 badGrammarPhrase = foundItem; 278 badGrammarPhrase = foundItem;
276 grammarPhraseOffset = foundOffset; 279 grammarPhraseOffset = foundOffset;
277 } 280 }
278 } else { 281 } else {
279 misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSe archRange).findFirstMisspelling(misspellingOffset, false, firstMisspellingRange) ; 282 misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSe archStart, spellingSearchEnd).findFirstMisspelling(misspellingOffset, false, fir stMisspellingRange);
280 grammarSearchRange = spellingSearchRange->cloneRange(); 283 grammarSearchStart = spellingSearchStart;
284 grammarSearchEnd = spellingSearchEnd;
281 if (!misspelledWord.isEmpty()) { 285 if (!misspelledWord.isEmpty()) {
282 // Stop looking at start of next misspelled word 286 // Stop looking at start of next misspelled word
283 CharacterIterator chars(grammarSearchRange.get()); 287 CharacterIterator chars(grammarSearchStart, grammarSearchEnd);
284 chars.advance(misspellingOffset); 288 chars.advance(misspellingOffset);
285 grammarSearchRange->setEnd(chars.startContainer(), chars.startOf fset(), IGNORE_EXCEPTION); 289 grammarSearchEnd = chars.startPosition();
286 } 290 }
287 291
288 if (isGrammarCheckingEnabled()) 292 if (isGrammarCheckingEnabled())
289 badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), gram marSearchRange).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false); 293 badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), gram marSearchStart, grammarSearchEnd).findFirstBadGrammar(grammarDetail, grammarPhra seOffset, false);
290 } 294 }
291 } 295 }
292 296
293 if (!badGrammarPhrase.isEmpty()) { 297 if (!badGrammarPhrase.isEmpty()) {
294 // We found bad grammar. Since we only searched for bad grammar up to th e first misspelled word, the bad grammar 298 // We found bad grammar. Since we only searched for bad grammar up to th e first misspelled word, the bad grammar
295 // takes precedence and we ignore any potential misspelled word. Select the grammar detail, update the spelling 299 // takes precedence and we ignore any potential misspelled word. Select the grammar detail, update the spelling
296 // panel, and store a marker so we draw the green squiggle later. 300 // panel, and store a marker so we draw the green squiggle later.
297 301
298 ASSERT(badGrammarPhrase.length() > 0); 302 ASSERT(badGrammarPhrase.length() > 0);
299 ASSERT(grammarDetail.location != -1 && grammarDetail.length > 0); 303 ASSERT(grammarDetail.location != -1 && grammarDetail.length > 0);
300 304
301 // FIXME 4859190: This gets confused with doubled punctuation at the end of a paragraph 305 // FIXME 4859190: This gets confused with doubled punctuation at the end of a paragraph
302 RefPtrWillBeRawPtr<Range> badGrammarRange = TextIterator::subrange(gramm arSearchRange.get(), grammarPhraseOffset + grammarDetail.location, grammarDetail .length); 306 Position badGrammarStart = grammarSearchStart;
303 m_frame.selection().setSelection(VisibleSelection(badGrammarRange.get(), SEL_DEFAULT_AFFINITY)); 307 Position badGrammarEnd = grammarSearchEnd;
308 TextIterator::subrange(badGrammarStart, badGrammarEnd, grammarPhraseOffs et + grammarDetail.location, grammarDetail.length);
309 m_frame.selection().setSelection(VisibleSelection(badGrammarStart, badGr ammarEnd));
304 m_frame.selection().revealSelection(); 310 m_frame.selection().revealSelection();
305 311
306 m_frame.document()->markers().addMarker(badGrammarRange.get(), DocumentM arker::Grammar, grammarDetail.userDescription); 312 m_frame.document()->markers().addMarker(badGrammarStart, badGrammarEnd, DocumentMarker::Grammar, grammarDetail.userDescription);
307 } else if (!misspelledWord.isEmpty()) { 313 } else if (!misspelledWord.isEmpty()) {
308 // We found a misspelling, but not any earlier bad grammar. Select the m isspelling, update the spelling panel, and store 314 // We found a misspelling, but not any earlier bad grammar. Select the m isspelling, update the spelling panel, and store
309 // a marker so we draw the red squiggle later. 315 // a marker so we draw the red squiggle later.
310 316
311 RefPtrWillBeRawPtr<Range> misspellingRange = TextIterator::subrange(spel lingSearchRange.get(), misspellingOffset, misspelledWord.length()); 317 Position misspellingStart = spellingSearchStart;
312 m_frame.selection().setSelection(VisibleSelection(misspellingRange.get() , DOWNSTREAM)); 318 Position misspellingEnd = spellingSearchEnd;
319 TextIterator::subrange(misspellingStart, misspellingEnd, misspellingOffs et, misspelledWord.length());
320 m_frame.selection().setSelection(VisibleSelection(misspellingStart, miss pellingEnd, DOWNSTREAM));
313 m_frame.selection().revealSelection(); 321 m_frame.selection().revealSelection();
314 322
315 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); 323 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord);
316 m_frame.document()->markers().addMarker(misspellingRange.get(), Document Marker::Spelling); 324 m_frame.document()->markers().addMarker(misspellingStart, misspellingEnd , DocumentMarker::Spelling);
317 } 325 }
318 } 326 }
319 327
320 void SpellChecker::showSpellingGuessPanel() 328 void SpellChecker::showSpellingGuessPanel()
321 { 329 {
322 if (spellCheckerClient().spellingUIIsShowing()) { 330 if (spellCheckerClient().spellingUIIsShowing()) {
323 spellCheckerClient().showSpellingUI(false); 331 spellCheckerClient().showSpellingUI(false);
324 return; 332 return;
325 } 333 }
326 334
(...skipping 25 matching lines...) Expand all
352 textCheckingOptions |= TextCheckingTypeGrammar; 360 textCheckingOptions |= TextCheckingTypeGrammar;
353 361
354 VisibleSelection wholeParagraph( 362 VisibleSelection wholeParagraph(
355 startOfParagraph(wordSelection.visibleStart()), 363 startOfParagraph(wordSelection.visibleStart()),
356 endOfParagraph(wordSelection.visibleEnd())); 364 endOfParagraph(wordSelection.visibleEnd()));
357 365
358 markAllMisspellingsAndBadGrammarInRanges( 366 markAllMisspellingsAndBadGrammarInRanges(
359 textCheckingOptions, wordSelection.toNormalizedRange().get(), 367 textCheckingOptions, wordSelection.toNormalizedRange().get(),
360 wholeParagraph.toNormalizedRange().get()); 368 wholeParagraph.toNormalizedRange().get());
361 } else { 369 } else {
362 RefPtrWillBeRawPtr<Range> misspellingRange = wordSelection.firstRange(); 370 RefPtrWillBeRawPtr<Range> misspellingRange = nullptr;
363 markMisspellings(wordSelection, misspellingRange); 371 markMisspellings(wordSelection, misspellingRange);
364 } 372 }
365 } 373 }
366 374
367 void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word Start, const VisibleSelection& selectionAfterTyping) 375 void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word Start, const VisibleSelection& selectionAfterTyping)
368 { 376 {
369 if (unifiedTextCheckerEnabled()) { 377 if (unifiedTextCheckerEnabled()) {
370 TextCheckingTypeMask textCheckingOptions = 0; 378 TextCheckingTypeMask textCheckingOptions = 0;
371 379
372 if (isContinuousSpellCheckingEnabled()) 380 if (isContinuousSpellCheckingEnabled())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 void SpellChecker::markMisspellingsOrBadGrammar(const VisibleSelection& selectio n, bool checkSpelling, RefPtrWillBeRawPtr<Range>& firstMisspellingRange) 435 void SpellChecker::markMisspellingsOrBadGrammar(const VisibleSelection& selectio n, bool checkSpelling, RefPtrWillBeRawPtr<Range>& firstMisspellingRange)
428 { 436 {
429 // This function is called with a selection already expanded to word boundar ies. 437 // This function is called with a selection already expanded to word boundar ies.
430 // Might be nice to assert that here. 438 // Might be nice to assert that here.
431 439
432 // This function is used only for as-you-type checking, so if that's off we do nothing. Note that 440 // This function is used only for as-you-type checking, so if that's off we do nothing. Note that
433 // grammar checking can only be on if spell checking is also on. 441 // grammar checking can only be on if spell checking is also on.
434 if (!isContinuousSpellCheckingEnabled()) 442 if (!isContinuousSpellCheckingEnabled())
435 return; 443 return;
436 444
437 RefPtrWillBeRawPtr<Range> searchRange(selection.toNormalizedRange()); 445 Position start, end;
438 if (!searchRange) 446 if (!selection.toNormalizedPositions(start, end))
439 return; 447 return;
440 448
441 // If we're not in an editable node, bail. 449 // If we're not in an editable node, bail.
442 Node* editableNode = searchRange->startContainer(); 450 Node* editableNode = start.containerNode();
443 if (!editableNode || !editableNode->hasEditableStyle()) 451 if (!editableNode || !editableNode->hasEditableStyle())
444 return; 452 return;
445 453
446 if (!isSpellCheckingEnabledFor(editableNode)) 454 if (!isSpellCheckingEnabledFor(editableNode))
447 return; 455 return;
448 456
449 TextCheckingHelper checker(spellCheckerClient(), searchRange); 457 TextCheckingHelper checker(spellCheckerClient(), start, end);
450 if (checkSpelling) 458 if (checkSpelling)
451 checker.markAllMisspellings(firstMisspellingRange); 459 checker.markAllMisspellings(firstMisspellingRange);
452 else if (isGrammarCheckingEnabled()) 460 else if (isGrammarCheckingEnabled())
453 checker.markAllBadGrammar(); 461 checker.markAllBadGrammar();
454 } 462 }
455 463
456 bool SpellChecker::isSpellCheckingEnabledFor(Node* node) const 464 bool SpellChecker::isSpellCheckingEnabledFor(Node* node) const
457 { 465 {
458 if (!node) 466 if (!node)
459 return false; 467 return false;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 728
721 // Now we remove markers on everything between startOfFirstWord and endOfLas tWord. 729 // Now we remove markers on everything between startOfFirstWord and endOfLas tWord.
722 // However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the 730 // However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the
723 // resulted words even we only edit one of them. For example, assuming autoc orrection changes "avantgarde" to "avant 731 // resulted words even we only edit one of them. For example, assuming autoc orrection changes "avantgarde" to "avant
724 // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde, 732 // garde", we will have CorrectionIndicator marker on both words and on the whitespace between them. If we then edit garde,
725 // we would like to remove the marker from word "avant" and whitespace as we ll. So we need to get the continous range of 733 // we would like to remove the marker from word "avant" and whitespace as we ll. So we need to get the continous range of
726 // of marker that contains the word in question, and remove marker on that w hole range. 734 // of marker that contains the word in question, and remove marker on that w hole range.
727 Document* document = m_frame.document(); 735 Document* document = m_frame.document();
728 ASSERT(document); 736 ASSERT(document);
729 RefPtrWillBeRawPtr<Range> wordRange = Range::create(*document, startOfFirstW ord.deepEquivalent(), endOfLastWord.deepEquivalent()); 737 RefPtrWillBeRawPtr<Range> wordRange = Range::create(*document, startOfFirstW ord.deepEquivalent(), endOfLastWord.deepEquivalent());
730
731 document->markers().removeMarkers(wordRange.get(), DocumentMarker::Misspelli ngMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker); 738 document->markers().removeMarkers(wordRange.get(), DocumentMarker::Misspelli ngMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker);
732 } 739 }
733 740
734 void SpellChecker::didEndEditingOnTextField(Element* e) 741 void SpellChecker::didEndEditingOnTextField(Element* e)
735 { 742 {
736 // Remove markers when deactivating a selection in an <input type="text"/>. 743 // Remove markers when deactivating a selection in an <input type="text"/>.
737 // Prevent new ones from appearing too. 744 // Prevent new ones from appearing too.
738 m_spellCheckRequester->cancelCheck(); 745 m_spellCheckRequester->cancelCheck();
739 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl ement(e); 746 HTMLTextFormControlElement* textFormControlElement = toHTMLTextFormControlEl ement(e);
740 HTMLElement* innerEditor = textFormControlElement->innerEditorElement(); 747 HTMLElement* innerEditor = textFormControlElement->innerEditorElement();
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 936 }
930 937
931 void SpellChecker::requestTextChecking(const Element& element) 938 void SpellChecker::requestTextChecking(const Element& element)
932 { 939 {
933 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element* >(&element)); 940 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element* >(&element));
934 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); 941 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck));
935 } 942 }
936 943
937 944
938 } // namespace blink 945 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/DOMSelection.cpp ('k') | Source/core/editing/TextCheckingHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698