2013-09-24 14:04:15 +04:00
|
|
|
/* -*- 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_MiscEvents_h__
|
|
|
|
#define mozilla_MiscEvents_h__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "mozilla/BasicEvents.h"
|
2021-05-18 09:30:35 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2017-10-03 01:05:19 +03:00
|
|
|
#include "nsAtom.h"
|
2018-07-30 15:20:47 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
#include "nsITransferable.h"
|
2021-05-18 09:30:35 +03:00
|
|
|
#include "nsString.h"
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-12-29 16:57:38 +03:00
|
|
|
namespace dom {
|
|
|
|
class PBrowserParent;
|
|
|
|
class PBrowserChild;
|
|
|
|
} // namespace dom
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetContentCommandEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetContentCommandEvent : public WidgetGUIEvent {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetContentCommandEvent* AsContentCommandEvent() override {
|
2013-10-18 10:10:20 +04:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetContentCommandEvent(bool aIsTrusted, EventMessage aMessage,
|
2014-08-04 09:28:56 +04:00
|
|
|
nsIWidget* aWidget, bool aOnlyEnabledCheck = false)
|
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget,
|
|
|
|
eContentCommandEventClass),
|
|
|
|
mOnlyEnabledCheck(aOnlyEnabledCheck),
|
|
|
|
mSucceeded(false),
|
|
|
|
mIsEnabled(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-01-27 10:10:44 +04:00
|
|
|
// This event isn't an internal event of any DOM event.
|
2014-03-27 17:53:19 +04:00
|
|
|
NS_ASSERTION(!IsAllowedToDispatchDOMEvent(),
|
|
|
|
"WidgetQueryContentEvent needs to support Duplicate()");
|
2014-01-27 10:10:44 +04:00
|
|
|
MOZ_CRASH("WidgetQueryContentEvent doesn't support Duplicate()");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-05-18 09:30:35 +03:00
|
|
|
// eContentCommandInsertText
|
|
|
|
mozilla::Maybe<nsString> mString; // [in]
|
|
|
|
|
2015-09-10 19:59:52 +03:00
|
|
|
// eContentCommandPasteTransferable
|
2013-09-24 14:04:15 +04:00
|
|
|
nsCOMPtr<nsITransferable> mTransferable; // [in]
|
|
|
|
|
2015-09-10 19:59:53 +03:00
|
|
|
// eContentCommandScroll
|
2013-09-24 14:04:15 +04:00
|
|
|
// for mScroll.mUnit
|
|
|
|
enum { eCmdScrollUnit_Line, eCmdScrollUnit_Page, eCmdScrollUnit_Whole };
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
struct ScrollInfo {
|
|
|
|
ScrollInfo()
|
|
|
|
: mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
int32_t mAmount; // [in]
|
|
|
|
uint8_t mUnit; // [in]
|
|
|
|
bool mIsHorizontal; // [in]
|
|
|
|
} mScroll;
|
|
|
|
|
|
|
|
bool mOnlyEnabledCheck; // [in]
|
|
|
|
|
|
|
|
bool mSucceeded; // [out]
|
|
|
|
bool mIsEnabled; // [out]
|
2013-10-25 01:35:07 +04:00
|
|
|
|
|
|
|
void AssignContentCommandEventData(const WidgetContentCommandEvent& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignGUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
2021-05-18 09:30:35 +03:00
|
|
|
mString = aEvent.mString;
|
2013-10-25 01:35:07 +04:00
|
|
|
mScroll = aEvent.mScroll;
|
|
|
|
mOnlyEnabledCheck = aEvent.mOnlyEnabledCheck;
|
|
|
|
mSucceeded = aEvent.mSucceeded;
|
|
|
|
mIsEnabled = aEvent.mIsEnabled;
|
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetCommandEvent
|
|
|
|
*
|
|
|
|
* This sends a command to chrome. If you want to request what is performed
|
|
|
|
* in focused content, you should use WidgetContentCommandEvent instead.
|
|
|
|
*
|
|
|
|
* XXX Should be |WidgetChromeCommandEvent|?
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetCommandEvent : public WidgetGUIEvent {
|
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetCommandEvent* AsCommandEvent() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2018-07-30 15:20:47 +03:00
|
|
|
protected:
|
2017-10-03 01:05:19 +03:00
|
|
|
WidgetCommandEvent(bool aIsTrusted, nsAtom* aEventType, nsAtom* aCommand,
|
|
|
|
nsIWidget* aWidget)
|
2015-09-10 04:40:04 +03:00
|
|
|
: WidgetGUIEvent(aIsTrusted, eUnidentifiedEvent, aWidget,
|
2014-08-04 09:28:56 +04:00
|
|
|
eCommandEventClass),
|
2016-05-12 07:28:31 +03:00
|
|
|
mCommand(aCommand) {
|
2016-04-18 17:53:03 +03:00
|
|
|
mSpecifiedEventType = aEventType;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2018-07-30 15:20:47 +03:00
|
|
|
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) {}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override {
|
2014-08-04 09:28:56 +04:00
|
|
|
MOZ_ASSERT(mClass == eCommandEventClass,
|
2014-01-27 10:10:44 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
|
|
|
WidgetCommandEvent* result =
|
2016-05-12 07:28:31 +03:00
|
|
|
new WidgetCommandEvent(false, mSpecifiedEventType, mCommand, nullptr);
|
2014-01-27 10:10:44 +04:00
|
|
|
result->AssignCommandEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> mCommand;
|
2013-09-24 14:04:15 +04:00
|
|
|
|
|
|
|
// XXX Not tested by test_assign_event_data.html
|
|
|
|
void AssignCommandEventData(const WidgetCommandEvent& aEvent,
|
|
|
|
bool aCopyTargets) {
|
|
|
|
AssignGUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-05-12 07:28:31 +03:00
|
|
|
// mCommand must have been initialized with the constructor.
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_MiscEvents_h__
|