Bug 912956 part.8 Create mozilla/MiscEvents.h r=roc

This commit is contained in:
Masayuki Nakano 2013-09-24 19:04:15 +09:00
Родитель 22c5f0a4eb
Коммит ed6389f9ff
6 изменённых файлов: 172 добавлений и 134 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "nsIMobileConnectionProvider.h"
#include "nsDOMEventTargetHelper.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWeakPtr.h"
namespace mozilla {
namespace dom {

Просмотреть файл

@ -57,19 +57,19 @@ enum nsEventStructType
NS_TRANSITION_EVENT, // InternalTransitionEvent
NS_ANIMATION_EVENT, // InternalAnimationEvent
// MiscEvents.h
NS_COMMAND_EVENT, // WidgetCommandEvent
NS_CONTENT_COMMAND_EVENT, // WidgetContentCommandEvent
NS_PLUGIN_EVENT, // WidgetPluginEvent
// DOM events
NS_MUTATION_EVENT, // nsMutationEvent
// SVG events
NS_SVGZOOM_EVENT, // GUIEvent
NS_SMIL_TIME_EVENT, // UIEvent
// Command events
NS_COMMAND_EVENT, // nsCommandEvent
NS_CONTENT_COMMAND_EVENT, // nsContentCommandEvent
// Plugin event
NS_PLUGIN_EVENT // nsPluginEvent
// Follwoing struct type values are ugly. They indicate other struct type
// actually. However, they are used for distinguishing which DOM event
// should be created for the event.
NS_SVGZOOM_EVENT, // WidgetGUIEvent
NS_SMIL_TIME_EVENT // InternalUIEvent
};
/******************************************************************************

Просмотреть файл

@ -92,49 +92,52 @@ class InternalClipboardEvent;
class InternalFocusEvent;
class InternalTransitionEvent;
class InternalAnimationEvent;
} // namespace mozilla
// MiscEvents.h
class nsCommandEvent;
class nsContentCommandEvent;
class nsPluginEvent;
class WidgetCommandEvent;
class WidgetContentCommandEvent;
class WidgetPluginEvent;
} // namespace mozilla
// content/events/public/nsMutationEvent.h
class nsMutationEvent;
// TODO: Remove following typedefs
typedef mozilla::WidgetEvent nsEvent;
typedef mozilla::WidgetGUIEvent nsGUIEvent;
typedef mozilla::WidgetInputEvent nsInputEvent;
typedef mozilla::InternalUIEvent nsUIEvent;
typedef mozilla::AlternativeCharCode nsAlternativeCharCode;
typedef mozilla::WidgetKeyboardEvent nsKeyEvent;
typedef mozilla::TextRangeStyle nsTextRangeStyle;
typedef mozilla::TextRange nsTextRange;
typedef mozilla::TextRangeArray nsTextRangeArray;
typedef mozilla::WidgetTextEvent nsTextEvent;
typedef mozilla::WidgetCompositionEvent nsCompositionEvent;
typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
typedef mozilla::WidgetSelectionEvent nsSelectionEvent;
typedef mozilla::WidgetMouseEventBase nsMouseEvent_base;
typedef mozilla::WidgetMouseEvent nsMouseEvent;
typedef mozilla::WidgetDragEvent nsDragEvent;
typedef mozilla::WidgetMouseScrollEvent nsMouseScrollEvent;
typedef mozilla::WidgetEvent nsEvent;
typedef mozilla::WidgetGUIEvent nsGUIEvent;
typedef mozilla::WidgetInputEvent nsInputEvent;
typedef mozilla::InternalUIEvent nsUIEvent;
typedef mozilla::AlternativeCharCode nsAlternativeCharCode;
typedef mozilla::WidgetKeyboardEvent nsKeyEvent;
typedef mozilla::TextRangeStyle nsTextRangeStyle;
typedef mozilla::TextRange nsTextRange;
typedef mozilla::TextRangeArray nsTextRangeArray;
typedef mozilla::WidgetTextEvent nsTextEvent;
typedef mozilla::WidgetCompositionEvent nsCompositionEvent;
typedef mozilla::WidgetQueryContentEvent nsQueryContentEvent;
typedef mozilla::WidgetSelectionEvent nsSelectionEvent;
typedef mozilla::WidgetMouseEventBase nsMouseEvent_base;
typedef mozilla::WidgetMouseEvent nsMouseEvent;
typedef mozilla::WidgetDragEvent nsDragEvent;
typedef mozilla::WidgetMouseScrollEvent nsMouseScrollEvent;
namespace mozilla {
typedef WidgetWheelEvent WheelEvent;
typedef WidgetWheelEvent WheelEvent;
}
typedef mozilla::WidgetGestureNotifyEvent nsGestureNotifyEvent;
typedef mozilla::WidgetSimpleGestureEvent nsSimpleGestureEvent;
typedef mozilla::WidgetTouchEvent nsTouchEvent;
typedef mozilla::InternalScriptErrorEvent nsScriptErrorEvent;
typedef mozilla::InternalScrollPortEvent nsScrollPortEvent;
typedef mozilla::InternalScrollAreaEvent nsScrollAreaEvent;
typedef mozilla::InternalFormEvent nsFormEvent;
typedef mozilla::InternalClipboardEvent nsClipboardEvent;
typedef mozilla::InternalFocusEvent nsFocusEvent;
typedef mozilla::InternalTransitionEvent nsTransitionEvent;
typedef mozilla::InternalAnimationEvent nsAnimationEvent;
typedef mozilla::WidgetGestureNotifyEvent nsGestureNotifyEvent;
typedef mozilla::WidgetSimpleGestureEvent nsSimpleGestureEvent;
typedef mozilla::WidgetTouchEvent nsTouchEvent;
typedef mozilla::InternalScriptErrorEvent nsScriptErrorEvent;
typedef mozilla::InternalScrollPortEvent nsScrollPortEvent;
typedef mozilla::InternalScrollAreaEvent nsScrollAreaEvent;
typedef mozilla::InternalFormEvent nsFormEvent;
typedef mozilla::InternalClipboardEvent nsClipboardEvent;
typedef mozilla::InternalFocusEvent nsFocusEvent;
typedef mozilla::InternalTransitionEvent nsTransitionEvent;
typedef mozilla::InternalAnimationEvent nsAnimationEvent;
typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
typedef mozilla::WidgetCommandEvent nsCommandEvent;
typedef mozilla::WidgetPluginEvent nsPluginEvent;
#endif // mozilla_EventForwards_h__

123
widget/MiscEvents.h Normal file
Просмотреть файл

@ -0,0 +1,123 @@
/* -*- 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 {
/******************************************************************************
* mozilla::WidgetContentCommandEvent
******************************************************************************/
class WidgetContentCommandEvent : public WidgetGUIEvent
{
public:
WidgetContentCommandEvent(bool aIsTrusted, uint32_t aMessage,
nsIWidget* aWidget,
bool aOnlyEnabledCheck = false) :
WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_CONTENT_COMMAND_EVENT),
mOnlyEnabledCheck(aOnlyEnabledCheck), mSucceeded(false), mIsEnabled(false)
{
}
// NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
nsCOMPtr<nsITransferable> mTransferable; // [in]
// NS_CONTENT_COMMAND_SCROLL
// 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]
};
/******************************************************************************
* 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:
WidgetCommandEvent(bool aIsTrusted, nsIAtom* aEventType,
nsIAtom* aCommand, nsIWidget* aWidget) :
WidgetGUIEvent(aIsTrusted, NS_USER_DEFINED_EVENT, aWidget,
NS_COMMAND_EVENT),
command(aCommand)
{
userType = aEventType;
}
nsCOMPtr<nsIAtom> command;
// XXX Not tested by test_assign_event_data.html
void AssignCommandEventData(const WidgetCommandEvent& aEvent,
bool aCopyTargets)
{
AssignGUIEventData(aEvent, aCopyTargets);
// command must have been initialized with the constructor.
}
};
/******************************************************************************
* mozilla::WidgetPluginEvent
*
* This event delivers only a native event to focused plugin.
******************************************************************************/
class WidgetPluginEvent : public WidgetGUIEvent
{
public:
WidgetPluginEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
WidgetGUIEvent(aIsTrusted, aMessage, aWidget, NS_PLUGIN_EVENT),
retargetToFocusedDocument(false)
{
}
// If true, this event needs to be retargeted to focused document.
// Otherwise, never retargeted. Defaults to false.
bool retargetToFocusedDocument;
};
} // namespace mozilla
// TODO: Remove following typedefs
typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
typedef mozilla::WidgetCommandEvent nsCommandEvent;
typedef mozilla::WidgetPluginEvent nsPluginEvent;
#endif // mozilla_MiscEvents_h__

