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"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsITransferable.h"
|
|
|
|
|
|
|
|
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,
|
2013-09-24 14:04:15 +04:00
|
|
|
nsIWidget* aWidget,
|
2014-08-04 09:28:56 +04:00
|
|
|
bool aOnlyEnabledCheck = false)
|
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, eContentCommandEventClass)
|
|
|
|
, mOnlyEnabledCheck(aOnlyEnabledCheck)
|
|
|
|
, mSucceeded(false)
|
|
|
|
, mIsEnabled(false)
|
2013-09-24 14:04:15 +04: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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ScrollInfo
|
|
|
|
{
|
|
|
|
ScrollInfo() :
|
|
|
|
mAmount(0), mUnit(eCmdScrollUnit_Line), mIsHorizontal(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
WidgetCommandEvent(bool aIsTrusted, nsIAtom* aEventType,
|
2014-08-04 09:28:56 +04:00
|
|
|
nsIAtom* 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-04-25 10:04:09 +03:00
|
|
|
, mCommand(aCommand)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
2016-04-18 17:53:03 +03:00
|
|
|
mSpecifiedEventType = aEventType;
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-01-27 10:10:44 +04:00
|
|
|
{
|
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-04-25 10:04:09 +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;
|
|
|
|
}
|
|
|
|
|
2016-04-25 10:04:09 +03:00
|
|
|
nsCOMPtr<nsIAtom> 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-04-25 10:04:09 +03:00
|
|
|
// mCommand must have been initialized with the constructor.
|
2013-09-24 14:04:15 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetPluginEvent
|
|
|
|
*
|
|
|
|
* This event delivers only a native event to focused plugin.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class WidgetPluginEvent : public WidgetGUIEvent
|
|
|
|
{
|
2015-12-29 16:57:38 +03:00
|
|
|
private:
|
|
|
|
friend class dom::PBrowserParent;
|
|
|
|
friend class dom::PBrowserChild;
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetPluginEvent* AsPluginEvent() override { return this; }
|
2013-10-18 10:10:20 +04:00
|
|
|
|
2015-08-26 15:56:59 +03:00
|
|
|
WidgetPluginEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
|
2014-08-04 09:28:57 +04:00
|
|
|
: WidgetGUIEvent(aIsTrusted, aMessage, aWidget, ePluginEventClass)
|
2016-03-30 12:07:50 +03:00
|
|
|
, mRetargetToFocusedDocument(false)
|
2013-09-24 14:04:15 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual WidgetEvent* Duplicate() const override
|
2014-01-27 10:10:44 +04:00
|
|
|
{
|
2014-03-27 17:53:19 +04:00
|
|
|
// NOTE: PluginEvent has to be dispatched to nsIFrame::HandleEvent().
|
|
|
|
// So, this event needs to support Duplicate().
|
2014-08-04 09:28:57 +04:00
|
|
|
MOZ_ASSERT(mClass == ePluginEventClass,
|
2014-03-27 17:53:19 +04:00
|
|
|
"Duplicate() must be overridden by sub class");
|
|
|
|
// Not copying widget, it is a weak reference.
|
2015-08-22 04:34:51 +03:00
|
|
|
WidgetPluginEvent* result = new WidgetPluginEvent(false, mMessage, nullptr);
|
2014-03-27 17:53:19 +04:00
|
|
|
result->AssignPluginEventData(*this, true);
|
|
|
|
result->mFlags = mFlags;
|
|
|
|
return result;
|
2014-01-27 10:10:44 +04:00
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:15 +04:00
|
|
|
// If true, this event needs to be retargeted to focused document.
|
|
|
|
// Otherwise, never retargeted. Defaults to false.
|
2016-03-30 12:07:50 +03:00
|
|
|
bool mRetargetToFocusedDocument;
|
2014-03-27 17:53:19 +04:00
|
|
|
|
|
|
|
void AssignPluginEventData(const WidgetPluginEvent& aEvent,
|
|
|
|
bool aCopyTargets)
|
|
|
|
{
|
|
|
|
AssignGUIEventData(aEvent, aCopyTargets);
|
|
|
|
|
2016-03-30 12:07:50 +03:00
|
|
|
mRetargetToFocusedDocument = aEvent.mRetargetToFocusedDocument;
|
2014-03-27 17:53:19 +04:00
|
|
|
}
|
2015-12-29 16:57:38 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
WidgetPluginEvent()
|
|
|
|
{
|
|
|
|
}
|
2013-09-24 14:04:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_MiscEvents_h__
|