haikuwebkit/LayoutTests/fast/events/before-input-prevent-undo-e...

14 lines
358 B
Plaintext
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/181027@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-10 03:11:20 +00:00
To manually test this, type some into the input field below and try to undo. The value of the text field should not change after attempting to undo.
initial value:
| <shadow:root>
| <div>
| contenteditable="plaintext-only"
| "abc"
after prevented undo:
| <shadow:root>
| <div>
| contenteditable="plaintext-only"
| "abc"