2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/* rendering objects for replaced elements implemented by a plugin */
|
|
|
|
|
2000-04-14 22:48:30 +00:00
|
|
|
#ifndef nsObjectFrame_h___
|
|
|
|
#define nsObjectFrame_h___
|
|
|
|
|
2011-06-01 04:37:54 +00:00
|
|
|
#include "nsPluginInstanceOwner.h"
|
2001-02-19 21:50:04 +00:00
|
|
|
#include "nsIObjectFrame.h"
|
2006-02-02 19:29:10 +00:00
|
|
|
#include "nsFrame.h"
|
2009-07-22 00:45:00 +00:00
|
|
|
#include "nsRegion.h"
|
|
|
|
#include "nsDisplayList.h"
|
2010-09-08 00:36:59 +00:00
|
|
|
#include "nsIReflowCallback.h"
|
2010-09-17 04:09:25 +00:00
|
|
|
#include "Layers.h"
|
|
|
|
#include "ImageLayers.h"
|
2000-04-14 22:48:30 +00:00
|
|
|
|
2002-05-10 22:34:53 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
class nsIAccessible;
|
|
|
|
#endif
|
|
|
|
|
2011-04-28 20:08:33 +00:00
|
|
|
class nsPluginHost;
|
2006-02-02 19:29:10 +00:00
|
|
|
class nsPresContext;
|
2009-07-22 00:45:00 +00:00
|
|
|
class nsDisplayPlugin;
|
2011-02-12 16:09:03 +00:00
|
|
|
class nsIOSurface;
|
2011-02-16 22:43:30 +00:00
|
|
|
class PluginBackgroundSink;
|
2000-04-14 22:48:30 +00:00
|
|
|
|
2005-12-31 00:25:36 +00:00
|
|
|
#define nsObjectFrameSuper nsFrame
|
2000-04-14 22:48:30 +00:00
|
|
|
|
2010-09-08 00:36:59 +00:00
|
|
|
class nsObjectFrame : public nsObjectFrameSuper,
|
|
|
|
public nsIObjectFrame,
|
|
|
|
public nsIReflowCallback {
|
2000-04-14 22:48:30 +00:00
|
|
|
public:
|
2010-09-17 04:09:25 +00:00
|
|
|
typedef mozilla::LayerState LayerState;
|
|
|
|
typedef mozilla::layers::Layer Layer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
typedef mozilla::layers::ImageContainer ImageContainer;
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
friend nsIFrame* NS_NewObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2001-02-19 21:50:04 +00:00
|
|
|
|
2006-03-09 18:55:21 +00:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
2005-01-05 00:21:06 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
2011-04-08 01:04:40 +00:00
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
|
2005-01-05 00:21:06 +00:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2000-04-14 22:48:30 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2005-01-05 00:21:06 +00:00
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
NS_IMETHOD DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus);
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
|
2005-01-05 00:21:06 +00:00
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
2000-04-14 22:48:30 +00:00
|
|
|
|
2010-01-22 20:57:04 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
NS_IMETHOD HandlePress(nsPresContext* aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus* aEventStatus);
|
|
|
|
#endif
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
virtual nsIAtom* GetType() const;
|
2007-02-24 18:33:33 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool IsFrameOfType(PRUint32 aFlags) const
|
2007-02-24 18:33:33 +00:00
|
|
|
{
|
|
|
|
return nsObjectFrameSuper::IsFrameOfType(aFlags & ~(nsIFrame::eReplaced));
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool NeedsView() { return true; }
|
2003-04-10 17:22:24 +00:00
|
|
|
|
2000-04-14 22:48:30 +00:00
|
|
|
#ifdef DEBUG
|
2001-11-14 01:33:42 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
2000-04-14 22:48:30 +00:00
|
|
|
#endif
|
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
2000-04-14 22:48:30 +00:00
|
|
|
|
2008-10-26 10:11:34 +00:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
|
2007-10-19 03:41:07 +00:00
|
|
|
|
2011-05-18 01:48:34 +00:00
|
|
|
NS_METHOD GetPluginInstance(nsNPAPIPluginInstance** aPluginInstance);
|
2001-02-19 21:50:04 +00:00
|
|
|
|
2012-01-31 21:55:54 +00:00
|
|
|
virtual void SetIsDocumentActive(bool aIsActive);
|
2011-08-30 06:09:56 +00:00
|
|
|
|
2011-04-08 19:58:04 +00:00
|
|
|
NS_IMETHOD GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor);
|
2002-01-26 00:39:43 +00:00
|
|
|
|
2009-07-22 00:45:00 +00:00
|
|
|
// Compute the desired position of the plugin's widget, on the assumption
|
|
|
|
// that it is not visible (clipped out or covered by opaque content).
|
|
|
|
// This will only be called for plugins which have been registered
|
|
|
|
// with the root pres context for geometry updates.
|
|
|
|
// The widget, its new position, size and (empty) clip region are appended
|
|
|
|
// as a Configuration record to aConfigurations.
|
|
|
|
// If there is no widget associated with the plugin, this
|
|
|
|
// simply does nothing.
|
|
|
|
void GetEmptyClipConfiguration(nsTArray<nsIWidget::Configuration>* aConfigurations) {
|
|
|
|
ComputeWidgetGeometry(nsRegion(), nsPoint(0,0), aConfigurations);
|
|
|
|
}
|
|
|
|
|
2009-07-22 00:45:02 +00:00
|
|
|
void DidSetWidgetGeometry();
|
|
|
|
|
2002-05-10 22:34:53 +00:00
|
|
|
// accessibility support
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-05-29 01:18:45 +00:00
|
|
|
virtual already_AddRefed<Accessible> CreateAccessible();
|
2002-05-10 22:34:53 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
NS_IMETHOD GetPluginPort(HWND *aPort);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2000-04-14 22:48:30 +00:00
|
|
|
//local methods
|
2012-01-31 21:55:54 +00:00
|
|
|
nsresult PrepForDrawing(nsIWidget *aWidget);
|
2005-01-05 00:21:06 +00:00
|
|
|
|
2001-09-18 02:11:09 +00:00
|
|
|
// for a given aRoot, this walks the frame tree looking for the next outFrame
|
2004-07-31 23:15:21 +00:00
|
|
|
static nsIObjectFrame* GetNextObjectFrame(nsPresContext* aPresContext,
|
2004-02-09 17:33:45 +00:00
|
|
|
nsIFrame* aRoot);
|
2001-09-18 02:11:09 +00:00
|
|
|
|
2010-09-08 00:36:59 +00:00
|
|
|
// nsIReflowCallback
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool ReflowFinished();
|
2010-09-08 00:36:59 +00:00
|
|
|
virtual void ReflowCallbackCanceled();
|
|
|
|
|
2012-02-08 15:34:27 +00:00
|
|
|
void UpdateImageLayer(const gfxRect& aRect);
|
2011-02-17 03:56:06 +00:00
|
|
|
|
2011-02-16 22:43:30 +00:00
|
|
|
/**
|
|
|
|
* Builds either an ImageLayer or a ReadbackLayer, depending on the type
|
|
|
|
* of aItem (TYPE_PLUGIN or TYPE_PLUGIN_READBACK respectively).
|
|
|
|
*/
|
2010-09-17 04:09:25 +00:00
|
|
|
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager,
|
|
|
|
nsDisplayItem* aItem);
|
|
|
|
|
2012-05-03 14:05:55 +00:00
|
|
|
LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
|
|
|
LayerManager* aManager);
|
2010-09-17 04:09:25 +00:00
|
|
|
|
2012-02-01 02:18:30 +00:00
|
|
|
already_AddRefed<ImageContainer> GetImageContainer();
|
2011-02-23 05:38:09 +00:00
|
|
|
/**
|
|
|
|
* Get the rectangle (relative to this frame) which it will paint. Normally
|
|
|
|
* the frame's content-box but may be smaller if the plugin is rendering
|
|
|
|
* asynchronously and has a different-sized image temporarily.
|
|
|
|
*/
|
|
|
|
nsRect GetPaintedRect(nsDisplayPlugin* aItem);
|
2010-09-17 04:09:25 +00:00
|
|
|
|
2010-09-18 11:28:49 +00:00
|
|
|
/**
|
|
|
|
* If aContent has a nsObjectFrame, then prepare it for a DocShell swap.
|
|
|
|
* @see nsSubDocumentFrame::BeginSwapDocShells.
|
|
|
|
* There will be a call to EndSwapDocShells after we were moved to the
|
|
|
|
* new view tree.
|
|
|
|
*/
|
|
|
|
static void BeginSwapDocShells(nsIContent* aContent, void*);
|
|
|
|
/**
|
|
|
|
* If aContent has a nsObjectFrame, then set it up after a DocShell swap.
|
|
|
|
* @see nsSubDocumentFrame::EndSwapDocShells.
|
|
|
|
*/
|
|
|
|
static void EndSwapDocShells(nsIContent* aContent, void*);
|
|
|
|
|
2012-03-23 18:21:57 +00:00
|
|
|
bool PaintedByGecko();
|
|
|
|
|
2012-07-06 00:45:23 +00:00
|
|
|
nsIWidget* GetWidget() { return mInnerView ? mWidget : nsnull; }
|
2011-03-31 21:33:46 +00:00
|
|
|
|
2011-08-30 06:09:56 +00:00
|
|
|
/**
|
|
|
|
* Adjust the plugin's idea of its size, using aSize as its new size.
|
|
|
|
* (aSize must be in twips)
|
|
|
|
*/
|
|
|
|
void FixupWindow(const nsSize& aSize);
|
|
|
|
|
2012-01-31 21:55:54 +00:00
|
|
|
/*
|
2011-08-30 06:09:56 +00:00
|
|
|
* Sets up the plugin window and calls SetWindow on the plugin.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult CallSetWindow(bool aCheckIsHidden = true);
|
2011-08-30 06:09:56 +00:00
|
|
|
|
2012-01-31 21:55:54 +00:00
|
|
|
void SetInstanceOwner(nsPluginInstanceOwner* aOwner);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsObjectFrame(nsStyleContext* aContext);
|
|
|
|
virtual ~nsObjectFrame();
|
|
|
|
|
|
|
|
// NOTE: This frame class does not inherit from |nsLeafFrame|, so
|
|
|
|
// this is not a virtual method implementation.
|
|
|
|
void GetDesiredSize(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsFocusable(PRInt32 *aTabIndex = nsnull, bool aWithMouse = false);
|
2005-03-31 01:38:04 +00:00
|
|
|
|
2002-04-13 01:53:23 +00:00
|
|
|
// check attributes and optionally CSS to see if we should display anything
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsHidden(bool aCheckVisibilityStyle = true) const;
|
2000-07-19 23:46:43 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsOpaque() const;
|
|
|
|
bool IsTransparentMode() const;
|
2009-07-22 00:45:00 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
nsIntPoint GetWindowOriginInPixels(bool aWindowless);
|
2001-12-22 00:00:44 +00:00
|
|
|
|
2008-07-07 02:49:38 +00:00
|
|
|
static void PaintPrintPlugin(nsIFrame* aFrame,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2008-07-07 02:49:38 +00:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt);
|
2011-04-08 01:04:40 +00:00
|
|
|
void PrintPlugin(nsRenderingContext& aRenderingContext,
|
2008-07-07 02:49:38 +00:00
|
|
|
const nsRect& aDirtyRect);
|
2010-10-25 14:38:09 +00:00
|
|
|
void PaintPlugin(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2009-09-11 01:44:20 +00:00
|
|
|
const nsRect& aDirtyRect, const nsRect& aPluginRect);
|
2008-07-07 02:49:38 +00:00
|
|
|
|
2009-07-22 00:45:00 +00:00
|
|
|
/**
|
|
|
|
* Get the widget geometry for the plugin. aRegion is in some appunits
|
|
|
|
* coordinate system whose origin is device-pixel-aligned (if possible),
|
2009-09-11 01:44:20 +00:00
|
|
|
* and aPluginOrigin gives the top-left of the plugin frame's content-rect
|
|
|
|
* in that coordinate system. It doesn't matter what that coordinate
|
|
|
|
* system actually is, as long as aRegion and aPluginOrigin are consistent.
|
2009-07-22 00:45:00 +00:00
|
|
|
* This will append a Configuration object to aConfigurations
|
|
|
|
* containing the widget, its desired position, size and clip region.
|
|
|
|
*/
|
|
|
|
void ComputeWidgetGeometry(const nsRegion& aRegion,
|
|
|
|
const nsPoint& aPluginOrigin,
|
|
|
|
nsTArray<nsIWidget::Configuration>* aConfigurations);
|
|
|
|
|
2010-01-21 15:17:52 +00:00
|
|
|
void NotifyPluginReflowObservers();
|
2009-11-20 22:59:27 +00:00
|
|
|
|
2003-04-12 15:03:08 +00:00
|
|
|
friend class nsPluginInstanceOwner;
|
2009-07-22 00:45:00 +00:00
|
|
|
friend class nsDisplayPlugin;
|
2011-02-16 22:43:30 +00:00
|
|
|
friend class PluginBackgroundSink;
|
2009-07-22 00:45:00 +00:00
|
|
|
|
2000-04-14 22:48:30 +00:00
|
|
|
private:
|
2010-01-21 15:17:52 +00:00
|
|
|
|
|
|
|
class PluginEventNotifier : public nsRunnable {
|
|
|
|
public:
|
|
|
|
PluginEventNotifier(const nsString &aEventType) :
|
|
|
|
mEventType(aEventType) {}
|
|
|
|
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
private:
|
|
|
|
nsString mEventType;
|
|
|
|
};
|
2012-01-31 21:55:54 +00:00
|
|
|
|
|
|
|
nsPluginInstanceOwner* mInstanceOwner; // WEAK
|
2009-09-11 01:44:20 +00:00
|
|
|
nsIView* mInnerView;
|
2009-07-22 00:45:00 +00:00
|
|
|
nsCOMPtr<nsIWidget> mWidget;
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntRect mWindowlessRect;
|
2011-02-16 22:43:30 +00:00
|
|
|
/**
|
|
|
|
* This is owned by the ReadbackLayer for this nsObjectFrame. It is
|
|
|
|
* automatically cleared if the PluginBackgroundSink is destroyed.
|
|
|
|
*/
|
|
|
|
PluginBackgroundSink* mBackgroundSink;
|
2005-04-14 21:50:46 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mReflowCallbackPosted;
|
2010-09-17 04:09:25 +00:00
|
|
|
|
|
|
|
// A reference to the ImageContainer which contains the current frame
|
|
|
|
// of plugin to display.
|
|
|
|
nsRefPtr<ImageContainer> mImageContainer;
|
2000-04-14 22:48:30 +00:00
|
|
|
};
|
|
|
|
|
2009-07-22 00:45:00 +00:00
|
|
|
class nsDisplayPlugin : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayPlugin(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame)
|
2009-07-22 00:45:00 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayPlugin);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayPlugin() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayPlugin);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-10 11:24:18 +00:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap);
|
2011-01-03 01:48:09 +00:00
|
|
|
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
|
2012-05-03 04:29:05 +00:00
|
|
|
bool* aSnap);
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aCtx);
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool ComputeVisibility(nsDisplayListBuilder* aBuilder,
|
2011-01-27 22:58:50 +00:00
|
|
|
nsRegion* aVisibleRegion,
|
2011-05-13 16:40:46 +00:00
|
|
|
const nsRect& aAllowVisibleRegionExpansion);
|
2009-07-22 00:45:00 +00:00
|
|
|
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("Plugin", TYPE_PLUGIN)
|
2009-07-22 00:45:00 +00:00
|
|
|
|
|
|
|
// Compute the desired position and clip region of the plugin's widget.
|
|
|
|
// This will only be called for plugins which have been registered
|
|
|
|
// with the root pres context for geometry updates.
|
|
|
|
// The widget, its new position, size and clip region are appended as
|
|
|
|
// a Configuration record to aConfigurations.
|
2011-03-31 21:33:46 +00:00
|
|
|
// If the plugin has no widget, no configuration is added, but
|
|
|
|
// the plugin visibility state may be adjusted.
|
2009-07-22 00:45:00 +00:00
|
|
|
void GetWidgetConfiguration(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsTArray<nsIWidget::Configuration>* aConfigurations);
|
|
|
|
|
2010-09-17 04:09:25 +00:00
|
|
|
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
|
2011-06-22 12:11:27 +00:00
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aContainerParameters)
|
2010-09-17 04:09:25 +00:00
|
|
|
{
|
2011-02-12 16:09:03 +00:00
|
|
|
return static_cast<nsObjectFrame*>(mFrame)->BuildLayer(aBuilder,
|
|
|
|
aManager,
|
|
|
|
this);
|
2010-09-17 04:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
|
2012-05-03 14:05:55 +00:00
|
|
|
LayerManager* aManager,
|
|
|
|
const ContainerParameters& aParameters)
|
2010-09-17 04:09:25 +00:00
|
|
|
{
|
2011-02-16 22:43:30 +00:00
|
|
|
return static_cast<nsObjectFrame*>(mFrame)->GetLayerState(aBuilder,
|
|
|
|
aManager);
|
2010-09-17 04:09:25 +00:00
|
|
|
}
|
|
|
|
|
2009-07-22 00:45:00 +00:00
|
|
|
private:
|
|
|
|
nsRegion mVisibleRegion;
|
|
|
|
};
|
2000-04-14 22:48:30 +00:00
|
|
|
|
|
|
|
#endif /* nsObjectFrame_h___ */
|