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" |
49 #include "core/dom/EventNames.h" | 50 #include "core/dom/EventNames.h" |
50 #include "core/dom/KeyboardEvent.h" | 51 #include "core/dom/KeyboardEvent.h" |
51 #include "core/editing/Editor.h" | 52 #include "core/editing/Editor.h" |
| 53 #include "core/editing/SpellCheckRequester.h" |
| 54 #include "core/editing/TextCheckingHelper.h" |
52 #include "core/editing/UndoStep.h" | 55 #include "core/editing/UndoStep.h" |
53 #include "core/html/HTMLInputElement.h" | 56 #include "core/html/HTMLInputElement.h" |
54 #include "core/page/EventHandler.h" | 57 #include "core/page/EventHandler.h" |
55 #include "core/page/Frame.h" | 58 #include "core/page/Frame.h" |
56 #include "core/page/Page.h" | 59 #include "core/page/Page.h" |
57 #include "core/page/Settings.h" | 60 #include "core/page/Settings.h" |
58 #include "core/platform/NotImplemented.h" | 61 #include "core/platform/NotImplemented.h" |
59 #include "core/platform/PlatformKeyboardEvent.h" | 62 #include "core/platform/PlatformKeyboardEvent.h" |
60 #include "core/platform/chromium/KeyboardCodes.h" | 63 #include "core/platform/chromium/KeyboardCodes.h" |
61 #include "core/rendering/RenderObject.h" | 64 #include "core/rendering/RenderObject.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 { | 134 { |
132 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) | 135 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) |
133 return false; | 136 return false; |
134 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) | 137 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) |
135 return true; | 138 return true; |
136 return shouldSpellcheckByDefault(); | 139 return shouldSpellcheckByDefault(); |
137 } | 140 } |
138 | 141 |
139 void EditorClientImpl::toggleContinuousSpellChecking() | 142 void EditorClientImpl::toggleContinuousSpellChecking() |
140 { | 143 { |
141 if (isContinuousSpellCheckingEnabled()) | 144 if (isContinuousSpellCheckingEnabled()) { |
142 m_spellCheckThisFieldStatus = SpellCheckForcedOff; | 145 m_spellCheckThisFieldStatus = SpellCheckForcedOff; |
143 else | 146 if (Page* page = m_webView->page()) { |
| 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 { |
144 m_spellCheckThisFieldStatus = SpellCheckForcedOn; | 152 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 } |
145 } | 164 } |
146 | 165 |
147 bool EditorClientImpl::isGrammarCheckingEnabled() | 166 bool EditorClientImpl::isGrammarCheckingEnabled() |
148 { | 167 { |
149 const Frame* frame = m_webView->focusedWebCoreFrame(); | 168 const Frame* frame = m_webView->focusedWebCoreFrame(); |
150 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh
eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); | 169 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh
eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); |
151 } | 170 } |
152 | 171 |
153 bool EditorClientImpl::shouldBeginEditing(Range* range) | 172 bool EditorClientImpl::shouldBeginEditing(Range* range) |
154 { | 173 { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 #endif | 781 #endif |
763 } | 782 } |
764 | 783 |
765 void EditorClientImpl::willSetInputMethodState() | 784 void EditorClientImpl::willSetInputMethodState() |
766 { | 785 { |
767 if (m_webView->client()) | 786 if (m_webView->client()) |
768 m_webView->client()->resetInputMethod(); | 787 m_webView->client()->resetInputMethod(); |
769 } | 788 } |
770 | 789 |
771 } // namesace WebKit | 790 } // namesace WebKit |
OLD | NEW |