Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
| index f97e73703b3312b7a184cef46a346e29f7b16325..3e54922a2c36e7a81dbbcbe663f47baf76c7671d 100644 |
| --- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
| +++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
| @@ -776,6 +776,18 @@ void SpellChecker::replaceMisspelledRange(const String& text) |
| frame().editor().replaceSelectionWithText(text, false, false); |
| } |
| +static bool shouldCheckOldSelection(const VisibleSelection& oldSelection) |
| +{ |
| + if (!oldSelection.start().inShadowIncludingDocument()) |
| + return false; |
| + if (isSelectionInTextField(oldSelection)) |
| + return false; |
| + if (isSelectionInTextArea(oldSelection)) |
| + return true; |
| + oldSelection.start().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| + return oldSelection.isContentEditable(); |
| +} |
| + |
| void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions options) |
| { |
| TRACE_EVENT0("blink", "SpellChecker::respondToChangedSelection"); |
| @@ -785,16 +797,19 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio |
| bool closeTyping = options & FrameSelection::CloseTyping; |
| bool isContinuousSpellCheckingEnabled = this->isContinuousSpellCheckingEnabled(); |
| bool isContinuousGrammarCheckingEnabled = isContinuousSpellCheckingEnabled; |
| - if (isContinuousSpellCheckingEnabled) { |
| + if (isContinuousSpellCheckingEnabled && closeTyping) { |
|
yoichio
2016/06/24 09:52:39
Why do you introduce the |closeTyping| condition?
yosin_UTC9
2016/06/27 01:46:49
This if-statement does nothing if |!closeTyping| e
yoichio
2016/06/27 02:10:40
I see. then we can move the |shouldCheckOldSelecti
yosin_UTC9
2016/06/27 04:11:07
You're right. Good catch!
I moved it.
|
| VisibleSelection newAdjacentWords; |
| bool caretBrowsing = frame().settings() && frame().settings()->caretBrowsingEnabled(); |
| const VisibleSelection newSelection = frame().selection().selection(); |
| if (isSelectionInTextFormControl(newSelection)) { |
| Position newStart = newSelection.start(); |
| newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::startOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart)); |
| - } else if (newSelection.isContentEditable() || caretBrowsing) { |
| - VisiblePosition newStart(newSelection.visibleStart()); |
| - newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary)); |
| + } else { |
| + frame().document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| + if (newSelection.isContentEditable() || caretBrowsing) { |
| + VisiblePosition newStart(newSelection.visibleStart()); |
| + newAdjacentWords = VisibleSelection(startOfWord(newStart, LeftWordIfOnBoundary), endOfWord(newStart, RightWordIfOnBoundary)); |
| + } |
| } |
| // When typing we check spelling elsewhere, so don't redo it here. |
| @@ -802,12 +817,8 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio |
| // oldSelection may no longer be in the document. |
| // FIXME(http://crbug.com/382809): if oldSelection is on a textarea |
| // element, we cause synchronous layout. |
| - if (closeTyping |
| - && !isSelectionInTextField(oldSelection) |
| - && (isSelectionInTextArea(oldSelection) || oldSelection.isContentEditable()) |
| - && oldSelection.start().inShadowIncludingDocument()) { |
| + if (shouldCheckOldSelection(oldSelection)) |
| spellCheckOldSelection(oldSelection, newAdjacentWords); |
| - } |
| } |
| // When continuous spell checking is off, existing markers disappear after the selection changes. |