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

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2701983002: Implement complete lifecycle transition for IdleSpellCheckCallback (Closed)
Patch Set: Fix compiler error Created 3 years, 9 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 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 // In the long term we should use idle time spell checker to prevent 916 // In the long term we should use idle time spell checker to prevent
917 // synchronous layout caused by spell checking (see crbug.com/517298). 917 // synchronous layout caused by spell checking (see crbug.com/517298).
918 oldSelectionStart.document()->updateStyleAndLayoutIgnorePendingStylesheets(); 918 oldSelectionStart.document()->updateStyleAndLayoutIgnorePendingStylesheets();
919 919
920 return isEditablePosition(oldSelectionStart); 920 return isEditablePosition(oldSelectionStart);
921 } 921 }
922 922
923 void SpellChecker::respondToChangedSelection( 923 void SpellChecker::respondToChangedSelection(
924 const Position& oldSelectionStart, 924 const Position& oldSelectionStart,
925 FrameSelection::SetSelectionOptions options) { 925 FrameSelection::SetSelectionOptions options) {
926 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) 926 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) {
927 m_idleSpellCheckCallback->setNeedsInvocation();
927 return; 928 return;
929 }
928 930
929 TRACE_EVENT0("blink", "SpellChecker::respondToChangedSelection"); 931 TRACE_EVENT0("blink", "SpellChecker::respondToChangedSelection");
930 if (!isSpellCheckingEnabledFor(oldSelectionStart)) 932 if (!isSpellCheckingEnabledFor(oldSelectionStart))
931 return; 933 return;
932 934
933 // When spell checking is off, existing markers disappear after the selection 935 // When spell checking is off, existing markers disappear after the selection
934 // changes. 936 // changes.
935 if (!isSpellCheckingEnabled()) { 937 if (!isSpellCheckingEnabled()) {
936 frame().document()->markers().removeMarkers(DocumentMarker::Spelling); 938 frame().document()->markers().removeMarkers(DocumentMarker::Spelling);
937 frame().document()->markers().removeMarkers(DocumentMarker::Grammar); 939 frame().document()->markers().removeMarkers(DocumentMarker::Grammar);
(...skipping 23 matching lines...) Expand all
961 } 963 }
962 964
963 // When typing we check spelling elsewhere, so don't redo it here. 965 // When typing we check spelling elsewhere, so don't redo it here.
964 // If this is a change in selection resulting from a delete operation, 966 // If this is a change in selection resulting from a delete operation,
965 // oldSelection may no longer be in the document. 967 // oldSelection may no longer be in the document.
966 // FIXME(http://crbug.com/382809): if oldSelection is on a textarea 968 // FIXME(http://crbug.com/382809): if oldSelection is on a textarea
967 // element, we cause synchronous layout. 969 // element, we cause synchronous layout.
968 spellCheckOldSelection(oldSelectionStart, newAdjacentWords); 970 spellCheckOldSelection(oldSelectionStart, newAdjacentWords);
969 } 971 }
970 972
973 void SpellChecker::respondToChangedContents() {
974 updateMarkersForWordsAffectedByEditing(true);
975 if (RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
976 m_idleSpellCheckCallback->setNeedsInvocation();
977 }
978
971 void SpellChecker::removeSpellingMarkers() { 979 void SpellChecker::removeSpellingMarkers() {
972 frame().document()->markers().removeMarkers( 980 frame().document()->markers().removeMarkers(
973 DocumentMarker::MisspellingMarkers()); 981 DocumentMarker::MisspellingMarkers());
974 } 982 }
975 983
976 void SpellChecker::removeSpellingMarkersUnderWords( 984 void SpellChecker::removeSpellingMarkersUnderWords(
977 const Vector<String>& words) { 985 const Vector<String>& words) {
978 MarkerRemoverPredicate removerPredicate(words); 986 MarkerRemoverPredicate removerPredicate(words);
979 987
980 DocumentMarkerController& markerController = frame().document()->markers(); 988 DocumentMarkerController& markerController = frame().document()->markers();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 frame().document()->markers().removeMarkers(range, markerTypes); 1102 frame().document()->markers().removeMarkers(range, markerTypes);
1095 } 1103 }
1096 1104
1097 // TODO(xiaochengh): This function is only used by unit tests. We should move it 1105 // TODO(xiaochengh): This function is only used by unit tests. We should move it
1098 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell 1106 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell
1099 // checker. 1107 // checker.
1100 void SpellChecker::cancelCheck() { 1108 void SpellChecker::cancelCheck() {
1101 m_spellCheckRequester->cancelCheck(); 1109 m_spellCheckRequester->cancelCheck();
1102 } 1110 }
1103 1111
1112 void SpellChecker::documentAttached(Document* document) {
1113 m_idleSpellCheckCallback->documentAttached(document);
1114 }
1115
1104 DEFINE_TRACE(SpellChecker) { 1116 DEFINE_TRACE(SpellChecker) {
1105 visitor->trace(m_frame); 1117 visitor->trace(m_frame);
1106 visitor->trace(m_spellCheckRequester); 1118 visitor->trace(m_spellCheckRequester);
1107 visitor->trace(m_idleSpellCheckCallback); 1119 visitor->trace(m_idleSpellCheckCallback);
1108 } 1120 }
1109 1121
1110 void SpellChecker::prepareForLeakDetection() { 1122 void SpellChecker::prepareForLeakDetection() {
1111 m_spellCheckRequester->prepareForLeakDetection(); 1123 m_spellCheckRequester->prepareForLeakDetection();
1112 } 1124 }
1113 1125
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 startOfNextParagraph(createVisiblePosition(paragraphEnd)); 1237 startOfNextParagraph(createVisiblePosition(paragraphEnd));
1226 paragraphStart = newParagraphStart.toParentAnchoredPosition(); 1238 paragraphStart = newParagraphStart.toParentAnchoredPosition();
1227 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); 1239 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition();
1228 firstIteration = false; 1240 firstIteration = false;
1229 totalLengthProcessed += currentLength; 1241 totalLengthProcessed += currentLength;
1230 } 1242 }
1231 return std::make_pair(firstFoundItem, firstFoundOffset); 1243 return std::make_pair(firstFoundItem, firstFoundOffset);
1232 } 1244 }
1233 1245
1234 } // namespace blink 1246 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | third_party/WebKit/Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698