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