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/. */
7 #ifndef DOM_SVG_SVGFEIMAGEELEMENT_H_
8 #define DOM_SVG_SVGFEIMAGEELEMENT_H_
10 #include "mozilla/dom/SVGFilters.h"
11 #include "SVGAnimatedPreserveAspectRatio.h"
13 nsresult
NS_NewSVGFEImageElement(
14 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
17 class SVGFEImageFrame
;
21 using SVGFEImageElementBase
= SVGFE
;
23 class SVGFEImageElement final
: public SVGFEImageElementBase
,
24 public nsImageLoadingContent
{
25 friend class mozilla::SVGFEImageFrame
;
28 friend nsresult(::NS_NewSVGFEImageElement(
30 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
31 explicit SVGFEImageElement(
32 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
33 virtual ~SVGFEImageElement();
34 JSObject
* WrapNode(JSContext
* aCx
,
35 JS::Handle
<JSObject
*> aGivenProto
) override
;
38 bool SubregionIsUnionOfRegions() override
{ return false; }
41 NS_DECL_ISUPPORTS_INHERITED
44 void AsyncEventRunning(AsyncEventDispatcher
* aEvent
) override
;
46 FilterPrimitiveDescription
GetPrimitiveDescription(
47 SVGFilterInstance
* aInstance
, const IntRect
& aFilterSubregion
,
48 const nsTArray
<bool>& aInputsAreTainted
,
49 nsTArray
<RefPtr
<SourceSurface
>>& aInputImages
) override
;
50 bool AttributeAffectsRendering(int32_t aNameSpaceID
,
51 nsAtom
* aAttribute
) const override
;
52 SVGAnimatedString
& GetResultImageName() override
{
53 return mStringAttributes
[RESULT
];
56 // nsImageLoadingContent
57 CORSMode
GetCORSMode() override
;
59 bool OutputIsTainted(const nsTArray
<bool>& aInputsAreTainted
,
60 nsIPrincipal
* aReferencePrincipal
) override
;
63 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
65 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
66 const nsAString
& aValue
,
67 nsIPrincipal
* aMaybeScriptedPrincipal
,
68 nsAttrValue
& aResult
) override
;
69 void AfterSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
70 const nsAttrValue
* aValue
, const nsAttrValue
* aOldValue
,
71 nsIPrincipal
* aSubjectPrincipal
, bool aNotify
) override
;
72 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
73 void UnbindFromTree(bool aNullParent
) override
;
74 ElementState
IntrinsicState() const override
;
75 void DestroyContent() override
;
77 NS_DECL_IMGINOTIFICATIONOBSERVER
79 // Override for nsIImageLoadingContent.
80 NS_IMETHOD_(void) FrameCreated(nsIFrame
* aFrame
) override
;
82 void MaybeLoadSVGImage();
85 already_AddRefed
<DOMSVGAnimatedString
> Href();
86 already_AddRefed
<DOMSVGAnimatedPreserveAspectRatio
> PreserveAspectRatio();
87 void GetCrossOrigin(nsAString
& aCrossOrigin
) {
88 // Null for both missing and invalid defaults is ok, since we
89 // always parse to an enum value, so we don't need an invalid
90 // default, and we _want_ the missing default to be null.
91 GetEnumAttr(nsGkAtoms::crossorigin
, nullptr, aCrossOrigin
);
93 void SetCrossOrigin(const nsAString
& aCrossOrigin
, ErrorResult
& aError
) {
94 SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin
, aCrossOrigin
, aError
);
98 nsresult
LoadSVGImage(bool aForce
, bool aNotify
);
99 bool ShouldLoadImage() const;
102 bool ProducesSRGB() override
{ return true; }
104 SVGAnimatedPreserveAspectRatio
* GetAnimatedPreserveAspectRatio() override
;
105 StringAttributesInfo
GetStringInfo() override
;
107 // Override for nsImageLoadingContent.
108 nsIContent
* AsContent() override
{ return this; }
110 enum { RESULT
, HREF
, XLINK_HREF
};
111 SVGAnimatedString mStringAttributes
[3];
112 static StringInfo sStringInfo
[3];
114 SVGAnimatedPreserveAspectRatio mPreserveAspectRatio
;
115 uint16_t mImageAnimationMode
;
119 } // namespace mozilla
121 #endif // DOM_SVG_SVGFEIMAGEELEMENT_H_