2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifndef nsImageBoxFrame_h___
|
|
|
|
#define nsImageBoxFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsLeafBoxFrame.h"
|
|
|
|
|
|
|
|
#include "imgILoader.h"
|
|
|
|
#include "imgIRequest.h"
|
|
|
|
#include "imgIContainer.h"
|
2012-10-12 09:11:22 -07:00
|
|
|
#include "imgINotificationObserver.h"
|
2013-03-15 19:53:25 -07:00
|
|
|
#include "imgIOnloadBlocker.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-12 05:43:01 -07:00
|
|
|
class imgRequestProxy;
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsImageBoxFrame;
|
|
|
|
|
2012-09-24 13:29:14 -07:00
|
|
|
class nsDisplayXULImage;
|
|
|
|
|
2013-03-15 19:53:25 -07:00
|
|
|
class nsImageBoxListener : public imgINotificationObserver,
|
|
|
|
public imgIOnloadBlocker
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsImageBoxListener();
|
|
|
|
virtual ~nsImageBoxListener();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-10-12 09:11:22 -07:00
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
2013-03-15 19:53:25 -07:00
|
|
|
NS_DECL_IMGIONLOADBLOCKER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void SetFrame(nsImageBoxFrame *frame) { mFrame = frame; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsImageBoxFrame *mFrame;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsImageBoxFrame : public nsLeafBoxFrame
|
|
|
|
{
|
|
|
|
public:
|
2012-11-27 18:34:45 -08:00
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
|
2012-09-24 13:29:14 -07:00
|
|
|
friend class nsDisplayXULImage;
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
|
|
|
virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-10-12 09:11:22 -07:00
|
|
|
nsresult Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
friend nsIFrame* NS_NewImageBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-09-14 09:10:08 -07:00
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-12-23 21:21:15 -08:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2012-09-14 09:10:08 -07:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update mUseSrcAttr from appropriate content attributes or from
|
|
|
|
* style, throw away the current image, and load the appropriate
|
|
|
|
* image.
|
|
|
|
* */
|
|
|
|
void UpdateImage();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update mLoadFlags from content attributes. Does not attempt to reload the
|
|
|
|
* image using the new load flags.
|
|
|
|
*/
|
|
|
|
void UpdateLoadFlags();
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual ~nsImageBoxFrame();
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
void PaintImage(nsRenderingContext& aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect,
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPoint aPt, uint32_t aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-11-27 18:34:45 -08:00
|
|
|
already_AddRefed<mozilla::layers::ImageContainer> GetContainer(LayerManager* aManager);
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
nsImageBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext);
|
|
|
|
|
|
|
|
virtual void GetImageSize();
|
|
|
|
|
|
|
|
private:
|
2012-10-12 09:11:22 -07:00
|
|
|
nsresult OnStartContainer(imgIRequest *request, imgIContainer *image);
|
2012-10-12 09:11:22 -07:00
|
|
|
nsresult OnStopDecode(imgIRequest *request);
|
|
|
|
nsresult OnStopRequest(imgIRequest *request, nsresult status);
|
2012-10-12 09:11:22 -07:00
|
|
|
nsresult OnImageIsAnimated(imgIRequest* aRequest);
|
|
|
|
nsresult FrameChanged(imgIRequest *aRequest);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-05-12 03:13:09 -07:00
|
|
|
nsRect mSubRect; ///< If set, indicates that only the portion of the image specified by the rect should be used.
|
|
|
|
nsSize mIntrinsicSize;
|
|
|
|
nsSize mImageSize;
|
|
|
|
|
2011-11-09 13:39:16 -08:00
|
|
|
// Boolean variable to determine if the current image request has been
|
|
|
|
// registered with the refresh driver.
|
|
|
|
bool mRequestRegistered;
|
|
|
|
|
2012-10-12 05:43:01 -07:00
|
|
|
nsRefPtr<imgRequestProxy> mImageRequest;
|
2012-10-12 09:11:22 -07:00
|
|
|
nsCOMPtr<imgINotificationObserver> mListener;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mLoadFlags;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mUseSrcAttr; ///< Whether or not the image src comes from an attribute.
|
|
|
|
bool mSuppressStyleCheck;
|
2013-03-15 19:53:25 -07:00
|
|
|
bool mFireEventOnDecode;
|
2007-03-22 10:30:00 -07:00
|
|
|
}; // class nsImageBoxFrame
|
|
|
|
|
2012-09-24 13:29:14 -07:00
|
|
|
class nsDisplayXULImage : public nsDisplayImageContainer {
|
|
|
|
public:
|
|
|
|
nsDisplayXULImage(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsImageBoxFrame* aFrame) :
|
|
|
|
nsDisplayImageContainer(aBuilder, aFrame) {
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayXULImage);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayXULImage() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayXULImage);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-27 18:34:45 -08:00
|
|
|
virtual already_AddRefed<ImageContainer> GetContainer(LayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE;
|
2012-09-24 13:29:14 -07:00
|
|
|
virtual void ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset) MOZ_OVERRIDE;
|
2012-11-13 11:56:47 -08:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap)
|
|
|
|
{
|
|
|
|
*aSnap = true;
|
|
|
|
return nsRect(ToReferenceFrame(), GetUnderlyingFrame()->GetSize());
|
|
|
|
}
|
2012-09-24 13:29:14 -07:00
|
|
|
|
|
|
|
// Doesn't handle HitTest because nsLeafBoxFrame already creates an
|
|
|
|
// event receiver for us
|
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsRenderingContext* aCtx);
|
|
|
|
NS_DISPLAY_DECL_NAME("XULImage", TYPE_XUL_IMAGE)
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsImageBoxFrame_h___ */
|