Bug 1857998 [wpt PR 42432] - [css-nesting-ident] Enable relaxed syntax, a=testonly
[gecko.git] / dom / svg / SVGTests.h
blob148c35fc5cc5dda61c2b1110b4ac0305ab146fbf
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 nsStaticAtom;
18 namespace mozilla {
20 namespace dom {
21 class DOMSVGStringList;
24 #define MOZILLA_DOMSVGTESTS_IID \
25 { \
26 0x92370da8, 0xda28, 0x4895, { \
27 0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 \
28 } \
31 namespace dom {
33 class SVGElement;
35 class SVGTests : public nsISupports {
36 public:
37 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTESTS_IID)
39 SVGTests();
41 friend class dom::DOMSVGStringList;
42 using SVGStringList = mozilla::SVGStringList;
44 /**
45 * Compare the language name(s) in a systemLanguage attribute to the
46 * user's language preferences, as defined in
47 * http://www.w3.org/TR/SVG11/struct.html#SystemLanguageAttribute
48 * We have a match if a language name in the users language preferences
49 * exactly equals one of the language names or exactly equals a prefix of
50 * one of the language names in the systemLanguage attribute.
51 * @returns 2 * the lowest index in the aAcceptLangs that matches + 1
52 * if only the prefix matches, -2 if there's no systemLanguage attribute,
53 * or -1 if no indices match.
54 * XXX This algorithm is O(M*N).
56 int32_t GetBestLanguagePreferenceRank(const nsAString& aAcceptLangs) const;
58 /**
59 * Check whether the conditional processing attributes other than
60 * systemLanguage "return true" if they apply to and are specified
61 * on the given element. Returns true if this element should be
62 * rendered, false if it should not.
64 bool PassesConditionalProcessingTestsIgnoringSystemLanguage() const;
66 /**
67 * Check whether the conditional processing attributes requiredExtensions
68 * and systemLanguage both "return true" if they apply to
69 * and are specified on the given element. Returns true if this element
70 * should be rendered, false if it should not.
72 bool PassesConditionalProcessingTests() const;
74 /**
75 * Check whether the conditional processing attributes requiredExtensions
76 * and systemLanguage both "return true" if they apply to
77 * and are specified on the given element. Returns true if this element
78 * should be rendered, false if it should not.
80 * @param aAcceptLangs The value of the intl.accept_languages preference
82 bool PassesConditionalProcessingTests(const nsAString& aAcceptLangs) const;
84 /**
85 * Returns true if the attribute is one of the conditional processing
86 * attributes.
88 bool IsConditionalProcessingAttribute(const nsAtom* aAttribute) const;
90 bool ParseConditionalProcessingAttribute(nsAtom* aAttribute,
91 const nsAString& aValue,
92 nsAttrValue& aResult);
94 /**
95 * Unsets a conditional processing attribute.
97 void UnsetAttr(const nsAtom* aAttribute);
99 nsStaticAtom* GetAttrName(uint8_t aAttrEnum) const;
100 void GetAttrValue(uint8_t aAttrEnum, nsAttrValue& aValue) const;
102 void MaybeInvalidate();
104 // WebIDL
105 already_AddRefed<DOMSVGStringList> RequiredExtensions();
106 already_AddRefed<DOMSVGStringList> SystemLanguage();
108 bool HasExtension(const nsAString& aExtension) const;
110 virtual SVGElement* AsSVGElement() = 0;
112 const SVGElement* AsSVGElement() const {
113 return const_cast<SVGTests*>(this)->AsSVGElement();
116 protected:
117 virtual ~SVGTests() = default;
119 private:
120 enum { EXTENSIONS, LANGUAGE };
121 SVGStringList mStringListAttributes[2];
122 static nsStaticAtom* const sStringListNames[2];
125 NS_DEFINE_STATIC_IID_ACCESSOR(SVGTests, MOZILLA_DOMSVGTESTS_IID)
127 } // namespace dom
128 } // namespace mozilla
130 #endif // DOM_SVG_SVGTESTS_H_