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

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

Issue 2637953002: Move CaretBase::shouldRepaintCaret() to FrameCaret.cpp (Closed)
Patch Set: 2017-01-17T12:43:36 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretBase.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5e5eee8c07e1c3c0ad7e4291d1c83384f24f5dea..e00c0a893d58f63f43859235240ba21fcb01f8b4 100644
--- a/third_party/WebKit/Source/core/editing/FrameCaret.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameCaret.cpp
@@ -166,6 +166,15 @@ bool FrameCaret::caretPositionIsValidForDocument(
return caretPosition().document() == document && !caretPosition().isOrphan();
}
+static bool shouldRepaintCaret(Node& node) {
+ // If PositionAnchorType::BeforeAnchor or PositionAnchorType::AfterAnchor,
+ // carets need to be repainted not only when the node is contentEditable but
+ // also when its parentNode() is contentEditable.
+ node.document().updateStyleAndLayoutTree();
+ return hasEditableStyle(node) ||
+ (node.parentNode() && hasEditableStyle(*node.parentNode()));
+}
+
void FrameCaret::invalidateCaretRect(bool forceInvalidation) {
if (!m_caretRectDirty)
return;
@@ -202,11 +211,11 @@ void FrameCaret::invalidateCaretRect(bool forceInvalidation) {
return;
if (m_previousCaretAnchorNode &&
- CaretBase::shouldRepaintCaret(*m_previousCaretAnchorNode)) {
+ shouldRepaintCaret(*m_previousCaretAnchorNode)) {
m_caretBase->invalidateLocalCaretRect(m_previousCaretAnchorNode.get(),
m_previousCaretRect);
}
- if (newAnchorNode && CaretBase::shouldRepaintCaret(*newAnchorNode))
+ if (newAnchorNode && shouldRepaintCaret(*newAnchorNode))
m_caretBase->invalidateLocalCaretRect(newAnchorNode, newRect);
m_previousCaretNode = newNode;
m_previousCaretAnchorNode = newAnchorNode;
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698