зеркало из https://github.com/mozilla/gecko-dev.git
90cd2122dd
`AutoEditActionDataSetter` is created in the stack when editor's public method is called and that guarantees lifetime of global objects in editor such as editor itself, selection controller, etc. The dispatcher of `beforeinput` event returns `NS_ERROR_EDITOR_ACTION_CANCELED` if an event is actually dispatched but canceled. The reason why it's an error is, editor code must stop handling anything when any methods return error. So, returning an error code is reasonable in editor module. But when it's filtered by `EditorBase::ToGenericNSResult()` at return statement of public methods, it's converted to `NS_SUCCESS_DOM_NO_OPERATION`. This avoids throwing new exception, but editor class users in C++ can distinguish whether each edit action is canceled or handled. The reason why we should not throw new exception from XPCOM API is, without taking care of each caller may break some our UI (especially for avoiding to break comm-central). Therefore, this patch does not make XPCOM methods return error code when `beforeinput` event is canceled. In most cases, immediately after creating `AutoEditActionDataSetter` is good timing to dispatch `beforeinput` event since editor has not touched the DOM yet. If `beforeinput` requires `data` or `dataTransfer`, methods need to dispatch `beforeinput` event after that. Alhtough this is not a good thing from point of view of consistency of the code. However, I have no better idea. Note 1: Our implementation does NOT conform to the spec about event order between `keypress` and `beforeinput` (dispatching `beforeinput` event after `keypress` event). However, we follow all other browsers' behavior so that it must be safe and the spec should be updated for backward compatibility. Spec issue: https://github.com/w3c/uievents/issues/220 Note 2: Our implementation does NOT conform to the spec about event order between `compositionupdate` and `beforeinput`. Our behavior is same as Safari, but different from Chrome. This might cause web-compat issues. However, our behavior does make sense from point of view of consistency of event spec. Additionally, at both `compositionupdate` and `beforeinput`, composition string in editor has not been modified yet. Therefore, this may not cause web-compat issues (and I hope so). Spec issue: https://github.com/w3c/input-events/issues/49 Note that this patch makes editor detect bugs that `beforeinput` event hasn't been handled yet when it dispatches `input` event or modifying `data` and `dataTransfer` value are modified after dispatching `beforeinput` event with `MOZ_ASSERT`s. Differential Revision: https://phabricator.services.mozilla.com/D58127 --HG-- extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
browser | ||
unit | ||
.eslintrc.js | ||
TestAppShellSteadyState.cpp | ||
TestChromeMargin.cpp | ||
bug586713_window.xhtml | ||
chrome.ini | ||
chrome_context_menus_win.xhtml | ||
empty_window.xhtml | ||
file_bug596600.html | ||
file_input_events_on_deactive_window.html | ||
file_secure_input.html | ||
mochitest.ini | ||
moz.build | ||
native_menus_window.xhtml | ||
native_mouse_mac_window.xhtml | ||
standalone_native_menu_window.xhtml | ||
system_font_changes.xhtml | ||
taskbar_previews.xhtml | ||
test_AltGr_key_events_in_web_content_on_windows.html | ||
test_actionhint.html | ||
test_assign_event_data.html | ||
test_bug343416.xhtml | ||
test_bug413277.html | ||
test_bug428405.xhtml | ||
test_bug429954.xhtml | ||
test_bug444800.xhtml | ||
test_bug466599.xhtml | ||
test_bug478536.xhtml | ||
test_bug485118.xhtml | ||
test_bug517396.xhtml | ||
test_bug522217.xhtml | ||
test_bug538242.xhtml | ||
test_bug565392.html | ||
test_bug586713.xhtml | ||
test_bug593307.xhtml | ||
test_bug596600.xhtml | ||
test_bug673301.xhtml | ||
test_bug760802.xhtml | ||
test_bug1123480.xhtml | ||
test_bug1151186.html | ||
test_chrome_context_menus_win.xhtml | ||
test_clipboard.xhtml | ||
test_composition_text_querycontent.xhtml | ||
test_imestate.html | ||
test_input_events_on_deactive_window.xhtml | ||
test_key_event_counts.xhtml | ||
test_keycodes.xhtml | ||
test_keypress_event_with_alt_on_mac.html | ||
test_mouse_scroll.xhtml | ||
test_native_key_bindings_mac.html | ||
test_native_menus.xhtml | ||
test_native_mouse_mac.xhtml | ||
test_panel_mouse_coords.xhtml | ||
test_picker_no_crash.html | ||
test_platform_colors.xhtml | ||
test_plugin_input_event.html | ||
test_plugin_scroll_consistency.html | ||
test_position_on_resize.xhtml | ||
test_scrollbar_colors.html | ||
test_secure_input.html | ||
test_sizemode_events.xhtml | ||
test_standalone_native_menu.xhtml | ||
test_system_font_changes.xhtml | ||
test_system_status_bar.xhtml | ||
test_taskbar_progress.xhtml | ||
test_transferable_overflow.xhtml | ||
test_wheeltransaction.xhtml | ||
utils.js | ||
window_bug429954.xhtml | ||
window_bug478536.xhtml | ||
window_bug522217.xhtml | ||
window_bug538242.xhtml | ||
window_bug593307_centerscreen.xhtml | ||
window_bug593307_offscreen.xhtml | ||
window_composition_text_querycontent.xhtml | ||
window_imestate_iframes.html | ||
window_mouse_scroll_win.html | ||
window_picker_no_crash_child.html | ||
window_state_windows.xhtml | ||
window_wheeltransaction.xhtml |