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

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

Issue 1201423002: Use VisibleSelection::InDOMTree::equalSelections() instead of operator==() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-06-24T15:30:20 Rebase - exclude FrameSelection Created 5 years, 6 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) 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (!misspellingRange) 409 if (!misspellingRange)
410 return; 410 return;
411 411
412 // Get the misspelled word. 412 // Get the misspelled word.
413 const String misspelledWord = plainText(misspellingRange.get()); 413 const String misspelledWord = plainText(misspellingRange.get());
414 String autocorrectedString = textChecker().getAutoCorrectSuggestionForMisspe lledWord(misspelledWord); 414 String autocorrectedString = textChecker().getAutoCorrectSuggestionForMisspe lledWord(misspelledWord);
415 415
416 // If autocorrected word is non empty, replace the misspelled word by this w ord. 416 // If autocorrected word is non empty, replace the misspelled word by this w ord.
417 if (!autocorrectedString.isEmpty()) { 417 if (!autocorrectedString.isEmpty()) {
418 VisibleSelection newSelection(misspellingRange.get(), DOWNSTREAM); 418 VisibleSelection newSelection(misspellingRange.get(), DOWNSTREAM);
419 if (newSelection != frame().selection().selection()) { 419 if (!VisibleSelection::InDOMTree::equalSelections(newSelection, frame(). selection().selection())) {
420 frame().selection().setSelection(newSelection); 420 frame().selection().setSelection(newSelection);
421 } 421 }
422 422
423 frame().editor().replaceSelectionWithText(autocorrectedString, false, fa lse); 423 frame().editor().replaceSelectionWithText(autocorrectedString, false, fa lse);
424 424
425 // Reset the charet one character further. 425 // Reset the charet one character further.
426 frame().selection().moveTo(frame().selection().selection().visibleEnd()) ; 426 frame().selection().moveTo(frame().selection().selection().visibleEnd()) ;
427 frame().selection().modify(FrameSelection::AlterationMove, DirectionForw ard, CharacterGranularity); 427 frame().selection().modify(FrameSelection::AlterationMove, DirectionForw ard, CharacterGranularity);
428 } 428 }
429 429
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 } 856 }
857 857
858 VisibleSelection empty; 858 VisibleSelection empty;
859 spellCheckOldSelection(frame().selection().selection(), empty); 859 spellCheckOldSelection(frame().selection().selection(), empty);
860 } 860 }
861 861
862 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords) 862 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection, const VisibleSelection& newAdjacentWords)
863 { 863 {
864 VisiblePosition oldStart(oldSelection.visibleStart()); 864 VisiblePosition oldStart(oldSelection.visibleStart());
865 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); 865 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary));
866 if (oldAdjacentWords != newAdjacentWords) { 866 if (!VisibleSelection::InDOMTree::equalSelections(oldAdjacentWords, newAdjac entWords)) {
867 if (isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled()) { 867 if (isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled()) {
868 VisibleSelection selectedSentence = VisibleSelection(startOfSentence (oldStart), endOfSentence(oldStart)); 868 VisibleSelection selectedSentence = VisibleSelection(startOfSentence (oldStart), endOfSentence(oldStart));
869 markMisspellingsAndBadGrammar(oldAdjacentWords, true, selectedSenten ce); 869 markMisspellingsAndBadGrammar(oldAdjacentWords, true, selectedSenten ce);
870 } else { 870 } else {
871 markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWo rds); 871 markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWo rds);
872 } 872 }
873 } 873 }
874 } 874 }
875 875
876 static Node* findFirstMarkable(Node* node) 876 static Node* findFirstMarkable(Node* node)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck)); 944 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe ck, rangeToCheck));
945 } 945 }
946 946
947 DEFINE_TRACE(SpellChecker) 947 DEFINE_TRACE(SpellChecker)
948 { 948 {
949 visitor->trace(m_frame); 949 visitor->trace(m_frame);
950 visitor->trace(m_spellCheckRequester); 950 visitor->trace(m_spellCheckRequester);
951 } 951 }
952 952
953 } // namespace blink 953 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698