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

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

Issue 2580773002: Let IdleSpellCheckCallback take full control over SpellCheckRequester (Closed)
Patch Set: Add CORE_EXPORT to IdleRequestCallback Created 4 years 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 document->markers().removeMarkers( 791 document->markers().removeMarkers(
792 wordRange, DocumentMarker::MisspellingMarkers(), 792 wordRange, DocumentMarker::MisspellingMarkers(),
793 DocumentMarkerController::RemovePartiallyOverlappingMarker); 793 DocumentMarkerController::RemovePartiallyOverlappingMarker);
794 } 794 }
795 795
796 void SpellChecker::didEndEditingOnTextField(Element* e) { 796 void SpellChecker::didEndEditingOnTextField(Element* e) {
797 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField"); 797 TRACE_EVENT0("blink", "SpellChecker::didEndEditingOnTextField");
798 798
799 // Remove markers when deactivating a selection in an <input type="text"/>. 799 // Remove markers when deactivating a selection in an <input type="text"/>.
800 // Prevent new ones from appearing too. 800 // Prevent new ones from appearing too.
801 m_spellCheckRequester->cancelCheck(); 801 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
802 m_spellCheckRequester->cancelCheck();
802 TextControlElement* textControlElement = toTextControlElement(e); 803 TextControlElement* textControlElement = toTextControlElement(e);
803 HTMLElement* innerEditor = textControlElement->innerEditorElement(); 804 HTMLElement* innerEditor = textControlElement->innerEditorElement();
804 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling); 805 DocumentMarker::MarkerTypes markerTypes(DocumentMarker::Spelling);
805 markerTypes.add(DocumentMarker::Grammar); 806 markerTypes.add(DocumentMarker::Grammar);
806 for (Node& node : NodeTraversal::inclusiveDescendantsOf(*innerEditor)) 807 for (Node& node : NodeTraversal::inclusiveDescendantsOf(*innerEditor))
807 frame().document()->markers().removeMarkers(&node, markerTypes); 808 frame().document()->markers().removeMarkers(&node, markerTypes);
808 } 809 }
809 810
810 void SpellChecker::replaceMisspelledRange(const String& text) { 811 void SpellChecker::replaceMisspelledRange(const String& text) {
811 EphemeralRange caretRange = 812 EphemeralRange caretRange =
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 DocumentMarker::MarkerTypes markerTypes) { 1029 DocumentMarker::MarkerTypes markerTypes) {
1029 DCHECK(!frame().document()->needsLayoutTreeUpdate()); 1030 DCHECK(!frame().document()->needsLayoutTreeUpdate());
1030 1031
1031 const EphemeralRange& range = selection.toNormalizedEphemeralRange(); 1032 const EphemeralRange& range = selection.toNormalizedEphemeralRange();
1032 if (range.isNull()) 1033 if (range.isNull())
1033 return; 1034 return;
1034 1035
1035 frame().document()->markers().removeMarkers(range, markerTypes); 1036 frame().document()->markers().removeMarkers(range, markerTypes);
1036 } 1037 }
1037 1038
1039 // TODO(xiaochengh): This function is only used by unit tests. We should move it
1040 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell
1041 // checker.
1038 void SpellChecker::cancelCheck() { 1042 void SpellChecker::cancelCheck() {
1039 m_spellCheckRequester->cancelCheck(); 1043 m_spellCheckRequester->cancelCheck();
1040 } 1044 }
1041 1045
1042 DEFINE_TRACE(SpellChecker) { 1046 DEFINE_TRACE(SpellChecker) {
1043 visitor->trace(m_frame); 1047 visitor->trace(m_frame);
1044 visitor->trace(m_spellCheckRequester); 1048 visitor->trace(m_spellCheckRequester);
1045 } 1049 }
1046 1050
1047 void SpellChecker::prepareForLeakDetection() { 1051 void SpellChecker::prepareForLeakDetection() {
1048 m_spellCheckRequester->prepareForLeakDetection(); 1052 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled())
1053 m_spellCheckRequester->prepareForLeakDetection();
1049 } 1054 }
1050 1055
1051 Vector<TextCheckingResult> SpellChecker::findMisspellings(const String& text) { 1056 Vector<TextCheckingResult> SpellChecker::findMisspellings(const String& text) {
1052 Vector<UChar> characters; 1057 Vector<UChar> characters;
1053 text.appendTo(characters); 1058 text.appendTo(characters);
1054 unsigned length = text.length(); 1059 unsigned length = text.length();
1055 1060
1056 TextBreakIterator* iterator = wordBreakIterator(characters.data(), length); 1061 TextBreakIterator* iterator = wordBreakIterator(characters.data(), length);
1057 if (!iterator) 1062 if (!iterator)
1058 return Vector<TextCheckingResult>(); 1063 return Vector<TextCheckingResult>();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 startOfNextParagraph(createVisiblePosition(paragraphEnd)); 1167 startOfNextParagraph(createVisiblePosition(paragraphEnd));
1163 paragraphStart = newParagraphStart.toParentAnchoredPosition(); 1168 paragraphStart = newParagraphStart.toParentAnchoredPosition();
1164 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); 1169 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition();
1165 firstIteration = false; 1170 firstIteration = false;
1166 totalLengthProcessed += currentLength; 1171 totalLengthProcessed += currentLength;
1167 } 1172 }
1168 return std::make_pair(firstFoundItem, firstFoundOffset); 1173 return std::make_pair(firstFoundItem, firstFoundOffset);
1169 } 1174 }
1170 1175
1171 } // namespace blink 1176 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698