Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp b/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp |
| index b5089bc6d6662368fbf3e7f2ab0dee5810393380..902f77b4112fb211a1fe912ef4068eb659fed405 100644 |
| --- a/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp |
| +++ b/third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp |
| @@ -117,8 +117,12 @@ LayoutRect CaretDisplayItemClient::computeCaretRect( |
| void CaretDisplayItemClient::updateStyleAndLayoutIfNeeded( |
| const PositionWithAffinity& caretPosition) { |
| - m_previousLayoutBlock = m_layoutBlock; |
| - m_previousVisualRect = m_visualRect; |
| + // We should save m_previousLayoutBlock and m_visualRectInPreviousLayoutBlock |
| + // only if they have not been saved since the last paint invalidation. |
|
chrishtr
2017/03/08 17:36:06
This conditional is needed because there may be mu
Xianzhu
2017/03/08 19:38:22
Yes. Added comment.
|
| + if (!m_previousLayoutBlock) { |
| + m_previousLayoutBlock = m_layoutBlock; |
| + m_visualRectInPreviousLayoutBlock = m_visualRect; |
| + } |
| LayoutBlock* newLayoutBlock = caretLayoutBlock(caretPosition.anchorNode()); |
| if (newLayoutBlock != m_layoutBlock) { |
| @@ -182,7 +186,7 @@ void CaretDisplayItemClient::invalidatePaintInPreviousLayoutBlock( |
| if (!isImmediateFullPaintInvalidationReason( |
| layoutBlockPaintInvalidationReason)) { |
| objectInvalidator.invalidatePaintRectangleWithContext( |
| - m_previousVisualRect, PaintInvalidationCaret); |
| + m_visualRectInPreviousLayoutBlock, PaintInvalidationCaret); |
| } |
| context.paintingLayer->setNeedsRepaint(); |
| @@ -210,12 +214,23 @@ void CaretDisplayItemClient::invalidatePaintInCurrentLayoutBlock( |
| } |
| } |
| - if (!m_needsPaintInvalidation && newVisualRect == m_visualRect) |
| + if (m_layoutBlock == m_previousLayoutBlock) |
| + m_previousLayoutBlock = nullptr; |
| + |
| + ObjectPaintInvalidatorWithContext objectInvalidator(*m_layoutBlock, context); |
| + if (!m_needsPaintInvalidation && newVisualRect == m_visualRect) { |
| + // The caret may change paint offset without changing visual rect, and we |
| + // need to invalidate the display item client. |
| + if (isImmediateFullPaintInvalidationReason( |
| + layoutBlockPaintInvalidationReason)) { |
| + objectInvalidator.invalidateDisplayItemClient(*this, |
| + PaintInvalidationCaret); |
| + } |
| return; |
| + } |
| m_needsPaintInvalidation = false; |
| - ObjectPaintInvalidatorWithContext objectInvalidator(*m_layoutBlock, context); |
| if (!isImmediateFullPaintInvalidationReason( |
| layoutBlockPaintInvalidationReason)) { |
| objectInvalidator.fullyInvalidatePaint(PaintInvalidationCaret, m_visualRect, |