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

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

Issue 14859008: Use a block cursor in overtype mode (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 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 6526607e7ff738dbb3ebd8cc889b833831f8b83f..5f009b04332c26fc4ac3c99336fc4607b3bba640 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -115,6 +115,7 @@ FrameSelection::FrameSelection(Frame* frame)
, m_caretPaint(true)
, m_isCaretBlinkingSuspended(false)
, m_focused(frame && frame->page() && frame->page()->focusController()->focusedFrame() == frame)
+ , m_shouldShowBlockCursor(false)
{
if (shouldAlwaysUseDirectionalSelection(m_frame))
m_selection.setIsDirectional(true);
@@ -1738,10 +1739,18 @@ inline static bool shouldStopBlinkingDueToTypingCommand(Frame* frame)
void FrameSelection::updateAppearance()
{
+ // Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case
+ // the FrameSelection will paint a blinking caret as usual).
esprehn 2013/05/06 16:42:10 Why doesn't the block blink? I seem to recall edit
+ VisiblePosition forwardPosition;
+ if (m_shouldShowBlockCursor && m_selection.isCaret()) {
+ forwardPosition = modifyExtendingForward(CharacterGranularity);
+ m_caretPaint = forwardPosition.isNull();
+ }
+
bool caretRectChangedOrCleared = recomputeCaretRect();
bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
- bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing);
+ bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing) && forwardPosition.isNull();
// If the caret moved, stop the blink timer so we can restart with a
// black caret in the new location.
@@ -1766,7 +1775,7 @@ void FrameSelection::updateAppearance()
// Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
// assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
- VisibleSelection selection(m_selection.visibleStart(), m_selection.visibleEnd());
+ VisibleSelection selection(m_selection.visibleStart(), forwardPosition.isNotNull() ? forwardPosition : m_selection.visibleEnd());
if (!selection.isRange()) {
view->clearSelection();
@@ -2026,6 +2035,15 @@ inline bool FrameSelection::visualWordMovementEnabled() const
return settings && settings->visualWordMovementEnabled();
}
+void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor)
+{
+ m_shouldShowBlockCursor = shouldShowBlockCursor;
+
+ m_frame->document()->updateLayoutIgnorePendingStylesheets();
+
+ updateAppearance();
+}
+
#ifndef NDEBUG
void FrameSelection::formatForDebugger(char* buffer, unsigned length) const

Powered by Google App Engine
This is Rietveld 408576698