| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/dom/Range.h" | 36 #include "core/dom/Range.h" |
| 37 #include "core/editing/EditingUtilities.h" | 37 #include "core/editing/EditingUtilities.h" |
| 38 #include "core/editing/Editor.h" | 38 #include "core/editing/Editor.h" |
| 39 #include "core/editing/EphemeralRange.h" | 39 #include "core/editing/EphemeralRange.h" |
| 40 #include "core/editing/VisibleUnits.h" | 40 #include "core/editing/VisibleUnits.h" |
| 41 #include "core/editing/commands/CompositeEditCommand.h" | 41 #include "core/editing/commands/CompositeEditCommand.h" |
| 42 #include "core/editing/commands/ReplaceSelectionCommand.h" | 42 #include "core/editing/commands/ReplaceSelectionCommand.h" |
| 43 #include "core/editing/commands/TypingCommand.h" | 43 #include "core/editing/commands/TypingCommand.h" |
| 44 #include "core/editing/iterators/CharacterIterator.h" | 44 #include "core/editing/iterators/CharacterIterator.h" |
| 45 #include "core/editing/markers/DocumentMarkerController.h" | 45 #include "core/editing/markers/DocumentMarkerController.h" |
| 46 #include "core/editing/spellcheck/IdleSpellCheckCallback.h" |
| 46 #include "core/editing/spellcheck/SpellCheckRequester.h" | 47 #include "core/editing/spellcheck/SpellCheckRequester.h" |
| 47 #include "core/editing/spellcheck/TextCheckingParagraph.h" | 48 #include "core/editing/spellcheck/TextCheckingParagraph.h" |
| 48 #include "core/frame/LocalFrame.h" | 49 #include "core/frame/LocalFrame.h" |
| 49 #include "core/frame/Settings.h" | 50 #include "core/frame/Settings.h" |
| 50 #include "core/html/HTMLInputElement.h" | 51 #include "core/html/HTMLInputElement.h" |
| 51 #include "core/layout/LayoutTextControl.h" | 52 #include "core/layout/LayoutTextControl.h" |
| 52 #include "core/loader/EmptyClients.h" | 53 #include "core/loader/EmptyClients.h" |
| 53 #include "core/page/Page.h" | 54 #include "core/page/Page.h" |
| 54 #include "core/page/SpellCheckerClient.h" | 55 #include "core/page/SpellCheckerClient.h" |
| 55 #include "platform/RuntimeEnabledFeatures.h" | 56 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 return page->spellCheckerClient(); | 159 return page->spellCheckerClient(); |
| 159 return emptySpellCheckerClient(); | 160 return emptySpellCheckerClient(); |
| 160 } | 161 } |
| 161 | 162 |
| 162 TextCheckerClient& SpellChecker::textChecker() const { | 163 TextCheckerClient& SpellChecker::textChecker() const { |
| 163 return spellCheckerClient().textChecker(); | 164 return spellCheckerClient().textChecker(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 SpellChecker::SpellChecker(LocalFrame& frame) | 167 SpellChecker::SpellChecker(LocalFrame& frame) |
| 167 : m_frame(&frame), | 168 : m_frame(&frame), |
| 168 m_spellCheckRequester(SpellCheckRequester::create(frame)) {} | 169 m_spellCheckRequester(SpellCheckRequester::create(frame)), |
| 170 m_idleSpellCheckCallback(IdleSpellCheckCallback::create(frame)) {} |
| 169 | 171 |
| 170 bool SpellChecker::isSpellCheckingEnabled() const { | 172 bool SpellChecker::isSpellCheckingEnabled() const { |
| 171 return spellCheckerClient().isSpellCheckingEnabled(); | 173 return spellCheckerClient().isSpellCheckingEnabled(); |
| 172 } | 174 } |
| 173 | 175 |
| 174 void SpellChecker::toggleSpellCheckingEnabled() { | 176 void SpellChecker::toggleSpellCheckingEnabled() { |
| 175 spellCheckerClient().toggleSpellCheckingEnabled(); | 177 spellCheckerClient().toggleSpellCheckingEnabled(); |
| 176 if (isSpellCheckingEnabled()) | 178 if (isSpellCheckingEnabled()) |
| 177 return; | 179 return; |
| 178 for (Frame* frame = this->frame().page()->mainFrame(); frame; | 180 for (Frame* frame = this->frame().page()->mainFrame(); frame; |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 // TODO(xiaochengh): This function is only used by unit tests. We should move it | 1104 // TODO(xiaochengh): This function is only used by unit tests. We should move it |
| 1103 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell | 1105 // to IdleSpellCheckCallback and modify unit tests to cope with idle time spell |
| 1104 // checker. | 1106 // checker. |
| 1105 void SpellChecker::cancelCheck() { | 1107 void SpellChecker::cancelCheck() { |
| 1106 m_spellCheckRequester->cancelCheck(); | 1108 m_spellCheckRequester->cancelCheck(); |
| 1107 } | 1109 } |
| 1108 | 1110 |
| 1109 DEFINE_TRACE(SpellChecker) { | 1111 DEFINE_TRACE(SpellChecker) { |
| 1110 visitor->trace(m_frame); | 1112 visitor->trace(m_frame); |
| 1111 visitor->trace(m_spellCheckRequester); | 1113 visitor->trace(m_spellCheckRequester); |
| 1114 visitor->trace(m_idleSpellCheckCallback); |
| 1112 } | 1115 } |
| 1113 | 1116 |
| 1114 void SpellChecker::prepareForLeakDetection() { | 1117 void SpellChecker::prepareForLeakDetection() { |
| 1115 if (!RuntimeEnabledFeatures::idleTimeSpellCheckingEnabled()) | 1118 m_spellCheckRequester->prepareForLeakDetection(); |
| 1116 m_spellCheckRequester->prepareForLeakDetection(); | |
| 1117 } | 1119 } |
| 1118 | 1120 |
| 1119 Vector<TextCheckingResult> SpellChecker::findMisspellings(const String& text) { | 1121 Vector<TextCheckingResult> SpellChecker::findMisspellings(const String& text) { |
| 1120 Vector<UChar> characters; | 1122 Vector<UChar> characters; |
| 1121 text.appendTo(characters); | 1123 text.appendTo(characters); |
| 1122 unsigned length = text.length(); | 1124 unsigned length = text.length(); |
| 1123 | 1125 |
| 1124 TextBreakIterator* iterator = wordBreakIterator(characters.data(), length); | 1126 TextBreakIterator* iterator = wordBreakIterator(characters.data(), length); |
| 1125 if (!iterator) | 1127 if (!iterator) |
| 1126 return Vector<TextCheckingResult>(); | 1128 return Vector<TextCheckingResult>(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 startOfNextParagraph(createVisiblePosition(paragraphEnd)); | 1232 startOfNextParagraph(createVisiblePosition(paragraphEnd)); |
| 1231 paragraphStart = newParagraphStart.toParentAnchoredPosition(); | 1233 paragraphStart = newParagraphStart.toParentAnchoredPosition(); |
| 1232 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); | 1234 paragraphEnd = endOfParagraph(newParagraphStart).toParentAnchoredPosition(); |
| 1233 firstIteration = false; | 1235 firstIteration = false; |
| 1234 totalLengthProcessed += currentLength; | 1236 totalLengthProcessed += currentLength; |
| 1235 } | 1237 } |
| 1236 return std::make_pair(firstFoundItem, firstFoundOffset); | 1238 return std::make_pair(firstFoundItem, firstFoundOffset); |
| 1237 } | 1239 } |
| 1238 | 1240 |
| 1239 } // namespace blink | 1241 } // namespace blink |
| OLD | NEW |