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

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

Issue 219903002: Revert 170347 "Convert HTMLFrameOwnerElement and FocusController..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1917/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/WebFrameImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (!m_webView->focusedWebCoreFrame()->isLocalFrame()) 59 const LocalFrame* frame = m_webView->focusedWebCoreFrame();
60 return false;
61 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame());
62 if (!frame) 60 if (!frame)
63 return false; 61 return false;
64 if (frame->spellChecker().isSpellCheckingEnabledInFocusedNode()) 62 if (frame->spellChecker().isSpellCheckingEnabledInFocusedNode())
65 return true; 63 return true;
66 const Document* document = frame->document(); 64 const Document* document = frame->document();
67 if (!document) 65 if (!document)
68 return false; 66 return false;
69 const Element* element = document->focusedElement(); 67 const Element* element = document->focusedElement();
70 // 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
71 // 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
95 { 93 {
96 if (isContinuousSpellCheckingEnabled()) { 94 if (isContinuousSpellCheckingEnabled()) {
97 m_spellCheckThisFieldStatus = SpellCheckForcedOff; 95 m_spellCheckThisFieldStatus = SpellCheckForcedOff;
98 if (Page* page = m_webView->page()) { 96 if (Page* page = m_webView->page()) {
99 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()) {
100 frame->document()->markers().removeMarkers(DocumentMarker::Missp ellingMarkers()); 98 frame->document()->markers().removeMarkers(DocumentMarker::Missp ellingMarkers());
101 } 99 }
102 } 100 }
103 } else { 101 } else {
104 m_spellCheckThisFieldStatus = SpellCheckForcedOn; 102 m_spellCheckThisFieldStatus = SpellCheckForcedOn;
105 if (m_webView->focusedWebCoreFrame()->isLocalFrame()) { 103 if (LocalFrame* frame = m_webView->focusedWebCoreFrame()) {
106 if (LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame( ))) { 104 VisibleSelection frameSelection = frame->selection().selection();
107 VisibleSelection frameSelection = frame->selection().selection() ; 105 // If a selection is in an editable element spell check its content.
108 // If a selection is in an editable element spell check its cont ent. 106 if (Element* rootEditableElement = frameSelection.rootEditableElemen t()) {
109 if (Element* rootEditableElement = frameSelection.rootEditableEl ement()) { 107 frame->spellChecker().didBeginEditing(rootEditableElement);
110 frame->spellChecker().didBeginEditing(rootEditableElement);
111 }
112 } 108 }
113 } 109 }
114 } 110 }
115 } 111 }
116 112
117 bool SpellCheckerClientImpl::isGrammarCheckingEnabled() 113 bool SpellCheckerClientImpl::isGrammarCheckingEnabled()
118 { 114 {
119 const LocalFrame* frame = toLocalFrame(m_webView->focusedWebCoreFrame()); 115 const LocalFrame* frame = m_webView->focusedWebCoreFrame();
120 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled()); 116 return frame && frame->settings() && (frame->settings()->asynchronousSpellCh eckingEnabled() || frame->settings()->unifiedTextCheckerEnabled());
121 } 117 }
122 118
123 bool SpellCheckerClientImpl::shouldEraseMarkersAfterChangeSelection(TextChecking Type type) const 119 bool SpellCheckerClientImpl::shouldEraseMarkersAfterChangeSelection(TextChecking Type type) const
124 { 120 {
125 const Frame* frame = m_webView->focusedWebCoreFrame(); 121 const LocalFrame* frame = m_webView->focusedWebCoreFrame();
126 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled()); 122 return !frame || !frame->settings() || (!frame->settings()->asynchronousSpel lCheckingEnabled() && !frame->settings()->unifiedTextCheckerEnabled());
127 } 123 }
128 124
129 void SpellCheckerClientImpl::checkSpellingOfString(const String& text, int* miss pellingLocation, int* misspellingLength) 125 void SpellCheckerClientImpl::checkSpellingOfString(const String& text, int* miss pellingLocation, int* misspellingLength)
130 { 126 {
131 // 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
132 // caller expects if the word is spelled correctly. 128 // caller expects if the word is spelled correctly.
133 int spellLocation = -1; 129 int spellLocation = -1;
134 int spellLength = 0; 130 int spellLength = 0;
135 131
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 220 }
225 221
226 bool SpellCheckerClientImpl::spellingUIIsShowing() 222 bool SpellCheckerClientImpl::spellingUIIsShowing()
227 { 223 {
228 if (m_webView->spellCheckClient()) 224 if (m_webView->spellCheckClient())
229 return m_webView->spellCheckClient()->isShowingSpellingUI(); 225 return m_webView->spellCheckClient()->isShowingSpellingUI();
230 return false; 226 return false;
231 } 227 }
232 228
233 } // namesace WebKit 229 } // namesace WebKit
OLDNEW
« no previous file with comments | « Source/web/ContextMenuClientImpl.cpp ('k') | Source/web/WebFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698