Files
palemoon27/dom/plugins/ipc/PluginInstanceParent.h
T
roytam1 e9ba40cf6b import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1178833 - Fix for unified builds when a new file is added to layout/base. r=mstange (bf961c00fd)
- Bug 1178847 - Add a MobileViewportManager to manage setting the CSS viewport on B2G. r=botond,tn (937ba486fa)
- Bug 1178847 - Don't use the MobileViewportManager code on Mulet or Fennec yet. r=botond (3061b2c617)
- Bug 1168950. Add the document to DoProcessRestyles profile label. r=dbaron (2347b76411)
- Bug 1187792 - Don't set the SPCSPS unless meta-viewport or zooming is enabled. r=botond (a8f5ed1006)
- Bug 1193062 - Don't double-send target APZC confirmations that might race each other. r=kats (de48467401)
- Bug 1186004 - Add a pref to enable/disable APZ zooming behaviour. r=botond (fc3653c979)
- Bug 1193062 - Add a PAN_MOMENTUM state. r=kats (10c8bb1a5e)
- Bug 1148350 - Have ConvertToGecko use a live screen-to-apzc transform to avoid transform mismatches. r=botond (9eee9ea6f2)
- Bug 1169844 - Remove incorrect assertion and properly untransform wheel events for overscroll situations. r=botond (9b101b53bb)
- Bug 1169690 - Accelerate flings correctly in the presence of overscroll handoff. r=kats (49d55c05f4)
- Bug 1158424 - Extract a BreadthFirstSearch() helper function. r=kats (6a49498185)
- Bug 1158424 - Add APZCTreeManager::FindRootContentApzcForLayersId(). r=kats (d6c7ecf781)
- Bug 1158424 - Fix APZCTreeManager::GetMultitouchTarget(). r=kats (bf8571a4ca)
- Bug 1174205 - Make sure to acquire the tree lock before finding the multitouch target. r=botond (bdbd98f2c7)
- Bug 1211660 - Remove dead obj argument from two functions. r=Waldo. (efba5a2f8d)
- Bug 1158424 - Undeprecate HasNoParentWithSameLayersId(). r=kats (d994ea28f8)
- Fix AsyncCompositionManager not comparing layer tree IDs when finding scrollbar targets. (bug 1151169, r=kats) (c7dbc4776a)
- Bug 1163259. Make sure we don't look at the parent ref layer when looking for a layer with the frame metrics for a scrollbar. r=kats (8b99d2c830)
- Bug 1164340. Convert the scrollbar thumb ratio to a unitless ratio properly for non-zoomable scrollframes. r=botond (27f56cab56)
- Bug 1164340. Fix up some scrollbar related comments in AsyncCompositionManager. r=botond (b9d540bea9)
- Bug 1164767. Modify async scrollbar positioning code to deal with containerless root scrollables. r=botond (501d07592e)
- Bug 1158424 - Remove FrameMetrics::IsRootScrollable() (it just duplicated IsRootContent()). r=kats (672fd034b3)
- Bug 1120683 - Properly handle unapplying 3D projective transforms throughout APZ code. r=botond (a46612811a)
- Bug 1148868 - Make APZ wheel handling handle pixel scrolling on OS X. r=dvander, r=kats (da3bd34135)
- Bug 1193062 - Add fields to PanGestureInput and ScrollWheelInput. r=kats (716ba34e18)
- Bug 1189565 - Send resize events when backing scale factor changes. r=mstange (4e81a7bbf7)
- Bug 1193062 - Add nsCocoaUtils::ModifiersForEvent. r=smichaud (da67b22ff7)
- Bug 1016035 - Remove the ability to swipe vertically. r=kats (fa315e0b97)
- Bug 1016035 - Refactor the code that decides whether we want to start a swipe. r=kats (3091961328)
- Bug 1016035 - Make the threshold in AxisPhysicsMSDModel::IsFinished controllable by the caller. r=kip (76df4d85a2)
- Bug 1016035 - More swipe refactoring. r=kats (2abcd05b33)
- Bug 1016035 - Implement the swipe animation ourselves instead of calling the NSEvent trackSwipe API. r=kats (4842b2a728)
- Bug 1016035 - Move swipe tracking code into DispatchAPZWheelInputEvent. r=kats (bb1052b87c)
- Bug 1016035 - Also mark widgetWheelEvents that are handled by APZ with mCanStartSwipe. r=kats (21809b902d)
- Bug 1016035 - Put PanGestureInput events into a queue if they can end up as a swipe. r=kats (2ebac59047)
- Bug 1016035 - Split up MaybeTrackScrollEventAsSwipe into SendMayStartSwipe and TrackScrollEventAsSwipe. r=kats (ced10d9671)
- Bug 1016035 - Send MayStartSwipe event before sending the wheel event. r=kats (b3346b81fb)
- Fix some fields missing in the widget event IPC glue. (bug 1139711, r=kats) (1298b25705)
- Bug 1016035 - Add mCanTriggerSwipe and TriggersSwipe(). r=masayuki (664a059972)
- Bug 1016035 - Make APZEventState report defaultPrevented=true when the event started a swipe. r=kats (128d627ac7)
- Bug 1016035 - Set scroll overflow information on potential swipe start events that have been processed by APZ. r=masayuki (b5931f6320)
- Bug 1206801 - fix broken CONFIG['DEBUG'] checks in moz.build files; r=mshal (292d5ac709)
- Bug 1186424: Refactor AsmJSValidate.cpp in preparation for parallelization; r=luke (4868bc66ca)
- Bug 1129267 - Fix by backing out patch for bug 1118615. r=mstange (ea8aaba04e)
- Bug 1182411 Part 1: Make plugin quirks available to the Parent as well as the Child. r=jimm (1f2551a6b7)
- Bug 1228462 - "PluginQuirks.* uses DOS CRLF". r=jmathies (b569a6c6c8)
- Bug 1152300 - When focus shifts from a native plugin window to content, content needs to forward the request for focus change to chrome. r=enn (5bd811fadd)
- Bug 1185529: On Windows, ensure that NPAPI child window has the correct parent before setwindow is called. r=jimm (9d94fdf2ff)
- Bug 1182411 Part 2: Change winless popup surrogate to have its parent set in the chrome process. r=jimm (adee9bb012)
2022-02-02 12:04:50 +08:00

