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

Unified Diff: third_party/WebKit/Source/core/editing/DragCaret.cpp

Issue 2665823002: Invalidate caret during paint invalidation (Closed)
Patch Set: Rebaseline Created 3 years, 11 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/DragCaret.cpp
diff --git a/third_party/WebKit/Source/core/editing/DragCaret.cpp b/third_party/WebKit/Source/core/editing/DragCaret.cpp
index dbf4fe9903d277d033d41ec5c7fc9e4676450490..6d67d951b25fa4ddcd3e7af1adf744837edb208c 100644
--- a/third_party/WebKit/Source/core/editing/DragCaret.cpp
+++ b/third_party/WebKit/Source/core/editing/DragCaret.cpp
@@ -40,43 +40,31 @@ DragCaret* DragCaret::create() {
return new DragCaret;
}
+LayoutBlock* DragCaret::caretLayoutBlock() const {
+ LayoutBlock* block =
+ CaretDisplayItemClient::caretLayoutObject(m_position.anchorNode());
+ if (!block)
+ return nullptr;
+ if (!rootEditableElementOf(m_position.position()))
+ return nullptr;
+ return block;
+}
+
bool DragCaret::hasCaretIn(const LayoutBlock& layoutBlock) const {
- Node* node = m_position.anchorNode();
- if (!node)
- return false;
- if (layoutBlock != CaretDisplayItemClient::caretLayoutObject(node))
- return false;
- return rootEditableElementOf(m_position.position());
+ return layoutBlock == this->caretLayoutBlock();
}
bool DragCaret::isContentRichlyEditable() const {
return isRichlyEditablePosition(m_position.position());
}
-void DragCaret::invalidateCaretRect(Node* node,
- const LayoutRect& caretLocalRect) {
- // TODO(editing-dev): The use of updateStyleAndLayout
- // 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).
- node->document().updateStyleAndLayoutTree();
- if (!hasEditableStyle(*node))
- return;
- m_caretBase->invalidateLocalCaretRect(node, caretLocalRect);
-}
-
void DragCaret::setCaretPosition(const PositionWithAffinity& position) {
- // for querying Layer::compositingState()
- // This code is probably correct, since it doesn't occur in a stack that
- // involves updating compositing state.
- DisableCompositingQueryAsserts disabler;
+ if (LayoutBlock* block = caretLayoutBlock())
+ block->setMayNeedPaintInvalidation();
- if (Node* node = m_position.anchorNode())
- invalidateCaretRect(node, m_caretLocalRect);
m_position = createVisiblePosition(position).toPositionWithAffinity();
Document* document = nullptr;
if (Node* node = m_position.anchorNode()) {
- invalidateCaretRect(node, m_caretLocalRect);
document = &node->document();
setContext(document);
}
@@ -87,6 +75,9 @@ void DragCaret::setCaretPosition(const PositionWithAffinity& position) {
document->updateStyleAndLayoutTree();
m_caretLocalRect = CaretDisplayItemClient::computeCaretRect(m_position);
}
+
+ if (LayoutBlock* block = caretLayoutBlock())
+ block->setMayNeedPaintInvalidation();
}
void DragCaret::nodeChildrenWillBeRemoved(ContainerNode& container) {

Powered by Google App Engine
This is Rietveld 408576698