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