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