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

50 lines
2.3 KiB
HTML
Raw Permalink Normal View History

Input type "formatSetInlineTextDirection" is dispatched when changing paragraph-level text direction https://bugs.webkit.org/show_bug.cgi?id=194703 <rdar://problem/48111775> Reviewed by Ryosuke Niwa. Source/WebCore: Currently, when changing text direction, WebKit always sends input events of type formatSetInlineTextDirection, even when changing paragraph text direction. Instead, we should be emitting formatSetBlockTextDirection in this scenario. This is problematic when using the context menus on macOS to change writing direction, since changing "Selection Direction" is currently indistinguishable from changing "Paragraph Direction". To fix this, we split EditAction::SetWritingDirection into EditAction::SetInlineWritingDirection and EditAction::SetBlockWritingDirection, which emit inline and block text direction input events, respectively. Tests: fast/events/before-input-events-prevent-block-text-direction.html fast/events/before-input-events-prevent-inline-text-direction.html * editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::apply): * editing/EditAction.cpp: (WebCore::undoRedoLabel): * editing/EditAction.h: * editing/EditCommand.cpp: (WebCore::inputTypeNameForEditingAction): * editing/Editor.cpp: (WebCore::inputEventDataForEditingStyleAndAction): (WebCore::Editor::setBaseWritingDirection): * editing/EditorCommand.cpp: (WebCore::executeMakeTextWritingDirectionLeftToRight): (WebCore::executeMakeTextWritingDirectionNatural): (WebCore::executeMakeTextWritingDirectionRightToLeft): Source/WebKitLegacy/win: * WebCoreSupport/WebEditorClient.cpp: (undoNameForEditAction): LayoutTests: Rebaseline some existing tests to expect input events of type "formatSetBlockTextDirection" instead of "formatSetInlineTextDirection" when changing paragraph text direction; additionally, add a new layout test that changes the inline text direction in some Bidi text, and verify that "formatSetInlineTextDirection" is emitted in this scenario, and that calling `preventDefault()` in the beforeinput event handler causes no change to be made. * editing/input/ios/rtl-keyboard-input-on-focus-expected.txt: * fast/events/before-input-events-prevent-block-text-direction-expected.txt: Added. * fast/events/before-input-events-prevent-block-text-direction.html: Renamed from LayoutTests/fast/events/before-input-events-prevent-text-direction.html. * fast/events/before-input-events-prevent-inline-text-direction-expected.txt: Added. * fast/events/before-input-events-prevent-inline-text-direction.html: Added. * fast/events/before-input-events-prevent-text-direction-expected.txt: Removed. Canonical link: https://commits.webkit.org/209309@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241949 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-22 17:09:27 +00:00
<!DOCTYPE html>
<meta charset="utf8">
<html>
<head>
<script src="../../resources/dump-as-markup.js"></script>
<style>
#editor {
border: 1px blue dashed;
}
</style>
<script>
const dumpMarkupOnInput = e => Markup.dump(e.target, `${e.type}, ${e.inputType}, ${e.data} on #${e.target.id}`);
Markup.description("Verifies that changing the text writing direction fires input events which may be prevented. To manually test, select 'מקור' in the top contenteditable and change the selection direction to 'left to right'; then, select the same word in the prevented contenteditable and change selection direction to 'left to right'. Check that the bottom editable area's contents did not change.");
Markup.noAutoDump();
addEventListener("load", () => {
const notPrevented = document.querySelector("#notPrevented");
const prevented = document.querySelector("#prevented");
notPrevented.addEventListener("input", dumpMarkupOnInput);
notPrevented.addEventListener("beforeinput", dumpMarkupOnInput);
prevented.addEventListener("input", dumpMarkupOnInput);
prevented.addEventListener("beforeinput", event => {
dumpMarkupOnInput(event);
event.preventDefault();
});
getSelection().setBaseAndExtent(notPrevented.firstChild, 6, notPrevented.firstChild, 10);
if (!window.testRunner)
return;
testRunner.execCommand("MakeTextWritingDirectionLeftToRight");
getSelection().setBaseAndExtent(notPrevented.lastChild, 11, notPrevented.lastChild, 16);
testRunner.execCommand("MakeTextWritingDirectionRightToLeft");
getSelection().setBaseAndExtent(prevented.firstChild, 6, prevented.firstChild, 10);
testRunner.execCommand("MakeTextWritingDirectionLeftToRight");
getSelection().setBaseAndExtent(prevented.lastChild, 21, prevented.lastChild, 26);
testRunner.execCommand("MakeTextWritingDirectionRightToLeft");
Markup.notifyDone();
});
</script>
</head>
<body>
<div contenteditable id="notPrevented">Hello מקור השם עברית world</div>
<div contenteditable id="prevented">Hello מקור השם עברית world</div>
</body>
</html>