Просмотреть файл

@ -115,6 +115,7 @@ EXPORTS.mozilla += [
'ContentEvents.h',
'EventForwards.h',
'LookAndFeel.h',
'MiscEvents.h',
'MouseEvents.h',
'TextEvents.h',
'TouchEvents.h',

Просмотреть файл

@ -8,104 +8,14 @@
#include "mozilla/BasicEvents.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "nsPoint.h"
#include "nsRect.h"
#include "nsWeakPtr.h"
#include "nsITransferable.h"
#define NS_EVENT_TYPE_NULL 0
#define NS_EVENT_TYPE_ALL 1 // Not a real event type
class nsContentCommandEvent : public nsGUIEvent
{
public:
nsContentCommandEvent(bool aIsTrusted, uint32_t aMsg, nsIWidget *aWidget,
bool aOnlyEnabledCheck = false) :
nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_CONTENT_COMMAND_EVENT),
mOnlyEnabledCheck(bool(aOnlyEnabledCheck)),
mSucceeded(false), mIsEnabled(false)
{
}
// NS_CONTENT_COMMAND_PASTE_TRANSFERABLE
nsCOMPtr<nsITransferable> mTransferable; // [in]
// NS_CONTENT_COMMAND_SCROLL
// 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]
};
/**
* Command event
*
* Custom commands for example from the operating system.
*/
class nsCommandEvent : public nsGUIEvent
{
public:
nsCommandEvent(bool isTrusted, nsIAtom* aEventType,
nsIAtom* aCommand, nsIWidget* w)
: nsGUIEvent(isTrusted, NS_USER_DEFINED_EVENT, w, NS_COMMAND_EVENT)
{
userType = aEventType;
command = aCommand;
}
nsCOMPtr<nsIAtom> command;
// XXX Not tested by test_assign_event_data.html
void AssignCommandEventData(const nsCommandEvent& aEvent, bool aCopyTargets)
{
AssignGUIEventData(aEvent, aCopyTargets);
// command must have been initialized with the constructor.
}
};
/**
* Native event pluginEvent for plugins.
*/
class nsPluginEvent : public nsGUIEvent
{
public:
nsPluginEvent(bool isTrusted, uint32_t msg, nsIWidget *w)
: nsGUIEvent(isTrusted, msg, w, NS_PLUGIN_EVENT),
retargetToFocusedDocument(false)
{
}
// If TRUE, this event needs to be retargeted to focused document.
// Otherwise, never retargeted.
// Defaults to false.
bool retargetToFocusedDocument;
};
#define NS_IS_INPUT_EVENT(evnt) \
(((evnt)->eventStructType == NS_INPUT_EVENT) || \
((evnt)->eventStructType == NS_MOUSE_EVENT) || \