Bug 586656 - Serialize external "pluginEvent" structs in WidgetGUIEvent so that plugin events work in e10s - r=masayuki,jimm
This commit is contained in:
@@ -1812,7 +1812,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
|
||||
// If we have to synthesize an event we'll use one of these.
|
||||
NPCocoaEvent synthCocoaEvent;
|
||||
void* event = anEvent.pluginEvent;
|
||||
const NPCocoaEvent* event = static_cast<const NPCocoaEvent*>(anEvent.mPluginEvent);
|
||||
nsPoint pt =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mObjectFrame) -
|
||||
mObjectFrame->GetContentRectRelativeToSelf().TopLeft();
|
||||
@@ -1879,7 +1879,9 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
int16_t response = kNPEventNotHandled;
|
||||
void* window = FixUpPluginWindow(ePluginPaintEnable);
|
||||
if (window || (eventModel == NPEventModelCocoa)) {
|
||||
mInstance->HandleEvent(event, &response, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
mInstance->HandleEvent(const_cast<NPCocoaEvent*>(event),
|
||||
&response,
|
||||
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
}
|
||||
|
||||
if (eventModel == NPEventModelCocoa && response == kNPEventStartIME) {
|
||||
@@ -1898,7 +1900,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
|
||||
#ifdef XP_WIN
|
||||
// this code supports windowless plugins
|
||||
NPEvent *pPluginEvent = (NPEvent*)anEvent.pluginEvent;
|
||||
const NPEvent *pPluginEvent = static_cast<const NPEvent*>(anEvent.mPluginEvent);
|
||||
// we can get synthetic events from the EventStateManager... these
|
||||
// have no pluginEvent
|
||||
NPEvent pluginEvent;
|
||||
@@ -1967,7 +1969,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
nsIntPoint ptPx(presContext->AppUnitsToDevPixels(pt.x),
|
||||
presContext->AppUnitsToDevPixels(pt.y));
|
||||
nsIntPoint widgetPtPx = ptPx + mObjectFrame->GetWindowOriginInPixels(true);
|
||||
pPluginEvent->lParam = MAKELPARAM(widgetPtPx.x, widgetPtPx.y);
|
||||
const_cast<NPEvent*>(pPluginEvent)->lParam = MAKELPARAM(widgetPtPx.x, widgetPtPx.y);
|
||||
}
|
||||
}
|
||||
else if (!pPluginEvent) {
|
||||
@@ -1995,7 +1997,9 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
|
||||
if (pPluginEvent) {
|
||||
int16_t response = kNPEventNotHandled;
|
||||
mInstance->HandleEvent(pPluginEvent, &response, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
mInstance->HandleEvent(const_cast<NPEvent*>(pPluginEvent),
|
||||
&response,
|
||||
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
if (response == kNPEventHandled)
|
||||
rv = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
@@ -2117,14 +2121,14 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
//XXX case NS_MOUSE_SCROLL_EVENT: not received.
|
||||
|
||||
case NS_KEY_EVENT:
|
||||
if (anEvent.pluginEvent)
|
||||
if (anEvent.mPluginEvent)
|
||||
{
|
||||
XKeyEvent &event = pluginEvent.xkey;
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
event.root = GDK_ROOT_WINDOW();
|
||||
event.time = anEvent.time;
|
||||
const GdkEventKey* gdkEvent =
|
||||
static_cast<const GdkEventKey*>(anEvent.pluginEvent);
|
||||
static_cast<const GdkEventKey*>(anEvent.mPluginEvent);
|
||||
event.keycode = gdkEvent->hardware_keycode;
|
||||
event.state = gdkEvent->state;
|
||||
switch (anEvent.message)
|
||||
@@ -2269,11 +2273,13 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
||||
const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent();
|
||||
LOG("Firing NS_KEY_EVENT %d %d\n", keyEvent.keyCode, keyEvent.charCode);
|
||||
// pluginEvent is initialized by nsWindow::InitKeyEvent().
|
||||
ANPEvent* pluginEvent = reinterpret_cast<ANPEvent*>(keyEvent.pluginEvent);
|
||||
const ANPEvent* pluginEvent = static_cast<const ANPEvent*>(keyEvent.mPluginEvent);
|
||||
if (pluginEvent) {
|
||||
MOZ_ASSERT(pluginEvent->inSize == sizeof(ANPEvent));
|
||||
MOZ_ASSERT(pluginEvent->eventType == kKey_ANPEventType);
|
||||
mInstance->HandleEvent(pluginEvent, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
mInstance->HandleEvent(const_cast<ANPEvent*>(pluginEvent),
|
||||
nullptr,
|
||||
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -2987,7 +2993,7 @@ void* nsPluginInstanceOwner::FixUpPluginWindow(int32_t inPaintState)
|
||||
InitializeNPCocoaEvent(&cocoaEvent);
|
||||
cocoaEvent.type = NPCocoaEventWindowFocusChanged;
|
||||
cocoaEvent.data.focus.hasFocus = cocoaTopLevelWindow ? NS_NPAPI_CocoaWindowIsMain(cocoaTopLevelWindow) : true;
|
||||
pluginEvent.pluginEvent = &cocoaEvent;
|
||||
pluginEvent.mPluginEvent.Copy(cocoaEvent);
|
||||
ProcessEvent(pluginEvent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user