Chromium Code Reviews| Index: Source/core/editing/SpellChecker.cpp |
| diff --git a/Source/core/editing/SpellChecker.cpp b/Source/core/editing/SpellChecker.cpp |
| index 43229a7769168f70ac1ce583e5ba4ec9a7267025..197dc67527c17574ec4f0e2704698e9b9b9194b4 100644 |
| --- a/Source/core/editing/SpellChecker.cpp |
| +++ b/Source/core/editing/SpellChecker.cpp |
| @@ -58,6 +58,17 @@ bool isSelectionInTextField(const VisibleSelection& selection) |
| return isHTMLInputElement(textControl) && toHTMLInputElement(textControl)->isTextField(); |
| } |
| +bool isSelectionInTextArea(const VisibleSelection& selection) |
| +{ |
| + HTMLTextFormControlElement* textControl = enclosingTextFormControl(selection.start()); |
| + return isHTMLTextAreaElement(textControl); |
| +} |
| + |
| +bool isSelectionInTextForm(const VisibleSelection& selection) |
|
yosin_UTC9
2014/07/02 09:44:03
nit: It is better to call |isSelectionInTextFormCo
|
| +{ |
| + return !!enclosingTextFormControl(selection.start()); |
| +} |
| + |
| } // namespace |
| PassOwnPtr<SpellChecker> SpellChecker::create(LocalFrame& frame) |
| @@ -759,8 +770,14 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio |
| VisibleSelection newAdjacentWords; |
| VisibleSelection newSelectedSentence; |
| bool caretBrowsing = m_frame.settings() && m_frame.settings()->caretBrowsingEnabled(); |
| - if (m_frame.selection().selection().isContentEditable() || caretBrowsing) { |
| - VisiblePosition newStart(m_frame.selection().selection().visibleStart()); |
| + const VisibleSelection newSelection = m_frame.selection().selection(); |
| + if (isSelectionInTextForm(newSelection)) { |
| + Position newStart = newSelection.start(); |
| + newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::startOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart)); |
| + if (isContinuousGrammarCheckingEnabled) |
| + newSelectedSentence.setWithoutValidation(HTMLTextFormControlElement::startOfSentence(newStart), HTMLTextFormControlElement::endOfSentence(newStart)); |
| + } else if (newSelection.isContentEditable() || caretBrowsing) { |
| + VisiblePosition newStart(newSelection.visibleStart()); |
| newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary)); |
| if (isContinuousGrammarCheckingEnabled) |
| newSelectedSentence = VisibleSelection(startOfSentence(newStart), endOfSentence(newStart)); |
| @@ -774,9 +791,9 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio |
| // oldSelection may no longer be in the document. |
| if (shouldCheckSpellingAndGrammar |
| && closeTyping |
| - && oldSelection.isContentEditable() |
| - && oldSelection.start().inDocument() |
| - && !isSelectionInTextField(oldSelection)) { |
| + && !isSelectionInTextField(oldSelection) |
| + && (isSelectionInTextArea(oldSelection) || oldSelection.isContentEditable()) |
| + && oldSelection.start().inDocument()) { |
| spellCheckOldSelection(oldSelection, newAdjacentWords); |
| } |