mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1257759 part.4 Rename WidgetGUIEvent::PluginEvent to NativeEventData for using this class to send native event from plugin process to content and/or chrome process r=smaug
PluginInstanceChild needs to send native key event to the chrome process via a content process. So, IPC needs a platform independent class/struct which can store native event. This purpose is exactly same as the purpose of WidgetGUIEvent::PluginEvent. Therefore, we can use it for this case too. This patch renames WidgetGUIEvent::PluginEvent to NativeEventData but this patch does NOT remove WidgetGUIEvent::PluginEvent. Instead of that, it's defined as an alias of NativeEventData since PluginEvent is clearer name for the original purpose and it's used by plugin module. MozReview-Commit-ID: 3nrHfb8gk8m --HG-- extra : rebase_source : b0b5a863360bf0893b161d70124d3a83aa2c3386
This commit is contained in:
parent
8a8e89ac9b
commit
d2c8ff21a8
@ -495,6 +495,61 @@ public:
|
|||||||
bool IsAllowedToDispatchDOMEvent() const;
|
bool IsAllowedToDispatchDOMEvent() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* mozilla::NativeEventData
|
||||||
|
*
|
||||||
|
* WidgetGUIEvent's mPluginEvent member used to be a void* pointer,
|
||||||
|
* used to reference external, OS-specific data structures.
|
||||||
|
*
|
||||||
|
* That void* pointer wasn't serializable by itself, causing
|
||||||
|
* certain plugin events not to function in e10s. See bug 586656.
|
||||||
|
*
|
||||||
|
* To make this serializable, we changed this void* pointer into
|
||||||
|
* a proper buffer, and copy these external data structures into this
|
||||||
|
* buffer.
|
||||||
|
*
|
||||||
|
* That buffer is NativeEventData::mBuffer below.
|
||||||
|
*
|
||||||
|
* We wrap this in that NativeEventData class providing operators to
|
||||||
|
* be compatible with existing code that was written around
|
||||||
|
* the old void* field.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
class NativeEventData final
|
||||||
|
{
|
||||||
|
nsTArray<uint8_t> mBuffer;
|
||||||
|
|
||||||
|
friend struct IPC::ParamTraits<mozilla::NativeEventData>;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MOZ_EXPLICIT_CONVERSION operator bool() const
|
||||||
|
{
|
||||||
|
return !mBuffer.IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
MOZ_EXPLICIT_CONVERSION operator const T*() const
|
||||||
|
{
|
||||||
|
return mBuffer.IsEmpty()
|
||||||
|
? nullptr
|
||||||
|
: reinterpret_cast<const T*>(mBuffer.Elements());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Copy(const T& other)
|
||||||
|
{
|
||||||
|
static_assert(!mozilla::IsPointer<T>::value, "Don't want a pointer!");
|
||||||
|
mBuffer.SetLength(sizeof(T));
|
||||||
|
memcpy(mBuffer.Elements(), &other, mBuffer.Length());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
mBuffer.Clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* mozilla::WidgetGUIEvent
|
* mozilla::WidgetGUIEvent
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@ -537,24 +592,6 @@ public:
|
|||||||
nsCOMPtr<nsIWidget> mWidget;
|
nsCOMPtr<nsIWidget> mWidget;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Explanation for this PluginEvent class:
|
|
||||||
*
|
|
||||||
* WidgetGUIEvent's mPluginEvent member used to be a void* pointer,
|
|
||||||
* used to reference external, OS-specific data structures.
|
|
||||||
*
|
|
||||||
* That void* pointer wasn't serializable by itself, causing
|
|
||||||
* certain plugin events not to function in e10s. See bug 586656.
|
|
||||||
*
|
|
||||||
* To make this serializable, we changed this void* pointer into
|
|
||||||
* a proper buffer, and copy these external data structures into this
|
|
||||||
* buffer.
|
|
||||||
*
|
|
||||||
* That buffer is PluginEvent::mBuffer below.
|
|
||||||
*
|
|
||||||
* We wrap this in that PluginEvent class providing operators to
|
|
||||||
* be compatible with existing code that was written around
|
|
||||||
* the old void* field.
|
|
||||||
*
|
|
||||||
* Ideally though, we wouldn't allow arbitrary reinterpret_cast'ing here;
|
* Ideally though, we wouldn't allow arbitrary reinterpret_cast'ing here;
|
||||||
* instead, we would at least store type information here so that
|
* instead, we would at least store type information here so that
|
||||||
* this class can't be used to reinterpret one structure type into another.
|
* this class can't be used to reinterpret one structure type into another.
|
||||||
@ -562,40 +599,7 @@ public:
|
|||||||
* WidgetGUIEvent and other Event classes to remove the need for this
|
* WidgetGUIEvent and other Event classes to remove the need for this
|
||||||
* mPluginEvent field.
|
* mPluginEvent field.
|
||||||
*/
|
*/
|
||||||
class PluginEvent final
|
typedef NativeEventData PluginEvent;
|
||||||
{
|
|
||||||
nsTArray<uint8_t> mBuffer;
|
|
||||||
|
|
||||||
friend struct IPC::ParamTraits<mozilla::WidgetGUIEvent>;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
MOZ_EXPLICIT_CONVERSION operator bool() const
|
|
||||||
{
|
|
||||||
return !mBuffer.IsEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
MOZ_EXPLICIT_CONVERSION operator const T*() const
|
|
||||||
{
|
|
||||||
return mBuffer.IsEmpty()
|
|
||||||
? nullptr
|
|
||||||
: reinterpret_cast<const T*>(mBuffer.Elements());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void Copy(const T& other)
|
|
||||||
{
|
|
||||||
static_assert(!mozilla::IsPointer<T>::value, "Don't want a pointer!");
|
|
||||||
mBuffer.SetLength(sizeof(T));
|
|
||||||
memcpy(mBuffer.Elements(), &other, mBuffer.Length());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clear()
|
|
||||||
{
|
|
||||||
mBuffer.Clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Event for NPAPI plugin
|
// Event for NPAPI plugin
|
||||||
PluginEvent mPluginEvent;
|
PluginEvent mPluginEvent;
|
||||||
|
@ -139,6 +139,8 @@ struct EventFlags;
|
|||||||
|
|
||||||
class WidgetEventTime;
|
class WidgetEventTime;
|
||||||
|
|
||||||
|
class NativeEventData;
|
||||||
|
|
||||||
// TextEvents.h
|
// TextEvents.h
|
||||||
struct AlternativeCharCode;
|
struct AlternativeCharCode;
|
||||||
struct ShortcutKeyCandidate;
|
struct ShortcutKeyCandidate;
|
||||||
|
@ -88,6 +88,22 @@ struct ParamTraits<mozilla::WidgetEvent>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct ParamTraits<mozilla::NativeEventData>
|
||||||
|
{
|
||||||
|
typedef mozilla::NativeEventData paramType;
|
||||||
|
|
||||||
|
static void Write(Message* aMsg, const paramType& aParam)
|
||||||
|
{
|
||||||
|
WriteParam(aMsg, aParam.mBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||||
|
{
|
||||||
|
return ReadParam(aMsg, aIter, &aResult->mBuffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ParamTraits<mozilla::WidgetGUIEvent>
|
struct ParamTraits<mozilla::WidgetGUIEvent>
|
||||||
{
|
{
|
||||||
@ -96,13 +112,13 @@ struct ParamTraits<mozilla::WidgetGUIEvent>
|
|||||||
static void Write(Message* aMsg, const paramType& aParam)
|
static void Write(Message* aMsg, const paramType& aParam)
|
||||||
{
|
{
|
||||||
WriteParam(aMsg, static_cast<mozilla::WidgetEvent>(aParam));
|
WriteParam(aMsg, static_cast<mozilla::WidgetEvent>(aParam));
|
||||||
WriteParam(aMsg, aParam.mPluginEvent.mBuffer);
|
WriteParam(aMsg, aParam.mPluginEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||||
{
|
{
|
||||||
return ReadParam(aMsg, aIter, static_cast<mozilla::WidgetEvent*>(aResult)) &&
|
return ReadParam(aMsg, aIter, static_cast<mozilla::WidgetEvent*>(aResult)) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mPluginEvent.mBuffer);
|
ReadParam(aMsg, aIter, &aResult->mPluginEvent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user