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

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2092063002: Make SpellChecker::respondToChangedSelection() to update layout tree explicitly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-06-27T12:44:31 Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5ced5f51e552afcf9632cbe705ffc64ad2f121cd 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 && shouldCheckOldSelection(oldSelection)) {
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,7 @@ 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()) {
- spellCheckOldSelection(oldSelection, newAdjacentWords);
- }
+ spellCheckOldSelection(oldSelection, newAdjacentWords);
}
// When continuous spell checking is off, existing markers disappear after the selection changes.
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698