Changeset 206979 in webkit


Ignore:
Timestamp:
Oct 9, 2016 8:11:20 PM (7 years ago)
Author:
Wenson Hsieh
Message:

Support InputEvent.inputType for the new InputEvent spec
https://bugs.webkit.org/show_bug.cgi?id=163025
<rdar://problem/28658092>

Reviewed by Darin Adler.

Source/WebCore:

Adds support for the inputType attribute of InputEvent. To do this, we introduce a helper to
map EditActions to inputType names, and also split out ambiguous EditActions (such as
EditActionTyping) into more specific subtypes (such as EditActionTypingDeleteBackward,
EditActionTypingInsertParagraph, etc.), each of which corresponds to an inputType.

In places where we create CompositeEditCommands, we now pass in these specific EditActions
where appropriate, and when dispatching beforeinput and input events, we ask the
CompositeEditCommand for its input type name, which it derives from its editingAction.

Tests: fast/events/before-input-prevent-biu.html

fast/events/before-input-prevent-cut.html
fast/events/before-input-prevent-paste.html
fast/events/before-input-prevent-typing.html
fast/events/before-input-prevent-undo.html

  • dom/InputEvent.h:
  • dom/Node.cpp:

(WebCore::Node::dispatchInputEvent):

  • dom/Node.h:
  • editing/CompositeEditCommand.cpp:

(WebCore::CompositeEditCommand::apply):
(WebCore::CompositeEditCommand::inputEventTypeName):

Allows a CompositeEditCommand to specify the inputType its corresponding beforeinput and input events
should have.

  • editing/CompositeEditCommand.h:

(WebCore::CompositeEditCommand::shouldStopCaretBlinking): Deleted.

  • editing/EditAction.h:
  • editing/EditCommand.cpp:

(WebCore::inputTypeNameForEditingAction):

  • editing/EditCommand.h:
  • editing/Editor.cpp:

(WebCore::Editor::willApplyEditing):
(WebCore::Editor::appliedEditing):
(WebCore::Editor::willUnapplyEditing):
(WebCore::Editor::unappliedEditing):
(WebCore::Editor::willReapplyEditing):
(WebCore::Editor::reappliedEditing):
(WebCore::Editor::computeAndSetTypingStyle):

  • editing/InsertListCommand.cpp:

(WebCore::InsertListCommand::editingAction):

  • editing/InsertListCommand.h:

(WebCore::InsertListCommand::preservesTypingStyle): Deleted.
(WebCore::InsertListCommand::editingAction): Deleted.

  • editing/ReplaceRangeWithTextCommand.cpp:

(WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand):

  • editing/SpellingCorrectionCommand.cpp:

(WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):

  • editing/TypingCommand.cpp:

(WebCore::editActionForTypingCommand):
(WebCore::TypingCommand::TypingCommand):
(WebCore::TypingCommand::inputEventTypeName):

The editingAction() of a TypingCommand is the first editing action the TypingCommand was initialized using.
Since subsequent typing commands update the last open typing command, we override inputEventTypeName here to
use the last updated editing action rather than the default (initial) editing action.

(WebCore::TypingCommand::willAddTypingToOpenCommand):
(WebCore::TypingCommand::insertTextRunWithoutNewlines):
(WebCore::TypingCommand::insertParagraphSeparator):

  • editing/TypingCommand.h:

Source/WebKit/mac:

Accounts for some changes to the EditAction enum in nameForEditAction. See WebCore ChangeLog
entry for more details.

  • WebCoreSupport/WebEditorClient.mm:

(undoNameForEditAction):

Source/WebKit/win:

  • WebCoreSupport/WebEditorClient.cpp:

(undoNameForEditAction):

Source/WebKit2:

Accounts for some changes to the EditAction enum in nameForEditAction. Some former edit
actions, such as EditActionTyping, have been split out into its more specific subtypes,
so we preserve shipping behavior by treating all of the new subtypes the same way as the
original type.

  • UIProcess/WebEditCommandProxy.cpp:

(WebKit::WebEditCommandProxy::nameForEditAction):

LayoutTests:

