| 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 2d6dec3326de54921cf960a98b277c33ad71143e..9091232ab9f57649f4978eeaa1db5be86f4e29a1 100644
|
| --- a/third_party/WebKit/Source/core/editing/FrameCaret.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/FrameCaret.cpp
|
| @@ -54,7 +54,8 @@ FrameCaret::FrameCaret(LocalFrame& frame,
|
| &FrameCaret::caretBlinkTimerFired),
|
| m_shouldPaintCaret(true),
|
| m_isCaretBlinkingSuspended(false),
|
| - m_shouldShowBlockCursor(false) {}
|
| + m_shouldShowBlockCursor(false),
|
| + m_shouldUpdateLayoutAndStyle(false) {}
|
|
|
| FrameCaret::~FrameCaret() = default;
|
|
|
| @@ -81,20 +82,14 @@ inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) {
|
| }
|
|
|
| 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).
|
| - 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;
|
| - }
|
| + const bool paintBlockCursor =
|
| + m_shouldShowBlockCursor && isActive() &&
|
| + !isLogicalEndOfLine(createVisiblePosition(caretPosition()));
|
|
|
| bool shouldBlink = !paintBlockCursor && shouldBlinkCaret();
|
|
|
| @@ -135,7 +130,8 @@ void FrameCaret::setCaretVisibility(CaretVisibility visibility) {
|
|
|
| m_caretVisibility = visibility;
|
|
|
| - updateAppearance();
|
| + if (visibility == CaretVisibility::Hidden)
|
| + stopCaretBlinkTimer();
|
| scheduleVisualUpdateForPaintInvalidationIfNeeded();
|
| }
|
|
|
| @@ -148,6 +144,9 @@ void FrameCaret::layoutBlockWillBeDestroyed(const LayoutBlock& block) {
|
| }
|
|
|
| void FrameCaret::updateStyleAndLayoutIfNeeded() {
|
| + DCHECK_GE(m_frame->document()->lifecycle().state(),
|
| + DocumentLifecycle::LayoutClean);
|
| + updateAppearance();
|
| bool shouldPaintCaret =
|
| m_shouldPaintCaret && isActive() &&
|
| m_caretVisibility == CaretVisibility::Visible &&
|
| @@ -206,10 +205,7 @@ IntRect FrameCaret::absoluteCaretBounds() const {
|
|
|
| void FrameCaret::setShouldShowBlockCursor(bool shouldShowBlockCursor) {
|
| m_shouldShowBlockCursor = shouldShowBlockCursor;
|
| -
|
| - m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
|
| -
|
| - updateAppearance();
|
| + scheduleVisualUpdateForPaintInvalidationIfNeeded();
|
| }
|
|
|
| bool FrameCaret::shouldPaintCaret(const LayoutBlock& block) const {
|
|
|