mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Backed out 6 changesets (bug 989198, bug 1082963) for causing bug 1083231.
Backed out changeset a7c972407578 (bug 1082963) Backed out changeset 94d1b30bde00 (bug 989198) Backed out changeset 01e064ceb505 (bug 989198) Backed out changeset f5a538109e36 (bug 989198) Backed out changeset 3ff227d79d74 (bug 989198) Backed out changeset 186743fc6f6d (bug 989198) CLOSED TREE
This commit is contained in:
parent
6ec44ff41f
commit
f00e2738a4
@ -788,9 +788,6 @@ pref("dom.ipc.systemMessageCPULockTimeoutSec", 30);
|
||||
// Ignore the "dialog=1" feature in window.open.
|
||||
pref("dom.disable_window_open_dialog_feature", true);
|
||||
|
||||
// Enable before keyboard events and after keyboard events.
|
||||
pref("dom.beforeAfterKeyboardEvent.enabled", true);
|
||||
|
||||
// Screen reader support
|
||||
pref("accessibility.accessfu.activate", 2);
|
||||
pref("accessibility.accessfu.quicknav_modes", "Link,Heading,FormElement,Landmark,ListItem");
|
||||
|
@ -324,8 +324,6 @@ var shell = {
|
||||
chromeEventHandler.addEventListener('keydown', this, true);
|
||||
chromeEventHandler.addEventListener('keypress', this, true);
|
||||
chromeEventHandler.addEventListener('keyup', this, true);
|
||||
chromeEventHandler.addEventListener('mozbrowserbeforekeydown', this, true);
|
||||
chromeEventHandler.addEventListener('mozbrowserbeforekeyup', this, true);
|
||||
|
||||
window.addEventListener('MozApplicationManifest', this);
|
||||
window.addEventListener('mozfullscreenchange', this);
|
||||
@ -358,8 +356,6 @@ var shell = {
|
||||
window.removeEventListener('keydown', this, true);
|
||||
window.removeEventListener('keypress', this, true);
|
||||
window.removeEventListener('keyup', this, true);
|
||||
window.removeEventListener('mozbrowserbeforekeydown', this, true);
|
||||
window.removeEventListener('mozbrowserbeforekeyup', this, true);
|
||||
window.removeEventListener('MozApplicationManifest', this);
|
||||
window.removeEventListener('mozfullscreenchange', this);
|
||||
window.removeEventListener('sizemodechange', this);
|
||||
@ -424,14 +420,17 @@ var shell = {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we didn't return, then the key event represents a hardware key
|
||||
// and we need to prevent it from propagating to Gaia
|
||||
evt.stopImmediatePropagation();
|
||||
evt.preventDefault(); // Prevent keypress events (when #501496 is fixed).
|
||||
|
||||
// If it is a key down or key up event, we send a chrome event to Gaia.
|
||||
// If it is a keypress event we just ignore it.
|
||||
switch (evt.type) {
|
||||
case 'mozbrowserbeforekeydown':
|
||||
case 'keydown':
|
||||
type = type + '-press';
|
||||
break;
|
||||
case 'mozbrowserbeforekeyup':
|
||||
case 'keyup':
|
||||
type = type + '-release';
|
||||
break;
|
||||
@ -474,8 +473,6 @@ var shell = {
|
||||
case 'keydown':
|
||||
case 'keyup':
|
||||
case 'keypress':
|
||||
case 'mozbrowserbeforekeydown':
|
||||
case 'mozbrowserbeforekeyup':
|
||||
this.filterHardwareKeys(evt);
|
||||
break;
|
||||
case 'mozfullscreenchange':
|
||||
|
@ -794,10 +794,6 @@ 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(onmozbrowserbeforekeydown, "onmozbrowserbeforekeydown")
|
||||
GK_ATOM(onmozbrowserbeforekeyup, "onmozbrowserbeforekeyup")
|
||||
GK_ATOM(onmozfullscreenchange, "onmozfullscreenchange")
|
||||
GK_ATOM(onmozfullscreenerror, "onmozfullscreenerror")
|
||||
GK_ATOM(onmozpointerlockchange, "onmozpointerlockchange")
|
||||
|
@ -493,12 +493,6 @@ this.PermissionsTable = { geolocation: {
|
||||
trusted: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
"before-after-keyboard-event": {
|
||||
app: DENY_ACTION,
|
||||
trusted: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,92 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/BeforeAfterKeyboardEvent.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "prtime.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
BeforeAfterKeyboardEvent::BeforeAfterKeyboardEvent(
|
||||
EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
InternalBeforeAfterKeyboardEvent* aEvent)
|
||||
: KeyboardEvent(aOwner, aPresContext,
|
||||
aEvent ? aEvent :
|
||||
new InternalBeforeAfterKeyboardEvent(false, 0,
|
||||
nullptr))
|
||||
{
|
||||
MOZ_ASSERT(mEvent->mClass == eBeforeAfterKeyboardEventClass,
|
||||
"event type mismatch eBeforeAfterKeyboardEventClass");
|
||||
|
||||
if (!aEvent) {
|
||||
mEventIsInternal = true;
|
||||
mEvent->time = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<BeforeAfterKeyboardEvent>
|
||||
BeforeAfterKeyboardEvent::Constructor(
|
||||
EventTarget* aOwner,
|
||||
const nsAString& aType,
|
||||
const BeforeAfterKeyboardEventInit& aParam)
|
||||
{
|
||||
nsRefPtr<BeforeAfterKeyboardEvent> event =
|
||||
new BeforeAfterKeyboardEvent(aOwner, nullptr, nullptr);
|
||||
ErrorResult rv;
|
||||
event->InitWithKeyboardEventInit(aOwner, aType, aParam, rv);
|
||||
NS_WARN_IF(rv.Failed());
|
||||
|
||||
event->mEvent->AsBeforeAfterKeyboardEvent()->mEmbeddedCancelled =
|
||||
aParam.mEmbeddedCancelled;
|
||||
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<BeforeAfterKeyboardEvent>
|
||||
BeforeAfterKeyboardEvent::Constructor(
|
||||
const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const BeforeAfterKeyboardEventInit& aParam,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
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;
|
||||
|
||||
nsresult
|
||||
NS_NewDOMBeforeAfterKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
InternalBeforeAfterKeyboardEvent* aEvent)
|
||||
{
|
||||
BeforeAfterKeyboardEvent* it =
|
||||
new BeforeAfterKeyboardEvent(aOwner, aPresContext, aEvent);
|
||||
|
||||
NS_ADDREF(it);
|
||||
*aInstancePtrResult = static_cast<Event*>(it);
|
||||
return NS_OK;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_BeforeAfterKeyboardEvent_h_
|
||||
#define mozilla_dom_BeforeAfterKeyboardEvent_h_
|
||||
|
||||
#include "mozilla/dom/KeyboardEvent.h"
|
||||
#include "mozilla/dom/BeforeAfterKeyboardEventBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class BeforeAfterKeyboardEvent : public KeyboardEvent
|
||||
{
|
||||
public:
|
||||
BeforeAfterKeyboardEvent(EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
InternalBeforeAfterKeyboardEvent* aEvent);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
|
||||
{
|
||||
return BeforeAfterKeyboardEventBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
static already_AddRefed<BeforeAfterKeyboardEvent>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
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
|
||||
|
||||
#endif // mozilla_dom_BeforeAfterKeyboardEvent_h_
|
@ -701,9 +701,6 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
|
||||
case eKeyboardEventClass:
|
||||
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext,
|
||||
aEvent->AsKeyboardEvent());
|
||||
case eBeforeAfterKeyboardEventClass:
|
||||
return NS_NewDOMBeforeAfterKeyboardEvent(aDOMEvent, aOwner, aPresContext,
|
||||
aEvent->AsBeforeAfterKeyboardEvent());
|
||||
case eCompositionEventClass:
|
||||
return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext,
|
||||
aEvent->AsCompositionEvent());
|
||||
|
@ -237,22 +237,6 @@ EVENT(keyup,
|
||||
NS_KEY_UP,
|
||||
EventNameType_HTMLXUL,
|
||||
eKeyboardEventClass)
|
||||
NON_IDL_EVENT(mozbrowserbeforekeydown,
|
||||
NS_KEY_BEFORE_DOWN,
|
||||
EventNameType_None,
|
||||
eBeforeAfterKeyboardEventClass)
|
||||
NON_IDL_EVENT(mozbrowserafterkeydown,
|
||||
NS_KEY_AFTER_DOWN,
|
||||
EventNameType_None,
|
||||
eBeforeAfterKeyboardEventClass)
|
||||
NON_IDL_EVENT(mozbrowserbeforekeyup,
|
||||
NS_KEY_BEFORE_UP,
|
||||
EventNameType_None,
|
||||
eBeforeAfterKeyboardEventClass)
|
||||
NON_IDL_EVENT(mozbrowserafterkeyup,
|
||||
NS_KEY_AFTER_UP,
|
||||
EventNameType_None,
|
||||
eBeforeAfterKeyboardEventClass)
|
||||
EVENT(loadeddata,
|
||||
NS_LOADEDDATA,
|
||||
EventNameType_HTML,
|
||||
|
@ -651,12 +651,8 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
// then fall through...
|
||||
case NS_KEY_BEFORE_DOWN:
|
||||
case NS_KEY_DOWN:
|
||||
case NS_KEY_AFTER_DOWN:
|
||||
case NS_KEY_BEFORE_UP:
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_AFTER_UP:
|
||||
{
|
||||
nsIContent* content = GetFocusedContent();
|
||||
if (content)
|
||||
@ -3167,9 +3163,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
|
||||
GenerateDragDropEnterExit(presContext, aEvent->AsDragEvent());
|
||||
break;
|
||||
|
||||
case NS_KEY_BEFORE_UP:
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_AFTER_UP:
|
||||
break;
|
||||
|
||||
case NS_KEY_PRESS:
|
||||
|
@ -17,8 +17,10 @@ KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
|
||||
: UIEvent(aOwner, aPresContext,
|
||||
aEvent ? aEvent : new WidgetKeyboardEvent(false, 0, nullptr))
|
||||
, mInitializedByCtor(false)
|
||||
, mInitializedWhichValue(0)
|
||||
, mInitialzedWhichValue(0)
|
||||
{
|
||||
NS_ASSERTION(mEvent->mClass == eKeyboardEventClass, "event type mismatch");
|
||||
|
||||
if (aEvent) {
|
||||
mEventIsInternal = false;
|
||||
}
|
||||
@ -255,12 +257,8 @@ KeyboardEvent::CharCode()
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_KEY_BEFORE_DOWN:
|
||||
case NS_KEY_DOWN:
|
||||
case NS_KEY_AFTER_DOWN:
|
||||
case NS_KEY_BEFORE_UP:
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_AFTER_UP:
|
||||
case NS_KEY_DOWN:
|
||||
return 0;
|
||||
case NS_KEY_PRESS:
|
||||
return mEvent->AsKeyboardEvent()->charCode;
|
||||
@ -284,7 +282,10 @@ KeyboardEvent::KeyCode()
|
||||
return mEvent->AsKeyboardEvent()->keyCode;
|
||||
}
|
||||
|
||||
if (mEvent->HasKeyEventMessage()) {
|
||||
switch (mEvent->message) {
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_PRESS:
|
||||
case NS_KEY_DOWN:
|
||||
return mEvent->AsKeyboardEvent()->keyCode;
|
||||
}
|
||||
return 0;
|
||||
@ -295,16 +296,12 @@ KeyboardEvent::Which()
|
||||
{
|
||||
// If this event is initialized with ctor, which can have independent value.
|
||||
if (mInitializedByCtor) {
|
||||
return mInitializedWhichValue;
|
||||
return mInitialzedWhichValue;
|
||||
}
|
||||
|
||||
switch (mEvent->message) {
|
||||
case NS_KEY_BEFORE_DOWN:
|
||||
case NS_KEY_DOWN:
|
||||
case NS_KEY_AFTER_DOWN:
|
||||
case NS_KEY_BEFORE_UP:
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_AFTER_UP:
|
||||
case NS_KEY_DOWN:
|
||||
return KeyCode();
|
||||
case NS_KEY_PRESS:
|
||||
//Special case for 4xp bug 62878. Try to make value of which
|
||||
@ -346,35 +343,26 @@ KeyboardEvent::Constructor(const GlobalObject& aGlobal,
|
||||
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<KeyboardEvent> newEvent =
|
||||
new KeyboardEvent(target, nullptr, nullptr);
|
||||
newEvent->InitWithKeyboardEventInit(target, aType, aParam, aRv);
|
||||
bool trusted = newEvent->Init(target);
|
||||
aRv = newEvent->InitKeyEvent(aType, aParam.mBubbles, aParam.mCancelable,
|
||||
aParam.mView, aParam.mCtrlKey, aParam.mAltKey,
|
||||
aParam.mShiftKey, aParam.mMetaKey,
|
||||
aParam.mKeyCode, aParam.mCharCode);
|
||||
newEvent->SetTrusted(trusted);
|
||||
newEvent->mDetail = aParam.mDetail;
|
||||
newEvent->mInitializedByCtor = true;
|
||||
newEvent->mInitialzedWhichValue = aParam.mWhich;
|
||||
|
||||
return newEvent.forget();
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardEvent::InitWithKeyboardEventInit(EventTarget* aOwner,
|
||||
const nsAString& aType,
|
||||
const KeyboardEventInit& aParam,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
bool trusted = Init(aOwner);
|
||||
aRv = InitKeyEvent(aType, aParam.mBubbles, aParam.mCancelable,
|
||||
aParam.mView, aParam.mCtrlKey, aParam.mAltKey,
|
||||
aParam.mShiftKey, aParam.mMetaKey,
|
||||
aParam.mKeyCode, aParam.mCharCode);
|
||||
SetTrusted(trusted);
|
||||
mDetail = aParam.mDetail;
|
||||
mInitializedByCtor = true;
|
||||
mInitializedWhichValue = aParam.mWhich;
|
||||
|
||||
WidgetKeyboardEvent* internalEvent = mEvent->AsKeyboardEvent();
|
||||
WidgetKeyboardEvent* internalEvent = newEvent->mEvent->AsKeyboardEvent();
|
||||
internalEvent->location = aParam.mLocation;
|
||||
internalEvent->mIsRepeat = aParam.mRepeat;
|
||||
internalEvent->mIsComposing = aParam.mIsComposing;
|
||||
internalEvent->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
|
||||
internalEvent->mCodeNameIndex = CODE_NAME_INDEX_USE_STRING;
|
||||
internalEvent->mKeyValue = aParam.mKey;
|
||||
internalEvent->mCodeNameIndex = CODE_NAME_INDEX_USE_STRING;
|
||||
internalEvent->mCodeValue = aParam.mCode;
|
||||
|
||||
return newEvent.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -74,19 +74,13 @@ public:
|
||||
protected:
|
||||
~KeyboardEvent() {}
|
||||
|
||||
void InitWithKeyboardEventInit(EventTarget* aOwner,
|
||||
const nsAString& aType,
|
||||
const KeyboardEventInit& aParam,
|
||||
ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
// True, if the instance is created with Constructor().
|
||||
bool mInitializedByCtor;
|
||||
|
||||
// If the instance is created with Constructor(), which may have independent
|
||||
// value. mInitializedWhichValue stores it. I.e., this is invalid when
|
||||
// mInitializedByCtor is false.
|
||||
uint32_t mInitializedWhichValue;
|
||||
uint32_t mInitialzedWhichValue;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -32,7 +32,6 @@ EXPORTS.mozilla += [
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'AnimationEvent.h',
|
||||
'BeforeAfterKeyboardEvent.h',
|
||||
'BeforeUnloadEvent.h',
|
||||
'ClipboardEvent.h',
|
||||
'CommandEvent.h',
|
||||
@ -72,7 +71,6 @@ if CONFIG['MOZ_WEBSPEECH']:
|
||||
UNIFIED_SOURCES += [
|
||||
'AnimationEvent.cpp',
|
||||
'AsyncEventDispatcher.cpp',
|
||||
'BeforeAfterKeyboardEvent.cpp',
|
||||
'BeforeUnloadEvent.cpp',
|
||||
'ClipboardEvent.cpp',
|
||||
'CommandEvent.cpp',
|
||||
|
@ -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>
|
@ -1,200 +0,0 @@
|
||||
/*
|
||||
* Constants and helper functions for testing BeforeAfterKeyboardEvent.
|
||||
*/
|
||||
|
||||
const kUnknownEvent = 0x000;
|
||||
const kKeyDownEvent = 0x001;
|
||||
const kKeyUpEvent = 0x002;
|
||||
const kBeforeEvent = 0x010;
|
||||
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('mozbrowserbeforekeydown', handler);
|
||||
addEventListener('mozbrowserbeforekeyup', handler);
|
||||
addEventListener('mozbrowserafterkeydown', handler);
|
||||
addEventListener('mozbrowserafterkeyup', handler);
|
||||
}
|
||||
|
||||
function prepareTest(useRemote)
|
||||
{
|
||||
setupHandlers(window, embedderHandler);
|
||||
|
||||
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 cleanupTest()
|
||||
{
|
||||
teardownHandlers(window, embedderHandler);
|
||||
runTests();
|
||||
}
|
||||
|
||||
function setupHandlers(element, handler)
|
||||
{
|
||||
element.addEventListener('keydown', handler);
|
||||
element.addEventListener('keyup', handler);
|
||||
element.addEventListener('mozbrowserbeforekeydown', handler);
|
||||
element.addEventListener('mozbrowserbeforekeyup', handler);
|
||||
element.addEventListener('mozbrowserafterkeydown', handler);
|
||||
element.addEventListener('mozbrowserafterkeyup', handler);
|
||||
}
|
||||
|
||||
function teardownHandlers(element, handler)
|
||||
{
|
||||
element.removeEventListener('keydown', handler);
|
||||
element.removeEventListener('keyup', handler);
|
||||
element.removeEventListener('mozbrowserbeforekeydown', handler);
|
||||
element.removeEventListener('mozbrowserbeforekeyup', handler);
|
||||
element.removeEventListener('mozbrowserafterkeydown', handler);
|
||||
element.removeEventListener('mozbrowserafterkeyup', handler);
|
||||
}
|
||||
|
||||
function convertNameToCode(name)
|
||||
{
|
||||
switch (name) {
|
||||
case "mozbrowserbeforekeydown":
|
||||
return kBeforeEvent | kKeyDownEvent;
|
||||
case "mozbrowserafterkeydown":
|
||||
return kAfterEvent | kKeyDownEvent;
|
||||
case "mozbrowserbeforekeyup":
|
||||
return kBeforeEvent | kKeyUpEvent;
|
||||
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)
|
||||
{
|
||||
// Verify value of attribute embeddedCancelled
|
||||
handler(e, kParent, function checkEmbeddedCancelled(code){
|
||||
switch (code) {
|
||||
case kBeforeEvent | kKeyDownEvent:
|
||||
case kBeforeEvent | kKeyUpEvent:
|
||||
is(e.embeddedCancelled, null,
|
||||
gCurrentTest.description + ': embeddedCancelled should be null');
|
||||
break;
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handler(e, highBit, callback)
|
||||
{
|
||||
var code = convertNameToCode(e.type);
|
||||
var newCode = highBit | code;
|
||||
gCurrentTest.resultEvents.push(newCode);
|
||||
|
||||
if (callback) {
|
||||
callback(code);
|
||||
}
|
||||
|
||||
// Return and let frameScript to handle
|
||||
if (highBit == kChild) {
|
||||
return newCode == gCurrentTest.doPreventDefaultAt;
|
||||
}
|
||||
|
||||
if (newCode == gCurrentTest.doPreventDefaultAt) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function runTests()
|
||||
{
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
test();
|
||||
}
|
@ -167,12 +167,3 @@ skip-if = buildapp == 'mulet'
|
||||
[test_onerror_handler_args.html]
|
||||
[test_wheel_default_action.html]
|
||||
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || e10s
|
||||
[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 = buildapp == 'b2g' || e10s
|
||||
|
@ -34,10 +34,6 @@ const kEventConstructors = {
|
||||
},
|
||||
AudioProcessingEvent: { create: null, // Cannot create untrusted event from JS.
|
||||
},
|
||||
BeforeAfterKeyboardEvent: { create: function (aName, aProps) {
|
||||
return new BeforeAfterKeyboardEvent(aName, aProps);
|
||||
},
|
||||
},
|
||||
BeforeUnloadEvent: { create: function (aName, aProps) {
|
||||
var e = document.createEvent("beforeunloadevent");
|
||||
e.initEvent(aName, aProps.bubbles, aProps.cancelable);
|
||||
|
@ -1,117 +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 testEventOrderAndAttr()
|
||||
{
|
||||
const mainDesc = 'Testing the order of the events';
|
||||
const kTests = [
|
||||
{
|
||||
description: mainDesc,
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kUnknownEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "mozbrowserbeforekeydown" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kParent | kBeforeEvent | kKeyDownEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "mozbrowserbeforekeyup" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kParent | kBeforeEvent | kKeyUpEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "keydown" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kChild | kKeyDownEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "keyup" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
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],
|
||||
["dom.ipc.tabs.disabled", false]] },
|
||||
runTests);
|
||||
},
|
||||
|
||||
// Tests for in-process iframe, i.e. <iframe mozbrowser>.
|
||||
()=>prepareTest(false),
|
||||
testEventOrderAndAttr,
|
||||
cleanupTest,
|
||||
];
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,142 +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();
|
||||
|
||||
const mainDesc = 'Testing the order of the events (OOP)';
|
||||
var testsForEventOrder = [
|
||||
{
|
||||
description: mainDesc,
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kParent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kParent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kUnknownEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "mozbrowserbeforekeydown" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kParent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kParent | kBeforeEvent | kKeyDownEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "mozbrowserbeforekeyup" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kParent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kParent | kBeforeEvent | kKeyUpEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "keydown" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kParent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kParent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kChild | kKeyDownEvent
|
||||
},
|
||||
{
|
||||
description: mainDesc + ', calling preventDefault() at "keyup" event',
|
||||
expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
|
||||
kParent | kKeyDownEvent,
|
||||
kChild | kKeyDownEvent,
|
||||
kParent | kAfterEvent | kKeyDownEvent ],
|
||||
[ kParent | kBeforeEvent | kKeyUpEvent,
|
||||
kParent | kKeyUpEvent,
|
||||
kChild | kKeyUpEvent,
|
||||
kParent | kAfterEvent | kKeyUpEvent ] ],
|
||||
resultEvents: [],
|
||||
classifiedEvents: [ [], [] ],
|
||||
doPreventDefaultAt: kChild | kKeyUpEvent
|
||||
}
|
||||
];
|
||||
|
||||
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(count) {
|
||||
expectedEventLength = gCurrentTest.expectedEvents[0].length +
|
||||
gCurrentTest.expectedEvents[1].length;
|
||||
if (gCurrentTest.resultEvents.length >= expectedEventLength || count > 10) {
|
||||
classifyEvents(gCurrentTest);
|
||||
verifyResults(gCurrentTest);
|
||||
testEventOrder();
|
||||
}
|
||||
else {
|
||||
setTimeout(()=>waitAndVerifyResult(count + 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],
|
||||
["dom.ipc.tabs.disabled", false]] },
|
||||
runTests);
|
||||
},
|
||||
|
||||
// Tests for out-of-process iframe, i.el. <iframe mozbrowser remote>
|
||||
()=>prepareTest(true),
|
||||
testEventOrder,
|
||||
cleanupTest
|
||||
];
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -272,13 +272,6 @@ NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
mozilla::WidgetKeyboardEvent* aEvent);
|
||||
|
||||
nsresult
|
||||
NS_NewDOMBeforeAfterKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
mozilla::InternalBeforeAfterKeyboardEvent* aEvent);
|
||||
|
||||
nsresult
|
||||
NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult,
|
||||
mozilla::dom::EventTarget* aOwner,
|
||||
|
@ -398,8 +398,6 @@ parent:
|
||||
|
||||
ReplyKeyEvent(WidgetKeyboardEvent event);
|
||||
|
||||
DispatchAfterKeyboardEvent(WidgetKeyboardEvent event);
|
||||
|
||||
sync RequestNativeKeyBindings(WidgetKeyboardEvent event)
|
||||
returns (MaybeNativeKeyBinding bindings);
|
||||
|
||||
|
@ -81,8 +81,8 @@
|
||||
#include "ClientLayerManager.h"
|
||||
#include "LayersLogging.h"
|
||||
#include "nsIOService.h"
|
||||
|
||||
#include "nsColorPickerProxy.h"
|
||||
#include "nsPresShell.h"
|
||||
|
||||
#define BROWSER_ELEMENT_CHILD_SCRIPT \
|
||||
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
|
||||
@ -2362,10 +2362,6 @@ TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event,
|
||||
SendReplyKeyEvent(localEvent);
|
||||
}
|
||||
|
||||
if (PresShell::BeforeAfterKeyboardEventEnabled()) {
|
||||
SendDispatchAfterKeyboardEvent(localEvent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPIWindowWatcher.h"
|
||||
#include "nsPresShell.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
@ -1464,29 +1463,6 @@ TabParent::RecvReplyKeyEvent(const WidgetKeyboardEvent& event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& aEvent)
|
||||
{
|
||||
NS_ENSURE_TRUE(mFrameElement, true);
|
||||
|
||||
WidgetKeyboardEvent localEvent(aEvent);
|
||||
localEvent.widget = GetWidget();
|
||||
|
||||
nsIDocument* doc = mFrameElement->OwnerDoc();
|
||||
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
|
||||
NS_ENSURE_TRUE(presShell, true);
|
||||
|
||||
if (mFrameElement &&
|
||||
PresShell::BeforeAfterKeyboardEventEnabled() &&
|
||||
localEvent.message != NS_KEY_PRESS) {
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(mFrameElement));
|
||||
presShell->DispatchAfterKeyboardEvent(mFrameElement, localEvent,
|
||||
aEvent.mFlags.mDefaultPrevented);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to answer query event using cached text.
|
||||
*
|
||||
|
@ -122,7 +122,6 @@ public:
|
||||
virtual bool RecvMoveFocus(const bool& aForward) MOZ_OVERRIDE;
|
||||
virtual bool RecvEvent(const RemoteDOMEvent& aEvent) MOZ_OVERRIDE;
|
||||
virtual bool RecvReplyKeyEvent(const WidgetKeyboardEvent& event);
|
||||
virtual bool RecvDispatchAfterKeyboardEvent(const WidgetKeyboardEvent& event);
|
||||
virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* aActor,
|
||||
ScrollingBehavior* aScrolling,
|
||||
TextureFactoryIdentifier* aFactoryIdentifier,
|
||||
|
@ -171,10 +171,6 @@ var interfaceNamesInGlobalScope =
|
||||
"BarProp",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"BatteryManager",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BeforeAfterKeyboardEvent", b2g: true,
|
||||
pref: "dom.beforeAfterKeyboardEvent.enabled",
|
||||
permission: ["embed-apps", "before-after-keyboard-event"]},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"BeforeUnloadEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
@ -184,18 +180,18 @@ var interfaceNamesInGlobalScope =
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"BlobEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BluetoothAdapter", b2g: true, permission: ["bluetooth"]},
|
||||
{name: "BluetoothAdapter", b2g: true, permission: "bluetooth"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BluetoothDevice", b2g: true, permission: ["bluetooth"]},
|
||||
{name: "BluetoothDevice", b2g: true, permission: "bluetooth"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BluetoothDeviceEvent", b2g: true, permission: ["bluetooth"]},
|
||||
{name: "BluetoothDeviceEvent", b2g: true, permission: "bluetooth"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BluetoothDiscoveryStateChangedEvent", b2g: true,
|
||||
permission: ["bluetooth"]},
|
||||
permission: "bluetooth"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BluetoothManager", b2g: true, permission: ["bluetooth"]},
|
||||
{name: "BluetoothManager", b2g: true, permission: "bluetooth"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BluetoothStatusChangedEvent", b2g: true, permission: ["bluetooth"]},
|
||||
{name: "BluetoothStatusChangedEvent", b2g: true, permission: "bluetooth"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "BoxObject", xbl: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
@ -757,7 +753,7 @@ var interfaceNamesInGlobalScope =
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"MozSettingsEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozSettingsTransactionEvent", permission: ["settings-api-read"]},
|
||||
{name: "MozSettingsTransactionEvent", permission: "settings-api-read"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"MozSmsEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
@ -777,23 +773,23 @@ var interfaceNamesInGlobalScope =
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWakeLock", b2g: true, pref: "dom.wakelock.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiCapabilities", b2g: true, permission: ["wifi-manage"]},
|
||||
{name: "MozWifiCapabilities", b2g: true, permission: "wifi-manage"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiConnectionInfoEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiStationInfoEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiManager", b2g: true, permission: ["wifi-manage"]},
|
||||
{name: "MozWifiManager", b2g: true, permission: "wifi-manage"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiNetwork", b2g: true, permission: ["wifi-manage"]},
|
||||
{name: "MozWifiNetwork", b2g: true, permission: "wifi-manage"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiStatusChangeEvent", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiP2pGroupOwner", b2g: true, permission: ["wifi-manage"]},
|
||||
{name: "MozWifiP2pGroupOwner", b2g: true, permission: "wifi-manage"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiP2pManager", b2g: true, permission: ["wifi-manage"]},
|
||||
{name: "MozWifiP2pManager", b2g: true, permission: "wifi-manage"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozWifiP2pStatusChangeEvent", b2g: true, permission: ["wifi-manage"]},
|
||||
{name: "MozWifiP2pStatusChangeEvent", b2g: true, permission: "wifi-manage"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"MutationEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
@ -851,9 +847,9 @@ var interfaceNamesInGlobalScope =
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"PeriodicWave",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "PermissionSettings", b2g: true, permission: ["permissions"]},
|
||||
{name: "PermissionSettings", b2g: true, permission: "permissions"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "PhoneNumberService", permission: ["phonenumberservice"]},
|
||||
{name: "PhoneNumberService", permission: "phonenumberservice"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"Plugin",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
@ -1235,11 +1231,9 @@ var interfaceNamesInGlobalScope =
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"TreeWalker",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "UDPMessageEvent", pref: "dom.udpsocket.enabled",
|
||||
permission: ["udp-socket"]},
|
||||
{name: "UDPMessageEvent", pref: "dom.udpsocket.enabled", permission: "udp-socket"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "UDPSocket", pref: "dom.udpsocket.enabled",
|
||||
permission: ["udp-socket"]},
|
||||
{name: "UDPSocket", pref: "dom.udpsocket.enabled", permission: "udp-socket"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"UIEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
@ -1349,12 +1343,8 @@ function createInterfaceMap(isXBLScope) {
|
||||
var isRelease = !version.contains("a");
|
||||
var isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
|
||||
var isB2G = !isDesktop && !navigator.userAgent.contains("Android");
|
||||
var hasPermission = function (aPermissions) {
|
||||
var result = false;
|
||||
for (var p of aPermissions) {
|
||||
result = result || SpecialPowers.hasPermission(p, window.document);
|
||||
}
|
||||
return result;
|
||||
var hasPermission = function (aPermission) {
|
||||
return SpecialPowers.hasPermission(aPermission, window.document);
|
||||
};
|
||||
|
||||
var interfaceMap = {};
|
||||
|
@ -1,24 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Constructor(DOMString typeArg,
|
||||
optional BeforeAfterKeyboardEventInit eventInitDict),
|
||||
CheckPermissions="embed-apps before-after-keyboard-event",
|
||||
Pref="dom.beforeAfterKeyboardEvent.enabled"]
|
||||
interface BeforeAfterKeyboardEvent : KeyboardEvent
|
||||
{
|
||||
// The valid value of embeddedCancelled is:
|
||||
// - "mozbrowserbeforekeydown": null
|
||||
// - "mozbrowserbeforekeyup": null
|
||||
// - "mozbrowserafterkeydown": true/false
|
||||
// - "mozbrowserafterkeyup": true/false
|
||||
readonly attribute boolean? embeddedCancelled;
|
||||
};
|
||||
|
||||
dictionary BeforeAfterKeyboardEventInit : KeyboardEventInit
|
||||
{
|
||||
boolean? embeddedCancelled = null;
|
||||
};
|
@ -49,7 +49,6 @@ WEBIDL_FILES = [
|
||||
'AutocompleteInfo.webidl',
|
||||
'BarProp.webidl',
|
||||
'BatteryManager.webidl',
|
||||
'BeforeAfterKeyboardEvent.webidl',
|
||||
'BeforeUnloadEvent.webidl',
|
||||
'BiquadFilterNode.webidl',
|
||||
'Blob.webidl',
|
||||
|
@ -78,7 +78,6 @@ class nsDisplayList;
|
||||
class nsDisplayListBuilder;
|
||||
class nsPIDOMWindow;
|
||||
struct nsPoint;
|
||||
class nsINode;
|
||||
struct nsIntPoint;
|
||||
struct nsIntRect;
|
||||
struct nsRect;
|
||||
@ -140,8 +139,8 @@ typedef struct CapturingContentInfo {
|
||||
} CapturingContentInfo;
|
||||
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xa0a4b515, 0x0b91, 0x4f13, \
|
||||
{ 0xa0, 0x60, 0x4b, 0xfb, 0x35, 0x00, 0xdc, 0x00 } }
|
||||
{ 0x42e9a352, 0x76f3, 0x4ba3, \
|
||||
{ 0x94, 0x0b, 0x78, 0x9e, 0x58, 0x38, 0x73, 0x4f } }
|
||||
|
||||
// debug VerifyReflow flags
|
||||
#define VERIFY_REFLOW_ON 0x01
|
||||
@ -856,13 +855,6 @@ public:
|
||||
nsIDOMEvent* aEvent,
|
||||
nsEventStatus* aStatus) = 0;
|
||||
|
||||
/**
|
||||
* Dispatch AfterKeyboardEvent with specific target.
|
||||
*/
|
||||
virtual void DispatchAfterKeyboardEvent(nsINode* aTarget,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
bool aEmbeddedCancelled) = 0;
|
||||
|
||||
/**
|
||||
* Gets the current target event frame from the PresShell
|
||||
*/
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "nsPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsIContent.h"
|
||||
#include "mozilla/dom/BeforeAfterKeyboardEvent.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Event.h" // for Event::GetEventPopupControlState()
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
@ -73,8 +72,6 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPageSequenceFrame.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsCaret.h"
|
||||
#include "TouchCaret.h"
|
||||
#include "SelectionCarets.h"
|
||||
@ -84,7 +81,6 @@
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsILineIterator.h" // for ScrollContentIntoView
|
||||
#include "pldhash.h"
|
||||
#include "mozilla/dom/BeforeAfterKeyboardEventBinding.h"
|
||||
#include "mozilla/dom/Touch.h"
|
||||
#include "mozilla/dom/PointerEventBinding.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -709,7 +705,6 @@ static uint32_t sNextPresShellId;
|
||||
static bool sPointerEventEnabled = true;
|
||||
static bool sTouchCaretEnabled = false;
|
||||
static bool sSelectionCaretEnabled = false;
|
||||
static bool sBeforeAfterKeyboardEventEnabled = false;
|
||||
|
||||
/* static */ bool
|
||||
PresShell::TouchCaretPrefEnabled()
|
||||
@ -733,18 +728,6 @@ PresShell::SelectionCaretPrefEnabled()
|
||||
return sSelectionCaretEnabled;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
PresShell::BeforeAfterKeyboardEventEnabled()
|
||||
{
|
||||
static bool sInitialized = false;
|
||||
if (!sInitialized) {
|
||||
Preferences::AddBoolVarCache(&sBeforeAfterKeyboardEventEnabled,
|
||||
"dom.beforeAfterKeyboardEvent.enabled");
|
||||
sInitialized = true;
|
||||
}
|
||||
return sBeforeAfterKeyboardEventEnabled;
|
||||
}
|
||||
|
||||
PresShell::PresShell()
|
||||
: mMouseLocation(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE)
|
||||
{
|
||||
@ -6879,236 +6862,6 @@ private:
|
||||
nsCOMPtr<nsIContent> mContent;
|
||||
};
|
||||
|
||||
static bool
|
||||
CheckPermissionForBeforeAfterKeyboardEvent(Element* aElement)
|
||||
{
|
||||
// An element which is chrome-privileged should be able to handle before
|
||||
// events and after events.
|
||||
nsIPrincipal* principal = aElement->NodePrincipal();
|
||||
if (nsContentUtils::IsSystemPrincipal(principal)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// An element which has "before-after-keyboard-event" permission should be
|
||||
// able to handle before events and after events.
|
||||
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
if (permMgr) {
|
||||
permMgr->TestPermissionFromPrincipal(principal, "before-after-keyboard-event", &permission);
|
||||
if (permission == nsIPermissionManager::ALLOW_ACTION) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check "embed-apps" permission for later use.
|
||||
permission = nsIPermissionManager::DENY_ACTION;
|
||||
permMgr->TestPermissionFromPrincipal(principal, "embed-apps", &permission);
|
||||
}
|
||||
|
||||
// An element can handle before events and after events if the following
|
||||
// conditions are met:
|
||||
// 1) <iframe mozbrowser mozapp>
|
||||
// 2) it has "embed-apps" permission.
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame(do_QueryInterface(aElement));
|
||||
if ((permission == nsIPermissionManager::ALLOW_ACTION) &&
|
||||
browserFrame && browserFrame->GetReallyIsApp()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
BuildTargetChainForBeforeAfterKeyboardEvent(nsINode* aTarget,
|
||||
nsTArray<nsCOMPtr<Element> >& aChain,
|
||||
bool& aTargetIsIframe)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aTarget));
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
Element* frameElement;
|
||||
|
||||
// Initialize frameElement.
|
||||
if (content && content->IsHTML(nsGkAtoms::iframe)) {
|
||||
aTargetIsIframe = true;
|
||||
frameElement = aTarget->AsElement();
|
||||
} else {
|
||||
// If event target is not an iframe, dispatch keydown/keyup event to its
|
||||
// window after dispatching before events to its ancestors.
|
||||
aTargetIsIframe = false;
|
||||
|
||||
// And skip the event target and get its parent frame.
|
||||
window = aTarget->OwnerDoc()->GetWindow();
|
||||
if (window) {
|
||||
frameElement = window->GetFrameElementInternal();
|
||||
}
|
||||
}
|
||||
|
||||
// Check permission for all ancestors and add them into the target chain.
|
||||
while (frameElement) {
|
||||
if (CheckPermissionForBeforeAfterKeyboardEvent(frameElement)) {
|
||||
aChain.AppendElement(frameElement);
|
||||
}
|
||||
window = frameElement->OwnerDoc()->GetWindow();
|
||||
frameElement = window ? window->GetFrameElementInternal() : nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::DispatchBeforeKeyboardEventInternal(const nsTArray<nsCOMPtr<Element> >& aChain,
|
||||
const WidgetKeyboardEvent& aEvent,
|
||||
size_t& aChainIndex,
|
||||
bool& aDefaultPrevented)
|
||||
{
|
||||
size_t length = aChain.Length();
|
||||
if (!CanDispatchEvent(&aEvent) || !length) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t message =
|
||||
(aEvent.message == NS_KEY_DOWN) ? NS_KEY_BEFORE_DOWN : NS_KEY_BEFORE_UP;
|
||||
nsCOMPtr<EventTarget> eventTarget;
|
||||
// Dispatch before events from the outermost element.
|
||||
for (int32_t i = length - 1; i >= 0; i--) {
|
||||
eventTarget = do_QueryInterface(aChain[i]->OwnerDoc()->GetWindow());
|
||||
if (!eventTarget || !CanDispatchEvent(&aEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
aChainIndex = i;
|
||||
InternalBeforeAfterKeyboardEvent beforeEvent(aEvent.mFlags.mIsTrusted,
|
||||
message, aEvent.widget);
|
||||
beforeEvent.AssignBeforeAfterKeyEventData(aEvent, false);
|
||||
EventDispatcher::Dispatch(eventTarget, mPresContext, &beforeEvent);
|
||||
|
||||
if (beforeEvent.mFlags.mDefaultPrevented) {
|
||||
aDefaultPrevented = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
uint32_t message =
|
||||
(aEvent.message == NS_KEY_DOWN) ? NS_KEY_AFTER_DOWN : NS_KEY_AFTER_UP;
|
||||
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.mFlags.mIsTrusted,
|
||||
message, aEvent.widget);
|
||||
afterEvent.AssignBeforeAfterKeyEventData(aEvent, false);
|
||||
afterEvent.mEmbeddedCancelled.SetValue(embeddedCancelled);
|
||||
EventDispatcher::Dispatch(eventTarget, mPresContext, &afterEvent);
|
||||
embeddedCancelled = afterEvent.mFlags.mDefaultPrevented;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::DispatchAfterKeyboardEvent(nsINode* aTarget,
|
||||
const WidgetKeyboardEvent& aEvent,
|
||||
bool aEmbeddedCancelled)
|
||||
{
|
||||
MOZ_ASSERT(aTarget);
|
||||
MOZ_ASSERT(BeforeAfterKeyboardEventEnabled());
|
||||
|
||||
if (NS_WARN_IF(aEvent.message != NS_KEY_DOWN &&
|
||||
aEvent.message != NS_KEY_UP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Build up a target chain. Each item in the chain will receive an after event.
|
||||
nsAutoTArray<nsCOMPtr<Element>, 5> chain;
|
||||
bool targetIsIframe = false;
|
||||
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->widget && !aEvent->widget->Destroyed());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
PresShell::HandleKeyboardEvent(nsINode* aTarget,
|
||||
WidgetKeyboardEvent& aEvent,
|
||||
bool aEmbeddedCancelled,
|
||||
nsEventStatus* aStatus,
|
||||
EventDispatchingCallback* aEventCB)
|
||||
{
|
||||
if (aEvent.message == NS_KEY_PRESS ||
|
||||
!BeforeAfterKeyboardEventEnabled()) {
|
||||
EventDispatcher::Dispatch(aTarget, mPresContext,
|
||||
&aEvent, nullptr, aStatus, aEventCB);
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aTarget);
|
||||
MOZ_ASSERT(aEvent.message == NS_KEY_DOWN || aEvent.message == NS_KEY_UP);
|
||||
|
||||
// Build up a target chain. Each item in the chain will receive a before event.
|
||||
nsAutoTArray<nsCOMPtr<Element>, 5> chain;
|
||||
bool targetIsIframe = false;
|
||||
BuildTargetChainForBeforeAfterKeyboardEvent(aTarget, chain, targetIsIframe);
|
||||
|
||||
// Dispatch before events. If each item in the chain consumes the before
|
||||
// event and doesn't prevent the default action, we will go further to
|
||||
// dispatch the actual key event and after events in the reverse order.
|
||||
// Otherwise, only items which has handled the before event will receive an
|
||||
// after event.
|
||||
size_t chainIndex;
|
||||
bool defaultPrevented = false;
|
||||
DispatchBeforeKeyboardEventInternal(chain, aEvent, chainIndex,
|
||||
defaultPrevented);
|
||||
|
||||
// Dispatch after events to partial items.
|
||||
if (defaultPrevented) {
|
||||
DispatchAfterKeyboardEventInternal(chain, aEvent,
|
||||
aEvent.mFlags.mDefaultPrevented, chainIndex);
|
||||
|
||||
// No need to forward the event to child process.
|
||||
aEvent.mFlags.mNoCrossProcessBoundaryForwarding = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Event listeners may kill nsPresContext and nsPresShell.
|
||||
if (!CanDispatchEvent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispatch actual key event to event target.
|
||||
EventDispatcher::Dispatch(aTarget, mPresContext,
|
||||
&aEvent, nullptr, aStatus, aEventCB);
|
||||
|
||||
// Event listeners may kill nsPresContext and nsPresShell.
|
||||
if (targetIsIframe || !CanDispatchEvent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispatch after events to all items in the chain.
|
||||
DispatchAfterKeyboardEventInternal(chain, aEvent,
|
||||
aEvent.mFlags.mDefaultPrevented);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::HandleEvent(nsIFrame* aFrame,
|
||||
WidgetGUIEvent* aEvent,
|
||||
@ -8113,9 +7866,6 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus)
|
||||
IMEStateManager::DispatchCompositionEvent(eventTarget,
|
||||
mPresContext, aEvent->AsCompositionEvent(), aStatus,
|
||||
eventCBPtr);
|
||||
} else if (aEvent->mClass == eKeyboardEventClass) {
|
||||
HandleKeyboardEvent(eventTarget, *(aEvent->AsKeyboardEvent()),
|
||||
false, aStatus, eventCBPtr);
|
||||
} else {
|
||||
EventDispatcher::Dispatch(eventTarget, mPresContext,
|
||||
aEvent, nullptr, aStatus, eventCBPtr);
|
||||
|
@ -50,7 +50,6 @@ class nsAutoCauseReflowNotifier;
|
||||
|
||||
namespace mozilla {
|
||||
class CSSStyleSheet;
|
||||
class EventDispatchingCallback;
|
||||
} // namespace mozilla
|
||||
|
||||
// 250ms. This is actually pref-controlled, but we use this value if we fail
|
||||
@ -76,9 +75,6 @@ public:
|
||||
// Selection caret preference
|
||||
static bool SelectionCaretPrefEnabled();
|
||||
|
||||
// BeforeAfterKeyboardEvent preference
|
||||
static bool BeforeAfterKeyboardEventEnabled();
|
||||
|
||||
void Init(nsIDocument* aDocument, nsPresContext* aPresContext,
|
||||
nsViewManager* aViewManager, nsStyleSet* aStyleSet,
|
||||
nsCompatibility aCompatMode);
|
||||
@ -373,10 +369,6 @@ public:
|
||||
|
||||
virtual void RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot);
|
||||
|
||||
virtual void DispatchAfterKeyboardEvent(nsINode* aTarget,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
bool aEmbeddedCancelled) MOZ_OVERRIDE;
|
||||
|
||||
void SetNextPaintCompressed() { mNextPaintCompressed = true; }
|
||||
|
||||
protected:
|
||||
@ -727,24 +719,6 @@ protected:
|
||||
|
||||
void EvictTouches();
|
||||
|
||||
// Methods for dispatching KeyboardEvent and BeforeAfterKeyboardEvent.
|
||||
void HandleKeyboardEvent(nsINode* aTarget,
|
||||
mozilla::WidgetKeyboardEvent& aEvent,
|
||||
bool aEmbeddedCancelled,
|
||||
nsEventStatus* aStatus,
|
||||
mozilla::EventDispatchingCallback* aEventCB);
|
||||
void DispatchBeforeKeyboardEventInternal(
|
||||
const nsTArray<nsCOMPtr<mozilla::dom::Element> >& aChain,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
size_t& aChainIndex,
|
||||
bool& aDefaultPrevented);
|
||||
void DispatchAfterKeyboardEventInternal(
|
||||
const nsTArray<nsCOMPtr<mozilla::dom::Element> >& aChain,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
bool aEmbeddedCancelled,
|
||||
size_t aChainIndex = 0);
|
||||
bool CanDispatchEvent(const mozilla::WidgetGUIEvent* aEvent = nullptr) const;
|
||||
|
||||
// A list of images that are visible or almost visible.
|
||||
nsTHashtable< nsRefPtrHashKey<nsIImageLoadingContent> > mVisibleImages;
|
||||
|
||||
|
@ -4349,9 +4349,6 @@ pref("camera.control.low_memory_thresholdMB", 404);
|
||||
// UDPSocket API
|
||||
pref("dom.udpsocket.enabled", false);
|
||||
|
||||
// Disable before keyboard events and after keyboard events by default.
|
||||
pref("dom.beforeAfterKeyboardEvent.enabled", false);
|
||||
|
||||
// Experiment: Get TTL from DNS records.
|
||||
// Unset initially (0); Randomly chosen on first run; will remain unchanged
|
||||
// unless adjusted by the user or experiment ends. Variants defined in
|
||||
|
@ -27,8 +27,7 @@
|
||||
"network-events":{},
|
||||
"embed-apps":{},
|
||||
"audio-channel-content":{},
|
||||
"audio-channel-alarm":{},
|
||||
"before-after-keyboard-event":{}
|
||||
"audio-channel-alarm":{}
|
||||
},
|
||||
"locales": {
|
||||
"en-US": {
|
||||
|
@ -41,11 +41,6 @@
|
||||
// Key is pressed within a window
|
||||
#define NS_KEY_DOWN (NS_WINDOW_START + 33)
|
||||
|
||||
#define NS_KEY_BEFORE_DOWN (NS_WINDOW_START + 34)
|
||||
#define NS_KEY_AFTER_DOWN (NS_WINDOW_START + 35)
|
||||
#define NS_KEY_BEFORE_UP (NS_WINDOW_START + 36)
|
||||
#define NS_KEY_AFTER_UP (NS_WINDOW_START + 37)
|
||||
|
||||
#define NS_RESIZE_EVENT (NS_WINDOW_START + 60)
|
||||
#define NS_SCROLL_EVENT (NS_WINDOW_START + 61)
|
||||
|
||||
|
@ -26,7 +26,6 @@ NS_EVENT_CLASS(Widget, CompositionEvent)
|
||||
NS_EVENT_CLASS(Widget, QueryContentEvent)
|
||||
NS_EVENT_CLASS(Widget, SelectionEvent)
|
||||
NS_EVENT_CLASS(Internal, EditorInputEvent)
|
||||
NS_EVENT_CLASS(Internal, BeforeAfterKeyboardEvent)
|
||||
|
||||
// MouseEvents.h
|
||||
NS_EVENT_CLASS(Widget, MouseEventBase)
|
||||
|
@ -75,7 +75,6 @@ private:
|
||||
friend class dom::PBrowserParent;
|
||||
friend class dom::PBrowserChild;
|
||||
|
||||
protected:
|
||||
WidgetKeyboardEvent()
|
||||
{
|
||||
}
|
||||
@ -83,9 +82,8 @@ protected:
|
||||
public:
|
||||
virtual WidgetKeyboardEvent* AsKeyboardEvent() MOZ_OVERRIDE { return this; }
|
||||
|
||||
WidgetKeyboardEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget,
|
||||
EventClassID aEventClassID = eKeyboardEventClass)
|
||||
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
|
||||
WidgetKeyboardEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget)
|
||||
: WidgetInputEvent(aIsTrusted, aMessage, aWidget, eKeyboardEventClass)
|
||||
, keyCode(0)
|
||||
, charCode(0)
|
||||
, location(nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD)
|
||||
@ -196,72 +194,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::InternalBeforeAfterKeyboardEvent
|
||||
*
|
||||
* This is extended from WidgetKeyboardEvent and is mapped to DOM event
|
||||
* "BeforeAfterKeyboardEvent".
|
||||
*
|
||||
* Event message: NS_KEY_BEFORE_DOWN
|
||||
* NS_KEY_BEFORE_UP
|
||||
* NS_KEY_AFTER_DOWN
|
||||
* NS_KEY_AFTER_UP
|
||||
******************************************************************************/
|
||||
class InternalBeforeAfterKeyboardEvent : public WidgetKeyboardEvent
|
||||
{
|
||||
private:
|
||||
friend class dom::PBrowserParent;
|
||||
friend class dom::PBrowserChild;
|
||||
|
||||
InternalBeforeAfterKeyboardEvent()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
// Extra member for InternalBeforeAfterKeyboardEvent. Indicates whether
|
||||
// default actions of keydown/keyup event is prevented.
|
||||
Nullable<bool> mEmbeddedCancelled;
|
||||
|
||||
virtual InternalBeforeAfterKeyboardEvent* AsBeforeAfterKeyboardEvent() MOZ_OVERRIDE
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
InternalBeforeAfterKeyboardEvent(bool aIsTrusted, uint32_t aMessage,
|
||||
nsIWidget* aWidget)
|
||||
: WidgetKeyboardEvent(aIsTrusted, aMessage, aWidget, eBeforeAfterKeyboardEventClass)
|
||||
{
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
|
||||
{
|
||||
MOZ_ASSERT(mClass == eBeforeAfterKeyboardEventClass,
|
||||
"Duplicate() must be overridden by sub class");
|
||||
// Not copying widget, it is a weak reference.
|
||||
InternalBeforeAfterKeyboardEvent* result =
|
||||
new InternalBeforeAfterKeyboardEvent(false, message, nullptr);
|
||||
result->AssignBeforeAfterKeyEventData(*this, true);
|
||||
result->mFlags = mFlags;
|
||||
return result;
|
||||
}
|
||||
|
||||
void AssignBeforeAfterKeyEventData(
|
||||
const InternalBeforeAfterKeyboardEvent& aEvent,
|
||||
bool aCopyTargets)
|
||||
{
|
||||
AssignKeyEventData(aEvent, aCopyTargets);
|
||||
mEmbeddedCancelled = aEvent.mEmbeddedCancelled;
|
||||
}
|
||||
|
||||
void AssignBeforeAfterKeyEventData(
|
||||
const WidgetKeyboardEvent& aEvent,
|
||||
bool aCopyTargets)
|
||||
{
|
||||
AssignKeyEventData(aEvent, aCopyTargets);
|
||||
}
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* mozilla::WidgetCompositionEvent
|
||||
******************************************************************************/
|
||||
|
@ -362,37 +362,6 @@ struct ParamTraits<mozilla::WidgetKeyboardEvent>
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::InternalBeforeAfterKeyboardEvent>
|
||||
{
|
||||
typedef mozilla::InternalBeforeAfterKeyboardEvent paramType;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam)
|
||||
{
|
||||
WriteParam(aMsg, static_cast<mozilla::WidgetKeyboardEvent>(aParam));
|
||||
WriteParam(aMsg, aParam.mEmbeddedCancelled.IsNull());
|
||||
WriteParam(aMsg, aParam.mEmbeddedCancelled.Value());
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
{
|
||||
bool isNull;
|
||||
bool value;
|
||||
bool rv =
|
||||
ReadParam(aMsg, aIter,
|
||||
static_cast<mozilla::WidgetKeyboardEvent*>(aResult)) &&
|
||||
ReadParam(aMsg, aIter, &isNull) &&
|
||||
ReadParam(aMsg, aIter, &value);
|
||||
|
||||
aResult->mEmbeddedCancelled = Nullable<bool>();
|
||||
if (rv && !isNull) {
|
||||
aResult->mEmbeddedCancelled.SetValue(value);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::TextRangeStyle>
|
||||
{
|
||||
|
@ -122,10 +122,6 @@ WidgetEvent::HasKeyEventMessage() const
|
||||
case NS_KEY_DOWN:
|
||||
case NS_KEY_PRESS:
|
||||
case NS_KEY_UP:
|
||||
case NS_KEY_BEFORE_DOWN:
|
||||
case NS_KEY_BEFORE_UP:
|
||||
case NS_KEY_AFTER_DOWN:
|
||||
case NS_KEY_AFTER_UP:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user