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

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-28T14:12:48 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
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 6183f67653c5cddc2ab1a423a11431876047f94a..9902e1a079f5ae5d5caa3b7a3b93698bd3ac3c1a 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -507,6 +507,11 @@ TextDirection FrameSelection::directionOfSelection()
return directionOfEnclosingBlock();
}
+void FrameSelection::didFocusChanged()
+{
+ updateAppearance();
+}
+
void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direction)
{
if (alter != AlterationExtend)
@@ -1780,12 +1785,17 @@ void FrameSelection::updateAppearance()
bool caretRectChangedOrCleared = recomputeCaretRect();
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
tkent 2013/06/28 06:46:56 The variable 'caretBrowing' is not used.
yosin_UTC9 2013/06/28 08:22:46 Done.
- 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 +1859,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().deprecatedNode());
tkent 2013/06/28 06:46:56 We should not use deprecatedNode in new code.
yosin_UTC9 2013/06/28 08:22:46 Done.
+}
+
void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*)
{
ASSERT(caretIsVisible());
« Source/core/editing/FrameSelection.h ('K') | « Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698