зеркало из https://github.com/mozilla/gecko-dev.git
Bug 971462 - Hide event type from constructor of WidgetCommandEvent r=smaug
The constructor of WidgetCommandEvent takes 2 nsAtom pointers. One is for specifying event type, the other is for specifying the command. The difference of these arguments are pretty unclear for other developers and the former argument is always nsGkAtoms::onAppCommand unless nullptr in C++ code. So, we can hide the former argument. Then, we should create another constructor for creating empty command event from constructor of dom::CommandEvent. Differential Revision: https://phabricator.services.mozilla.com/D2506 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
11bdeb280a
Коммит
6da4b51b7b
|
@ -15,8 +15,7 @@ CommandEvent::CommandEvent(EventTarget* aOwner,
|
|||
nsPresContext* aPresContext,
|
||||
WidgetCommandEvent* aEvent)
|
||||
: Event(aOwner, aPresContext,
|
||||
aEvent ? aEvent :
|
||||
new WidgetCommandEvent(false, nullptr, nullptr, nullptr))
|
||||
aEvent ? aEvent : new WidgetCommandEvent())
|
||||
{
|
||||
mEvent->mTime = PR_Now();
|
||||
if (aEvent) {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/BasicEvents.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsITransferable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -106,6 +107,7 @@ class WidgetCommandEvent : public WidgetGUIEvent
|
|||
public:
|
||||
virtual WidgetCommandEvent* AsCommandEvent() override { return this; }
|
||||
|
||||
protected:
|
||||
WidgetCommandEvent(bool aIsTrusted, nsAtom* aEventType,
|
||||
nsAtom* aCommand, nsIWidget* aWidget)
|
||||
: WidgetGUIEvent(aIsTrusted, eUnidentifiedEvent, aWidget,
|
||||
|
@ -115,6 +117,25 @@ public:
|
|||
mSpecifiedEventType = aEventType;
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor to initialize an app command. This is the only case to
|
||||
* initialize this class as a command in C++ stack.
|
||||
*/
|
||||
WidgetCommandEvent(bool aIsTrusted, nsAtom* aCommand, nsIWidget* aWidget)
|
||||
: WidgetCommandEvent(aIsTrusted, nsGkAtoms::onAppCommand,
|
||||
aCommand, aWidget)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to initialize as internal event of dom::CommandEvent.
|
||||
*/
|
||||
WidgetCommandEvent()
|
||||
: WidgetCommandEvent(false, nullptr, nullptr, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
virtual WidgetEvent* Duplicate() const override
|
||||
{
|
||||
MOZ_ASSERT(mClass == eCommandEventClass,
|
||||
|
|
|
@ -2933,8 +2933,8 @@ bool
|
|||
nsWindow::DispatchCommandEvent(nsAtom* aCommand)
|
||||
{
|
||||
nsEventStatus status;
|
||||
WidgetCommandEvent event(true, nsGkAtoms::onAppCommand, aCommand, this);
|
||||
DispatchEvent(&event, status);
|
||||
WidgetCommandEvent appCommandEvent(true, aCommand, this);
|
||||
DispatchEvent(&appCommandEvent, status);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2146,16 +2146,17 @@ NativeKey::DispatchCommandEvent(uint32_t aEventCommand) const
|
|||
"event", this));
|
||||
return false;
|
||||
}
|
||||
WidgetCommandEvent commandEvent(true, nsGkAtoms::onAppCommand,
|
||||
command, mWidget);
|
||||
WidgetCommandEvent appCommandEvent(true, command, mWidget);
|
||||
|
||||
mWidget->InitEvent(commandEvent);
|
||||
mWidget->InitEvent(appCommandEvent);
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::DispatchCommandEvent(), dispatching %s command event...",
|
||||
("%p NativeKey::DispatchCommandEvent(), dispatching "
|
||||
"%s app command event...",
|
||||
this, nsAtomCString(command).get()));
|
||||
bool ok = mWidget->DispatchWindowEvent(&commandEvent) || mWidget->Destroyed();
|
||||
bool ok =
|
||||
mWidget->DispatchWindowEvent(&appCommandEvent) || mWidget->Destroyed();
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::DispatchCommandEvent(), dispatched command event, "
|
||||
("%p NativeKey::DispatchCommandEvent(), dispatched app command event, "
|
||||
"result=%s, mWidget->Destroyed()=%s",
|
||||
this, GetBoolName(ok), GetBoolName(mWidget->Destroyed())));
|
||||
return ok;
|
||||
|
|
|
@ -1415,10 +1415,10 @@ MouseScrollHandler::Device::Elantech::HandleKeyMessage(nsWindowBase* aWidget,
|
|||
"%s command event",
|
||||
aWParam == VK_NEXT ? "Forward" : "Back"));
|
||||
|
||||
WidgetCommandEvent commandEvent(true, nsGkAtoms::onAppCommand,
|
||||
WidgetCommandEvent appCommandEvent(true,
|
||||
(aWParam == VK_NEXT) ? nsGkAtoms::Forward : nsGkAtoms::Back, aWidget);
|
||||
InitEvent(aWidget, commandEvent);
|
||||
aWidget->DispatchWindowEvent(&commandEvent);
|
||||
InitEvent(aWidget, appCommandEvent);
|
||||
aWidget->DispatchWindowEvent(&appCommandEvent);
|
||||
}
|
||||
else {
|
||||
MOZ_LOG(gMouseScrollLog, LogLevel::Info,
|
||||
|
|
Загрузка…
Ссылка в новой задаче