413 lines
14 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* 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 dom_plugins_PluginInstanceParent_h
#define dom_plugins_PluginInstanceParent_h 1
#include "mozilla/plugins/PPluginInstanceParent.h"
#include "mozilla/plugins/PluginScriptableObjectParent.h"
#if defined(OS_WIN)
#include "mozilla/gfx/SharedDIBWin.h"
#include <d3d10_1.h>
#include "nsRefPtrHashtable.h"
#elif defined(MOZ_WIDGET_COCOA)
#include "mozilla/gfx/QuartzSupport.h"
#endif
#include "npfunctions.h"
#include "nsAutoPtr.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsRect.h"
#include "PluginDataResolver.h"
#include "mozilla/unused.h"
class gfxASurface;
class gfxContext;
class nsPluginInstanceOwner;
namespace mozilla {
namespace layers {
class ImageContainer;
}
namespace plugins {
class PBrowserStreamParent;
class PluginModuleParent;
class PluginInstanceParent : public PPluginInstanceParent
, public PluginDataResolver
{
friend class PluginModuleParent;
friend class BrowserStreamParent;
friend class PluginStreamParent;
friend class StreamNotifyParent;
#if defined(XP_WIN)
public:
/**
* Helper method for looking up instances based on a supplied id.
*/
static PluginInstanceParent*
LookupPluginInstanceByID(uintptr_t aId);
#endif // defined(XP_WIN)
public:
PluginInstanceParent(PluginModuleParent* parent,
NPP npp,
const nsCString& mimeType,
const NPNetscapeFuncs* npniface);
virtual ~PluginInstanceParent();
bool InitMetadata(const nsACString& aMimeType,
const nsACString& aSrcAttribute);
NPError Destroy();
virtual void ActorDestroy(ActorDestroyReason why) override;
virtual PPluginScriptableObjectParent*
AllocPPluginScriptableObjectParent() override;
virtual bool
RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectParent* aActor) override;
virtual bool
DeallocPPluginScriptableObjectParent(PPluginScriptableObjectParent* aObject) override;
virtual PBrowserStreamParent*
AllocPBrowserStreamParent(const nsCString& url,
const uint32_t& length,
const uint32_t& lastmodified,
PStreamNotifyParent* notifyData,
const nsCString& headers) override;
virtual bool
DeallocPBrowserStreamParent(PBrowserStreamParent* stream) override;
virtual PPluginStreamParent*
AllocPPluginStreamParent(const nsCString& mimeType,
const nsCString& target,
NPError* result) override;
virtual bool
DeallocPPluginStreamParent(PPluginStreamParent* stream) override;
virtual bool
AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle* value,
NPError* result) override;
virtual bool
AnswerNPN_GetValue_NPNVWindowNPObject(
PPluginScriptableObjectParent** value,
NPError* result) override;
virtual bool
AnswerNPN_GetValue_NPNVPluginElementNPObject(
PPluginScriptableObjectParent** value,
NPError* result) override;
virtual bool
AnswerNPN_GetValue_NPNVprivateModeBool(bool* value, NPError* result) override;
virtual bool
AnswerNPN_GetValue_DrawingModelSupport(const NPNVariable& model, bool* value) override;
virtual bool
AnswerNPN_GetValue_NPNVdocumentOrigin(nsCString* value, NPError* result) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginWindow(const bool& windowed, NPError* result) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginTransparent(const bool& transparent,
NPError* result) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginUsesDOMForCursor(const bool& useDOMForCursor,
NPError* result) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginDrawingModel(const int& drawingModel,
NPError* result) override;
virtual bool
AnswerNPN_SetValue_NPPVpluginEventModel(const int& eventModel,
NPError* result) override;
virtual bool
AnswerNPN_GetURL(const nsCString& url, const nsCString& target,
NPError *result) override;
virtual bool
AnswerNPN_PostURL(const nsCString& url, const nsCString& target,
const nsCString& buffer, const bool& file,
NPError* result) override;
virtual PStreamNotifyParent*
AllocPStreamNotifyParent(const nsCString& url, const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result) override;
virtual bool
AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
const nsCString& url,
const nsCString& target,
const bool& post, const nsCString& buffer,
const bool& file,
NPError* result) override;
virtual bool
DeallocPStreamNotifyParent(PStreamNotifyParent* notifyData) override;
virtual bool
RecvNPN_InvalidateRect(const NPRect& rect) override;
// Async rendering
virtual bool
RecvShow(const NPRect& updatedRect,
const SurfaceDescriptor& newSurface,
SurfaceDescriptor* prevSurface) override;
virtual PPluginSurfaceParent*
AllocPPluginSurfaceParent(const WindowsSharedMemoryHandle& handle,
const gfxIntSize& size,
const bool& transparent) override;
virtual bool
DeallocPPluginSurfaceParent(PPluginSurfaceParent* s) override;
virtual bool
AnswerNPN_PushPopupsEnabledState(const bool& aState) override;
virtual bool
AnswerNPN_PopPopupsEnabledState() override;
virtual bool
AnswerNPN_GetValueForURL(const NPNURLVariable& variable,
const nsCString& url,
nsCString* value, NPError* result) override;
virtual bool
AnswerNPN_SetValueForURL(const NPNURLVariable& variable,
const nsCString& url,
const nsCString& value, NPError* result) override;
virtual bool
AnswerNPN_GetAuthenticationInfo(const nsCString& protocol,
const nsCString& host,
const int32_t& port,
const nsCString& scheme,
const nsCString& realm,
nsCString* username,
nsCString* password,
NPError* result) override;
virtual bool
AnswerNPN_ConvertPoint(const double& sourceX,
const bool& ignoreDestX,
const double& sourceY,
const bool& ignoreDestY,
const NPCoordinateSpace& sourceSpace,
const NPCoordinateSpace& destSpace,
double *destX,
double *destY,
bool *result) override;
virtual bool
RecvRedrawPlugin() override;
virtual bool
RecvNegotiatedCarbon() override;
virtual bool
RecvAsyncNPP_NewResult(const NPError& aResult) override;
virtual bool
RecvSetNetscapeWindowAsParent(const NativeWindowHandle& childWindow) override;
NPError NPP_SetWindow(const NPWindow* aWindow);
NPError NPP_GetValue(NPPVariable variable, void* retval);
NPError NPP_SetValue(NPNVariable variable, void* value);
void NPP_URLRedirectNotify(const char* url, int32_t status,
void* notifyData);
NPError NPP_NewStream(NPMIMEType type, NPStream* stream,
NPBool seekable, uint16_t* stype);
NPError NPP_DestroyStream(NPStream* stream, NPReason reason);
void NPP_Print(NPPrint* platformPrint);
int16_t NPP_HandleEvent(void* event);
void NPP_URLNotify(const char* url, NPReason reason, void* notifyData);
PluginModuleParent* Module()
{
return mParent;
}
const NPNetscapeFuncs* GetNPNIface()
{
return mNPNIface;
}
bool
RegisterNPObjectForActor(NPObject* aObject,
PluginScriptableObjectParent* aActor);
void
UnregisterNPObject(NPObject* aObject);
PluginScriptableObjectParent*
GetActorForNPObject(NPObject* aObject);
NPP
GetNPP()
{
return mNPP;
}
bool
UseSurrogate() const
{
return mUseSurrogate;
}
void
GetSrcAttribute(nsACString& aOutput) const
{
aOutput = mSrcAttribute;
}
/**
* This function tells us whether this plugin instance would have been
* whitelisted for Shumway if Shumway had been enabled. This is being used
* for the purpose of gathering telemetry on Flash hangs that could
* potentially be avoided by using Shumway instead.
*/
bool
IsWhitelistedForShumway() const
{
return mIsWhitelistedForShumway;
}
virtual bool
AnswerPluginFocusChange(const bool& gotFocus) override;
nsresult AsyncSetWindow(NPWindow* window);
nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer);
nsresult GetImageSize(nsIntSize* aSize);
#ifdef XP_MACOSX
nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing);
nsresult ContentsScaleFactorChanged(double aContentsScaleFactor);
#endif
nsresult SetBackgroundUnknown();
nsresult BeginUpdateBackground(const nsIntRect& aRect,
gfxContext** aCtx);
nsresult EndUpdateBackground(gfxContext* aCtx,
const nsIntRect& aRect);
void DidComposite() { unused << SendNPP_DidComposite(); }
virtual PluginAsyncSurrogate* GetAsyncSurrogate() override;
virtual PluginInstanceParent* GetInstance() override { return this; }
static PluginInstanceParent* Cast(NPP instance,
PluginAsyncSurrogate** aSurrogate = nullptr);
private:
// Create an appropriate platform surface for a background of size
// |aSize|. Return true if successful.
bool CreateBackground(const nsIntSize& aSize);
void DestroyBackground();
SurfaceDescriptor BackgroundDescriptor() /*const*/;
typedef mozilla::layers::ImageContainer ImageContainer;
ImageContainer *GetImageContainer();
virtual PPluginBackgroundDestroyerParent*
AllocPPluginBackgroundDestroyerParent() override;
virtual bool
DeallocPPluginBackgroundDestroyerParent(PPluginBackgroundDestroyerParent* aActor) override;
bool InternalGetValueForNPObject(NPNVariable aVariable,
PPluginScriptableObjectParent** aValue,
NPError* aResult);
nsPluginInstanceOwner* GetOwner();
private:
PluginModuleParent* mParent;
nsRefPtr<PluginAsyncSurrogate> mSurrogate;
bool mUseSurrogate;
NPP mNPP;
const NPNetscapeFuncs* mNPNIface;
nsCString mSrcAttribute;
bool mIsWhitelistedForShumway;
NPWindowType mWindowType;
int16_t mDrawingModel;
nsDataHashtable<nsPtrHashKey<NPObject>, PluginScriptableObjectParent*> mScriptableObjects;
#if defined(OS_WIN)
private:
// Used in rendering windowless plugins in other processes.
bool SharedSurfaceSetWindow(const NPWindow* aWindow, NPRemoteWindow& aRemoteWindow);
void SharedSurfaceBeforePaint(RECT &rect, NPRemoteEvent& npremoteevent);
void SharedSurfaceAfterPaint(NPEvent* npevent);
void SharedSurfaceRelease();
// Used in handling parent/child forwarding of events.
static LRESULT CALLBACK PluginWindowHookProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void SubclassPluginWindow(HWND aWnd);
void UnsubclassPluginWindow();
bool MaybeCreateAndParentChildPluginWindow();
void MaybeCreateChildPopupSurrogate();
private:
gfx::SharedDIBWin mSharedSurfaceDib;
nsIntRect mPluginPort;
nsIntRect mSharedSize;
HWND mPluginHWND;
// This is used for the normal child plugin HWND for windowed plugins and,
// if needed, also the child popup surrogate HWND for windowless plugins.
HWND mChildPluginHWND;
HWND mChildPluginsParentHWND;
WNDPROC mPluginWndProc;
bool mNestedEventState;
// This will automatically release the textures when this object goes away.
nsRefPtrHashtable<nsPtrHashKey<void>, ID3D10Texture2D> mTextureMap;
#endif // defined(XP_WIN)
#if defined(MOZ_WIDGET_COCOA)
private:
Shmem mShSurface;
uint16_t mShWidth;
uint16_t mShHeight;
CGColorSpaceRef mShColorSpace;
RefPtr<MacIOSurface> mIOSurface;
RefPtr<MacIOSurface> mFrontIOSurface;
#endif // definied(MOZ_WIDGET_COCOA)
// ObjectFrame layer wrapper
nsRefPtr<gfxASurface> mFrontSurface;
// For windowless+transparent instances, this surface contains a
// "pretty recent" copy of the pixels under its <object> frame.
// On the plugin side, we use this surface to avoid doing alpha
// recovery when possible. This surface is created and owned by
// the browser, but a "read-only" reference is sent to the plugin.
//
// We have explicitly chosen not to provide any guarantees about
// the consistency of the pixels in |mBackground|. A plugin may
// be able to observe partial updates to the background.
nsRefPtr<gfxASurface> mBackground;
nsRefPtr<ImageContainer> mImageContainer;
};
} // namespace plugins
} // namespace mozilla
#endif // ifndef dom_plugins_PluginInstanceParent_h