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

Side by Side Diff: third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp

Issue 2739253002: Fix another caret paint invalidation issue (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void CaretDisplayItemClient::updateStyleAndLayoutIfNeeded( 118 void CaretDisplayItemClient::updateStyleAndLayoutIfNeeded(
119 const PositionWithAffinity& caretPosition) { 119 const PositionWithAffinity& caretPosition) {
120 // This method may be called multiple times (e.g. in partial lifecycle 120 // This method may be called multiple times (e.g. in partial lifecycle
121 // updates) before a paint invalidation. We should save m_previousLayoutBlock 121 // updates) before a paint invalidation. We should save m_previousLayoutBlock
122 // and m_visualRectInPreviousLayoutBlock only if they have not been saved 122 // and m_visualRectInPreviousLayoutBlock only if they have not been saved
123 // since the last paint invalidation to ensure the caret painted in the 123 // since the last paint invalidation to ensure the caret painted in the
124 // previous paint invalidated block will be invalidated. We don't care about 124 // previous paint invalidated block will be invalidated. We don't care about
125 // intermediate changes of layoutBlock because they are not painted. 125 // intermediate changes of layoutBlock because they are not painted.
126 if (!m_previousLayoutBlock) { 126 if (!m_previousLayoutBlock) {
127 m_previousLayoutBlock = m_layoutBlock; 127 m_previousLayoutBlock = m_layoutBlock;
128 DCHECK(m_visualRectInPreviousLayoutBlock.isEmpty());
128 m_visualRectInPreviousLayoutBlock = m_visualRect; 129 m_visualRectInPreviousLayoutBlock = m_visualRect;
129 } 130 }
130 131
131 LayoutBlock* newLayoutBlock = caretLayoutBlock(caretPosition.anchorNode()); 132 LayoutBlock* newLayoutBlock = caretLayoutBlock(caretPosition.anchorNode());
132 if (newLayoutBlock != m_layoutBlock) { 133 if (newLayoutBlock != m_layoutBlock) {
133 if (m_layoutBlock) 134 if (m_layoutBlock)
134 m_layoutBlock->setMayNeedPaintInvalidation(); 135 m_layoutBlock->setMayNeedPaintInvalidation();
135 m_layoutBlock = newLayoutBlock; 136 m_layoutBlock = newLayoutBlock;
136 if (newLayoutBlock) 137 if (newLayoutBlock)
137 m_needsPaintInvalidation = true; 138 m_needsPaintInvalidation = true;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 context); 185 context);
185 if (!isImmediateFullPaintInvalidationReason( 186 if (!isImmediateFullPaintInvalidationReason(
186 m_previousLayoutBlock->fullPaintInvalidationReason())) { 187 m_previousLayoutBlock->fullPaintInvalidationReason())) {
187 objectInvalidator.invalidatePaintRectangleWithContext( 188 objectInvalidator.invalidatePaintRectangleWithContext(
188 m_visualRectInPreviousLayoutBlock, PaintInvalidationCaret); 189 m_visualRectInPreviousLayoutBlock, PaintInvalidationCaret);
189 } 190 }
190 191
191 context.paintingLayer->setNeedsRepaint(); 192 context.paintingLayer->setNeedsRepaint();
192 objectInvalidator.invalidateDisplayItemClient(*this, PaintInvalidationCaret); 193 objectInvalidator.invalidateDisplayItemClient(*this, PaintInvalidationCaret);
193 m_previousLayoutBlock = nullptr; 194 m_previousLayoutBlock = nullptr;
195 m_visualRectInPreviousLayoutBlock = LayoutRect();
194 } 196 }
195 197
196 void CaretDisplayItemClient::invalidatePaintInCurrentLayoutBlock( 198 void CaretDisplayItemClient::invalidatePaintInCurrentLayoutBlock(
197 const PaintInvalidatorContext& context) { 199 const PaintInvalidatorContext& context) {
198 DCHECK(m_layoutBlock); 200 DCHECK(m_layoutBlock);
199 201
200 LayoutRect newVisualRect; 202 LayoutRect newVisualRect;
201 if (!m_localRect.isEmpty()) { 203 if (!m_localRect.isEmpty()) {
202 newVisualRect = m_localRect; 204 newVisualRect = m_localRect;
203 context.mapLocalRectToPaintInvalidationBacking(*m_layoutBlock, 205 context.mapLocalRectToPaintInvalidationBacking(*m_layoutBlock,
204 newVisualRect); 206 newVisualRect);
205 newVisualRect.move(m_layoutBlock->scrollAdjustmentForPaintInvalidation( 207 newVisualRect.move(m_layoutBlock->scrollAdjustmentForPaintInvalidation(
206 *context.paintInvalidationContainer)); 208 *context.paintInvalidationContainer));
207 209
208 if (m_layoutBlock->usesCompositedScrolling()) { 210 if (m_layoutBlock->usesCompositedScrolling()) {
209 // The caret should use scrolling coordinate space. 211 // The caret should use scrolling coordinate space.
210 DCHECK(m_layoutBlock == context.paintInvalidationContainer); 212 DCHECK(m_layoutBlock == context.paintInvalidationContainer);
211 newVisualRect.move(LayoutSize(m_layoutBlock->scrolledContentOffset())); 213 newVisualRect.move(LayoutSize(m_layoutBlock->scrolledContentOffset()));
212 } 214 }
213 } 215 }
214 216
215 if (m_layoutBlock == m_previousLayoutBlock) 217 if (m_layoutBlock == m_previousLayoutBlock &&
218 m_visualRect == m_visualRectInPreviousLayoutBlock) {
chrishtr 2017/03/10 05:06:07 Why is this conditional required? Can't figure thi
216 m_previousLayoutBlock = nullptr; 219 m_previousLayoutBlock = nullptr;
220 m_visualRectInPreviousLayoutBlock = LayoutRect();
221 }
217 222
218 ObjectPaintInvalidatorWithContext objectInvalidator(*m_layoutBlock, context); 223 ObjectPaintInvalidatorWithContext objectInvalidator(*m_layoutBlock, context);
219 if (!m_needsPaintInvalidation && newVisualRect == m_visualRect) { 224 if (!m_needsPaintInvalidation && newVisualRect == m_visualRect) {
220 // The caret may change paint offset without changing visual rect, and we 225 // The caret may change paint offset without changing visual rect, and we
221 // need to invalidate the display item client if the block is doing full 226 // need to invalidate the display item client if the block is doing full
222 // paint invalidation. 227 // paint invalidation.
223 if (isImmediateFullPaintInvalidationReason( 228 if (isImmediateFullPaintInvalidationReason(
224 m_layoutBlock->fullPaintInvalidationReason()) || 229 m_layoutBlock->fullPaintInvalidationReason()) ||
225 // For non-SPv2, ForcedSubtreeInvalidationChecking may hint change of 230 // For non-SPv2, ForcedSubtreeInvalidationChecking may hint change of
226 // paint offset. See ObjectPaintInvalidatorWithContext:: 231 // paint offset. See ObjectPaintInvalidatorWithContext::
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 271
267 String CaretDisplayItemClient::debugName() const { 272 String CaretDisplayItemClient::debugName() const {
268 return "Caret"; 273 return "Caret";
269 } 274 }
270 275
271 LayoutRect CaretDisplayItemClient::visualRect() const { 276 LayoutRect CaretDisplayItemClient::visualRect() const {
272 return m_visualRect; 277 return m_visualRect;
273 } 278 }
274 279
275 } // namespace blink 280 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698