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