Changeset 27009 in webkit


Ignore:
Timestamp:
Oct 24, 2007 5:58:54 PM (16 years ago)
Author:
justing
Message:

WebCore:

Reviewed by Darin Adler.

Correcting the fix for:
<rdar://problem/5544856>
REGRESSION: After typing 2-byte text, undo only undoes one keystroke at a time


Made removal of the previous composition part of the current Undo step in the
case where the new composition is the empty string, too.

  • editing/Editor.cpp: (WebCore::Editor::confirmComposition): Call the new TypingCommand::deleteSelection, which either has the currently open typing command delete the current selection, or opens a new typing command (of type DeleteSelection) if one is not already open. (WebCore::Editor::setComposition): Ditto.
  • editing/TypingCommand.cpp: (WebCore::TypingCommand::deleteSelection): Added. (WebCore::TypingCommand::doApply): Handle DeleteSelection. (WebCore::TypingCommand::deleteKeyPressed): Clarified which deleteSelection is called. (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto. (WebCore::TypingCommand::preservesTypingStyle): Handle DeleteSelection.
  • editing/TypingCommand.h:

LayoutTests:

Reviewed by Darin.


<rdar://problem/5544856>
REGRESSION: After typing 2-byte text, undo only undoes one keystroke at a time

  • platform/mac/editing/input/text-input-controller-expected.txt: The delete we were using previously to remove the old composition makes fewer calls to the editing delegate.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r27005 r27009  
     12007-10-24  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Darin.
     4       
     5        <rdar://problem/5544856>
     6        REGRESSION: After typing 2-byte text, undo only undoes one keystroke at a time
     7
     8        * platform/mac/editing/input/text-input-controller-expected.txt: The delete
     9        we were using previously to remove the old composition makes fewer calls to
     10        the editing delegate.
     11
    1122007-10-24  Alice Liu  <alice.liu@apple.com>
    213
  • trunk/LayoutTests/platform/mac/editing/input/text-input-controller-expected.txt

    r26943 r27009  
    2323EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2424EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    25 EDITING DELEGATE: shouldInsertText:Success replacingDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionTyped
     25EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     26EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
     27EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     28EDITING DELEGATE: shouldInsertText:Failure replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionTyped
    2629EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2730EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    2831EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    2932EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
    30 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    31 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    32 Success
     33Failure
  • trunk/WebCore/ChangeLog

    r27008 r27009  
     12007-10-24  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Correcting the fix for:
     6        <rdar://problem/5544856>
     7        REGRESSION: After typing 2-byte text, undo only undoes one keystroke at a time
     8       
     9        Made removal of the previous composition part of the current Undo step in the
     10        case where the new composition is the empty string, too.
     11
     12        * editing/Editor.cpp:
     13        (WebCore::Editor::confirmComposition): Call the new TypingCommand::deleteSelection,
     14        which either has the currently open typing command delete the current selection, or
     15        opens a new typing command (of type DeleteSelection) if one is not already open.
     16        (WebCore::Editor::setComposition): Ditto.
     17        * editing/TypingCommand.cpp:
     18        (WebCore::TypingCommand::deleteSelection): Added.
     19        (WebCore::TypingCommand::doApply): Handle DeleteSelection.
     20        (WebCore::TypingCommand::deleteKeyPressed): Clarified which deleteSelection
     21        is called.
     22        (WebCore::TypingCommand::forwardDeleteKeyPressed): Ditto.
     23        (WebCore::TypingCommand::preservesTypingStyle): Handle DeleteSelection.
     24        * editing/TypingCommand.h:
     25
    1262007-10-24  Sam Weinig  <sam@webkit.org>
    227
  • trunk/WebCore/editing/Editor.cpp

    r26942 r27009  
    17061706        return;
    17071707    }
     1708   
     1709    // If there is a composition to replace, remove it with a deletion that will be part of the
     1710    // same Undo step as the next and previous insertions.
     1711    TypingCommand::deleteSelection(m_frame->document(), false);
    17081712
    17091713    m_compositionNode = 0;
     
    17281732        return;
    17291733    }
     1734   
     1735    // If there is a composition to replace, remove it with a deletion that will be part of the
     1736    // same Undo step as the next and previous insertions.
     1737    TypingCommand::deleteSelection(m_frame->document(), false);
    17301738
    17311739    m_compositionNode = 0;
  • trunk/WebCore/editing/TypingCommand.cpp

    r25547 r27009  
    5757}
    5858
     59void TypingCommand::deleteSelection(Document* document, bool smartDelete)
     60{
     61    ASSERT(document);
     62   
     63    Frame* frame = document->frame();
     64    ASSERT(frame);
     65   
     66    if (!frame->selectionController()->isRange())
     67        return;
     68   
     69    EditCommand* lastEditCommand = frame->editor()->lastEditCommand();
     70    if (isOpenForMoreTypingCommand(lastEditCommand)) {
     71        static_cast<TypingCommand*>(lastEditCommand)->deleteSelection(smartDelete);
     72        return;
     73    }
     74   
     75    RefPtr<TypingCommand> typingCommand = new TypingCommand(document, DeleteSelection, "", false);
     76    typingCommand->setSmartDelete(smartDelete);
     77    typingCommand->apply();
     78}
     79
    5980void TypingCommand::deleteKeyPressed(Document *document, bool smartDelete, TextGranularity granularity)
    6081{
     
    227248
    228249    switch (m_commandType) {
     250        case DeleteSelection:
     251            deleteSelection(m_smartDelete);
     252            return;
    229253        case DeleteKey:
    230254            deleteKeyPressed(m_granularity);
     
    403427        if (m_openedByBackwardDelete)
    404428            setStartingSelection(selectionAfterUndo);
    405         deleteSelection(selectionToDelete, m_smartDelete);
     429        CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
    406430        setSmartDelete(false);
    407431        typingAddedToOpenCommand();
     
    473497        // make undo select what was deleted
    474498        setStartingSelection(selectionAfterUndo);
    475         deleteSelection(selectionToDelete, m_smartDelete);
     499        CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
    476500        setSmartDelete(false);
    477501        typingAddedToOpenCommand();
     
    479503}
    480504
     505void TypingCommand::deleteSelection(bool smartDelete)
     506{
     507    CompositeEditCommand::deleteSelection(smartDelete);
     508}
     509
    481510bool TypingCommand::preservesTypingStyle() const
    482511{
    483512    switch (m_commandType) {
     513        case DeleteSelection:
    484514        case DeleteKey:
    485515        case ForwardDeleteKey:
  • trunk/WebCore/editing/TypingCommand.h

    r25547 r27009  
    3434public:
    3535    enum ETypingCommand {
     36        DeleteSelection,
    3637        DeleteKey,
    3738        ForwardDeleteKey,
     
    4445    TypingCommand(Document*, ETypingCommand, const String& text = "", bool selectInsertedText = false, TextGranularity = CharacterGranularity);
    4546
     47    static void deleteSelection(Document*, bool smartDelete = false);
    4648    static void deleteKeyPressed(Document*, bool smartDelete = false, TextGranularity = CharacterGranularity);
    4749    static void forwardDeleteKeyPressed(Document*, bool smartDelete = false, TextGranularity = CharacterGranularity);
     
    6769    void deleteKeyPressed(TextGranularity);
    6870    void forwardDeleteKeyPressed(TextGranularity);
     71    void deleteSelection(bool);
    6972
    7073private:
Note: See TracChangeset for help on using the changeset viewer.