Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGTests.h
blob90991fd60dfa84d081085474eafe8907d4e0026c
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_SVGTESTS_H_
8 #define DOM_SVG_SVGTESTS_H_
10 #include "nsStringFwd.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "mozilla/SVGStringList.h"
14 class nsAttrValue;
15 class nsAtom;
16 class nsIContent;
17 class nsStaticAtom;
19 namespace mozilla {
21 namespace dom {
22 class DOMSVGStringList;
23 class SVGSwitchElement;
24 } // namespace dom
26 #define MOZILLA_DOMSVGTESTS_IID \
27 { \
28 0x92370da8, 0xda28, 0x4895, { \
29 0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 \
30 } \
33 namespace dom {
35 class SVGElement;
37 class SVGTests : public nsISupports {
38 public:
39 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTESTS_IID)
41 SVGTests();
43 friend class dom::DOMSVGStringList;
44 using SVGStringList = mozilla::SVGStringList;
46 /**
47 * Find the active switch child using BCP 47 rules.
49 static nsIContent* FindActiveSwitchChild(
50 const dom::SVGSwitchElement* aSwitch);
52 /**
53 * Check whether the conditional processing attributes requiredExtensions
54 * and systemLanguage both "return true" if they apply to
55 * and are specified on the given element. Returns true if this element
56 * should be rendered, false if it should not.
58 bool PassesConditionalProcessingTests() const;
60 /**
61 * Returns true if the attribute is one of the conditional processing
62 * attributes.
64 bool IsConditionalProcessingAttribute(const nsAtom* aAttribute) const;
66 bool ParseConditionalProcessingAttribute(nsAtom* aAttribute,
67 const nsAString& aValue,
68 nsAttrValue& aResult);
70 /**
71 * Unsets a conditional processing attribute.
73 void UnsetAttr(const nsAtom* aAttribute);
75 nsStaticAtom* GetAttrName(uint8_t aAttrEnum) const;
76 void GetAttrValue(uint8_t aAttrEnum, nsAttrValue& aValue) const;
78 void MaybeInvalidate();
80 // WebIDL
81 already_AddRefed<DOMSVGStringList> RequiredExtensions();
82 already_AddRefed<DOMSVGStringList> SystemLanguage();
84 bool HasExtension(const nsAString& aExtension) const;
86 virtual SVGElement* AsSVGElement() = 0;
88 const SVGElement* AsSVGElement() const {
89 return const_cast<SVGTests*>(this)->AsSVGElement();
92 protected:
93 virtual ~SVGTests() = default;
95 private:
96 /**
97 * Check whether the extensions processing attribute applies to and is
98 * specified on the given element. Returns true if this element should be
99 * rendered, false if it should not.
101 bool PassesRequiredExtensionsTests() const;
103 enum { EXTENSIONS, LANGUAGE };
104 SVGStringList mStringListAttributes[2];
105 static nsStaticAtom* const sStringListNames[2];
106 mutable Maybe<bool> mPassesConditionalProcessingTests = Some(true);
109 NS_DEFINE_STATIC_IID_ACCESSOR(SVGTests, MOZILLA_DOMSVGTESTS_IID)
111 } // namespace dom
112 } // namespace mozilla
114 #endif // DOM_SVG_SVGTESTS_H_