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: */
|
2017-05-23 22:11:13 +03: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/. */
|
|
|
|
|
|
|
|
#ifndef __NS_SVGIMAGEFRAME_H__
|
|
|
|
#define __NS_SVGIMAGEFRAME_H__
|
|
|
|
|
|
|
|
// Keep in (case-insensitive) order:
|
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxPlatform.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "imgINotificationObserver.h"
|
2017-08-30 16:14:46 +03:00
|
|
|
#include "SVGObserverUtils.h"
|
2017-05-23 22:11:13 +03:00
|
|
|
#include "nsSVGUtils.h"
|
|
|
|
#include "SVGContentUtils.h"
|
|
|
|
#include "SVGGeometryFrame.h"
|
|
|
|
#include "SVGImageContext.h"
|
|
|
|
#include "mozilla/dom/SVGImageElement.h"
|
|
|
|
#include "nsIReflowCallback.h"
|
|
|
|
#include "mozilla/Unused.h"
|
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
nsIFrame* NS_NewSVGImageFrame(mozilla::PresShell* aPresShell,
|
|
|
|
mozilla::ComputedStyle* aStyle);
|
2017-05-23 22:11:13 +03:00
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
namespace mozilla {
|
2017-05-23 22:11:13 +03:00
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
class SVGImageFrame final : public SVGGeometryFrame, public nsIReflowCallback {
|
|
|
|
friend nsIFrame* ::NS_NewSVGImageFrame(mozilla::PresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle);
|
2017-05-23 22:11:13 +03:00
|
|
|
|
2020-05-15 21:49:52 +03:00
|
|
|
virtual bool CreateWebRenderCommands(
|
2020-06-25 23:42:49 +03:00
|
|
|
wr::DisplayListBuilder& aBuilder, wr::IpcResourceUpdateQueue& aResources,
|
|
|
|
const layers::StackingContextHelper& aSc,
|
|
|
|
layers::RenderRootStateManager* aManager,
|
|
|
|
nsDisplayListBuilder* aDisplayListBuilder, DisplaySVGGeometry* aItem,
|
|
|
|
bool aDryRun) override;
|
2020-05-15 21:49:52 +03:00
|
|
|
|
2017-05-23 22:11:13 +03:00
|
|
|
protected:
|
2020-06-25 23:42:49 +03:00
|
|
|
explicit SVGImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
2019-02-05 19:45:54 +03:00
|
|
|
: SVGGeometryFrame(aStyle, aPresContext, kClassID),
|
2017-05-23 22:11:13 +03:00
|
|
|
mReflowCallbackPosted(false),
|
|
|
|
mForceSyncDecoding(false) {
|
|
|
|
EnableVisibilityTracking();
|
|
|
|
}
|
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
virtual ~SVGImageFrame();
|
2017-05-23 22:11:13 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_QUERYFRAME
|
2020-06-25 23:42:49 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(SVGImageFrame)
|
2017-05-23 22:11:13 +03:00
|
|
|
|
2020-07-09 21:34:54 +03:00
|
|
|
// ISVGDisplayableFrame interface:
|
2017-05-23 22:11:13 +03:00
|
|
|
virtual void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
|
|
|
|
imgDrawingParams& aImgParams,
|
|
|
|
const nsIntRect* aDirtyRect = nullptr) override;
|
|
|
|
virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override;
|
|
|
|
virtual void ReflowSVG() override;
|
|
|
|
|
|
|
|
// SVGGeometryFrame methods:
|
|
|
|
virtual uint16_t GetHitTestFlags() override;
|
|
|
|
|
|
|
|
// nsIFrame interface:
|
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
|
|
|
int32_t aModType) override;
|
|
|
|
|
|
|
|
void OnVisibilityChange(
|
|
|
|
Visibility aNewVisibility,
|
|
|
|
const Maybe<OnNonvisible>& aNonvisibleAction = Nothing()) override;
|
|
|
|
|
|
|
|
virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) override;
|
2017-11-07 03:20:33 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
2020-05-18 03:04:03 +03:00
|
|
|
void DidSetComputedStyle(ComputedStyle* aOldStyle) final;
|
2017-05-23 22:11:13 +03:00
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
bool GetIntrinsicImageDimensions(gfx::Size& aSize,
|
|
|
|
AspectRatio& aAspectRatio) const;
|
2019-05-24 15:40:12 +03:00
|
|
|
|
2017-05-23 22:11:13 +03:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override {
|
2020-07-01 11:29:29 +03:00
|
|
|
return MakeFrameName(u"SVGImage"_ns, aResult);
|
2017-05-23 22:11:13 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsIReflowCallback
|
|
|
|
virtual bool ReflowFinished() override;
|
|
|
|
virtual void ReflowCallbackCanceled() override;
|
|
|
|
|
|
|
|
/// Always sync decode our image when painting if @aForce is true.
|
|
|
|
void SetForceSyncDecoding(bool aForce) { mForceSyncDecoding = aForce; }
|
|
|
|
|
|
|
|
private:
|
2020-06-25 23:42:49 +03:00
|
|
|
gfx::Matrix GetRasterImageTransform(int32_t aNativeWidth,
|
|
|
|
int32_t aNativeHeight);
|
|
|
|
gfx::Matrix GetVectorImageTransform();
|
2017-05-23 22:11:13 +03:00
|
|
|
bool TransformContextForPainting(gfxContext* aGfxContext,
|
|
|
|
const gfxMatrix& aTransform);
|
|
|
|
|
|
|
|
nsCOMPtr<imgINotificationObserver> mListener;
|
|
|
|
|
|
|
|
nsCOMPtr<imgIContainer> mImageContainer;
|
|
|
|
|
|
|
|
bool mReflowCallbackPosted;
|
|
|
|
bool mForceSyncDecoding;
|
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
friend class SVGImageListener;
|
2017-05-23 22:11:13 +03:00
|
|
|
};
|
|
|
|
|
2020-06-25 23:42:49 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-05-23 22:11:13 +03:00
|
|
|
#endif // __NS_SVGIMAGEFRAME_H__
|