OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. |
3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
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 28 matching lines...) Expand all Loading... |
39 #include "WebNode.h" | 39 #include "WebNode.h" |
40 #include "WebPermissionClient.h" | 40 #include "WebPermissionClient.h" |
41 #include "WebRange.h" | 41 #include "WebRange.h" |
42 #include "WebSpellCheckClient.h" | 42 #include "WebSpellCheckClient.h" |
43 #include "WebTextAffinity.h" | 43 #include "WebTextAffinity.h" |
44 #include "WebTextCheckingCompletionImpl.h" | 44 #include "WebTextCheckingCompletionImpl.h" |
45 #include "WebTextCheckingResult.h" | 45 #include "WebTextCheckingResult.h" |
46 #include "WebViewClient.h" | 46 #include "WebViewClient.h" |
47 #include "WebViewImpl.h" | 47 #include "WebViewImpl.h" |
48 #include "core/dom/Document.h" | 48 #include "core/dom/Document.h" |
49 #include "core/dom/DocumentMarkerController.h" | |
50 #include "core/dom/EventNames.h" | 49 #include "core/dom/EventNames.h" |
51 #include "core/dom/KeyboardEvent.h" | 50 #include "core/dom/KeyboardEvent.h" |
52 #include "core/editing/Editor.h" | 51 #include "core/editing/Editor.h" |
53 #include "core/editing/SpellCheckRequester.h" | |
54 #include "core/editing/TextCheckingHelper.h" | |
55 #include "core/editing/UndoStep.h" | 52 #include "core/editing/UndoStep.h" |
56 #include "core/html/HTMLInputElement.h" | 53 #include "core/html/HTMLInputElement.h" |
57 #include "core/page/EventHandler.h" | 54 #include "core/page/EventHandler.h" |
58 #include "core/page/Frame.h" | 55 #include "core/page/Frame.h" |
59 #include "core/page/Page.h" | 56 #include "core/page/Page.h" |
60 #include "core/page/Settings.h" | 57 #include "core/page/Settings.h" |
61 #include "core/platform/NotImplemented.h" | 58 #include "core/platform/NotImplemented.h" |
62 #include "core/platform/PlatformKeyboardEvent.h" | 59 #include "core/platform/PlatformKeyboardEvent.h" |
63 #include "core/platform/chromium/KeyboardCodes.h" | 60 #include "core/platform/chromium/KeyboardCodes.h" |
64 #include "core/rendering/RenderObject.h" | 61 #include "core/rendering/RenderObject.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 { | 131 { |
135 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) | 132 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) |
136 return false; | 133 return false; |
137 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) | 134 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) |
138 return true; | 135 return true; |
139 return shouldSpellcheckByDefault(); | 136 return shouldSpellcheckByDefault(); |
140 } | 137 } |
141 | 138 |
142 void EditorClientImpl::toggleContinuousSpellChecking() | 139 void EditorClientImpl::toggleContinuousSpellChecking() |
143 { | 140 { |
144 if (isContinuousSpellCheckingEnabled()) { | 141 if (isContinuousSpellCheckingEnabled()) |
145 m_spellCheckThisFieldStatus = SpellCheckForcedOff; | 142 m_spellCheckThisFieldStatus = SpellCheckForcedOff; |
146 if (Page* page = m_webView->page()) { | 143 else |
147 for (Frame* frame = page->mainFrame(); frame && frame->document(); f
rame = frame->tree()->traverseNext()) { | |
148 frame->document()->markers()->removeMarkers(DocumentMarker::Spel
ling | DocumentMarker::Grammar); | |
149 } | |
150 } | |
151 } else { | |
152 m_spellCheckThisFieldStatus = SpellCheckForcedOn; | 144 m_spellCheckThisFieldStatus = SpellCheckForcedOn; |
153 if (Frame* frame = m_webView->focusedWebCoreFrame()) { | |
154 if (unifiedTextCheckerEnabled(frame)) { | |
155 VisibleSelection frameSelection = frame->selection()->selection(
); | |
156 // If a selection is in an editable element spell check its cont
ent. | |
157 if (Element* rootEditableElement = frameSelection.rootEditableEl
ement()) { | |
158 VisibleSelection selection = VisibleSelection::selectionFrom
ContentsOfNode(rootEditableElement); | |
159 frame->editor()->markMisspellingsAndBadGrammar(selection); | |
160 } | |
161 } | |
162 } | |
163 } | |
164 } | 145 } |
165 | 146 |
166 bool EditorClientImpl::isGrammarCheckingEnabled() | 147 bool EditorClientImpl::isGrammarCheckingEnabled() |
167 { | 148 { |
168 const Frame* frame = m_webView->focusedWebCoreFrame(); | 149 const Frame* frame = m_webView->focusedWebCoreFrame(); |
169 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh
eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); | 150 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh
eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); |
170 } | 151 } |
171 | 152 |
172 bool EditorClientImpl::shouldBeginEditing(Range* range) | 153 bool EditorClientImpl::shouldBeginEditing(Range* range) |
173 { | 154 { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 #endif | 762 #endif |
782 } | 763 } |
783 | 764 |
784 void EditorClientImpl::willSetInputMethodState() | 765 void EditorClientImpl::willSetInputMethodState() |
785 { | 766 { |
786 if (m_webView->client()) | 767 if (m_webView->client()) |
787 m_webView->client()->resetInputMethod(); | 768 m_webView->client()->resetInputMethod(); |
788 } | 769 } |
789 | 770 |
790 } // namesace WebKit | 771 } // namesace WebKit |
OLD | NEW |