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

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

Issue 2297503002: Fix usage of DocumentLifecycle::DisallowTransitionScope (Closed)
Patch Set: Add missing layout update Created 4 years, 4 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
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 d2c5e41370ab6354838c884429562b356c886432..f04fa44cc1db8bd85a2ceb6b9e8252edd503f8a6 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -177,7 +177,7 @@ void SpellChecker::didBeginEditing(Element* element)
// synchronous layout caused by spell checking (see crbug.com/517298).
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
- DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle());
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
bool isTextField = false;
HTMLTextFormControlElement* enclosingHTMLTextFormControlElement = 0;
@@ -212,7 +212,7 @@ void SpellChecker::ignoreSpelling()
void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection)
{
- DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle());
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
// The basic approach is to search in two phases - from the selection end to the end of the doc, and
// then we wrap and search from the doc start to (approximately) where we started.
@@ -329,7 +329,7 @@ void SpellChecker::markMisspellingsAndBadGrammarForMovingParagraphs(const Visibl
// synchronous layout caused by spell checking (see crbug.com/517298).
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
- DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle());
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
markMisspellingsAndBadGrammar(movingSelection);
}
@@ -517,7 +517,7 @@ void SpellChecker::markAndReplaceFor(SpellCheckRequest* request, const Vector<Te
bool adjustSelectionForParagraphBoundaries = false;
{
- DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle());
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
if (frame().selection().isCaret()) {
// Attempt to save the caret position so we can restore it later if needed
@@ -733,7 +733,13 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio
if (!shouldCheckOldSelection(oldSelection))
return;
- DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle());
+ // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
+ // needs to be audited. See http://crbug.com/590369 for more details.
+ // In the long term we should use idle time spell checker to prevent
+ // synchronous layout caused by spell checking (see crbug.com/517298).
+ frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
+
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
VisibleSelection newAdjacentWords;
const VisibleSelection newSelection = frame().selection().selection();
@@ -741,7 +747,6 @@ void SpellChecker::respondToChangedSelection(const VisibleSelection& oldSelectio
const Position newStart = newSelection.start();
newAdjacentWords.setWithoutValidation(HTMLTextFormControlElement::startOfWord(newStart), HTMLTextFormControlElement::endOfWord(newStart));
} else {
- frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
const bool caretBrowsing = frame().settings() && frame().settings()->caretBrowsingEnabled();
if (newSelection.isContentEditable() || caretBrowsing) {
const VisiblePosition newStart(newSelection.visibleStart());
@@ -787,7 +792,7 @@ void SpellChecker::spellCheckAfterBlur()
// synchronous layout caused by spell checking (see crbug.com/517298).
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
- DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle());
+ DocumentLifecycle::DisallowTransitionScope disallowTransition(frame().document()->lifecycle());
VisibleSelection empty;
spellCheckOldSelection(frame().selection().selection(), empty);

Powered by Google App Engine
This is Rietveld 408576698