gecko-dev/widget/nsIKeyEventInPluginCallback.h
Masayuki Nakano b332dc9ff4 Bug 1257759 part.5 PluginInstanceChild should post received native key event to chrome process if the key combination may be a shortcut key r=jimm
When PluginInstanceChild receives native key events, it should post the events to the chrome process first for checking if the key combination is reserved.  However, posting all key events to the chrome process may make damage to the performance of text input.  Therefore, this patch starts to post a key event whose key combination may be a shortcut key.  However, for avoiding to shuffle the event order, it posts following key events until all posted key events are handled by the chrome process.

For receiving response from widget, this patch defines nsIKeyEventInPluginCallback.  It's specified by nsIWidget::OnWindowedPluginKeyEvent() for ensuring the caller will receive the reply.  Basically, the caller of nsIWidget::OnWindowedPluginKeyEvent() should reply to the child process.  However, if the widget is a PuppetWidget, it cannot return the result synchronously.  Therefore, PuppetWidget::OnWindowedPluginKeyEvent() returns NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY and stores the callback to mKeyEventInPluginCallbacks.  Then, TabParent::HandledWindowedPluginKeyEvent() will call PuppetWidget::HandledWindowedPluginKeyEvent().

MozReview-Commit-ID: G6brOU26NwQ

--HG--
extra : rebase_source : 8140456de278956d2d594e85c7b397ae366b4962
2016-04-19 20:09:37 +09:00

43 lines
1.5 KiB
C++

/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 nsIKeyEventInPluginCallback_h_
#define nsIKeyEventInPluginCallback_h_
#include "mozilla/EventForwards.h"
#include "nsISupports.h"
#define NS_IKEYEVENTINPLUGINCALLBACK_IID \
{ 0x543c5a8a, 0xc50e, 0x4cf9, \
{ 0xa6, 0xba, 0x29, 0xa1, 0xc5, 0xa5, 0x47, 0x07 } }
class nsIKeyEventInPluginCallback : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IKEYEVENTINPLUGINCALLBACK_IID)
/**
* HandledWindowedPluginKeyEvent() is a callback method of
* nsIWidget::OnWindowedPluginKeyEvent(). When it returns
* NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY, it should call this method
* when the key event is handled.
*
* @param aKeyEventData The key event which was posted to the parent
* process from a plugin process.
* @param aIsConsumed true if aKeyEventData is consumed in the
* parent process. Otherwise, false.
*/
virtual void HandledWindowedPluginKeyEvent(
const mozilla::NativeEventData& aKeyEventData,
bool aIsConsumed) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIKeyEventInPluginCallback,
NS_IKEYEVENTINPLUGINCALLBACK_IID)
#endif // #ifndef nsIKeyEventInPluginCallback_h_