Bug 1873144 - Disabled test_conformance__textures__misc__texture-npot-video.html...
[gecko.git] / dom / svg / SVGFEImageElement.h
blob41b28b83a92521ffddf198623abdce222e19e650
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);
16 namespace mozilla {
17 class SVGFEImageFrame;
19 namespace dom {
21 using SVGFEImageElementBase = SVGFilterPrimitiveElement;
23 class SVGFEImageElement final : public SVGFEImageElementBase,
24 public nsImageLoadingContent {
25 friend class mozilla::SVGFEImageFrame;
27 protected:
28 friend nsresult(::NS_NewSVGFEImageElement(
29 nsIContent** aResult,
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;
37 public:
38 bool SubregionIsUnionOfRegions() override { return false; }
40 // interfaces:
41 NS_DECL_ISUPPORTS_INHERITED
43 // EventTarget
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;
62 // nsIContent
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(UnbindContext&) override;
74 void DestroyContent() override;
76 NS_DECL_IMGINOTIFICATIONOBSERVER
78 // Override for nsIImageLoadingContent.
79 NS_IMETHOD_(void) FrameCreated(nsIFrame* aFrame) override;
81 void MaybeLoadSVGImage();
83 // WebIDL
84 already_AddRefed<DOMSVGAnimatedString> Href();
85 already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
86 void GetCrossOrigin(nsAString& aCrossOrigin) {
87 // Null for both missing and invalid defaults is ok, since we
88 // always parse to an enum value, so we don't need an invalid
89 // default, and we _want_ the missing default to be null.
90 GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aCrossOrigin);
92 void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError) {
93 SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
96 private:
97 nsresult LoadSVGImage(bool aForce, bool aNotify);
98 bool ShouldLoadImage() const;
100 protected:
101 bool ProducesSRGB() override { return true; }
103 SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() override;
104 StringAttributesInfo GetStringInfo() override;
106 // Override for nsImageLoadingContent.
107 nsIContent* AsContent() override { return this; }
109 enum { RESULT, HREF, XLINK_HREF };
110 SVGAnimatedString mStringAttributes[3];
111 static StringInfo sStringInfo[3];
113 SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
114 uint16_t mImageAnimationMode;
117 } // namespace dom
118 } // namespace mozilla
120 #endif // DOM_SVG_SVGFEIMAGEELEMENT_H_