Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGFEImageElement.h
blob4df686d2d58f93953bbe6c05a900e02f30bde56e
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 void DidAnimateAttribute(int32_t aNameSpaceID, nsAtom* aAttribute) override;
98 nsresult LoadSVGImage(bool aForce, bool aNotify);
99 bool ShouldLoadImage() const;
101 protected:
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;
118 } // namespace dom
119 } // namespace mozilla
121 #endif // DOM_SVG_SVGFEIMAGEELEMENT_H_