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

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

Issue 1654123002: Invalidate the previous caret even if the parent text node is removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more polishing if statement Created 4 years, 10 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/FrameSelection.h ('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/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index b51173b7bff61bb2ec2393b037a0360637a3abdf..cc2c54f34ed175fcc29b0dcd9799c7753d5c105c 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -634,6 +634,7 @@ void FrameSelection::prepareForDestruction()
setSelection(VisibleSelection(), CloseTyping | ClearTypingStyle | DoNotUpdateAppearance);
m_selectionEditor->dispose();
m_previousCaretNode.clear();
+ m_parentOfPreviousCaretNode.clear();
}
void FrameSelection::setStart(const VisiblePosition &pos, EUserTriggered trigger)
@@ -713,11 +714,20 @@ void FrameSelection::invalidateCaretRect()
return;
LayoutView* view = m_frame->document()->layoutView();
- if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shouldRepaintCaret(view)))
+ if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shouldRepaintCaret(view))) {
invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect);
- if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view)))
+ m_previousCaretRect = LayoutRect();
+ }
+ if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) {
invalidateLocalCaretRect(newNode, newRect);
+ if (!m_previousCaretRect.isEmpty() && m_previousCaretNode && !m_previousCaretNode->parentNode()
+ && newNode == m_parentOfPreviousCaretNode.get()) {
dshwang 2016/02/05 10:25:47 It means |newNode| is also detached from document.
yosin_UTC9 2016/02/12 03:53:13 I would like to have radical change. Current imple
+ // Must invalidate #text even if it's detached. crbug.com/528922
+ invalidateLocalCaretRect(newNode, m_previousCaretRect);
+ }
+ }
m_previousCaretNode = newNode;
+ m_parentOfPreviousCaretNode = newNode ? newNode->parentNode() : nullptr;
m_previousCaretRect = newRect;
m_previousCaretVisibility = caretVisibility();
}
@@ -1328,6 +1338,7 @@ DEFINE_TRACE(FrameSelection)
visitor->trace(m_originalBase);
visitor->trace(m_originalBaseInComposedTree);
visitor->trace(m_previousCaretNode);
+ visitor->trace(m_parentOfPreviousCaretNode);
visitor->trace(m_typingStyle);
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698