Title: [102413] trunk/Source/WebCore
Revision
102413
Author
commit-qu...@webkit.org
Date
2011-12-08 18:28:27 -0800 (Thu, 08 Dec 2011)

Log Message

Caret keeps blinking during forward-delete
https://bugs.webkit.org/show_bug.cgi?id=38564

Patch by Van Lam <van...@google.com> on 2011-12-08
Reviewed by Darin Adler.

Currently updateAppearance determines if the caret should stop blinking
based on whether or not the editing operation changed the position of
the caret; so the caret stops blinking in case of typing text and
backwards delete (which always displace the caret) but does not stop
blinking in the case of forward delete (which does not displace the
caret).

Added a boolean member function shouldStopCaretBlinking in EditCommand
which will return true if the object is a TypingCommand (my
understanding here is that all TypingCommands should stop the caret
from blinking for a cycle, currently 0.5 seconds). Then used this
function to stop the caret from blinking if the last editing command
is a TypingCommand.

* editing/EditCommand.h:
(WebCore::EditCommand::shouldStopCaretBlinking):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::updateAppearance):
* editing/TypingCommand.h:
(WebCore::TypingCommand::shouldStopCaretBlinking):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102412 => 102413)


--- trunk/Source/WebCore/ChangeLog	2011-12-09 02:00:57 UTC (rev 102412)
+++ trunk/Source/WebCore/ChangeLog	2011-12-09 02:28:27 UTC (rev 102413)
@@ -1,3 +1,31 @@
+2011-12-08  Van Lam  <van...@google.com>
+
+        Caret keeps blinking during forward-delete
+        https://bugs.webkit.org/show_bug.cgi?id=38564
+
+        Reviewed by Darin Adler.
+
+        Currently updateAppearance determines if the caret should stop blinking
+        based on whether or not the editing operation changed the position of
+        the caret; so the caret stops blinking in case of typing text and
+        backwards delete (which always displace the caret) but does not stop
+        blinking in the case of forward delete (which does not displace the
+        caret).
+
+        Added a boolean member function shouldStopCaretBlinking in EditCommand
+        which will return true if the object is a TypingCommand (my
+        understanding here is that all TypingCommands should stop the caret
+        from blinking for a cycle, currently 0.5 seconds). Then used this
+        function to stop the caret from blinking if the last editing command
+        is a TypingCommand.
+
+        * editing/EditCommand.h:
+        (WebCore::EditCommand::shouldStopCaretBlinking):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::updateAppearance):
+        * editing/TypingCommand.h:
+        (WebCore::TypingCommand::shouldStopCaretBlinking):
+
 2011-12-08  Adam Klein  <ad...@chromium.org>
 
         Use HashMap<Node*, OwnPtr<...>> in ChildListMutationScope

Modified: trunk/Source/WebCore/editing/EditCommand.h (102412 => 102413)


--- trunk/Source/WebCore/editing/EditCommand.h	2011-12-09 02:00:57 UTC (rev 102412)
+++ trunk/Source/WebCore/editing/EditCommand.h	2011-12-09 02:28:27 UTC (rev 102413)
@@ -65,6 +65,7 @@
 
     virtual bool shouldRetainAutocorrectionIndicator() const;
     virtual void setShouldRetainAutocorrectionIndicator(bool);
+    virtual bool shouldStopCaretBlinking() const { return false; }
 
 protected:
     EditCommand(Document*);

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (102412 => 102413)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2011-12-09 02:00:57 UTC (rev 102412)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2011-12-09 02:28:27 UTC (rev 102413)
@@ -1656,10 +1656,13 @@
 
     bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsingEnabled();
     bool shouldBlink = caretIsVisible() && isCaret() && (isContentEditable() || caretBrowsing);
+    
+    EditCommand* lastEditCommand = m_frame ? m_frame->editor()->lastEditCommand() : 0;
+    bool shouldStopBlinkingDueToTypingCommand = lastEditCommand && lastEditCommand->shouldStopCaretBlinking();
 
     // If the caret moved, stop the blink timer so we can restart with a
     // black caret in the new location.
-    if (caretRectChanged || !shouldBlink)
+    if (caretRectChanged || !shouldBlink || shouldStopBlinkingDueToTypingCommand)
         m_caretBlinkTimer.stop();
 
     // Start blinking with a black caret. Be sure not to restart if we're

Modified: trunk/Source/WebCore/editing/TypingCommand.h (102412 => 102413)


--- trunk/Source/WebCore/editing/TypingCommand.h	2011-12-09 02:00:57 UTC (rev 102412)
+++ trunk/Source/WebCore/editing/TypingCommand.h	2011-12-09 02:28:27 UTC (rev 102413)
@@ -103,6 +103,7 @@
     virtual bool preservesTypingStyle() const { return m_preservesTypingStyle; }
     virtual bool shouldRetainAutocorrectionIndicator() const { return m_shouldRetainAutocorrectionIndicator; }
     virtual void setShouldRetainAutocorrectionIndicator(bool retain) { m_shouldRetainAutocorrectionIndicator = retain; }
+    virtual bool shouldStopCaretBlinking() const { return true; }
     void setShouldPreventSpellChecking(bool prevent) { m_shouldPreventSpellChecking = prevent; }
 
     static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Frame*);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to