| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 SpellCheckerClientImpl::~SpellCheckerClientImpl() | 51 SpellCheckerClientImpl::~SpellCheckerClientImpl() |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool SpellCheckerClientImpl::shouldSpellcheckByDefault() | 55 bool SpellCheckerClientImpl::shouldSpellcheckByDefault() |
| 56 { | 56 { |
| 57 // Spellcheck should be enabled for all editable areas (such as textareas, | 57 // Spellcheck should be enabled for all editable areas (such as textareas, |
| 58 // contentEditable regions, designMode docs and inputs). | 58 // contentEditable regions, designMode docs and inputs). |
| 59 const LocalFrame* frame = m_webView->focusedWebCoreFrame(); | 59 if (!m_webView->focusedWebCoreFrame()->isLocalFrame()) |
| 60 return false; |
| 61 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame()); |
| 60 if (!frame) | 62 if (!frame) |
| 61 return false; | 63 return false; |
| 62 if (frame->spellChecker().isSpellCheckingEnabledInFocusedNode()) | 64 if (frame->spellChecker().isSpellCheckingEnabledInFocusedNode()) |
| 63 return true; | 65 return true; |
| 64 const Document* document = frame->document(); | 66 const Document* document = frame->document(); |
| 65 if (!document) | 67 if (!document) |
| 66 return false; | 68 return false; |
| 67 const Element* element = document->focusedElement(); | 69 const Element* element = document->focusedElement(); |
| 68 // If |element| is null, we default to allowing spellchecking. This is done | 70 // If |element| is null, we default to allowing spellchecking. This is done |
| 69 // in order to mitigate the issue when the user clicks outside the textbox, | 71 // in order to mitigate the issue when the user clicks outside the textbox, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 93 { | 95 { |
| 94 if (isContinuousSpellCheckingEnabled()) { | 96 if (isContinuousSpellCheckingEnabled()) { |
| 95 m_spellCheckThisFieldStatus = SpellCheckForcedOff; | 97 m_spellCheckThisFieldStatus = SpellCheckForcedOff; |
| 96 if (Page* page = m_webView->page()) { | 98 if (Page* page = m_webView->page()) { |
| 97 for (LocalFrame* frame = page->mainFrame(); frame && frame->document
(); frame = frame->tree().traverseNext()) { | 99 for (LocalFrame* frame = page->mainFrame(); frame && frame->document
(); frame = frame->tree().traverseNext()) { |
| 98 frame->document()->markers().removeMarkers(DocumentMarker::Missp
ellingMarkers()); | 100 frame->document()->markers().removeMarkers(DocumentMarker::Missp
ellingMarkers()); |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 } else { | 103 } else { |
| 102 m_spellCheckThisFieldStatus = SpellCheckForcedOn; | 104 m_spellCheckThisFieldStatus = SpellCheckForcedOn; |
| 103 if (LocalFrame* frame = m_webView->focusedWebCoreFrame()) { | 105 if (m_webView->focusedWebCoreFrame()->isLocalFrame()) { |
| 104 VisibleSelection frameSelection = frame->selection().selection(); | 106 if (LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame(
))) { |
| 105 // If a selection is in an editable element spell check its content. | 107 VisibleSelection frameSelection = frame->selection().selection()
; |
| 106 if (Element* rootEditableElement = frameSelection.rootEditableElemen
t()) { | 108 // If a selection is in an editable element spell check its cont
ent. |
| 107 frame->spellChecker().didBeginEditing(rootEditableElement); | 109 if (Element* rootEditableElement = frameSelection.rootEditableEl
ement()) { |
| 110 frame->spellChecker().didBeginEditing(rootEditableElement); |
| 111 } |
| 108 } | 112 } |
| 109 } | 113 } |
| 110 } | 114 } |
| 111 } | 115 } |
| 112 | 116 |
| 113 bool SpellCheckerClientImpl::isGrammarCheckingEnabled() | 117 bool SpellCheckerClientImpl::isGrammarCheckingEnabled() |
| 114 { | 118 { |
| 115 const LocalFrame* frame = m_webView->focusedWebCoreFrame(); | 119 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame()); |
| 116 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh
eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); | 120 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh
eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); |
| 117 } | 121 } |
| 118 | 122 |
| 119 bool SpellCheckerClientImpl::shouldEraseMarkersAfterChangeSelection(TextChecking
Type type) const | 123 bool SpellCheckerClientImpl::shouldEraseMarkersAfterChangeSelection(TextChecking
Type type) const |
| 120 { | 124 { |
| 121 const LocalFrame* frame = m_webView->focusedWebCoreFrame(); | 125 const Frame* frame = m_webView->focusedWebCoreFrame(); |
| 122 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel
lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); | 126 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel
lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); |
| 123 } | 127 } |
| 124 | 128 |
| 125 void SpellCheckerClientImpl::checkSpellingOfString(const String& text, int* miss
pellingLocation, int* misspellingLength) | 129 void SpellCheckerClientImpl::checkSpellingOfString(const String& text, int* miss
pellingLocation, int* misspellingLength) |
| 126 { | 130 { |
| 127 // SpellCheckWord will write (0, 0) into the output vars, which is what our | 131 // SpellCheckWord will write (0, 0) into the output vars, which is what our |
| 128 // caller expects if the word is spelled correctly. | 132 // caller expects if the word is spelled correctly. |
| 129 int spellLocation = -1; | 133 int spellLocation = -1; |
| 130 int spellLength = 0; | 134 int spellLength = 0; |
| 131 | 135 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 224 } |
| 221 | 225 |
| 222 bool SpellCheckerClientImpl::spellingUIIsShowing() | 226 bool SpellCheckerClientImpl::spellingUIIsShowing() |
| 223 { | 227 { |
| 224 if (m_webView->spellCheckClient()) | 228 if (m_webView->spellCheckClient()) |
| 225 return m_webView->spellCheckClient()->isShowingSpellingUI(); | 229 return m_webView->spellCheckClient()->isShowingSpellingUI(); |
| 226 return false; | 230 return false; |
| 227 } | 231 } |
| 228 | 232 |
| 229 } // namesace WebKit | 233 } // namesace WebKit |
| OLD | NEW |