Adds new layout tests to check that various actions, such as cutting, pasting and undoing can
be prevented via the InputEvent fired in a beforechange handler.

  • fast/events/before-input-prevent-biu-expected.txt: Added.
  • fast/events/before-input-prevent-biu.html: Added.
  • fast/events/before-input-prevent-cut-expected.txt: Added.
  • fast/events/before-input-prevent-cut.html: Added.
  • fast/events/before-input-prevent-paste-expected.txt: Added.
  • fast/events/before-input-prevent-paste.html: Added.
  • fast/events/before-input-prevent-typing-expected.txt: Added.
  • fast/events/before-input-prevent-typing.html: Added.
  • fast/events/before-input-prevent-undo-expected.txt: Added.
  • fast/events/before-input-prevent-undo.html: Added.
  • platform/ios-simulator/TestExpectations:
Location:
trunk
Files:
10 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206978 r206979  
     12016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Support InputEvent.inputType for the new InputEvent spec
     4        https://bugs.webkit.org/show_bug.cgi?id=163025
     5        <rdar://problem/28658092>
     6
     7        Reviewed by Darin Adler.
     8
     9        Adds new layout tests to check that various actions, such as cutting, pasting and undoing can
     10        be prevented via the InputEvent fired in a `beforechange` handler.
     11
     12        * fast/events/before-input-prevent-biu-expected.txt: Added.
     13        * fast/events/before-input-prevent-biu.html: Added.
     14        * fast/events/before-input-prevent-cut-expected.txt: Added.
     15        * fast/events/before-input-prevent-cut.html: Added.
     16        * fast/events/before-input-prevent-paste-expected.txt: Added.
     17        * fast/events/before-input-prevent-paste.html: Added.
     18        * fast/events/before-input-prevent-typing-expected.txt: Added.
     19        * fast/events/before-input-prevent-typing.html: Added.
     20        * fast/events/before-input-prevent-undo-expected.txt: Added.
     21        * fast/events/before-input-prevent-undo.html: Added.
     22        * platform/ios-simulator/TestExpectations:
     23
    1242016-10-09  Gyuyoung Kim  <gyuyoung.kim@navercorp.com>
    225
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r206946 r206979  
    12021202fast/events/before-input-events-prevent-default-in-textfield.html [ Failure ]
    12031203fast/events/before-input-events-different-start-end-elements.html [ Failure ]
     1204fast/events/before-input-prevent-biu.html [ Failure ]
     1205fast/events/before-input-prevent-cut.html [ Failure ]
     1206fast/events/before-input-prevent-paste.html [ Failure ]
     1207fast/events/before-input-prevent-undo.html [ Failure ]
     1208fast/events/before-input-prevent-typing.html [ Failure ]
    12041209fast/events/key-events-in-input-button.html [ Failure ]
    12051210fast/events/keydown-1.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r206977 r206979  
     12016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Support InputEvent.inputType for the new InputEvent spec
     4        https://bugs.webkit.org/show_bug.cgi?id=163025
     5        <rdar://problem/28658092>
     6
     7        Reviewed by Darin Adler.
     8
     9        Adds support for the inputType attribute of InputEvent. To do this, we introduce a helper to
     10        map EditActions to inputType names, and also split out ambiguous EditActions (such as
     11        EditActionTyping) into more specific subtypes (such as EditActionTypingDeleteBackward,
     12        EditActionTypingInsertParagraph, etc.), each of which corresponds to an inputType.
     13
     14        In places where we create CompositeEditCommands, we now pass in these specific EditActions
     15        where appropriate, and when dispatching `beforeinput` and `input` events, we ask the
     16        CompositeEditCommand for its input type name, which it derives from its editingAction.
     17
     18        Tests: fast/events/before-input-prevent-biu.html
     19               fast/events/before-input-prevent-cut.html
     20               fast/events/before-input-prevent-paste.html
     21               fast/events/before-input-prevent-typing.html
     22               fast/events/before-input-prevent-undo.html
     23
     24        * dom/InputEvent.h:
     25        * dom/Node.cpp:
     26        (WebCore::Node::dispatchInputEvent):
     27        * dom/Node.h:
     28        * editing/CompositeEditCommand.cpp:
     29        (WebCore::CompositeEditCommand::apply):
     30        (WebCore::CompositeEditCommand::inputEventTypeName):
     31
     32        Allows a CompositeEditCommand to specify the inputType its corresponding `beforeinput` and `input` events
     33        should have.
     34
     35        * editing/CompositeEditCommand.h:
     36        (WebCore::CompositeEditCommand::shouldStopCaretBlinking): Deleted.
     37        * editing/EditAction.h:
     38        * editing/EditCommand.cpp:
     39        (WebCore::inputTypeNameForEditingAction):
     40        * editing/EditCommand.h:
     41        * editing/Editor.cpp:
     42        (WebCore::Editor::willApplyEditing):
     43        (WebCore::Editor::appliedEditing):
     44        (WebCore::Editor::willUnapplyEditing):
     45        (WebCore::Editor::unappliedEditing):
     46        (WebCore::Editor::willReapplyEditing):
     47        (WebCore::Editor::reappliedEditing):
     48        (WebCore::Editor::computeAndSetTypingStyle):
     49        * editing/InsertListCommand.cpp:
     50        (WebCore::InsertListCommand::editingAction):
     51        * editing/InsertListCommand.h:
     52        (WebCore::InsertListCommand::preservesTypingStyle): Deleted.
     53        (WebCore::InsertListCommand::editingAction): Deleted.
     54        * editing/ReplaceRangeWithTextCommand.cpp:
     55        (WebCore::ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand):
     56        * editing/SpellingCorrectionCommand.cpp:
     57        (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand):
     58        * editing/TypingCommand.cpp:
     59        (WebCore::editActionForTypingCommand):
     60        (WebCore::TypingCommand::TypingCommand):
     61        (WebCore::TypingCommand::inputEventTypeName):
     62
     63        The editingAction() of a TypingCommand is the first editing action the TypingCommand was initialized using.
     64        Since subsequent typing commands update the last open typing command, we override inputEventTypeName here to
     65        use the last updated editing action rather than the default (initial) editing action.
     66
     67        (WebCore::TypingCommand::willAddTypingToOpenCommand):
     68        (WebCore::TypingCommand::insertTextRunWithoutNewlines):
     69        (WebCore::TypingCommand::insertParagraphSeparator):
     70        * editing/TypingCommand.h:
     71
    1722016-10-09  Darin Adler  <darin@apple.com>
    273
  • trunk/Source/WebCore/dom/InputEvent.h

    r206843 r206979  
    5656    bool isInputEvent() const override { return true; }
    5757    EventInterface eventInterface() const final { return InputEventInterfaceType; }
    58     String inputType() const { return m_inputType.string(); }
     58    String inputType() const { return m_inputType; }
    5959
    6060private:
    61     AtomicString m_inputType;
     61    String m_inputType;
    6262};
    6363
  • trunk/Source/WebCore/dom/Node.cpp

    r206975 r206979  
    21992199}
    22002200
    2201 void Node::dispatchInputEvent(const AtomicString& inputType)
     2201void Node::dispatchInputEvent(const String& inputType)
    22022202{
    22032203    auto* settings = document().settings();
  • trunk/Source/WebCore/dom/Node.h

    r206956 r206979  
    526526    bool dispatchBeforeLoadEvent(const String& sourceURL);
    527527
    528     virtual void dispatchInputEvent(const AtomicString& inputType);
     528    virtual void dispatchInputEvent(const String& inputType);
    529529
    530530    // Perform the default action for an event.
  • trunk/Source/WebCore/editing/CompositeEditCommand.cpp

    r206944 r206979  
    327327    if (!endingSelection().isContentRichlyEditable()) {
    328328        switch (editingAction()) {
    329         case EditActionTyping:
     329        case EditActionTypingDeleteSelection:
     330        case EditActionTypingDeleteBackward:
     331        case EditActionTypingDeleteForward:
     332        case EditActionTypingDeleteWordBackward:
     333        case EditActionTypingDeleteWordForward:
     334        case EditActionTypingDeleteLineBackward:
     335        case EditActionTypingDeleteLineForward:
     336        case EditActionTypingInsertText:
     337        case EditActionTypingInsertLineBreak:
     338        case EditActionTypingInsertParagraph:
    330339        case EditActionPaste:
    331340        case EditActionDrag:
     
    334343        case EditActionUnspecified:
    335344        case EditActionInsert:
     345        case EditActionInsertReplacement:
    336346        case EditActionDelete:
    337347        case EditActionDictation:
     
    398408void CompositeEditCommand::setShouldRetainAutocorrectionIndicator(bool)
    399409{
     410}
     411
     412String CompositeEditCommand::inputEventTypeName() const
     413{
     414    return inputTypeNameForEditingAction(editingAction());
    400415}
    401416
  • trunk/Source/WebCore/editing/CompositeEditCommand.h

    r206944 r206979  
    114114    virtual void setShouldRetainAutocorrectionIndicator(bool);
    115115    virtual bool shouldStopCaretBlinking() const { return false; }
     116    virtual String inputEventTypeName() const;
    116117
    117118protected:
  • trunk/Source/WebCore/editing/EditAction.h

    r183368 r206979  
    3131        EditActionUnspecified,
    3232        EditActionInsert,
     33        EditActionInsertReplacement,
    3334        EditActionSetColor,
    3435        EditActionSetBackgroundColor,
     
    6465        EditActionPasteFont,
    6566        EditActionPasteRuler,
    66         EditActionTyping,
     67        EditActionTypingDeleteSelection,
     68        EditActionTypingDeleteBackward,
     69        EditActionTypingDeleteForward,
     70        EditActionTypingDeleteWordBackward,
     71        EditActionTypingDeleteWordForward,
     72        EditActionTypingDeleteLineBackward,
     73        EditActionTypingDeleteLineForward,
     74        EditActionTypingInsertText,
     75        EditActionTypingInsertLineBreak,
     76        EditActionTypingInsertParagraph,
    6777        EditActionCreateLink,
    6878        EditActionUnlink,
    6979        EditActionFormatBlock,
    70         EditActionInsertList,
     80        EditActionInsertOrderedList,
     81        EditActionInsertUnorderedList,
    7182        EditActionIndent,
    7283        EditActionOutdent
  • trunk/Source/WebCore/editing/EditCommand.cpp

    r200922 r206979  
    3939namespace WebCore {
    4040
     41String inputTypeNameForEditingAction(EditAction action)
     42{
     43    switch (action) {
     44    case EditActionJustify:
     45    case EditActionAlignLeft:
     46        return ASCIILiteral("formatJustifyLeft");
     47    case EditActionAlignRight:
     48        return ASCIILiteral("formatJustifyRight");
     49    case EditActionCenter:
     50        return ASCIILiteral("formatJustifyCenter");
     51    case EditActionSubscript:
     52        return ASCIILiteral("formatSubscript");
     53    case EditActionSuperscript:
     54        return ASCIILiteral("formatSuperscript");
     55    case EditActionUnderline:
     56        return ASCIILiteral("formatUnderline");
     57    case EditActionDrag:
     58        return ASCIILiteral("deleteByDrag");
     59    case EditActionCut:
     60        return ASCIILiteral("deleteByCut");
     61    case EditActionBold:
     62        return ASCIILiteral("formatBold");
     63    case EditActionItalics:
     64        return ASCIILiteral("formatItalic");
     65    case EditActionPaste:
     66        return ASCIILiteral("insertFromPaste");
     67    case EditActionDelete:
     68    case EditActionTypingDeleteSelection:
     69        return ASCIILiteral("deleteContent");
     70    case EditActionTypingDeleteBackward:
     71        return ASCIILiteral("deleteContentBackward");
     72    case EditActionTypingDeleteForward:
     73        return ASCIILiteral("deleteContentForward");
     74    case EditActionTypingDeleteWordBackward:
     75        return ASCIILiteral("deleteWordBackward");
     76    case EditActionTypingDeleteWordForward:
     77        return ASCIILiteral("deleteWordForward");
     78    case EditActionTypingDeleteLineBackward:
     79        return ASCIILiteral("deleteHardLineBackward");
     80    case EditActionTypingDeleteLineForward:
     81        return ASCIILiteral("deleteHardLineForward");
     82    case EditActionInsert:
     83    case EditActionTypingInsertText:
     84        return ASCIILiteral("insertText");
     85    case EditActionInsertReplacement:
     86        return ASCIILiteral("insertReplacementText");
     87    case EditActionTypingInsertLineBreak:
     88        return ASCIILiteral("insertLineBreak");
     89    case EditActionTypingInsertParagraph:
     90        return ASCIILiteral("insertParagraph");
     91    case EditActionInsertOrderedList:
     92        return ASCIILiteral("insertOrderedList");
     93    case EditActionInsertUnorderedList:
     94        return ASCIILiteral("insertUnorderedList");
     95    case EditActionIndent:
     96        return ASCIILiteral("formatIndent");
     97    case EditActionOutdent:
     98        return ASCIILiteral("formatOutdent");
     99    default:
     100        return emptyString();
     101    }
     102}
     103
    41104EditCommand::EditCommand(Document& document, EditAction editingAction)
    42105    : m_document(document)
  • trunk/Source/WebCore/editing/EditCommand.h

    r199030 r206979  
    4242class Frame;
    4343
     44String inputTypeNameForEditingAction(EditAction);
     45
    4446class EditCommand : public RefCounted<EditCommand> {
    4547public:
     
    4850    void setParent(CompositeEditCommand*);
    4951
    50     EditAction editingAction() const;
     52    virtual EditAction editingAction() const;
    5153
    5254    const VisibleSelection& startingSelection() const { return m_startingSelection; }
  • trunk/Source/WebCore/editing/Editor.cpp

    r206974 r206979  
    10681068        return true;
    10691069
    1070     return dispatchBeforeInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), emptyString());
     1070    return dispatchBeforeInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), command.inputEventTypeName());
    10711071}
    10721072
     
    10871087   
    10881088    changeSelectionAfterCommand(newSelection, options);
    1089     dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), emptyString());
     1089    dispatchInputEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement(), cmd->inputEventTypeName());
    10901090
    10911091    updateEditorUINowIfScheduled();
     
    11121112bool Editor::willUnapplyEditing(const EditCommandComposition& composition) const
    11131113{
    1114     return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), emptyString());
     1114    return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), "historyUndo");
    11151115}
    11161116
     
    11231123    VisibleSelection newSelection(cmd->startingSelection());
    11241124    changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions());
    1125     dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), emptyString());
     1125    dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), "historyUndo");
    11261126
    11271127    updateEditorUINowIfScheduled();
     
    11371137bool Editor::willReapplyEditing(const EditCommandComposition& composition) const
    11381138{
    1139     return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), emptyString());
     1139    return dispatchBeforeInputEvents(composition.startingRootEditableElement(), composition.endingRootEditableElement(), "historyRedo");
    11401140}
    11411141
     
    11481148    VisibleSelection newSelection(cmd->endingSelection());
    11491149    changeSelectionAfterCommand(newSelection, FrameSelection::defaultSetSelectionOptions());
    1150     dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), emptyString());
     1150    dispatchInputEvents(cmd->startingRootEditableElement(), cmd->endingRootEditableElement(), "historyRedo");
    11511151   
    11521152    updateEditorUINowIfScheduled();
     
    30983098    }
    30993099
     3100    String inputTypeName = inputTypeNameForEditingAction(editingAction);
    31003101    auto* element = m_frame.selection().selection().rootEditableElement();
    3101     if (element && !dispatchBeforeInputEvent(*element, emptyString()))
     3102    if (element && !dispatchBeforeInputEvent(*element, inputTypeName))
    31023103        return;
    31033104
     
    31163117
    31173118    if (element)
    3118         element->dispatchInputEvent(emptyString());
     3119        element->dispatchInputEvent(inputTypeName);
    31193120
    31203121    // Set the remaining style as the typing style.
  • trunk/Source/WebCore/editing/InsertListCommand.cpp

    r201823 r206979  
    194194}
    195195
     196EditAction InsertListCommand::editingAction() const
     197{
     198    return m_type == OrderedList ? EditActionInsertOrderedList : EditActionInsertUnorderedList;
     199}
     200
    196201void InsertListCommand::doApplyForSingleParagraph(bool forceCreateList, const HTMLQualifiedName& listTag, Range* currentSelection)
    197202{
  • trunk/Source/WebCore/editing/InsertListCommand.h

    r184709 r206979  
    3434class HTMLQualifiedName;
    3535
    36 class InsertListCommand : public CompositeEditCommand {
     36class InsertListCommand final : public CompositeEditCommand {
    3737public:
    3838    enum Type { OrderedList, UnorderedList };
     
    4545    static RefPtr<HTMLElement> insertList(Document&, Type);
    4646   
    47     virtual bool preservesTypingStyle() const { return true; }
     47    bool preservesTypingStyle() const final { return true; }
    4848
    4949private:
    5050    InsertListCommand(Document&, Type);
    5151
    52     virtual void doApply();
    53     virtual EditAction editingAction() const { return EditActionInsertList; }
     52    void doApply() final;
     53    EditAction editingAction() const final;
    5454
    5555    HTMLElement* fixOrphanedListChild(Node*);
  • trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp

    r205870 r206979  
    4040
    4141ReplaceRangeWithTextCommand::ReplaceRangeWithTextCommand(RefPtr<Range> rangeToBeReplaced, const String& text)
    42     : CompositeEditCommand(rangeToBeReplaced->startContainer().document())
     42    : CompositeEditCommand(rangeToBeReplaced->startContainer().document(), EditActionInsertReplacement)
    4343    , m_rangeToBeReplaced(rangeToBeReplaced)
    4444    , m_text(text)
  • trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp

    r200626 r206979  
    8383
    8484SpellingCorrectionCommand::SpellingCorrectionCommand(PassRefPtr<Range> rangeToBeCorrected, const String& correction)
    85     : CompositeEditCommand(rangeToBeCorrected->startContainer().document())
     85    : CompositeEditCommand(rangeToBeCorrected->startContainer().document(), EditActionInsertReplacement)
    8686    , m_rangeToBeCorrected(rangeToBeCorrected)
    8787    , m_selectionToBeCorrected(*m_rangeToBeCorrected)
  • trunk/Source/WebCore/editing/TypingCommand.cpp

    r206944 r206979  
    7777};
    7878
     79static inline EditAction editActionForTypingCommand(TypingCommand::ETypingCommand command, TextGranularity granularity)
     80{
     81    switch (command) {
     82    case TypingCommand::DeleteSelection:
     83        return EditActionTypingDeleteSelection;
     84    case TypingCommand::DeleteKey: {
     85        if (granularity == WordGranularity)
     86            return EditActionTypingDeleteWordBackward;
     87        if (granularity == LineBoundary)
     88            return EditActionTypingDeleteLineBackward;
     89        return EditActionTypingDeleteBackward;
     90    }
     91    case TypingCommand::ForwardDeleteKey:
     92        if (granularity == WordGranularity)
     93            return EditActionTypingDeleteWordForward;
     94        if (granularity == LineBoundary)
     95            return EditActionTypingDeleteLineForward;
     96        return EditActionTypingDeleteForward;
     97    case TypingCommand::InsertText:
     98        return EditActionTypingInsertText;
     99    case TypingCommand::InsertLineBreak:
     100        return EditActionTypingInsertLineBreak;
     101    case TypingCommand::InsertParagraphSeparator:
     102    case TypingCommand::InsertParagraphSeparatorInQuotedContent:
     103        return EditActionTypingInsertParagraph;
     104    default:
     105        return EditActionUnspecified;
     106    }
     107}
     108
    79109TypingCommand::TypingCommand(Document& document, ETypingCommand commandType, const String &textToInsert, Options options, TextGranularity granularity, TextCompositionType compositionType)
    80     : TextInsertionBaseCommand(document, EditActionTyping)
     110    : TextInsertionBaseCommand(document, editActionForTypingCommand(commandType, granularity))
    81111    , m_commandType(commandType)
    82112    , m_textToInsert(textToInsert)
     
    91121    , m_shouldPreventSpellChecking(options & PreventSpellChecking)
    92122{
     123    m_currentTypingEditAction = editingAction();
    93124    updatePreservesTypingStyle(m_commandType);
    94125}
     
    307338
    308339    ASSERT_NOT_REACHED();
     340}
     341
     342String TypingCommand::inputEventTypeName() const
     343{
     344    return inputTypeNameForEditingAction(m_currentTypingEditAction);
    309345}
    310346
     
    369405}
    370406
    371 bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand, TextGranularity)
     407bool TypingCommand::willAddTypingToOpenCommand(ETypingCommand commandType, TextGranularity granularity)
    372408{
    373409    if (m_isHandlingInitialTypingCommand)
     
    376412    // FIXME: Use the newly added typing command and granularity to ensure that an InputEvent with the
    377413    // correct inputType is dispatched.
     414    m_currentTypingEditAction = editActionForTypingCommand(commandType, granularity);
    378415    return frame().editor().willApplyEditing(*this);
    379416}
     
    424461
    425462    RefPtr<InsertTextCommand> command = InsertTextCommand::create(document(), text, selectInsertedText,
    426         m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces, EditActionTyping);
     463        m_compositionType == TextCompositionNone ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces : InsertTextCommand::RebalanceAllWhitespaces, EditActionTypingInsertText);
    427464
    428465    applyCommandToComposite(command, endingSelection());
     
    459496        return;
    460497
    461     applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditActionTyping));
     498    applyCommandToComposite(InsertParagraphSeparatorCommand::create(document(), false, false, EditActionTypingInsertParagraph));
    462499    typingAddedToOpenCommand(InsertParagraphSeparator);
    463500}
  • trunk/Source/WebCore/editing/TypingCommand.h

    r206944 r206979  
    117117    void setShouldPreventSpellChecking(bool prevent) { m_shouldPreventSpellChecking = prevent; }
    118118
     119    String inputEventTypeName() const final;
     120
    119121    static void updateSelectionIfDifferentFromCurrentSelection(TypingCommand*, Frame*);
    120122
     
    135137
    136138    ETypingCommand m_commandType;
     139    EditAction m_currentTypingEditAction;
    137140    String m_textToInsert;
    138141    bool m_openForMoreTyping;
  • trunk/Source/WebKit/mac/ChangeLog

    r206960 r206979  
     12016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Support InputEvent.inputType for the new InputEvent spec
     4        https://bugs.webkit.org/show_bug.cgi?id=163025
     5        <rdar://problem/28658092>
     6
     7        Reviewed by Darin Adler.
     8
     9        Accounts for some changes to the EditAction enum in nameForEditAction. See WebCore ChangeLog
     10        entry for more details.
     11
     12        * WebCoreSupport/WebEditorClient.mm:
     13        (undoNameForEditAction):
     14
    1152016-10-06  Darin Adler  <darin@apple.com>
    216
  • trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm

    r205858 r206979  
    564564        case EditActionUnspecified: return nil;
    565565        case EditActionInsert: return nil;
     566        case EditActionInsertReplacement: return nil;
    566567        case EditActionSetColor: return UI_STRING_KEY_INTERNAL("Set Color", "Set Color (Undo action name)", "Undo action name");
    567568        case EditActionSetBackgroundColor: return UI_STRING_KEY_INTERNAL("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
     
    593594        case EditActionPasteFont: return UI_STRING_KEY_INTERNAL("Paste Font", "Paste Font (Undo action name)", "Undo action name");
    594595        case EditActionPasteRuler: return UI_STRING_KEY_INTERNAL("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
    595         case EditActionTyping: return UI_STRING_KEY_INTERNAL("Typing", "Typing (Undo action name)", "Undo action name");
     596        case EditActionTypingDeleteSelection:
     597        case EditActionTypingDeleteBackward:
     598        case EditActionTypingDeleteForward:
     599        case EditActionTypingDeleteWordBackward:
     600        case EditActionTypingDeleteWordForward:
     601        case EditActionTypingDeleteLineBackward:
     602        case EditActionTypingDeleteLineForward:
     603        case EditActionTypingInsertText:
     604        case EditActionTypingInsertLineBreak:
     605        case EditActionTypingInsertParagraph:
     606            return UI_STRING_KEY_INTERNAL("Typing", "Typing (Undo action name)", "Undo action name");
    596607        case EditActionCreateLink: return UI_STRING_KEY_INTERNAL("Create Link", "Create Link (Undo action name)", "Undo action name");
    597608        case EditActionUnlink: return UI_STRING_KEY_INTERNAL("Unlink", "Unlink (Undo action name)", "Undo action name");
    598         case EditActionInsertList: return UI_STRING_KEY_INTERNAL("Insert List", "Insert List (Undo action name)", "Undo action name");
     609        case EditActionInsertOrderedList:
     610        case EditActionInsertUnorderedList:
     611            return UI_STRING_KEY_INTERNAL("Insert List", "Insert List (Undo action name)", "Undo action name");
    599612        case EditActionFormatBlock: return UI_STRING_KEY_INTERNAL("Formatting", "Format Block (Undo action name)", "Undo action name");
    600613        case EditActionIndent: return UI_STRING_KEY_INTERNAL("Indent", "Indent (Undo action name)", "Undo action name");
  • trunk/Source/WebKit/win/ChangeLog

    r206816 r206979  
     12016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Support InputEvent.inputType for the new InputEvent spec
     4        https://bugs.webkit.org/show_bug.cgi?id=163025
     5        <rdar://problem/28658092>
     6
     7        Reviewed by Darin Adler.
     8
     9        * WebCoreSupport/WebEditorClient.cpp:
     10        (undoNameForEditAction):
     11
    1122016-10-04  Brent Fulgham  <bfulgham@apple.com>
    213
  • trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp

    r201905 r206979  
    564564{
    565565    switch (editAction) {
    566     case EditActionUnspecified: return String();
     566    case EditActionUnspecified:
     567    case EditActionInsertReplacement:
     568        return String();
    567569    case EditActionSetColor: return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
    568570    case EditActionSetBackgroundColor: return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
     
    596598    case EditActionPasteFont: return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
    597599    case EditActionPasteRuler: return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
    598     case EditActionTyping: return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
     600    case EditActionTypingDeleteSelection:
     601    case EditActionTypingDeleteBackward:
     602    case EditActionTypingDeleteForward:
     603    case EditActionTypingDeleteWordBackward:
     604    case EditActionTypingDeleteWordForward:
     605    case EditActionTypingDeleteLineBackward:
     606    case EditActionTypingDeleteLineForward:
     607    case EditActionTypingInsertText:
     608    case EditActionTypingInsertLineBreak:
     609    case EditActionTypingInsertParagraph:
     610        return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
    599611    case EditActionCreateLink: return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
    600612    case EditActionUnlink: return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
    601     case EditActionInsertList: return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
     613    case EditActionInsertUnorderedList:
     614    case EditActionInsertOrderedList:
     615        return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
    602616    case EditActionFormatBlock: return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
    603617    case EditActionIndent: return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
  • trunk/Source/WebKit2/ChangeLog

    r206961 r206979  
     12016-10-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Support InputEvent.inputType for the new InputEvent spec
     4        https://bugs.webkit.org/show_bug.cgi?id=163025
     5        <rdar://problem/28658092>
     6
     7        Reviewed by Darin Adler.
     8
     9        Accounts for some changes to the EditAction enum in nameForEditAction. Some former edit
     10        actions, such as EditActionTyping, have been split out into its more specific subtypes,
     11        so we preserve shipping behavior by treating all of the new subtypes the same way as the
     12        original type.
     13
     14        * UIProcess/WebEditCommandProxy.cpp:
     15        (WebKit::WebEditCommandProxy::nameForEditAction):
     16
    1172016-10-08  Emanuele Aina  <emanuele.aina@collabora.com>
    218
  • trunk/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp

    r204996 r206979  
    7777    case EditActionInsert:
    7878        return String();
     79    case EditActionInsertReplacement:
     80        return String();
    7981    case EditActionSetColor:
    8082        return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
     
    143145    case EditActionPasteRuler:
    144146        return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
    145     case EditActionTyping:
     147    case EditActionTypingDeleteSelection:
     148    case EditActionTypingDeleteBackward:
     149    case EditActionTypingDeleteForward:
     150    case EditActionTypingDeleteWordBackward:
     151    case EditActionTypingDeleteWordForward:
     152    case EditActionTypingDeleteLineBackward:
     153    case EditActionTypingDeleteLineForward:
     154    case EditActionTypingInsertText:
     155    case EditActionTypingInsertLineBreak:
     156    case EditActionTypingInsertParagraph:
    146157        return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
    147158    case EditActionCreateLink:
     
    149160    case EditActionUnlink:
    150161        return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
    151     case EditActionInsertList:
     162    case EditActionInsertUnorderedList:
     163    case EditActionInsertOrderedList:
    152164        return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
    153165    case EditActionFormatBlock:
Note: See TracChangeset for help on using the changeset viewer.