--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -835,18 +835,16 @@ GK_ATOM(onmouseenter, "onmouseenter")
GK_ATOM(onmouseleave, "onmouseleave")
GK_ATOM(onmouselongtap, "onmouselongtap")
GK_ATOM(onmousemove, "onmousemove")
GK_ATOM(onmouseout, "onmouseout")
GK_ATOM(onmouseover, "onmouseover")
GK_ATOM(onMozMouseHittest, "onMozMouseHittest")
GK_ATOM(onmouseup, "onmouseup")
GK_ATOM(onMozAfterPaint, "onMozAfterPaint")
-GK_ATOM(onmozbrowserafterkeydown, "onmozbrowserafterkeydown")
-GK_ATOM(onmozbrowserafterkeyup, "onmozbrowserafterkeyup")
GK_ATOM(onmozfullscreenchange, "onmozfullscreenchange")
GK_ATOM(onmozfullscreenerror, "onmozfullscreenerror")
GK_ATOM(onmozkeydownonplugin, "onmozkeydownonplugin")
GK_ATOM(onmozkeyuponplugin, "onmozkeyuponplugin")
GK_ATOM(onmozpointerlockchange, "onmozpointerlockchange")
GK_ATOM(onmozpointerlockerror, "onmozpointerlockerror")
GK_ATOM(onmoztimechange, "onmoztimechange")
GK_ATOM(onMozMousePixelScroll, "onMozMousePixelScroll")
--- a/dom/events/BeforeAfterKeyboardEvent.cpp
+++ b/dom/events/BeforeAfterKeyboardEvent.cpp
@@ -61,22 +61,16 @@ BeforeAfterKeyboardEvent::Constructor(
{
nsCOMPtr<EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
return Constructor(owner, aType, aParam);
}
Nullable<bool>
BeforeAfterKeyboardEvent::GetEmbeddedCancelled()
{
- nsAutoString type;
- GetType(type);
- if (type.EqualsLiteral("mozbrowserafterkeydown") ||
- type.EqualsLiteral("mozbrowserafterkeyup")) {
- return mEvent->AsBeforeAfterKeyboardEvent()->mEmbeddedCancelled;
- }
return Nullable<bool>();
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
--- a/dom/events/BeforeAfterKeyboardEvent.h
+++ b/dom/events/BeforeAfterKeyboardEvent.h
@@ -30,18 +30,16 @@ public:
const nsAString& aType,
const BeforeAfterKeyboardEventInit& aParam,
ErrorResult& aRv);
static already_AddRefed<BeforeAfterKeyboardEvent>
Constructor(EventTarget* aOwner, const nsAString& aType,
const BeforeAfterKeyboardEventInit& aEventInitDict);
- // This function returns a boolean value when event typs is either
- // "mozbrowserafterkeydown" or "mozbrowserafterkeyup".
Nullable<bool> GetEmbeddedCancelled();
};
} // namespace dom
} // namespace mozilla
already_AddRefed<mozilla::dom::BeforeAfterKeyboardEvent>
NS_NewDOMBeforeAfterKeyboardEvent(mozilla::dom::EventTarget* aOwner,
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -261,24 +261,16 @@ EVENT(keyup,
EVENT(mozkeydownonplugin,
eKeyDownOnPlugin,
EventNameType_None,
eKeyboardEventClass)
EVENT(mozkeyuponplugin,
eKeyUpOnPlugin,
EventNameType_None,
eKeyboardEventClass)
-NON_IDL_EVENT(mozbrowserafterkeydown,
- eAfterKeyDown,
- EventNameType_None,
- eBeforeAfterKeyboardEventClass)
-NON_IDL_EVENT(mozbrowserafterkeyup,
- eAfterKeyUp,
- EventNameType_None,
- eBeforeAfterKeyboardEventClass)
NON_IDL_EVENT(mozaccesskeynotfound,
eAccessKeyNotFound,
EventNameType_None,
eKeyboardEventClass)
EVENT(loadeddata,
eLoadedData,
EventNameType_HTML,
eBasicEventClass)
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -753,19 +753,17 @@ EventStateManager::PreHandleEvent(nsPres
*aStatus = nsEventStatus_eConsumeNoDefault;
}
}
}
}
// then fall through...
MOZ_FALLTHROUGH;
case eKeyDown:
- case eAfterKeyDown:
case eKeyUp:
- case eAfterKeyUp:
{
nsIContent* content = GetFocusedContent();
if (content)
mCurrentTargetContent = content;
// NOTE: Don't refer TextComposition::IsComposing() since UI Events
// defines that KeyboardEvent.isComposing is true when it's
// dispatched after compositionstart and compositionend.
@@ -3447,17 +3445,16 @@ EventStateManager::PostHandleEvent(nsPre
}
case eDragExit:
// make sure to fire the enter and exit_synth events after the
// eDragExit event, otherwise we'll clean up too early
GenerateDragDropEnterExit(presContext, aEvent->AsDragEvent());
break;
case eKeyUp:
- case eAfterKeyUp:
break;
case eKeyPress:
{
WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
PostHandleKeyboardEvent(keyEvent, *aStatus, dispatchedToContentProcess);
}
break;
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -185,20 +185,18 @@ KeyboardEvent::CharCode()
// If this event is initialized with ctor, we shouldn't check event type.
if (mInitializedByCtor) {
return mEvent->AsKeyboardEvent()->mCharCode;
}
switch (mEvent->mMessage) {
case eKeyDown:
case eKeyDownOnPlugin:
- case eAfterKeyDown:
case eKeyUp:
case eKeyUpOnPlugin:
- case eAfterKeyUp:
return 0;
case eKeyPress:
case eAccessKeyNotFound:
return mEvent->AsKeyboardEvent()->mCharCode;
default:
break;
}
return 0;
@@ -232,20 +230,18 @@ KeyboardEvent::Which()
// If this event is initialized with ctor, which can have independent value.
if (mInitializedByCtor) {
return mInitializedWhichValue;
}
switch (mEvent->mMessage) {
case eKeyDown:
case eKeyDownOnPlugin:
- case eAfterKeyDown:
case eKeyUp:
case eKeyUpOnPlugin:
- case eAfterKeyUp:
return KeyCode();
case eKeyPress:
//Special case for 4xp bug 62878. Try to make value of which
//more closely mirror the values that 4.x gave for RETURN and BACKSPACE
{
uint32_t keyCode = mEvent->AsKeyboardEvent()->mKeyCode;
if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) {
return keyCode;
deleted file mode 100644
--- a/dom/events/test/bug989198_embedded.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <title>Embedded iframe</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload="getFocus();">
- <p id="display"></p>
- <div id="content" style="display: none"></div>
- <input id="input" style="display: block;">
- <pre id="test">
- <script type="application/javascript">
- function getFocus() {
- input = document.getElementById("input");
- input.focus();
- }
- </script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/events/test/bug989198_helper.js
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Helper functions for testing BeforeAfterKeyboardEvent.
- */
-
-const kUnknownEvent = 0x000;
-const kKeyDownEvent = 0x001;
-const kKeyUpEvent = 0x002;
-const kAfterEvent = 0x020;
-const kParent = 0x100;
-const kChild = 0x200;
-
-var gCurrentTest;
-
-function frameScript()
-{
- function handler(e) {
- var results = sendSyncMessage("forwardevent", { type: e.type });
- if (results[0]) {
- e.preventDefault();
- }
- }
- addEventListener('keydown', handler);
- addEventListener('keyup', handler);
- addEventListener('mozbrowserafterkeydown', handler);
- addEventListener('mozbrowserafterkeyup', handler);
-}
-
-function prepareTest(useRemote)
-{
- if (useRemote) {
- setupHandlers(window, embedderHandler);
- } else {
- setupHandlers(window, embedderHandlerWithCheck);
- }
-
- var iframe = document.createElement("iframe");
- iframe.id = "embedded";
- iframe.src = "bug989198_embedded.html";
- iframe.setAttribute("remote", useRemote ? "true" : "false");
- SpecialPowers.wrap(iframe).mozbrowser = true;
-
- iframe.addEventListener("mozbrowserloadend", function onloadend() {
- iframe.removeEventListener("mozbrowserloadend", onloadend);
- iframe.focus();
- var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
- mm.addMessageListener("forwardevent", function(msg) {
- return embeddedHandler(msg.json);
- });
- mm.loadFrameScript("data:,(" + frameScript.toString() + ")();", false);
- runTests();
- return;
- });
-
- document.body.appendChild(iframe);
-}
-
-function setupHandlers(element, handler)
-{
- element.addEventListener('keydown', handler);
- element.addEventListener('keyup', handler);
- element.addEventListener('mozbrowserafterkeydown', handler);
- element.addEventListener('mozbrowserafterkeyup', handler);
-}
-
-function teardownHandlers(element, handler)
-{
- element.removeEventListener('keydown', handler);
- element.removeEventListener('keyup', handler);
- element.removeEventListener('mozbrowserafterkeydown', handler);
- element.removeEventListener('mozbrowserafterkeyup', handler);
-}
-
-function convertNameToCode(name)
-{
- switch (name) {
- case "mozbrowserafterkeydown":
- return kAfterEvent | kKeyDownEvent;
- case "mozbrowserafterkeyup":
- return kAfterEvent | kKeyUpEvent;
- case "keydown":
- return kKeyDownEvent;
- case "keyup":
- return kKeyUpEvent;
- default:
- return kUnknownEvent;
- }
-}
-
-function classifyEvents(test)
-{
- // Categorize resultEvents into KEYDOWN group and KEYUP group.
- for (var i = 0; i < gCurrentTest.resultEvents.length ; i++) {
- var code = test.resultEvents[i];
- if ((code & 0xF) == 0x1) { // KEYDOWN
- test.classifiedEvents[0].push(code);
- } else if ((code & 0xF) == 0x2) { // KEYUP
- test.classifiedEvents[1].push(code);
- } else {
- ok(false, "Invalid code for events");
- }
- }
-}
-
-function verifyResults(test)
-{
- for (var i = 0; i < gCurrentTest.expectedEvents.length; i++) {
- is(test.classifiedEvents[i].length,
- test.expectedEvents[i].length,
- test.description + ": Wrong number of events");
-
- for (var j = 0; j < gCurrentTest.classifiedEvents[i].length; j++) {
- var item = test.classifiedEvents[i][j];
- is(item, test.expectedEvents[i][j],
- test.description + ": Wrong order of events");
- }
- }
-}
-
-function embeddedHandler(e)
-{
- return handler(e, kChild);
-}
-
-function embedderHandler(e, callback)
-{
- handler(e, kParent, callback);
-}
-
-function handler(e, highBit, callback)
-{
- var code = convertNameToCode(e.type);
- var newCode = highBit | code;
- gCurrentTest.resultEvents.push(newCode);
-
- if (callback) {
- callback(code);
- }
-
- if (highBit == kChild) {
- // return and let frameScript to handle
- return newCode == gCurrentTest.doPreventDefaultAt;
- }
-
- if (newCode == gCurrentTest.doPreventDefaultAt) {
- e.preventDefault();
- }
-}
-
-function embedderHandlerWithCheck(e)
-{
- // Verify value of attribute embeddedCancelled
- embedderHandler(e, function checkEmbeddedCancelled(code){
- switch (code) {
- case kAfterEvent | kKeyDownEvent:
- if ((gCurrentTest.doPreventDefaultAt & 0xFF) == kKeyDownEvent) {
- is(e.embeddedCancelled, true,
- gCurrentTest.description + ": embeddedCancelled should be true");
- } else {
- is(e.embeddedCancelled, false,
- gCurrentTest.description + ": embeddedCancelled should be false");
- }
- break;
- case kAfterEvent | kKeyUpEvent:
- if ((gCurrentTest.doPreventDefaultAt & 0xFF) == kKeyUpEvent) {
- is(e.embeddedCancelled, true,
- gCurrentTest.description + ": embeddedCancelled should be true");
- } else {
- is(e.embeddedCancelled, false,
- gCurrentTest.description + ": embeddedCancelled should be false");
- }
- break;
- default:
- break;
- }
- });
-}
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -139,25 +139,16 @@ support-files = bug1017086_inner.html
[test_bug1248459.html]
[test_bug1264380.html]
run-if = (e10s && os != "win") # Bug 1270043, crash at windows platforms; Bug1264380 comment 20, nsDragService::InvokeDragSessionImpl behaves differently among platform implementations in non-e10s mode which prevents us to check the validity of nsIDragService::getCurrentSession() consistently via synthesize mouse clicks in non-e10s mode.
[test_clickevent_on_input.html]
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_continuous_wheel_events.html]
[test_dblclick_explicit_original_target.html]
[test_dom_activate_event.html]
-[test_dom_before_after_keyboard_event.html]
-support-files =
- bug989198_embedded.html
- bug989198_helper.js
-[test_dom_before_after_keyboard_event_remote.html]
-support-files =
- bug989198_embedded.html
- bug989198_helper.js
-skip-if = e10s
[test_dom_keyboard_event.html]
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_dom_mouse_event.html]
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
[test_dom_storage_event.html]
[test_dom_wheel_event.html]
[test_draggableprop.html]
skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
deleted file mode 100644
--- a/dom/events/test/test_dom_before_after_keyboard_event.html
+++ /dev/null
@@ -1,108 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <title>Test for Bug 989198</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/NativeKeyCodes.js"></script>
- <script type="text/javascript" src="bug989198_helper.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload="runTests();">
-<a target="_blank"
- href="https://bugzilla.mozilla.org/show_bug.cgi?id=989198">Mozilla Bug 989198</a>
-<p id="display"></p>
-<pre id="test">
-<script type="application/javascript">
-
-SimpleTest.waitForExplicitFinish();
-
-function cleanupTest()
-{
- teardownHandlers(window, embedderHandler);
- runTests();
-}
-
-function testEventOrderAndAttr()
-{
- const kTests = [
- {
- description: "Testing the order of the events",
- expectedEvents: [ [ kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kUnknownEvent
- },
- {
- description: "Testing the order of the events, calling preventDefault() at \"keydown\" event",
- expectedEvents: [ [ kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kChild | kKeyDownEvent
- },
- {
- description: "Testing the order of the events, calling preventDefault() at \"keyup\" event",
- expectedEvents: [ [ kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kChild | kKeyUpEvent
- }
- ];
-
- for (var k = 0; k < kTests.length; k++ ) {
- gCurrentTest = kTests[k];
- synthesizeKey('a', {}, document.getElementById("embedded").contentWindow);
- classifyEvents(kTests[k]);
- verifyResults(kTests[k]);
- }
-
- runTests();
-}
-
-var tests = [
- function addPermissions() {
- SpecialPowers.pushPermissions(
- [{ type: "before-after-keyboard-event", allow: true, context: document },
- { type: "browser", allow: true, context: document }],
- runTests);
- },
- function addPreferences() {
- SpecialPowers.pushPrefEnv(
- { "set": [["dom.beforeAfterKeyboardEvent.enabled", true],
- ["dom.mozBrowserFramesEnabled", true],
- ["network.disable.ipc.security", true],
- ["dom.ipc.tabs.disabled", false]] },
- runTests);
- },
-
- // Tests for in-process iframe, i.e. <iframe mozbrowser>.
- function () {
- prepareTest(false);
- },
- testEventOrderAndAttr,
- cleanupTest,
-];
-
-function runTests()
-{
- if (!tests.length) {
- SimpleTest.finish();
- return;
- }
-
- var test = tests.shift();
- test();
-}
-
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/events/test/test_dom_before_after_keyboard_event_remote.html
+++ /dev/null
@@ -1,159 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <title>Test for Bug 989198</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/NativeKeyCodes.js"></script>
- <script type="text/javascript" src="bug989198_helper.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload="runTests();">
-<a target="_blank"
- href="https://bugzilla.mozilla.org/show_bug.cgi?id=989198">Mozilla Bug 989198</a>
-<p id="display"></p>
-<div id="content">
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-SimpleTest.waitForExplicitFinish();
-SimpleTest.requestFlakyTimeout("untriaged");
-
-var testsForEventOrder = [
- {
- description: "Testing the order of the events (OOP)",
- expectedEvents: [ [ kParent | kKeyDownEvent,
- kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kParent | kKeyUpEvent,
- kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kUnknownEvent
- },
- {
- description: "Testing the order of the events (OOP), calling " +
- "preventDefault() at \"keydown\" event in parent process",
- expectedEvents: [ [ kParent | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kParent | kKeyUpEvent,
- kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kParent | kKeyDownEvent
- },
- {
- description: "Testing the order of the events (OOP), calling " +
- "preventDefault() at \"keydown\" event in child process",
- expectedEvents: [ [ kParent | kKeyDownEvent,
- kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kParent | kKeyUpEvent,
- kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kChild | kKeyDownEvent
- },
- {
- description: "Testing the order of the events (OOP), calling " +
- "preventDefault() at \"keyup\" event in parent process",
- expectedEvents: [ [ kParent | kKeyDownEvent,
- kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kParent | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kParent | kKeyUpEvent
- },
- {
- description: "Testing the order of the events (OOP), calling " +
- "preventDefault() at \"keyup\" event in child process",
- expectedEvents: [ [ kParent | kKeyDownEvent,
- kChild | kKeyDownEvent,
- kParent | kAfterEvent | kKeyDownEvent ],
- [ kParent | kKeyUpEvent,
- kChild | kKeyUpEvent,
- kParent | kAfterEvent | kKeyUpEvent ] ],
- resultEvents: [],
- classifiedEvents: [ [], [] ],
- doPreventDefaultAt: kChild | kKeyUpEvent
- }
-];
-
-function cleanupTest()
-{
- teardownHandlers(window, embedderHandler);
- runTests();
-}
-
-function testEventOrder()
-{
- if (!testsForEventOrder.length) {
- runTests();
- return;
- }
- gCurrentTest = testsForEventOrder.shift();
-
- synthesizeKey('a', {}, document.getElementById("embedded").contentWindow);
- // It take some time to propagate events to a remote iframe.
-
- waitAndVerifyResult(0);
-}
-
-function waitAndVerifyResult(aCount) {
- expectedEventLength = gCurrentTest.expectedEvents[0].length +
- gCurrentTest.expectedEvents[1].length;
- if (gCurrentTest.resultEvents.length >= expectedEventLength || aCount > 10) {
- classifyEvents(gCurrentTest);
- verifyResults(gCurrentTest);
- testEventOrder();
- }
- else {
- setTimeout(() => waitAndVerifyResult(aCount + 1),
- 100);
- }
-}
-
-var tests = [
- function addPermissions() {
- SpecialPowers.pushPermissions(
- [{ type: "before-after-keyboard-event", allow: true, context: document },
- { type: "browser", allow: true, context: document }],
- runTests);
- },
- function addPreferences() {
- SpecialPowers.pushPrefEnv(
- { "set": [["dom.beforeAfterKeyboardEvent.enabled", true],
- ["dom.mozBrowserFramesEnabled", true],
- ["network.disable.ipc.security", true],
- ["dom.ipc.tabs.disabled", false]] },
- runTests);
- },
-
- // Tests for out-of-process iframe, i.el. <iframe mozbrowser remote>
- function () {
- prepareTest(true);
- },
- testEventOrder,
- cleanupTest
-];
-
-function runTests()
-{
- if (!tests.length) {
- SimpleTest.finish();
- return;
- }
-
- var test = tests.shift();
- test();
-}
-
-</script>
-</body>
-</html>
--- a/dom/inputmethod/HardwareKeyHandler.cpp
+++ b/dom/inputmethod/HardwareKeyHandler.cpp
@@ -207,25 +207,19 @@ HardwareKeyHandler::OnHandledByInputMeth
// the key is consumed by input-method-app
SetDefaultPrevented(keyInfo->mEvent, aDefaultPrevented);
// Set the flag to specify the reply phase
keyInfo->mEvent.mInputMethodAppState = WidgetKeyboardEvent::eHandled;
// Check whether the event is still valid to be fired
if (CanDispatchEvent(keyInfo->mTarget, keyInfo->mEvent)) {
- // If the key's defaultPrevented is true, it means that the
- // input-method-app has already consumed this key,
- // so we can dispatch |mozbrowserafterkey*| directly if
- // preference "dom.beforeAfterKeyboardEvent.enabled" is enabled.
- if (keyInfo->mEvent.mFlags.mDefaultPrevented) {
- DispatchAfterKeyEvent(keyInfo->mTarget, keyInfo->mEvent);
- // Otherwise, it means that input-method-app doesn't handle this key,
+ // If input-method-app doesn't handle this key,
// so we need to dispatch it to its current event target.
- } else {
+ if (!keyInfo->mEvent.mFlags.mDefaultPrevented) {
DispatchToTargetApp(keyInfo->mTarget,
keyInfo->mEvent,
keyInfo->mStatus);
}
}
// No need to do further processing if the event is not keydown
if (keyInfo->mEvent.mMessage != eKeyDown) {
@@ -292,35 +286,16 @@ HardwareKeyHandler::DispatchKeyPress(nsI
bool ret = DispatchToTargetApp(aTarget, aEvent, aStatus);
// Re-trigger EventStateManager::PostHandleKeyboardEvent for keypress
PostHandleKeyboardEvent(aTarget, aEvent, aStatus);
return ret;
}
-void
-HardwareKeyHandler::DispatchAfterKeyEvent(nsINode* aTarget,
- WidgetKeyboardEvent& aEvent)
-{
- MOZ_ASSERT(aTarget, "No target provided");
-
- if (!PresShell::BeforeAfterKeyboardEventEnabled() ||
- aEvent.mMessage == eKeyPress) {
- return;
- }
-
- nsCOMPtr<nsIPresShell> presShell = GetPresShell(aTarget);
- if (NS_WARN_IF(presShell)) {
- presShell->DispatchAfterKeyboardEvent(aTarget,
- aEvent,
- aEvent.mFlags.mDefaultPrevented);
- }
-}
-
bool
HardwareKeyHandler::DispatchToTargetApp(nsINode* aTarget,
WidgetKeyboardEvent& aEvent,
nsEventStatus& aStatus)
{
MOZ_ASSERT(aTarget, "No target provided");
// Get current focused element as the event target
@@ -349,32 +324,21 @@ HardwareKeyHandler::DispatchToTargetApp(
if (!presShell->CanDispatchEvent(&aEvent)) {
return false;
}
// In-process case: the event target is in the current process
if (!PresShell::IsTargetIframe(currentTarget)) {
DispatchToCurrentProcess(presShell, currentTarget, aEvent, aStatus);
-
- if (presShell->CanDispatchEvent(&aEvent)) {
- DispatchAfterKeyEvent(aTarget, aEvent);
- }
-
return true;
}
// OOP case: the event target is in the child process
return DispatchToCrossProcess(aTarget, aEvent);
-
- // After the oop target receives the event from TabChild::RecvRealKeyEvent
- // and return the result through TabChild::SendDispatchAfterKeyboardEvent,
- // the |mozbrowserafterkey*| will be fired from
- // TabParent::RecvDispatchAfterKeyboardEvent, so we don't need to dispatch
- // |mozbrowserafterkey*| by ourselves in this module.
}
void
HardwareKeyHandler::DispatchToCurrentProcess(nsIPresShell* presShell,
nsIContent* aTarget,
WidgetKeyboardEvent& aEvent,
nsEventStatus& aStatus)
{
--- a/dom/inputmethod/HardwareKeyHandler.h
+++ b/dom/inputmethod/HardwareKeyHandler.h
@@ -141,18 +141,16 @@ private:
virtual ~HardwareKeyHandler();
// Return true if the keypress is successfully dispatched.
// Otherwise, return false.
bool DispatchKeyPress(nsINode* aTarget,
WidgetKeyboardEvent& aEvent,
nsEventStatus& aStatus);
- void DispatchAfterKeyEvent(nsINode* aTarget, WidgetKeyboardEvent& aEvent);
-
void DispatchToCurrentProcess(nsIPresShell* aPresShell,
nsIContent* aTarget,
WidgetKeyboardEvent& aEvent,
nsEventStatus& aStatus);
bool DispatchToCrossProcess(nsINode* aTarget, WidgetKeyboardEvent& aEvent);
// This method will dispatch not only key* event to its event target,
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -506,18 +506,16 @@ parent:
*/
async LookUpDictionary(nsString aText, FontRange[] aFontRangeArray,
bool aIsVertical, LayoutDeviceIntPoint aPoint);
async __delete__();
async ReplyKeyEvent(WidgetKeyboardEvent event);
- async DispatchAfterKeyboardEvent(WidgetKeyboardEvent event);
-
sync RequestNativeKeyBindings(WidgetKeyboardEvent event)
returns (MaybeNativeKeyBinding bindings);
async SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
int32_t aNativeKeyCode,
uint32_t aModifierFlags,
nsString aCharacters,
nsString aUnmodifiedCharacters,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1812,20 +1812,16 @@ TabChild::RecvRealKeyEvent(const WidgetK
if (localEvent.mFlags.mWantReplyFromContentProcess) {
SendReplyKeyEvent(localEvent);
}
if (localEvent.mAccessKeyForwardedToChild) {
SendAccessKeyNotHandled(localEvent);
}
- if (PresShell::BeforeAfterKeyboardEventEnabled()) {
- SendDispatchAfterKeyboardEvent(localEvent);
- }
-
return IPC_OK();
}
mozilla::ipc::IPCResult
TabChild::RecvKeyEvent(const nsString& aType,
const int32_t& aKeyCode,
const int32_t& aCharCode,
const int32_t& aModifiers,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1947,38 +1947,16 @@ TabParent::RecvReplyKeyEvent(const Widge
AutoHandlingUserInputStatePusher userInpStatePusher(localEvent.IsTrusted(),
&localEvent, doc);
EventDispatcher::Dispatch(mFrameElement, presContext, &localEvent);
return IPC_OK();
}
mozilla::ipc::IPCResult
-TabParent::RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& aEvent)
-{
- NS_ENSURE_TRUE(mFrameElement, IPC_OK());
-
- WidgetKeyboardEvent localEvent(aEvent);
- localEvent.mWidget = GetWidget();
-
- nsIDocument* doc = mFrameElement->OwnerDoc();
- nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
- NS_ENSURE_TRUE(presShell, IPC_OK());
-
- if (mFrameElement &&
- PresShell::BeforeAfterKeyboardEventEnabled() &&
- localEvent.mMessage != eKeyPress) {
- presShell->DispatchAfterKeyboardEvent(mFrameElement, localEvent,
- aEvent.DefaultPrevented());
- }
-
- return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
TabParent::RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent)
{
NS_ENSURE_TRUE(mFrameElement, IPC_OK());
WidgetKeyboardEvent localEvent(aEvent);
localEvent.mMessage = eAccessKeyNotFound;
localEvent.mAccessKeyForwardedToChild = false;
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -169,19 +169,16 @@ public:
virtual mozilla::ipc::IPCResult RecvDropLinks(nsTArray<nsString>&& aLinks) override;
virtual mozilla::ipc::IPCResult RecvEvent(const RemoteDOMEvent& aEvent) override;
virtual mozilla::ipc::IPCResult RecvReplyKeyEvent(const WidgetKeyboardEvent& aEvent) override;
virtual mozilla::ipc::IPCResult
- RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& aEvent) override;
-
- virtual mozilla::ipc::IPCResult
RecvAccessKeyNotHandled(const WidgetKeyboardEvent& aEvent) override;
virtual mozilla::ipc::IPCResult RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
PRenderFrameParent* aRenderFrame,
const nsString& aURL,
const nsString& aName,
const nsString& aFeatures,
bool* aOutWindowOpened,
--- a/dom/webidl/BeforeAfterKeyboardEvent.webidl
+++ b/dom/webidl/BeforeAfterKeyboardEvent.webidl
@@ -5,18 +5,15 @@
*/
[Constructor(DOMString typeArg,
optional BeforeAfterKeyboardEventInit eventInitDict),
Pref="dom.beforeAfterKeyboardEvent.enabled",
ChromeOnly]
interface BeforeAfterKeyboardEvent : KeyboardEvent
{
- // The valid value of embeddedCancelled is:
- // - "mozbrowserafterkeydown": true/false
- // - "mozbrowserafterkeyup": true/false
readonly attribute boolean? embeddedCancelled;
};
dictionary BeforeAfterKeyboardEventInit : KeyboardEventInit
{
boolean? embeddedCancelled = null;
};
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -7087,66 +7087,16 @@ BuildTargetChainForBeforeAfterKeyboardEv
if (CheckPermissionForBeforeAfterKeyboardEvent(frameElement)) {
aChain.AppendElement(frameElement);
}
nsPIDOMWindowOuter* window = frameElement->OwnerDoc()->GetWindow();
frameElement = window ? window->GetFrameElementInternal() : nullptr;
}
}
-void
-PresShell::DispatchAfterKeyboardEventInternal(const nsTArray<nsCOMPtr<Element> >& aChain,
- const WidgetKeyboardEvent& aEvent,
- bool aEmbeddedCancelled,
- size_t aStartOffset)
-{
- size_t length = aChain.Length();
- if (!CanDispatchEvent(&aEvent) || !length) {
- return;
- }
-
- EventMessage message =
- (aEvent.mMessage == eKeyDown) ? eAfterKeyDown : eAfterKeyUp;
- bool embeddedCancelled = aEmbeddedCancelled;
- nsCOMPtr<EventTarget> eventTarget;
- // Dispatch after events from the innermost element.
- for (uint32_t i = aStartOffset; i < length; i++) {
- eventTarget = do_QueryInterface(aChain[i]->OwnerDoc()->GetWindow());
- if (!eventTarget || !CanDispatchEvent(&aEvent)) {
- return;
- }
-
- InternalBeforeAfterKeyboardEvent afterEvent(aEvent.IsTrusted(),
- message, aEvent.mWidget);
- afterEvent.AssignBeforeAfterKeyEventData(aEvent, false);
- afterEvent.mEmbeddedCancelled.SetValue(embeddedCancelled);
- EventDispatcher::Dispatch(eventTarget, mPresContext, &afterEvent);
- embeddedCancelled = afterEvent.DefaultPrevented();
- }
-}
-
-void
-PresShell::DispatchAfterKeyboardEvent(nsINode* aTarget,
- const WidgetKeyboardEvent& aEvent,
- bool aEmbeddedCancelled)
-{
- MOZ_ASSERT(aTarget);
- MOZ_ASSERT(BeforeAfterKeyboardEventEnabled());
-
- if (NS_WARN_IF(aEvent.mMessage != eKeyDown && aEvent.mMessage != eKeyUp)) {
- return;
- }
-
- // Build up a target chain. Each item in the chain will receive an after event.
- AutoTArray<nsCOMPtr<Element>, 5> chain;
- bool targetIsIframe = IsTargetIframe(aTarget);
- BuildTargetChainForBeforeAfterKeyboardEvent(aTarget, chain, targetIsIframe);
- DispatchAfterKeyboardEventInternal(chain, aEvent, aEmbeddedCancelled);
-}
-
bool
PresShell::CanDispatchEvent(const WidgetGUIEvent* aEvent) const
{
bool rv =
mPresContext && !mHaveShutDown && nsContentUtils::IsSafeToRunScript();
if (aEvent) {
rv &= (aEvent && aEvent->mWidget && !aEvent->mWidget->Destroyed());
}
@@ -7160,53 +7110,18 @@ PresShell::HandleKeyboardEvent(nsINode*
nsEventStatus* aStatus,
EventDispatchingCallback* aEventCB)
{
MOZ_ASSERT(aTarget);
// return true if the event target is in its child process
bool targetIsIframe = IsTargetIframe(aTarget);
- // Dispatch event directly if the event is a keypress event, a key event on
- // plugin, or there is no need to fire beforeKey* and afterKey* events.
- if (aEvent.mMessage == eKeyPress ||
- aEvent.IsKeyEventOnPlugin() ||
- !BeforeAfterKeyboardEventEnabled()) {
- ForwardKeyToInputMethodAppOrDispatch(targetIsIframe, aTarget, aEvent,
- aStatus, aEventCB);
- return;
- }
-
- MOZ_ASSERT(aEvent.mMessage == eKeyDown || aEvent.mMessage == eKeyUp);
-
- // Build up a target chain. Each item in the chain will receive a before event.
- AutoTArray<nsCOMPtr<Element>, 5> chain;
- BuildTargetChainForBeforeAfterKeyboardEvent(aTarget, chain, targetIsIframe);
-
- if (ForwardKeyToInputMethodAppOrDispatch(targetIsIframe, aTarget, aEvent,
- aStatus, aEventCB)) {
- return;
- }
-
- if (aEvent.DefaultPrevented()) {
- // When embedder prevents the default action of actual key event, attribute
- // 'embeddedCancelled' of after event is false, i.e. |!targetIsIframe|.
- // On the contrary, if the defult action is prevented by embedded iframe,
- // 'embeddedCancelled' is true which equals to |!targetIsIframe|.
- DispatchAfterKeyboardEventInternal(chain, aEvent, !targetIsIframe, 0);
- return;
- }
-
- // Event listeners may kill nsPresContext and nsPresShell.
- if (targetIsIframe || !CanDispatchEvent()) {
- return;
- }
-
- // Dispatch after events to all items in the chain.
- DispatchAfterKeyboardEventInternal(chain, aEvent, aEvent.DefaultPrevented());
+ ForwardKeyToInputMethodAppOrDispatch(targetIsIframe, aTarget, aEvent,
+ aStatus, aEventCB);
}
#ifdef MOZ_B2G
bool
PresShell::ForwardKeyToInputMethodApp(nsINode* aTarget,
WidgetKeyboardEvent& aEvent,
nsEventStatus* aStatus)
{
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -411,20 +411,16 @@ public:
void EnsureFrameInApproximatelyVisibleList(nsIFrame* aFrame) override;
void RemoveFrameFromApproximatelyVisibleList(nsIFrame* aFrame) override;
bool AssumeAllFramesVisible() override;
virtual void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot) override;
- virtual void DispatchAfterKeyboardEvent(nsINode* aTarget,
- const mozilla::WidgetKeyboardEvent& aEvent,
- bool aEmbeddedCancelled) override;
-
virtual bool CanDispatchEvent(
const mozilla::WidgetGUIEvent* aEvent = nullptr) const override;
void SetNextPaintCompressed() { mNextPaintCompressed = true; }
protected:
virtual ~PresShell();
@@ -791,21 +787,16 @@ protected:
// Methods for dispatching KeyboardEvent and BeforeAfterKeyboardEvent.
//////////////////////////////////////////////////////////////////////////////
void HandleKeyboardEvent(nsINode* aTarget,
mozilla::WidgetKeyboardEvent& aEvent,
bool aEmbeddedCancelled,
nsEventStatus* aStatus,
mozilla::EventDispatchingCallback* aEventCB);
- void DispatchAfterKeyboardEventInternal(
- const nsTArray<nsCOMPtr<mozilla::dom::Element> >& aChain,
- const mozilla::WidgetKeyboardEvent& aEvent,
- bool aEmbeddedCancelled,
- size_t aChainIndex = 0);
#ifdef MOZ_B2G
// This method is used to forward the keyboard event to the input-method-app
// before the event is dispatched to its event target.
// Return true if it's successfully forwarded. Otherwise, return false.
bool ForwardKeyToInputMethodApp(nsINode* aTarget,
mozilla::WidgetKeyboardEvent& aEvent,
nsEventStatus* aStatus);
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -862,23 +862,16 @@ public:
* Dispatch event to content only (NOT full processing)
* @note The caller must have a strong reference to the PresShell.
*/
virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsIDOMEvent* aEvent,
nsEventStatus* aStatus) = 0;
/**
- * Dispatch AfterKeyboardEvent with specific target.
- */
- virtual void DispatchAfterKeyboardEvent(nsINode* aTarget,
- const mozilla::WidgetKeyboardEvent& aEvent,
- bool aEmbeddedCancelled) = 0;
-
- /**
* Return whether or not the event is valid to be dispatched
*/
virtual bool CanDispatchEvent(
const mozilla::WidgetGUIEvent* aEvent = nullptr) const = 0;
/**
* Gets the current target event frame from the PresShell
*/
--- a/widget/EventMessageList.h
+++ b/widget/EventMessageList.h
@@ -42,19 +42,16 @@ NS_EVENT_MESSAGE(eKeyDown)
// These messages are dispatched when PluginInstaceChild receives native
// keyboard events directly and it posts the information to the widget.
// These messages shouldn't be handled by content and non-reserved chrome
// event handlers.
NS_EVENT_MESSAGE(eKeyDownOnPlugin)
NS_EVENT_MESSAGE(eKeyUpOnPlugin)
-NS_EVENT_MESSAGE(eAfterKeyDown)
-NS_EVENT_MESSAGE(eAfterKeyUp)
-
// This message is sent after a content process handles a key event or accesskey
// to indicate that an potential accesskey was not found. The parent process may
// then respond by, for example, opening menus and processing other shortcuts.
// It inherits its properties from a keypress event.
NS_EVENT_MESSAGE(eAccessKeyNotFound)
NS_EVENT_MESSAGE(eResize)
NS_EVENT_MESSAGE(eScroll)
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -421,19 +421,16 @@ private:
};
/******************************************************************************
* mozilla::InternalBeforeAfterKeyboardEvent
*
* This is extended from WidgetKeyboardEvent and is mapped to DOM event
* "BeforeAfterKeyboardEvent".
- *
- * Event mMessage: eAfterKeyDown
- * eAfterKeyUp
******************************************************************************/
class InternalBeforeAfterKeyboardEvent : public WidgetKeyboardEvent
{
private:
friend class dom::PBrowserParent;
friend class dom::PBrowserChild;
InternalBeforeAfterKeyboardEvent()
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -272,18 +272,16 @@ bool
WidgetEvent::HasKeyEventMessage() const
{
switch (mMessage) {
case eKeyDown:
case eKeyPress:
case eKeyUp:
case eKeyDownOnPlugin:
case eKeyUpOnPlugin:
- case eAfterKeyDown:
- case eAfterKeyUp:
case eAccessKeyNotFound:
return true;
default:
return false;
}
}
bool