Skip to content
  • sergio@webkit.org's avatar
    Implement overtype mode for editable content · 1874d7a9
    sergio@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=112126
    
    Reviewed by Ryosuke Niwa.
    
    Source/WebCore:
    
    Tests: editing/execCommand/overtype-support.html
           editing/execCommand/overtype.html
    
    Add a new Overwrite command to the editor. This command will
    perform overtype operations when enabled instead of "normal" text
    insertions. As IE does, we maintain a single toggle state in the
    editor (enabled/disabled) for all the editable content in the
    page.
    
    This new command will be only available for richly editable
    content via keybindings or the context menu. For testing purposes
    it is also accessible via internals.
    
    * editing/CompositeEditCommand.cpp:
    (WebCore::CompositeEditCommand::replaceTextInNode): Use RefPtr for
    local variables.
    * editing/Editor.cpp:
    (WebCore::Editor::Editor):
    * editing/Editor.h:
    (WebCore::Editor::isOverwriteModeEnabled):
    (WebCore::Editor::toggleOverwriteModeEnabled):
    (Editor): Added two new functions and a new attribute.
    * editing/EditorCommand.cpp:
    (WebCore::executeToggleOverwrite): Enables/disables overwrite mode.
    (WebCore):
    (WebCore::createCommandMap): New OverWrite command.
    * editing/InsertTextCommand.cpp:
    (WebCore::InsertTextCommand::setEndingSelectionWithoutValidation):
    Refactored from performTrivialReplace(), shared by
    performOverwrite().
    (WebCore):
    (WebCore::InsertTextCommand::performTrivialReplace):
    (WebCore::InsertTextCommand::performOverwrite):
    (WebCore::InsertTextCommand::doApply): Perform overwrite if enabled.
    * editing/InsertTextCommand.h:
    (InsertTextCommand):
    * testing/Internals.cpp:
    (WebCore::Internals::resetToConsistentState): Reset OverWrite mode
    to false.
    (WebCore::Internals::isOverwriteModeEnabled):
    (WebCore):
    (WebCore::Internals::toggleOverwriteModeEnabled): Provide access
    to overwrite functionality in Editor for testing purposes.
    * testing/Internals.h:
    (Internals):
    * testing/Internals.idl:
    
    Source/WebKit/mac:
    
    Added the OverWrite editing command to the WebCore editing
    commands lists.
    
    * WebView/WebHTMLView.mm:
    * WebView/WebView.h:
    * WebView/WebView.mm:
    
    LayoutTests:
    
    Two new layout tests for the new overtype mode. We use
    overtype-support.html to check that the Overwrite command is not
    exported to JavaScript but accessible through Internals. The
    overtype.html one is used to test the actual behaviour of the
    command.
    
    The new command was also added to enabling-and-selection-2.js to
    check that it is only available for richly editable content.
    
    * editing/execCommand/enabling-and-selection-2-expected.txt:
    Updated expectations for OverWrite command.
    * editing/execCommand/overtype-expected.txt: Added.
    * editing/execCommand/overtype-support-expected.txt: Added.
    * editing/execCommand/overtype-support.html: Added.
    * editing/execCommand/overtype.html: Added.
    * editing/execCommand/script-tests/enabling-and-selection-2.js:
    Added a check for OverWrite command.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146907 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    1874d7a9