Back to index

lightning-sunbird  0.9+nobinonly
nsImageBoxFrame.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 Communicator client 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 nsImageBoxFrame_h___
00038 #define nsImageBoxFrame_h___
00039 
00040 #include "nsLeafBoxFrame.h"
00041 
00042 #include "imgILoader.h"
00043 #include "imgIRequest.h"
00044 #include "imgIContainer.h"
00045 #include "imgIDecoderObserver.h"
00046 
00047 class nsImageBoxFrame;
00048 
00049 class nsImageBoxListener : public imgIDecoderObserver
00050 {
00051 public:
00052   nsImageBoxListener();
00053   virtual ~nsImageBoxListener();
00054 
00055   NS_DECL_ISUPPORTS
00056   NS_DECL_IMGIDECODEROBSERVER
00057   NS_DECL_IMGICONTAINEROBSERVER
00058 
00059   void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
00060 
00061 private:
00062   nsImageBoxFrame *mFrame;
00063 };
00064 
00065 class nsImageBoxFrame : public nsLeafBoxFrame
00066 {
00067 public:
00068 
00069   // nsIBox
00070   NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00071   NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
00072   NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
00073   NS_IMETHOD NeedsRecalc();
00074 
00075   friend nsresult NS_NewImageBoxFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00076 
00077   // nsIBox frame interface
00078 
00079   NS_IMETHOD  Init(nsPresContext*  aPresContext,
00080                    nsIContent*      aContent,
00081                    nsIFrame*        aParent,
00082                    nsStyleContext*  aContext,
00083                    nsIFrame*        asPrevInFlow);
00084 
00085   NS_IMETHOD AttributeChanged(nsIContent* aChild,
00086                               PRInt32 aNameSpaceID,
00087                               nsIAtom* aAttribute,
00088                               PRInt32 aModType);
00089 
00090   NS_IMETHOD  DidSetStyleContext (nsPresContext* aPresContext);
00091 
00092   NS_IMETHOD Destroy(nsPresContext* aPresContext);
00093 
00094   virtual nsIAtom* GetType() const;
00095 #ifdef DEBUG
00096   NS_IMETHOD GetFrameName(nsAString& aResult) const;
00097 #endif
00098 
00104   void UpdateImage();
00105 
00110   void UpdateLoadFlags();
00111 
00112   NS_IMETHOD  Paint(nsPresContext*      aPresContext,
00113                     nsIRenderingContext& aRenderingContext,
00114                     const nsRect&        aDirtyRect,
00115                     nsFramePaintLayer    aWhichLayer,
00116                     PRUint32             aFlags = 0);
00117 
00118   NS_IMETHOD OnStartContainer(imgIRequest *request, imgIContainer *image);
00119   NS_IMETHOD OnStopContainer(imgIRequest *request, imgIContainer *image);
00120   NS_IMETHOD OnStopDecode(imgIRequest *request,
00121                           nsresult status,
00122                           const PRUnichar *statusArg);
00123   NS_IMETHOD FrameChanged(imgIContainer *container,
00124                           gfxIImageFrame *newframe,
00125                           nsRect * dirtyRect);
00126 
00127   virtual ~nsImageBoxFrame();
00128 protected:
00129 
00130   void  PaintImage(nsIRenderingContext& aRenderingContext,
00131                    const nsRect& aDirtyRect,
00132                    nsFramePaintLayer aWhichLayer);
00133 
00134   nsImageBoxFrame(nsIPresShell* aShell);
00135 
00136   virtual void GetImageSize();
00137 
00138 private:
00139 
00140   nsCOMPtr<imgIRequest> mImageRequest;
00141   nsCOMPtr<imgIDecoderObserver> mListener;
00142 
00143   PRPackedBool mUseSrcAttr; 
00144   PRPackedBool mSuppressStyleCheck;
00145   
00146   nsRect mSubRect; 
00147 
00148   nsSize mIntrinsicSize;
00149   PRInt32 mLoadFlags;
00150 
00151   nsSize mImageSize;
00152 }; // class nsImageBoxFrame
00153 
00154 #endif /* nsImageBoxFrame_h___ */