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

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, 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') | Source/core/testing/Internals.h » ('j') | 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 229f473861437434ef32364958688bbf5d59dfa0..f15e997a27ccfdb6fe8bd4087586884829171daf 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -111,6 +111,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);
@@ -1760,10 +1761,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).
+ 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.
@@ -1788,7 +1797,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();
@@ -2048,6 +2057,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
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/testing/Internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698