mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 591047 - (2/7) Adding event handling support to PuppetWidget; r=cjones a=blocking-fennec
This commit is contained in:
parent
6878ccd6f4
commit
847fb9effa
@ -991,7 +991,7 @@ TabChild::InitWidget(const nsIntSize& size)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!mWidget && !mRemoteFrame, "CreateWidget twice?");
|
||||
|
||||
mWidget = nsIWidget::CreatePuppetWidget();
|
||||
mWidget = nsIWidget::CreatePuppetWidget(this);
|
||||
if (!mWidget) {
|
||||
NS_ERROR("couldn't create fake widget");
|
||||
return false;
|
||||
|
@ -73,6 +73,11 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
class LayerManager;
|
||||
}
|
||||
#ifdef MOZ_IPC
|
||||
namespace dom {
|
||||
class PBrowserChild;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,6 +194,10 @@ enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
|
||||
* all basic and necessary functionality.
|
||||
*/
|
||||
class nsIWidget : public nsISupports {
|
||||
#ifdef MOZ_IPC
|
||||
protected:
|
||||
typedef mozilla::dom::PBrowserChild PBrowserChild;
|
||||
#endif
|
||||
|
||||
public:
|
||||
typedef mozilla::layers::LayerManager LayerManager;
|
||||
@ -1262,7 +1271,7 @@ class nsIWidget : public nsISupports {
|
||||
* The returned widget must still be nsIWidget::Create()d.
|
||||
*/
|
||||
static already_AddRefed<nsIWidget>
|
||||
CreatePuppetWidget();
|
||||
CreatePuppetWidget(PBrowserChild *aTabChild);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -38,6 +38,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
#include "BasicLayers.h"
|
||||
|
||||
#include "gfxPlatform.h"
|
||||
@ -45,6 +46,7 @@
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::widget;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
static void
|
||||
InvalidateRegion(nsIWidget* aWidget, const nsIntRegion& aRegion)
|
||||
@ -56,12 +58,12 @@ InvalidateRegion(nsIWidget* aWidget, const nsIntRegion& aRegion)
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<nsIWidget>
|
||||
nsIWidget::CreatePuppetWidget()
|
||||
nsIWidget::CreatePuppetWidget(PBrowserChild *aTabChild)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(nsIWidget::UsePuppetWidgets(),
|
||||
"PuppetWidgets not allowed in this configuration");
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = new PuppetWidget();
|
||||
nsCOMPtr<nsIWidget> widget = new PuppetWidget(aTabChild);
|
||||
return widget.forget();
|
||||
}
|
||||
|
||||
@ -74,7 +76,8 @@ const size_t PuppetWidget::kMaxDimension = 4000;
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(PuppetWidget, nsBaseWidget,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
PuppetWidget::PuppetWidget()
|
||||
PuppetWidget::PuppetWidget(PBrowserChild *aTabChild)
|
||||
: mTabChild(aTabChild)
|
||||
{
|
||||
MOZ_COUNT_CTOR(PuppetWidget);
|
||||
}
|
||||
@ -130,7 +133,7 @@ PuppetWidget::CreateChild(const nsIntRect &aRect,
|
||||
{
|
||||
bool isPopup = aInitData && aInitData->mWindowType == eWindowType_popup;
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget();
|
||||
nsCOMPtr<nsIWidget> widget = nsIWidget::CreatePuppetWidget(mTabChild);
|
||||
return ((widget &&
|
||||
NS_SUCCEEDED(widget->Create(isPopup ? nsnull: this, nsnull, aRect,
|
||||
aHandleEventFunction,
|
||||
@ -146,6 +149,7 @@ PuppetWidget::Destroy()
|
||||
mPaintTask.Revoke();
|
||||
mChild = nsnull;
|
||||
mLayerManager = nsnull;
|
||||
mTabChild = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -243,6 +247,21 @@ PuppetWidget::Update()
|
||||
return DispatchPaintEvent();
|
||||
}
|
||||
|
||||
void
|
||||
PuppetWidget::InitEvent(nsGUIEvent& event, nsIntPoint* aPoint)
|
||||
{
|
||||
if (nsnull == aPoint) {
|
||||
event.refPoint.x = 0;
|
||||
event.refPoint.y = 0;
|
||||
}
|
||||
else {
|
||||
// use the point override if provided
|
||||
event.refPoint.x = aPoint->x;
|
||||
event.refPoint.y = aPoint->y;
|
||||
}
|
||||
event.time = PR_Now() / 1000;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PuppetWidget::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
|
||||
{
|
||||
@ -254,9 +273,8 @@ PuppetWidget::DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus)
|
||||
aStatus = nsEventStatus_eIgnore;
|
||||
if (mEventCallback) {
|
||||
aStatus = (*mEventCallback)(event);
|
||||
}
|
||||
|
||||
if (mChild) {
|
||||
} else if (mChild) {
|
||||
event->widget = mChild;
|
||||
mChild->DispatchEvent(event, aStatus);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ class PuppetWidget : public nsBaseWidget, public nsSupportsWeakReference
|
||||
static const size_t kMaxDimension;
|
||||
|
||||
public:
|
||||
PuppetWidget();
|
||||
PuppetWidget(PBrowserChild *aTabChild);
|
||||
virtual ~PuppetWidget();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
@ -151,6 +151,8 @@ public:
|
||||
virtual nsIntPoint WidgetToScreenOffset()
|
||||
{ return nsIntPoint(0, 0); }
|
||||
|
||||
void InitEvent(nsGUIEvent& event, nsIntPoint* aPoint = nsnull);
|
||||
|
||||
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus& aStatus);
|
||||
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, nsIMenuRollup* aMenuRollup,
|
||||
@ -181,6 +183,13 @@ private:
|
||||
PuppetWidget* mWidget;
|
||||
};
|
||||
|
||||
// TabChild normally holds a strong reference to this PuppetWidget
|
||||
// or its root ancestor, but each PuppetWidget also needs a reference
|
||||
// back to TabChild (e.g. to delegate nsIWidget IME calls to chrome)
|
||||
// So we hold a weak reference to TabChild (PBrowserChild) here.
|
||||
// Since it's possible for TabChild to outlive the PuppetWidget,
|
||||
// we clear this weak reference in Destroy()
|
||||
PBrowserChild *mTabChild;
|
||||
// The "widget" to which we delegate events if we don't have an
|
||||
// event handler.
|
||||
nsRefPtr<PuppetWidget> mChild;
|
||||
|
Loading…
Reference in New Issue
Block a user