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"
|
|
|
|
|
|
|
|
class nsSVGImageFrame;
|
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
namespace mozilla {
|
|
|
|
class PresShell;
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2017-05-23 22:11:13 +03:00
|
|
|
class nsSVGImageListener final : public imgINotificationObserver {
|
|
|
|
public:
|
|
|
|
explicit nsSVGImageListener(nsSVGImageFrame* aFrame);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_IMGINOTIFICATIONOBSERVER
|
|
|
|
|
|
|
|
void SetFrame(nsSVGImageFrame* frame) { mFrame = frame; }
|
|
|
|
|
|
|
|
private:
|
2019-04-18 01:38:02 +03:00
|
|
|
~nsSVGImageListener() = default;
|
2017-05-23 22:11:13 +03:00
|
|
|
|
|
|
|
nsSVGImageFrame* mFrame;
|
|
|
|
};
|
|
|
|
|
2018-06-13 22:13:07 +03:00
|
|
|
class nsSVGImageFrame final : public mozilla::SVGGeometryFrame,
|
2017-05-23 22:11:13 +03:00
|
|
|
public nsIReflowCallback {
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsIFrame* NS_NewSVGImageFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
2017-05-23 22:11:13 +03:00
|
|
|
|
|
|
|
protected:
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsSVGImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
|
|
|
: SVGGeometryFrame(aStyle, aPresContext, kClassID),
|
2017-05-23 22:11:13 +03:00
|
|
|
mReflowCallbackPosted(false),
|
|
|
|
mForceSyncDecoding(false) {
|
|
|
|
EnableVisibilityTracking();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~nsSVGImageFrame();
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsSVGImageFrame)
|
2017-05-23 22:11:13 +03:00
|
|
|
|
|
|
|
// nsSVGDisplayableFrame interface:
|
|
|
|
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;
|
2017-05-23 22:11:13 +03:00
|
|
|
|
2019-06-08 03:33:36 +03:00
|
|
|
bool GetIntrinsicImageDimensions(mozilla::gfx::Size& aSize,
|
2019-07-06 11:18:28 +03:00
|
|
|
mozilla::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 {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("SVGImage"), aResult);
|
|
|
|
}
|
|
|
|
#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:
|
2018-06-13 22:13:07 +03:00
|
|
|
mozilla::gfx::Matrix GetRasterImageTransform(int32_t aNativeWidth,
|
|
|
|
int32_t aNativeHeight);
|
|
|
|
mozilla::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;
|
|
|
|
|
|
|
|
friend class nsSVGImageListener;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __NS_SVGIMAGEFRAME_H__
|