/src/mozilla-central/layout/svg/nsSVGImageFrame.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef __NS_SVGIMAGEFRAME_H__ |
8 | | #define __NS_SVGIMAGEFRAME_H__ |
9 | | |
10 | | // Keep in (case-insensitive) order: |
11 | | #include "gfxContext.h" |
12 | | #include "gfxPlatform.h" |
13 | | #include "mozilla/gfx/2D.h" |
14 | | #include "imgIContainer.h" |
15 | | #include "nsContainerFrame.h" |
16 | | #include "nsIImageLoadingContent.h" |
17 | | #include "nsLayoutUtils.h" |
18 | | #include "imgINotificationObserver.h" |
19 | | #include "SVGObserverUtils.h" |
20 | | #include "nsSVGUtils.h" |
21 | | #include "SVGContentUtils.h" |
22 | | #include "SVGGeometryFrame.h" |
23 | | #include "SVGImageContext.h" |
24 | | #include "mozilla/dom/SVGImageElement.h" |
25 | | #include "nsIReflowCallback.h" |
26 | | #include "mozilla/Unused.h" |
27 | | |
28 | | class nsSVGImageFrame; |
29 | | |
30 | | class nsSVGImageListener final : public imgINotificationObserver |
31 | | { |
32 | | public: |
33 | | explicit nsSVGImageListener(nsSVGImageFrame *aFrame); |
34 | | |
35 | | NS_DECL_ISUPPORTS |
36 | | NS_DECL_IMGINOTIFICATIONOBSERVER |
37 | | |
38 | 0 | void SetFrame(nsSVGImageFrame *frame) { mFrame = frame; } |
39 | | |
40 | | private: |
41 | 0 | ~nsSVGImageListener() {} |
42 | | |
43 | | nsSVGImageFrame *mFrame; |
44 | | }; |
45 | | |
46 | | class nsSVGImageFrame final |
47 | | : public mozilla::SVGGeometryFrame |
48 | | , public nsIReflowCallback |
49 | | { |
50 | | friend nsIFrame* |
51 | | NS_NewSVGImageFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle); |
52 | | |
53 | | protected: |
54 | | explicit nsSVGImageFrame(ComputedStyle* aStyle) |
55 | | : SVGGeometryFrame(aStyle, kClassID) |
56 | | , mReflowCallbackPosted(false) |
57 | | , mForceSyncDecoding(false) |
58 | 0 | { |
59 | 0 | EnableVisibilityTracking(); |
60 | 0 | } |
61 | | |
62 | | virtual ~nsSVGImageFrame(); |
63 | | |
64 | | public: |
65 | | NS_DECL_QUERYFRAME |
66 | | NS_DECL_FRAMEARENA_HELPERS(nsSVGImageFrame) |
67 | | |
68 | | // nsSVGDisplayableFrame interface: |
69 | | virtual void PaintSVG(gfxContext& aContext, |
70 | | const gfxMatrix& aTransform, |
71 | | imgDrawingParams& aImgParams, |
72 | | const nsIntRect* aDirtyRect = nullptr) override; |
73 | | virtual nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; |
74 | | virtual void ReflowSVG() override; |
75 | | |
76 | | // SVGGeometryFrame methods: |
77 | | virtual uint16_t GetHitTestFlags() override; |
78 | | |
79 | | // nsIFrame interface: |
80 | | virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
81 | | nsAtom* aAttribute, |
82 | | int32_t aModType) override; |
83 | | |
84 | | void OnVisibilityChange(Visibility aNewVisibility, |
85 | | const Maybe<OnNonvisible>& aNonvisibleAction = Nothing()) override; |
86 | | |
87 | | virtual void Init(nsIContent* aContent, |
88 | | nsContainerFrame* aParent, |
89 | | nsIFrame* aPrevInFlow) override; |
90 | | virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) override; |
91 | | |
92 | | #ifdef DEBUG_FRAME_DUMP |
93 | | virtual nsresult GetFrameName(nsAString& aResult) const override |
94 | | { |
95 | | return MakeFrameName(NS_LITERAL_STRING("SVGImage"), aResult); |
96 | | } |
97 | | #endif |
98 | | |
99 | | // nsIReflowCallback |
100 | | virtual bool ReflowFinished() override; |
101 | | virtual void ReflowCallbackCanceled() override; |
102 | | |
103 | | /// Always sync decode our image when painting if @aForce is true. |
104 | 0 | void SetForceSyncDecoding(bool aForce) { mForceSyncDecoding = aForce; } |
105 | | |
106 | | private: |
107 | | mozilla::gfx::Matrix GetRasterImageTransform(int32_t aNativeWidth, |
108 | | int32_t aNativeHeight); |
109 | | mozilla::gfx::Matrix GetVectorImageTransform(); |
110 | | bool TransformContextForPainting(gfxContext* aGfxContext, |
111 | | const gfxMatrix& aTransform); |
112 | | |
113 | | nsCOMPtr<imgINotificationObserver> mListener; |
114 | | |
115 | | nsCOMPtr<imgIContainer> mImageContainer; |
116 | | |
117 | | bool mReflowCallbackPosted; |
118 | | bool mForceSyncDecoding; |
119 | | |
120 | | friend class nsSVGImageListener; |
121 | | }; |
122 | | |
123 | | #endif // __NS_SVGIMAGEFRAME_H__ |