зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1704948 - Give XULCommandEvent a button property. r=smaug,preferences-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D111955
This commit is contained in:
Родитель
a1df50db93
Коммит
81d211846c
|
@ -375,6 +375,7 @@ var gGestureSupport = {
|
|||
aEvent.altKey,
|
||||
aEvent.shiftKey,
|
||||
aEvent.metaKey,
|
||||
0,
|
||||
aEvent,
|
||||
aEvent.mozInputSource
|
||||
);
|
||||
|
|
|
@ -837,6 +837,7 @@ const gClickAndHoldListenersOnElement = {
|
|||
aEvent.altKey,
|
||||
aEvent.shiftKey,
|
||||
aEvent.metaKey,
|
||||
0,
|
||||
null,
|
||||
aEvent.mozInputSource
|
||||
);
|
||||
|
|
|
@ -732,6 +732,7 @@ function checkForMiddleClick(node, event) {
|
|||
event.altKey,
|
||||
event.shiftKey,
|
||||
event.metaKey,
|
||||
0,
|
||||
event,
|
||||
event.mozInputSource
|
||||
);
|
||||
|
|
|
@ -4607,6 +4607,7 @@ var CustomizableUI = {
|
|||
event.altKey,
|
||||
event.shiftKey,
|
||||
event.metaKey,
|
||||
0,
|
||||
event.sourceEvent,
|
||||
0
|
||||
);
|
||||
|
|
|
@ -1899,6 +1899,7 @@ var PanelView = class extends AssociatedToNode {
|
|||
event.altKey,
|
||||
event.shiftKey,
|
||||
event.metaKey,
|
||||
0,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
|
|
@ -37,6 +37,7 @@ add_task(async function() {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
|
|
@ -60,6 +60,7 @@ add_task(async function() {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
@ -106,6 +107,7 @@ add_task(async function() {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
|
|
@ -14,6 +14,7 @@ add_task(async function newtabPreloaded() {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
|
|
@ -20,6 +20,7 @@ exports.command = node => {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
0,
|
||||
null,
|
||||
0
|
||||
);
|
||||
|
|
|
@ -6182,7 +6182,7 @@ nsresult nsContentUtils::DispatchXULCommand(nsIContent* aTarget, bool aTrusted,
|
|||
new XULCommandEvent(doc, presContext, nullptr);
|
||||
xulCommand->InitCommandEvent(u"command"_ns, true, true,
|
||||
nsGlobalWindowInner::Cast(doc->GetInnerWindow()),
|
||||
0, aCtrl, aAlt, aShift, aMeta, aSourceEvent,
|
||||
0, aCtrl, aAlt, aShift, aMeta, 0, aSourceEvent,
|
||||
aInputSource, IgnoreErrors());
|
||||
|
||||
if (aPresShell) {
|
||||
|
|
|
@ -45,8 +45,8 @@ uint16_t XULCommandEvent::InputSource() { return mInputSource; }
|
|||
void XULCommandEvent::InitCommandEvent(
|
||||
const nsAString& aType, bool aCanBubble, bool aCancelable,
|
||||
nsGlobalWindowInner* aView, int32_t aDetail, bool aCtrlKey, bool aAltKey,
|
||||
bool aShiftKey, bool aMetaKey, Event* aSourceEvent, uint16_t aInputSource,
|
||||
ErrorResult& aRv) {
|
||||
bool aShiftKey, bool aMetaKey, int16_t aButton, Event* aSourceEvent,
|
||||
uint16_t aInputSource, ErrorResult& aRv) {
|
||||
if (NS_WARN_IF(mEvent->mFlags.mIsBeingDispatched)) {
|
||||
return;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ void XULCommandEvent::InitCommandEvent(
|
|||
aMetaKey);
|
||||
mSourceEvent = aSourceEvent;
|
||||
mInputSource = aInputSource;
|
||||
mButton = aButton;
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
|
|
@ -36,6 +36,7 @@ class XULCommandEvent : public UIEvent {
|
|||
bool ShiftKey();
|
||||
bool MetaKey();
|
||||
uint16_t InputSource();
|
||||
int16_t Button() { return mButton; }
|
||||
|
||||
already_AddRefed<Event> GetSourceEvent() {
|
||||
RefPtr<Event> e = mSourceEvent;
|
||||
|
@ -45,14 +46,16 @@ class XULCommandEvent : public UIEvent {
|
|||
void InitCommandEvent(const nsAString& aType, bool aCanBubble,
|
||||
bool aCancelable, nsGlobalWindowInner* aView,
|
||||
int32_t aDetail, bool aCtrlKey, bool aAltKey,
|
||||
bool aShiftKey, bool aMetaKey, Event* aSourceEvent,
|
||||
uint16_t aInputSource, ErrorResult& aRv);
|
||||
bool aShiftKey, bool aMetaKey, int16_t aButton,
|
||||
Event* aSourceEvent, uint16_t aInputSource,
|
||||
ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
~XULCommandEvent() = default;
|
||||
|
||||
RefPtr<Event> mSourceEvent;
|
||||
uint16_t mInputSource;
|
||||
int16_t mButton = 0;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -21,6 +21,12 @@ interface XULCommandEvent : UIEvent
|
|||
readonly attribute boolean altKey;
|
||||
readonly attribute boolean metaKey;
|
||||
|
||||
/**
|
||||
* Command events use the same button values as mouse events.
|
||||
* The button will be 0 if the command was not caused by a mouse event.
|
||||
*/
|
||||
readonly attribute short button;
|
||||
|
||||
/**
|
||||
* The input source, if this event was triggered by a mouse event.
|
||||
*/
|
||||
|
@ -46,6 +52,7 @@ interface XULCommandEvent : UIEvent
|
|||
optional boolean altKey = false,
|
||||
optional boolean shiftKey = false,
|
||||
optional boolean metaKey = false,
|
||||
optional short buttonArg = 0,
|
||||
optional Event? sourceEvent = null,
|
||||
optional unsigned short inputSource = 0);
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
let cmdEvent = document.createEvent("xulcommandevent");
|
||||
cmdEvent.initCommandEvent("command", true, true, window, 0,
|
||||
aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
|
||||
aEvent.metaKey, null, aEvent.mozInputSource);
|
||||
aEvent.metaKey, 0, null, aEvent.mozInputSource);
|
||||
aEvent.currentTarget.dispatchEvent(cmdEvent);
|
||||
});
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
|||
let cmdEvent = document.createEvent("xulcommandevent");
|
||||
cmdEvent.initCommandEvent("command", true, true, window, 0,
|
||||
aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
|
||||
aEvent.metaKey, null, aEvent.mozInputSource);
|
||||
aEvent.metaKey, 0, null, aEvent.mozInputSource);
|
||||
aEvent.currentTarget.dispatchEvent(cmdEvent);
|
||||
});
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ void nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent,
|
|||
IgnoredErrorResult rv;
|
||||
event->InitCommandEvent(u"command"_ns, true, true,
|
||||
nsGlobalWindowInner::Cast(doc->GetInnerWindow()), 0, ctrlKey, altKey,
|
||||
shiftKey, cmdKey, nullptr, 0, rv);
|
||||
shiftKey, cmdKey, 0, nullptr, 0, rv);
|
||||
if (!rv.Failed()) {
|
||||
event->SetTrusted(true);
|
||||
aTargetContent->DispatchEvent(*event);
|
||||
|
|
Загрузка…
Ссылка в новой задаче