1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* rendering objects for replaced elements implemented by a plugin */
40 #ifndef nsObjectFrame_h___
41 #define nsObjectFrame_h___
47 #include "nsIObjectFrame.h"
54 class nsPluginInstanceOwner
;
56 class nsIPluginInstance
;
59 #define nsObjectFrameSuper nsFrame
61 class nsObjectFrame
: public nsObjectFrameSuper
, public nsIObjectFrame
{
63 friend nsIFrame
* NS_NewObjectFrame(nsIPresShell
* aPresShell
, nsStyleContext
* aContext
);
66 NS_IMETHOD
QueryInterface(const nsIID
& aIID
, void** aInstancePtr
);
68 NS_IMETHOD
Init(nsIContent
* aContent
,
70 nsIFrame
* aPrevInFlow
);
71 virtual nscoord
GetMinWidth(nsIRenderingContext
*aRenderingContext
);
72 virtual nscoord
GetPrefWidth(nsIRenderingContext
*aRenderingContext
);
73 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
74 nsHTMLReflowMetrics
& aDesiredSize
,
75 const nsHTMLReflowState
& aReflowState
,
76 nsReflowStatus
& aStatus
);
77 NS_IMETHOD
DidReflow(nsPresContext
* aPresContext
,
78 const nsHTMLReflowState
* aReflowState
,
79 nsDidReflowStatus aStatus
);
80 NS_IMETHOD
BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
81 const nsRect
& aDirtyRect
,
82 const nsDisplayListSet
& aLists
);
84 NS_IMETHOD
HandleEvent(nsPresContext
* aPresContext
,
86 nsEventStatus
* aEventStatus
);
88 virtual nsIAtom
* GetType() const;
90 virtual PRBool
IsFrameOfType(PRUint32 aFlags
) const
92 return nsObjectFrameSuper::IsFrameOfType(aFlags
& ~(nsIFrame::eReplaced
));
95 virtual PRBool
SupportsVisibilityHidden() { return PR_FALSE
; }
96 virtual PRBool
NeedsView() { return PR_TRUE
; }
97 virtual nsresult
CreateWidgetForView(nsIView
* aView
);
100 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const;
103 virtual void Destroy();
105 NS_IMETHOD
DidSetStyleContext();
107 NS_IMETHOD
GetPluginInstance(nsIPluginInstance
*& aPluginInstance
);
108 virtual nsresult
Instantiate(nsIChannel
* aChannel
, nsIStreamListener
** aStreamListener
);
109 virtual nsresult
Instantiate(const char* aMimeType
, nsIURI
* aURI
);
110 virtual void TryNotifyContentObjectWrapper();
111 virtual void StopPlugin();
114 * Stop a plugin instance. If aDelayedStop is true, the plugin will
115 * be stopped at a later point when it's safe to do so (i.e. not
116 * while destroying the frame tree). Delayed stopping is only
117 * implemented on Win32 for now.
119 void StopPluginInternal(PRBool aDelayedStop
);
121 /* fail on any requests to get a cursor from us because plugins set their own! see bug 118877 */
122 NS_IMETHOD
GetCursor(const nsPoint
& aPoint
, nsIFrame::Cursor
& aCursor
)
124 return NS_ERROR_NOT_IMPLEMENTED
;
127 // accessibility support
129 NS_IMETHOD
GetAccessible(nsIAccessible
** aAccessible
);
131 NS_IMETHOD
GetPluginPort(HWND
*aPort
);
136 nsresult
CreateWidget(nscoord aWidth
, nscoord aHeight
, PRBool aViewOnly
);
138 // for a given aRoot, this walks the frame tree looking for the next outFrame
139 static nsIObjectFrame
* GetNextObjectFrame(nsPresContext
* aPresContext
,
144 NS_IMETHOD_(nsrefcnt
) AddRef(void);
145 NS_IMETHOD_(nsrefcnt
) Release(void);
147 nsObjectFrame(nsStyleContext
* aContext
);
148 virtual ~nsObjectFrame();
150 // NOTE: This frame class does not inherit from |nsLeafFrame|, so
151 // this is not a virtual method implementation.
152 void GetDesiredSize(nsPresContext
* aPresContext
,
153 const nsHTMLReflowState
& aReflowState
,
154 nsHTMLReflowMetrics
& aDesiredSize
);
156 nsresult
InstantiatePlugin(nsIPluginHost
* aPluginHost
,
157 const char* aMimetype
,
161 * Adjust the plugin's idea of its size, using aSize as its new size.
162 * (aSize must be in twips)
164 void FixupWindow(const nsSize
& aSize
);
167 * Sets up the plugin window and calls SetWindow on the plugin.
169 void CallSetWindow();
171 PRBool
IsFocusable(PRInt32
*aTabIndex
= nsnull
, PRBool aWithMouse
= PR_FALSE
);
173 // check attributes and optionally CSS to see if we should display anything
174 PRBool
IsHidden(PRBool aCheckVisibilityStyle
= PR_TRUE
) const;
176 void NotifyContentObjectWrapper();
178 nsPoint
GetWindowOriginInPixels(PRBool aWindowless
);
180 static void PaintPrintPlugin(nsIFrame
* aFrame
,
181 nsIRenderingContext
* aRenderingContext
,
182 const nsRect
& aDirtyRect
, nsPoint aPt
);
183 static void PaintPlugin(nsIFrame
* aFrame
,
184 nsIRenderingContext
* aRenderingContext
,
185 const nsRect
& aDirtyRect
, nsPoint aPt
);
186 void PrintPlugin(nsIRenderingContext
& aRenderingContext
,
187 const nsRect
& aDirtyRect
);
188 void PaintPlugin(nsIRenderingContext
& aRenderingContext
,
189 const nsRect
& aDirtyRect
, const nsPoint
& aFramePt
);
192 * Makes sure that mInstanceOwner is valid and without a current plugin
193 * instance. Essentially, this prepares the frame to receive a new plugin.
195 NS_HIDDEN_(nsresult
) PrepareInstanceOwner();
197 friend class nsPluginInstanceOwner
;
199 nsRefPtr
<nsPluginInstanceOwner
> mInstanceOwner
;
200 nsRect mWindowlessRect
;
202 // For assertions that make it easier to determine if a crash is due
203 // to the underlying problem described in bug 136927, and to prevent
204 // reentry into instantiation.
205 PRBool mPreventInstantiation
;
209 #endif /* nsObjectFrame_h___ */