2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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 "imgIRequest.h"
|
|
|
|
#include "imgIContainer.h"
|
Bug 1600545 - Remove useless inclusions of header files generated from IDL files in accessible/, browser/, caps/, chrome/, devtools/, docshell/, editor/, extensions/, gfx/, hal/, image/, intl/, ipc/, js/, layout/, and media/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55443
--HG--
extra : moz-landing-system : lando
2019-12-06 12:16:44 +03:00
|
|
|
#include "imgINotificationObserver.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;
|
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-11-01 13:59:10 +03:00
|
|
|
class nsImageBoxListener final : public imgINotificationObserver {
|
2001-03-20 02:44:55 +03:00
|
|
|
public:
|
2018-06-15 14:12:46 +03:00
|
|
|
explicit nsImageBoxListener(nsImageBoxFrame* frame);
|
2001-03-20 02:44:55 +03:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
2012-10-12 20:11:22 +04:00
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
2001-03-20 02:44:55 +03:00
|
|
|
|
2018-06-15 14:12:46 +03:00
|
|
|
void ClearFrame() { mFrame = nullptr; }
|
2001-03-20 02:44:55 +03:00
|
|
|
|
|
|
|
private:
|
2014-06-24 02:40:01 +04:00
|
|
|
virtual ~nsImageBoxListener();
|
|
|
|
|
2001-03-20 02:44:55 +03:00
|
|
|
nsImageBoxFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsImageBoxFrame final : public nsLeafBoxFrame {
|
2000-02-17 02:00:52 +03:00
|
|
|
public:
|
2017-12-11 18:37:59 +03:00
|
|
|
typedef mozilla::image::ImgDrawResult ImgDrawResult;
|
2015-03-18 05:40:16 +03:00
|
|
|
typedef mozilla::layers::ImageContainer ImageContainer;
|
2012-11-28 06:34:45 +04:00
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
|
2012-09-25 00:29:14 +04:00
|
|
|
friend class nsDisplayXULImage;
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsImageBoxFrame)
|
2019-03-25 22:11:22 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:32 +03:00
|
|
|
virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void MarkIntrinsicISizesDirty() override;
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2020-03-12 07:25:34 +03:00
|
|
|
void Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData);
|
2012-10-12 20:11:22 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsIFrame* NS_NewImageBoxFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* asPrevInFlow) override;
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2019-11-09 19:48:04 +03:00
|
|
|
virtual void DidSetComputedStyle(ComputedStyle* aOldStyle) override;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2019-11-09 19:48:04 +03:00
|
|
|
/**
|
|
|
|
* Gets the image request to be loaded from the current style.
|
|
|
|
*
|
|
|
|
* May be null if themed.
|
|
|
|
*/
|
|
|
|
imgRequestProxy* GetRequestFromStyle();
|
|
|
|
|
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
|
|
|
|
2019-03-25 22:11:22 +03:00
|
|
|
void RestartAnimation();
|
|
|
|
void StopAnimation();
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) 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
|
|
|
|
2017-09-10 07:45:11 +03:00
|
|
|
already_AddRefed<imgIContainer> GetImageContainerForPainting(
|
2017-12-11 18:37:59 +03:00
|
|
|
const nsPoint& aPt, ImgDrawResult& aDrawResult,
|
2017-09-10 07:45:11 +03:00
|
|
|
Maybe<nsPoint>& aAnchorPoint, nsRect& aDest);
|
|
|
|
|
2017-12-11 18:37:59 +03:00
|
|
|
ImgDrawResult PaintImage(gfxContext& aRenderingContext,
|
2015-02-05 00:50:56 +03:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt,
|
|
|
|
uint32_t aFlags);
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2018-09-14 02:48:27 +03:00
|
|
|
ImgDrawResult CreateWebRenderCommands(
|
|
|
|
mozilla::wr::DisplayListBuilder& aBuilder,
|
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
|
|
|
const mozilla::layers::StackingContextHelper& aSc,
|
2019-01-08 00:33:10 +03:00
|
|
|
mozilla::layers::RenderRootStateManager* aManager, nsDisplayItem* aItem,
|
2018-09-14 02:48:27 +03:00
|
|
|
nsPoint aPt, uint32_t aFlags);
|
2017-09-10 07:45:11 +03:00
|
|
|
|
2016-04-07 09:52:35 +03:00
|
|
|
bool CanOptimizeToImageLayer();
|
2015-03-18 05:40:16 +03:00
|
|
|
|
2017-05-22 12:26:17 +03:00
|
|
|
nsRect GetDestRect(const nsPoint& aOffset, Maybe<nsPoint>& aAnchorPoint);
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
protected:
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsImageBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
|
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:
|
2020-03-12 07:25:34 +03:00
|
|
|
void OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage);
|
|
|
|
void OnDecodeComplete(imgIRequest* aRequest);
|
|
|
|
void OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);
|
|
|
|
void OnImageIsAnimated(imgIRequest* aRequest);
|
|
|
|
void OnFrameUpdate(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;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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
|
|
|
|
2015-04-09 19:56:25 +03:00
|
|
|
// Boolean variable to determine if the current image request has been
|
|
|
|
// registered with the refresh driver.
|
|
|
|
bool mRequestRegistered;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mUseSrcAttr; ///< Whether or not the image src comes from an attribute.
|
|
|
|
bool mSuppressStyleCheck;
|
2000-03-31 11:02:06 +04:00
|
|
|
}; // class nsImageBoxFrame
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-05-02 04:50:16 +03:00
|
|
|
class nsDisplayXULImage final : public nsDisplayImageContainer {
|
2012-09-25 00:29:14 +04:00
|
|
|
public:
|
|
|
|
nsDisplayXULImage(nsDisplayListBuilder* aBuilder, nsImageBoxFrame* aFrame)
|
|
|
|
: nsDisplayImageContainer(aBuilder, aFrame) {
|
|
|
|
MOZ_COUNT_CTOR(nsDisplayXULImage);
|
|
|
|
}
|
2020-02-20 14:40:14 +03:00
|
|
|
MOZ_COUNTED_DTOR_OVERRIDE(nsDisplayXULImage)
|
2012-09-25 00:29:14 +04:00
|
|
|
|
2015-05-13 10:23:46 +03:00
|
|
|
virtual bool CanOptimizeToImageLayer(LayerManager* aManager,
|
|
|
|
nsDisplayListBuilder* aBuilder) override;
|
2016-04-07 09:52:35 +03:00
|
|
|
virtual already_AddRefed<imgIContainer> GetImage() override;
|
2017-08-24 18:09:44 +03:00
|
|
|
virtual nsRect GetDestRect() const override;
|
2018-01-30 01:16:51 +03:00
|
|
|
virtual void UpdateDrawResult(
|
|
|
|
mozilla::image::ImgDrawResult aResult) override {
|
|
|
|
nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, aResult);
|
|
|
|
}
|
2017-08-24 18:09:44 +03:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap) const 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
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsDisplayItemGeometry* AllocateGeometry(
|
|
|
|
nsDisplayListBuilder* aBuilder) override;
|
2013-06-26 20:43:27 +04:00
|
|
|
virtual void ComputeInvalidationRegion(
|
2015-03-21 19:28:04 +03:00
|
|
|
nsDisplayListBuilder* aBuilder, const nsDisplayItemGeometry* aGeometry,
|
2017-08-24 18:09:44 +03:00
|
|
|
nsRegion* aInvalidRegion) const 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, gfxContext* aCtx) override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-09-10 07:45:11 +03:00
|
|
|
virtual bool CreateWebRenderCommands(
|
|
|
|
mozilla::wr::DisplayListBuilder& aBuilder,
|
2017-09-14 19:48:55 +03:00
|
|
|
mozilla::wr::IpcResourceUpdateQueue& aResources,
|
2017-09-10 07:45:11 +03:00
|
|
|
const StackingContextHelper& aSc,
|
2019-01-08 00:33:10 +03:00
|
|
|
mozilla::layers::RenderRootStateManager* aManager,
|
2017-09-10 07:45:11 +03:00
|
|
|
nsDisplayListBuilder* aDisplayListBuilder) 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___ */
|