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

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

Issue 17005008: Don't show caret when containing element doesn't have focus (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-06-28T17:13:40 Created 7 years, 6 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 | « 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: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 6183f67653c5cddc2ab1a423a11431876047f94a..44df81eafbaf421f9c0a7d765a7fcdc0ceb9dd34 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -507,6 +507,11 @@ TextDirection FrameSelection::directionOfSelection()
return directionOfEnclosingBlock();
}
+void FrameSelection::didChangeFocus()
+{
+ updateAppearance();
+}
+
void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direction)
{
if (alter != AlterationExtend)
@@ -1778,14 +1783,17 @@ void FrameSelection::updateAppearance()
}
bool caretRectChangedOrCleared = recomputeCaretRect();
-
- bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
- bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull();
+ bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull();
// If the caret moved, stop the blink timer so we can restart with a
// black caret in the new location.
- if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypingCommand(m_frame))
+ if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypingCommand(m_frame)) {
m_caretBlinkTimer.stop();
+ if (!shouldBlink && m_caretPaint) {
+ m_caretPaint = false;
+ invalidateCaretRect();
+ }
+ }
// Start blinking with a black caret. Be sure not to restart if we're
// already blinking in the right location.
@@ -1849,6 +1857,25 @@ void FrameSelection::setCaretVisibility(CaretVisibility visibility)
updateAppearance();
}
+bool FrameSelection::shouldBlinkCaret() const
+{
+ if (!caretIsVisible() || !isCaret())
+ return false;
+
+ if (m_frame->settings() && m_frame->settings()->caretBrowsingEnabled())
+ return false;
+
+ Node* root = rootEditableElement();
+ if (!root)
+ return false;
+
+ Node* focusedNode = root->document()->focusedNode();
+ if (!focusedNode)
+ return false;
+
+ return focusedNode->containsIncludingShadowDOM(m_selection.start().anchorNode());
+}
+
void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*)
{
ASSERT(caretIsVisible());
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698