Back to index

lightning-sunbird  0.9+nobinonly
nsObjectFrame.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsObjectFrame_h___
00038 #define nsObjectFrame_h___
00039 
00040 #include "nsHTMLParts.h"
00041 #include "nsHTMLContainerFrame.h"
00042 #include "nsPresContext.h"
00043 #include "nsIPresShell.h"
00044 #include "nsIPluginHost.h"
00045 #include "nsplugin.h"
00046 #include "nsIWidget.h"
00047 #include "nsIObjectFrame.h"
00048 
00049 #ifdef ACCESSIBILITY
00050 class nsIAccessible;
00051 #endif
00052 
00053 class nsPluginInstanceOwner;
00054 
00055 #define nsObjectFrameSuper nsHTMLContainerFrame
00056 
00057 class nsObjectFrame : public nsObjectFrameSuper, public nsIObjectFrame {
00058 public:
00059   // nsISupports 
00060   NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
00061 
00062   NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
00063                                  nsIAtom* aListName,
00064                                  nsIFrame* aChildList);
00065   NS_IMETHOD Init(nsPresContext* aPresContext,
00066                   nsIContent* aContent,
00067                   nsIFrame* aParent,
00068                   nsStyleContext* aContext,
00069                   nsIFrame* aPrevInFlow);
00070   NS_IMETHOD Reflow(nsPresContext* aPresContext,
00071                     nsHTMLReflowMetrics& aDesiredSize,
00072                     const nsHTMLReflowState& aReflowState,
00073                     nsReflowStatus& aStatus);
00074   NS_IMETHOD DidReflow(nsPresContext* aPresContext,
00075                        const nsHTMLReflowState* aReflowState,
00076                        nsDidReflowStatus aStatus);
00077   NS_IMETHOD Paint(nsPresContext* aPresContext,
00078                    nsIRenderingContext& aRenderingContext,
00079                    const nsRect& aDirtyRect,
00080                    nsFramePaintLayer aWhichLayer,
00081                    PRUint32 aFlags = 0);
00082 
00083   NS_IMETHOD  HandleEvent(nsPresContext* aPresContext,
00084                           nsGUIEvent* aEvent,
00085                           nsEventStatus* aEventStatus);
00086 
00087   virtual nsIAtom* GetType() const;
00088   virtual PRBool SupportsVisibilityHidden() { return PR_FALSE; }
00089   virtual PRBool NeedsView() { return PR_TRUE; }
00090   virtual nsresult CreateWidgetForView(nsIView* aView);
00091 
00092   virtual PRBool IsLeaf() const;
00093   
00094 #ifdef DEBUG
00095   NS_IMETHOD GetFrameName(nsAString& aResult) const;
00096 #endif
00097 
00098   NS_IMETHOD Destroy(nsPresContext* aPresContext);
00099 
00100   NS_IMETHOD GetPluginInstance(nsIPluginInstance*& aPluginInstance);
00101 
00102   /* fail on any requests to get a cursor from us because plugins set their own! see bug 118877 */
00103   NS_IMETHOD GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor) 
00104   {
00105     return NS_ERROR_NOT_IMPLEMENTED;
00106   };
00107 
00108   //i18n helper
00109   nsresult MakeAbsoluteURL(nsIURI* *aFullURI, nsString aSrc,
00110                            nsIURI* aBaseURI);
00111   // accessibility support
00112 #ifdef ACCESSIBILITY
00113   NS_IMETHOD GetAccessible(nsIAccessible** aAccessible);
00114 #ifdef XP_WIN
00115   NS_IMETHOD GetPluginPort(HWND *aPort);
00116 #endif
00117 #endif
00118 
00119   //local methods
00120   nsresult CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly);
00121   nsIURI* GetFullURL()
00122   {
00123     return mFullURL;
00124   }
00125 
00130   NS_HIDDEN_(nsresult) GetMIMEType(nsACString& aType);
00131 
00132 
00133 
00134   // for a given aRoot, this walks the frame tree looking for the next outFrame
00135   static nsIObjectFrame* GetNextObjectFrame(nsPresContext* aPresContext,
00136                                             nsIFrame* aRoot);
00137 
00138   void FixUpURLS(const nsString &name, nsAString &value);
00139 
00140   void PluginNotAvailable(const char *aMimeType);
00141 
00142   // Returns true if this object frame links to content that we have
00143   // no enabled plugin for, that means not even the default plugin.
00144   PRBool IsBroken() const
00145   {
00146     return mIsBrokenPlugin;
00147   }
00148 
00149   virtual PRBool IsContainingBlock() const
00150   {
00151     // Broken plugins are containing blocks.
00152 
00153     return IsBroken();
00154   }
00155 
00156 protected:
00157   // nsISupports
00158   NS_IMETHOD_(nsrefcnt) AddRef(void);
00159   NS_IMETHOD_(nsrefcnt) Release(void);
00160 
00161   virtual ~nsObjectFrame();
00162 
00163   virtual PRIntn GetSkipSides() const;
00164 
00165   // NOTE:  This frame class does not inherit from |nsLeafFrame|, so
00166   // this is not a virtual method implementation.
00167   void GetDesiredSize(nsPresContext* aPresContext,
00168                       const nsHTMLReflowState& aReflowState,
00169                       nsHTMLReflowMetrics& aDesiredSize);
00170 
00171   nsresult InstantiateWidget(nsPresContext* aPresContext,
00172                              nsHTMLReflowMetrics& aMetrics,
00173                              const nsHTMLReflowState& aReflowState,
00174                              nsCID aWidgetCID);
00175 
00176   nsresult InstantiatePlugin(nsPresContext* aPresContext,
00177                              nsHTMLReflowMetrics& aMetrics,
00178                              const nsHTMLReflowState& aReflowState,
00179                              nsIPluginHost* aPluginHost, 
00180                              const char* aMimetype,
00181                              nsIURI* aURL);
00182 
00183   nsresult ReinstantiatePlugin(nsPresContext* aPresContext, 
00184                                nsHTMLReflowMetrics& aMetrics, 
00185                                const nsHTMLReflowState& aReflowState);
00186 
00187   nsresult HandleChild(nsPresContext* aPresContext,
00188                        nsHTMLReflowMetrics& aMetrics,
00189                        const nsHTMLReflowState& aReflowState,
00190                        nsReflowStatus& aStatus,
00191                        nsIFrame* child);
00192  
00193   PRBool IsFocusable(PRInt32 *aTabIndex = nsnull, PRBool aWithMouse = PR_FALSE);
00194 
00195   // check attributes and optionally CSS to see if we should display anything
00196   PRBool IsHidden(PRBool aCheckVisibilityStyle = PR_TRUE) const;
00197 
00198   void NotifyContentObjectWrapper();
00199 
00200   nsPoint GetWindowOriginInPixels(PRBool aWindowless);
00201 
00202   void CreateDefaultFrames(nsPresContext *aPresContext,
00203                            nsHTMLReflowMetrics& aMetrics,
00204                            const nsHTMLReflowState& aReflowState);
00205 
00206   friend class nsPluginInstanceOwner;
00207 private:
00208   nsPluginInstanceOwner *mInstanceOwner;
00209   nsCOMPtr<nsIURI>      mFullURL;
00210   nsIFrame              *mFirstChild;
00211   nsCOMPtr<nsIWidget>   mWidget;
00212   nsRect                mWindowlessRect;
00213 
00214 #ifdef DEBUG
00215   // For assertions that make it easier to determine if a crash is due
00216   // to the underlying problem described in bug 136927.
00217   PRBool mInstantiating;
00218 #endif
00219 
00220   PRPackedBool          mIsBrokenPlugin;
00221 };
00222 
00223 
00224 #endif /* nsObjectFrame_h___ */