Index: third_party/WebKit/Source/core/editing/FrameCaret.cpp |
diff --git a/third_party/WebKit/Source/core/editing/FrameCaret.cpp b/third_party/WebKit/Source/core/editing/FrameCaret.cpp |
index 640f161b6e3af20a571c37df626391730399aa5c..a69dbedbf67c7fc4c8ef97a7a564f5b93b9a9fa0 100644 |
--- a/third_party/WebKit/Source/core/editing/FrameCaret.cpp |
+++ b/third_party/WebKit/Source/core/editing/FrameCaret.cpp |
@@ -81,14 +81,20 @@ |
} |
void FrameCaret::updateAppearance() { |
- DCHECK_GE(m_frame->document()->lifecycle().state(), |
- DocumentLifecycle::LayoutClean); |
// Paint a block cursor instead of a caret in overtype mode unless the caret |
// is at the end of a line (in this case the FrameSelection will paint a |
// blinking caret as usual). |
- const bool paintBlockCursor = |
- m_shouldShowBlockCursor && isActive() && |
- !isLogicalEndOfLine(createVisiblePosition(caretPosition())); |
+ bool paintBlockCursor = m_shouldShowBlockCursor && isActive(); |
+ if (paintBlockCursor) { |
+ // TODO(editing-dev): Use of updateStyleAndLayoutIgnorePendingStylesheets |
+ // needs to be audited. see http://crbug.com/590369 for more details. |
+ // In the long term, we should defer the update of the caret's appearance |
+ // to prevent synchronous layout. |
+ m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ |
+ if (isLogicalEndOfLine(createVisiblePosition(caretPosition()))) |
+ paintBlockCursor = false; |
+ } |
bool shouldBlink = !paintBlockCursor && shouldBlinkCaret(); |
@@ -129,8 +135,7 @@ |
m_caretVisibility = visibility; |
- if (visibility == CaretVisibility::Hidden) |
- stopCaretBlinkTimer(); |
+ updateAppearance(); |
scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
} |
@@ -143,9 +148,6 @@ |
} |
void FrameCaret::updateStyleAndLayoutIfNeeded() { |
- DCHECK_GE(m_frame->document()->lifecycle().state(), |
- DocumentLifecycle::LayoutClean); |
- updateAppearance(); |
bool shouldPaintCaret = |
m_shouldPaintCaret && isActive() && |
m_caretVisibility == CaretVisibility::Visible && |
@@ -197,7 +199,10 @@ |
void FrameCaret::setShouldShowBlockCursor(bool shouldShowBlockCursor) { |
m_shouldShowBlockCursor = shouldShowBlockCursor; |
- scheduleVisualUpdateForPaintInvalidationIfNeeded(); |
+ |
+ m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
+ |
+ updateAppearance(); |
} |
bool FrameCaret::shouldPaintCaret(const LayoutBlock& block) const { |