Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: Source/web/SpellCheckerClientImpl.cpp

Issue 189573002: Convert HTMLFrameOwnerElement and FocusController to use Frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Improve FocusController handling of RemoteFrames Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame());
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 23 matching lines...) Expand all
93 { 93 {
94 if (isContinuousSpellCheckingEnabled()) { 94 if (isContinuousSpellCheckingEnabled()) {
95 m_spellCheckThisFieldStatus = SpellCheckForcedOff; 95 m_spellCheckThisFieldStatus = SpellCheckForcedOff;
96 if (Page* page = m_webView->page()) { 96 if (Page* page = m_webView->page()) {
97 for (LocalFrame* frame = page->mainFrame(); frame && frame->document (); frame = frame->tree().traverseNext()) { 97 for (LocalFrame* frame = page->mainFrame(); frame && frame->document (); frame = frame->tree().traverseNext()) {
98 frame->document()->markers().removeMarkers(DocumentMarker::Missp ellingMarkers()); 98 frame->document()->markers().removeMarkers(DocumentMarker::Missp ellingMarkers());
99 } 99 }
100 } 100 }
101 } else { 101 } else {
102 m_spellCheckThisFieldStatus = SpellCheckForcedOn; 102 m_spellCheckThisFieldStatus = SpellCheckForcedOn;
103 if (LocalFrame* frame = m_webView->focusedWebCoreFrame()) { 103 if (LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame())) {
104 VisibleSelection frameSelection = frame->selection().selection(); 104 VisibleSelection frameSelection = frame->selection().selection();
105 // If a selection is in an editable element spell check its content. 105 // If a selection is in an editable element spell check its content.
106 if (Element* rootEditableElement = frameSelection.rootEditableElemen t()) { 106 if (Element* rootEditableElement = frameSelection.rootEditableElemen t()) {
107 frame->spellChecker().didBeginEditing(rootEditableElement); 107 frame->spellChecker().didBeginEditing(rootEditableElement);
108 } 108 }
109 } 109 }
110 } 110 }
111 } 111 }
112 112
113 bool SpellCheckerClientImpl::isGrammarCheckingEnabled() 113 bool SpellCheckerClientImpl::isGrammarCheckingEnabled()
114 { 114 {
115 const LocalFrame* frame = m_webView->focusedWebCoreFrame(); 115 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame());
116 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); 116 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled());
117 } 117 }
118 118
119 bool SpellCheckerClientImpl::shouldEraseMarkersAfterChangeSelection(TextChecking Type type) const 119 bool SpellCheckerClientImpl::shouldEraseMarkersAfterChangeSelection(TextChecking Type type) const
120 { 120 {
121 const LocalFrame* frame = m_webView->focusedWebCoreFrame(); 121 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame());
122 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); 122 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled());
123 } 123 }
124 124
125 void SpellCheckerClientImpl::checkSpellingOfString(const String& text, int* miss pellingLocation, int* misspellingLength) 125 void SpellCheckerClientImpl::checkSpellingOfString(const String& text, int* miss pellingLocation, int* misspellingLength)
126 { 126 {
127 // SpellCheckWord will write (0, 0) into the output vars, which is what our 127 // SpellCheckWord will write (0, 0) into the output vars, which is what our
128 // caller expects if the word is spelled correctly. 128 // caller expects if the word is spelled correctly.
129 int spellLocation = -1; 129 int spellLocation = -1;
130 int spellLength = 0; 130 int spellLength = 0;
131 131
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 221
222 bool SpellCheckerClientImpl::spellingUIIsShowing() 222 bool SpellCheckerClientImpl::spellingUIIsShowing()
223 { 223 {
224 if (m_webView->spellCheckClient()) 224 if (m_webView->spellCheckClient())
225 return m_webView->spellCheckClient()->isShowingSpellingUI(); 225 return m_webView->spellCheckClient()->isShowingSpellingUI();
226 return false; 226 return false;
227 } 227 }
228 228
229 } // namesace WebKit 229 } // namesace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698