Chromium Code Reviews| 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" |
| 52 #include "core/editing/SpellChecker.h" | 53 #include "core/editing/SpellChecker.h" |
| 53 #include "core/editing/UndoStep.h" | 54 #include "core/editing/UndoStep.h" |
| 54 #include "core/html/HTMLInputElement.h" | 55 #include "core/html/HTMLInputElement.h" |
| 55 #include "core/page/EventHandler.h" | 56 #include "core/page/EventHandler.h" |
| 56 #include "core/page/Frame.h" | 57 #include "core/page/Frame.h" |
| 57 #include "core/page/Page.h" | 58 #include "core/page/Page.h" |
| 58 #include "core/page/Settings.h" | 59 #include "core/page/Settings.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 { | 133 { |
| 133 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) | 134 if (m_spellCheckThisFieldStatus == SpellCheckForcedOff) |
| 134 return false; | 135 return false; |
| 135 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) | 136 if (m_spellCheckThisFieldStatus == SpellCheckForcedOn) |
| 136 return true; | 137 return true; |
| 137 return shouldSpellcheckByDefault(); | 138 return shouldSpellcheckByDefault(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void EditorClientImpl::toggleContinuousSpellChecking() | 141 void EditorClientImpl::toggleContinuousSpellChecking() |
| 141 { | 142 { |
| 142 if (isContinuousSpellCheckingEnabled()) | 143 if (isContinuousSpellCheckingEnabled()) { |
| 143 m_spellCheckThisFieldStatus = SpellCheckForcedOff; | 144 m_spellCheckThisFieldStatus = SpellCheckForcedOff; |
| 144 else | 145 const Frame* frame = m_webView->focusedWebCoreFrame(); |
| 146 if (frame) | |
|
abarth-chromium
2013/07/31 00:42:14
No need for "const". There's no meaningful sense
pstanek
2013/08/12 12:21:23
Won't this remove markers in one frame only (it sh
| |
| 147 frame->document()->markers()->removeMarkers(DocumentMarker::Spelling | DocumentMarker::Grammar); | |
| 148 } else { | |
| 145 m_spellCheckThisFieldStatus = SpellCheckForcedOn; | 149 m_spellCheckThisFieldStatus = SpellCheckForcedOn; |
| 150 const Frame* frame = m_webView->focusedWebCoreFrame(); | |
| 151 if (frame) { | |
|
abarth-chromium
2013/07/31 00:42:14
ditto
| |
| 152 VisibleSelection frameSelection = frame->selection()->selection(); | |
| 153 Element* rootEditableElement = frameSelection.rootEditableElement(); | |
| 154 // If a selection is in an editable element spell check its content. | |
| 155 if (rootEditableElement) { | |
|
abarth-chromium
2013/07/31 00:42:14
You can also combine this if statement with the pr
| |
| 156 VisibleSelection selection = VisibleSelection::selectionFromCont entsOfNode(rootEditableElement); | |
| 157 frame->editor()->markMisspellingsAndBadGrammar(selection); | |
| 158 } | |
| 159 } | |
| 160 } | |
| 146 } | 161 } |
| 147 | 162 |
| 148 bool EditorClientImpl::isGrammarCheckingEnabled() | 163 bool EditorClientImpl::isGrammarCheckingEnabled() |
| 149 { | 164 { |
| 150 const Frame* frame = m_webView->focusedWebCoreFrame(); | 165 const Frame* frame = m_webView->focusedWebCoreFrame(); |
| 151 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); | 166 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); |
| 152 } | 167 } |
| 153 | 168 |
| 154 bool EditorClientImpl::shouldBeginEditing(Range* range) | 169 bool EditorClientImpl::shouldBeginEditing(Range* range) |
| 155 { | 170 { |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 #endif | 778 #endif |
| 764 } | 779 } |
| 765 | 780 |
| 766 void EditorClientImpl::willSetInputMethodState() | 781 void EditorClientImpl::willSetInputMethodState() |
| 767 { | 782 { |
| 768 if (m_webView->client()) | 783 if (m_webView->client()) |
| 769 m_webView->client()->resetInputMethod(); | 784 m_webView->client()->resetInputMethod(); |
| 770 } | 785 } |
| 771 | 786 |
| 772 } // namesace WebKit | 787 } // namesace WebKit |
| OLD | NEW |