зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1134542 - Get rid of nsIDOMWindowUtils::sendKeyEvent() and nsIFrameLoader::sendCrossProcessKeyEvent() r=smaug
nsIDOMWindowUtils::sendKeyEvent() is already replaced with nsITextInputProcessor for making callers set any attributes of KeyboardEvent and guaranteeing consistency behavior with keyboard events caused by native key events. E.g., whether keypress event should be dispatched or not is automatically decided. nsIFrameLoader::sendCrossProcessKeyEvent() is similart to nsIDOMWindowUtils::sendKeyEvent() but it dispatches keyboard events in child process directly. Currently, nsITextInputProcessor doesn't have this feature but nobody wants/uses this feature. So, for removing actual implementation of nsIDOMWindowUtils::sendKeyEvent(), i.e., nsContentUtils::SendKeyEvent(), which is shared by both nsDOMWindowUtils::SendKeyEvent() and nsFrameLoader::SendCrossProcessKeyEvent(), we should remove this unused API too. (FYI: it's implemented for old Fennec, by bug 553149.) MozReview-Commit-ID: 9n0UVo8Me8k --HG-- extra : rebase_source : e9b117f5b9afec76e63d57ab8cd86dafb5873789
This commit is contained in:
Родитель
126281c8a6
Коммит
a04da0af59
|
@ -8570,112 +8570,6 @@ nsContentUtils::GetViewToDispatchEvent(nsPresContext* presContext,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentUtils::SendKeyEvent(nsIWidget* aWidget,
|
||||
const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
uint32_t aAdditionalFlags,
|
||||
bool* aDefaultActionTaken)
|
||||
{
|
||||
// get the widget to send the event to
|
||||
if (!aWidget)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
EventMessage msg;
|
||||
if (aType.EqualsLiteral("keydown"))
|
||||
msg = eKeyDown;
|
||||
else if (aType.EqualsLiteral("keyup"))
|
||||
msg = eKeyUp;
|
||||
else if (aType.EqualsLiteral("keypress"))
|
||||
msg = eKeyPress;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
WidgetKeyboardEvent event(true, msg, aWidget);
|
||||
event.mModifiers = GetWidgetModifiers(aModifiers);
|
||||
|
||||
if (msg == eKeyPress) {
|
||||
event.mKeyCode = aCharCode ? 0 : aKeyCode;
|
||||
event.mCharCode = aCharCode;
|
||||
} else {
|
||||
event.mKeyCode = aKeyCode;
|
||||
event.mCharCode = 0;
|
||||
}
|
||||
|
||||
uint32_t locationFlag = (aAdditionalFlags &
|
||||
(nsIDOMWindowUtils::KEY_FLAG_LOCATION_STANDARD | nsIDOMWindowUtils::KEY_FLAG_LOCATION_LEFT |
|
||||
nsIDOMWindowUtils::KEY_FLAG_LOCATION_RIGHT | nsIDOMWindowUtils::KEY_FLAG_LOCATION_NUMPAD));
|
||||
switch (locationFlag) {
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_STANDARD:
|
||||
event.mLocation = eKeyLocationStandard;
|
||||
break;
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_LEFT:
|
||||
event.mLocation = eKeyLocationLeft;
|
||||
break;
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_RIGHT:
|
||||
event.mLocation = eKeyLocationRight;
|
||||
break;
|
||||
case nsIDOMWindowUtils::KEY_FLAG_LOCATION_NUMPAD:
|
||||
event.mLocation = eKeyLocationNumpad;
|
||||
break;
|
||||
default:
|
||||
if (locationFlag != 0) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
// If location flag isn't set, choose the location from keycode.
|
||||
switch (aKeyCode) {
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD0:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD1:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD2:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD3:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD4:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD5:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD6:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD7:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD8:
|
||||
case nsIDOMKeyEvent::DOM_VK_NUMPAD9:
|
||||
case nsIDOMKeyEvent::DOM_VK_MULTIPLY:
|
||||
case nsIDOMKeyEvent::DOM_VK_ADD:
|
||||
case nsIDOMKeyEvent::DOM_VK_SEPARATOR:
|
||||
case nsIDOMKeyEvent::DOM_VK_SUBTRACT:
|
||||
case nsIDOMKeyEvent::DOM_VK_DECIMAL:
|
||||
case nsIDOMKeyEvent::DOM_VK_DIVIDE:
|
||||
event.mLocation = eKeyLocationNumpad;
|
||||
break;
|
||||
case nsIDOMKeyEvent::DOM_VK_SHIFT:
|
||||
case nsIDOMKeyEvent::DOM_VK_CONTROL:
|
||||
case nsIDOMKeyEvent::DOM_VK_ALT:
|
||||
case nsIDOMKeyEvent::DOM_VK_META:
|
||||
event.mLocation = eKeyLocationLeft;
|
||||
break;
|
||||
default:
|
||||
event.mLocation = eKeyLocationStandard;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
event.mRefPoint = LayoutDeviceIntPoint(0, 0);
|
||||
event.mTime = PR_IntervalNow();
|
||||
if (!(aAdditionalFlags & nsIDOMWindowUtils::KEY_FLAG_NOT_SYNTHESIZED_FOR_TESTS)) {
|
||||
event.mFlags.mIsSynthesizedForTests = true;
|
||||
}
|
||||
|
||||
if (aAdditionalFlags & nsIDOMWindowUtils::KEY_FLAG_PREVENT_DEFAULT) {
|
||||
event.PreventDefaultBeforeDispatch();
|
||||
}
|
||||
|
||||
nsEventStatus status;
|
||||
nsresult rv = aWidget->DispatchEvent(&event, status);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aDefaultActionTaken = (status != nsEventStatus_eConsumeNoDefault);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentUtils::SendMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
|
||||
const nsAString& aType,
|
||||
|
@ -10958,7 +10852,6 @@ nsContentUtils::IsMessageInputEvent(const IPC::Message& aMsg)
|
|||
case mozilla::dom::PBrowser::Msg_RealDragEvent__ID:
|
||||
case mozilla::dom::PBrowser::Msg_UpdateDimensions__ID:
|
||||
case mozilla::dom::PBrowser::Msg_MouseEvent__ID:
|
||||
case mozilla::dom::PBrowser::Msg_KeyEvent__ID:
|
||||
case mozilla::dom::PBrowser::Msg_SetDocShellIsActive__ID:
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2875,18 +2875,6 @@ public:
|
|||
static nsView* GetViewToDispatchEvent(nsPresContext* aPresContext,
|
||||
nsIPresShell** aPresShell);
|
||||
|
||||
/**
|
||||
* Synthesize a key event to the given widget
|
||||
* (see nsIDOMWindowUtils.sendKeyEvent).
|
||||
*/
|
||||
static nsresult SendKeyEvent(nsIWidget* aWidget,
|
||||
const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
uint32_t aAdditionalFlags,
|
||||
bool* aDefaultActionTaken);
|
||||
|
||||
/**
|
||||
* Synthesize a mouse event to the given widget
|
||||
* (see nsIDOMWindowUtils.sendMouseEvent).
|
||||
|
|
|
@ -977,22 +977,6 @@ nsDOMWindowUtils::SendTouchEventCommon(const nsAString& aType,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::SendKeyEvent(const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
uint32_t aAdditionalFlags,
|
||||
bool* aDefaultActionTaken)
|
||||
{
|
||||
// get the widget to send the event to
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
|
||||
return nsContentUtils::SendKeyEvent(widget, aType, aKeyCode, aCharCode,
|
||||
aModifiers, aAdditionalFlags,
|
||||
aDefaultActionTaken);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::SendNativeKeyEvent(int32_t aNativeKeyboardLayout,
|
||||
int32_t aNativeKeyCode,
|
||||
|
|
|
@ -2930,35 +2930,6 @@ nsFrameLoader::ActivateFrameEvent(const nsAString& aType,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameLoader::SendCrossProcessKeyEvent(const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
bool aPreventDefault,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsresult rv = SendCrossProcessKeyEvent(aType, aKeyCode, aCharCode, aModifiers, aPreventDefault);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::SendCrossProcessKeyEvent(const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
bool aPreventDefault)
|
||||
{
|
||||
if (mRemoteBrowser) {
|
||||
mRemoteBrowser->SendKeyEvent(aType, aKeyCode, aCharCode, aModifiers,
|
||||
aPreventDefault);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
|
||||
{
|
||||
|
|
|
@ -138,13 +138,6 @@ public:
|
|||
bool aIgnoreRootScrollFrame,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
void SendCrossProcessKeyEvent(const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
bool aPreventDefault,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
void ActivateFrameEvent(const nsAString& aType,
|
||||
bool aCapture,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
|
|
@ -110,15 +110,6 @@ interface nsIFrameLoader : nsISupports
|
|||
// Note, when frameloaders are swapped, also messageManagers are swapped.
|
||||
readonly attribute nsIMessageSender messageManager;
|
||||
|
||||
/**
|
||||
* @see nsIDOMWindowUtils sendKeyEvent.
|
||||
*/
|
||||
void sendCrossProcessKeyEvent(in AString aType,
|
||||
in long aKeyCode,
|
||||
in long aCharCode,
|
||||
in long aModifiers,
|
||||
[optional] in boolean aPreventDefault);
|
||||
|
||||
/**
|
||||
* Request that the next time a remote layer transaction has been
|
||||
* received by the Compositor, a MozAfterRemoteFrame event be sent
|
||||
|
|
|
@ -462,46 +462,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||
in long aLineOrPageDeltaY,
|
||||
in unsigned long aOptions);
|
||||
|
||||
/**
|
||||
* Synthesize a key event to the window. The event types supported are:
|
||||
* keydown, keyup, keypress
|
||||
*
|
||||
* Key events generally end up being sent to the focused node.
|
||||
*
|
||||
* Cannot be accessed from unprivileged context (not content-accessible)
|
||||
* Will throw a DOM security error if called without chrome privileges.
|
||||
*
|
||||
* @param aType event type
|
||||
* @param aKeyCode key code
|
||||
* @param aCharCode character code
|
||||
* @param aModifiers modifiers pressed, using constants defined as MODIFIER_*
|
||||
* @param aAdditionalFlags special flags for the key event, see KEY_FLAG_*.
|
||||
*
|
||||
* @return false if the event had preventDefault() called on it,
|
||||
* true otherwise. In other words, true if and only if the
|
||||
* default action was taken.
|
||||
*/
|
||||
|
||||
// If this is set, preventDefault() the event before dispatch.
|
||||
const unsigned long KEY_FLAG_PREVENT_DEFAULT = 0x0001;
|
||||
|
||||
// If this is set, the mIsSynthesizedForTests flag is set to false
|
||||
// on the key event. Otherwise it is true.
|
||||
const unsigned long KEY_FLAG_NOT_SYNTHESIZED_FOR_TESTS = 0x0002;
|
||||
|
||||
// if one of these flags is set, the KeyboardEvent.location will be the value.
|
||||
// Otherwise, it will be computed from aKeyCode.
|
||||
const unsigned long KEY_FLAG_LOCATION_STANDARD = 0x0010;
|
||||
const unsigned long KEY_FLAG_LOCATION_LEFT = 0x0020;
|
||||
const unsigned long KEY_FLAG_LOCATION_RIGHT = 0x0040;
|
||||
const unsigned long KEY_FLAG_LOCATION_NUMPAD = 0x0080;
|
||||
|
||||
boolean sendKeyEvent(in AString aType,
|
||||
in long aKeyCode,
|
||||
in long aCharCode,
|
||||
in long aModifiers,
|
||||
[optional] in unsigned long aAdditionalFlags);
|
||||
|
||||
/**
|
||||
* See nsIWidget::SynthesizeNativeKeyEvent
|
||||
*
|
||||
|
|
|
@ -710,15 +710,6 @@ child:
|
|||
|
||||
async PluginEvent(WidgetPluginEvent aEvent);
|
||||
|
||||
/**
|
||||
* @see nsIDOMWindowUtils sendKeyEvent.
|
||||
*/
|
||||
async KeyEvent(nsString aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
bool aPreventDefault);
|
||||
|
||||
prio(input) async CompositionEvent(WidgetCompositionEvent event);
|
||||
async NormalPriorityCompositionEvent(WidgetCompositionEvent event);
|
||||
|
||||
|
|
|
@ -2131,19 +2131,6 @@ TabChild::RecvNormalPriorityRealKeyEvent(const WidgetKeyboardEvent& aEvent)
|
|||
return RecvRealKeyEvent(aEvent);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvKeyEvent(const nsString& aType,
|
||||
const int32_t& aKeyCode,
|
||||
const int32_t& aCharCode,
|
||||
const int32_t& aModifiers,
|
||||
const bool& aPreventDefault)
|
||||
{
|
||||
bool ignored = false;
|
||||
nsContentUtils::SendKeyEvent(mPuppetWidget, aType, aKeyCode, aCharCode,
|
||||
aModifiers, aPreventDefault, &ignored);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvCompositionEvent(const WidgetCompositionEvent& aEvent)
|
||||
{
|
||||
|
|
|
@ -432,12 +432,6 @@ public:
|
|||
const uint64_t& aInputBlockId,
|
||||
const nsEventStatus& aApzResponse) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvKeyEvent(const nsString& aType,
|
||||
const int32_t& aKeyCode,
|
||||
const int32_t& aCharCode,
|
||||
const int32_t& aModifiers,
|
||||
const bool& aPreventDefault) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvNativeSynthesisResponse(const uint64_t& aObserverId,
|
||||
const nsCString& aResponse) override;
|
||||
|
||||
|
|
|
@ -1103,20 +1103,6 @@ TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
TabParent::SendKeyEvent(const nsAString& aType,
|
||||
int32_t aKeyCode,
|
||||
int32_t aCharCode,
|
||||
int32_t aModifiers,
|
||||
bool aPreventDefault)
|
||||
{
|
||||
if (mIsDestroyed || !mIsReadyToHandleInputEvents) {
|
||||
return;
|
||||
}
|
||||
Unused << PBrowserParent::SendKeyEvent(nsString(aType), aKeyCode, aCharCode,
|
||||
aModifiers, aPreventDefault);
|
||||
}
|
||||
|
||||
void
|
||||
TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent)
|
||||
{
|
||||
|
|
|
@ -429,10 +429,6 @@ public:
|
|||
int32_t aButton, int32_t aClickCount,
|
||||
int32_t aModifiers, bool aIgnoreRootScrollFrame);
|
||||
|
||||
void SendKeyEvent(const nsAString& aType, int32_t aKeyCode,
|
||||
int32_t aCharCode, int32_t aModifiers,
|
||||
bool aPreventDefault);
|
||||
|
||||
/**
|
||||
* The following Send*Event() marks aEvent as posted to remote process if
|
||||
* it succeeded. So, you can check the result with
|
||||
|
|
|
@ -73,18 +73,6 @@
|
|||
frameLoader.sendCrossProcessMouseEvent("mouseup", x, y, 0, 1, 0, false);
|
||||
}
|
||||
|
||||
function keyPress() {
|
||||
// First focus the remote frame, then dispatch click. This way remote frame gets focus before
|
||||
// mouse event.
|
||||
document.getElementById('page').focus();
|
||||
var frameLoader = document.getElementById('page').QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
|
||||
|
||||
var keyCode = Components.interfaces.nsIDOMKeyEvent.DOM_VK_A;
|
||||
frameLoader.sendCrossProcessKeyEvent("keydown", keyCode, 0, 0);
|
||||
frameLoader.sendCrossProcessKeyEvent("keypress", keyCode, 0, 0);
|
||||
frameLoader.sendCrossProcessKeyEvent("keyup", keyCode, 0, 0);
|
||||
}
|
||||
|
||||
function openWindow() {
|
||||
window.open('chrome://global/content/test-ipc.xul', '_blank', 'chrome,resizable,width=800,height=800');
|
||||
}
|
||||
|
@ -248,7 +236,6 @@
|
|||
<toolbar>
|
||||
<toolbarbutton onclick="restart()" label="Recover"/>
|
||||
<toolbarbutton onclick="randomClick()" label="random click"/>
|
||||
<toolbarbutton onclick="keyPress()" label="key press"/>
|
||||
<toolbarbutton onclick="messageSpeed()" label="test message handling speed"/>
|
||||
<toolbarbutton onclick="listenerAddRemove()" label="test listener add/remove"/>
|
||||
<toolbarbutton onclick="enableMozAfterPaint()" label="MozAfterPaint"/>
|
||||
|
|
|
@ -106,16 +106,6 @@ interface FrameLoader {
|
|||
// Note, when frameloaders are swapped, also messageManagers are swapped.
|
||||
readonly attribute nsIMessageSender? messageManager;
|
||||
|
||||
/**
|
||||
* @see nsIDOMWindowUtils sendKeyEvent.
|
||||
*/
|
||||
[Throws]
|
||||
void sendCrossProcessKeyEvent(DOMString aType,
|
||||
long aKeyCode,
|
||||
long aCharCode,
|
||||
long aModifiers,
|
||||
optional boolean aPreventDefault = false);
|
||||
|
||||
/**
|
||||
* Request that the next time a remote layer transaction has been
|
||||
* received by the Compositor, a MozAfterRemoteFrame event be sent
|
||||
|
|
Загрузка…
Ссылка в новой задаче