Bug 1444460 [wpt PR 9948] - gyroscope: Rename LocalCoordinateSystem to GyroscopeLocal...
[gecko.git] / dom / svg / SVGTests.h
blob6d9cdd42bcef4770757196e46b89d55f92c93efb
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 mozilla_dom_SVGTests_h
8 #define mozilla_dom_SVGTests_h
10 #include "nsStringFwd.h"
11 #include "SVGStringList.h"
12 #include "nsCOMPtr.h"
14 class nsAttrValue;
15 class nsAtom;
16 class nsStaticAtom;
17 class nsSVGElement;
19 namespace mozilla {
20 class DOMSVGStringList;
22 #define MOZILLA_DOMSVGTESTS_IID \
23 { 0x92370da8, 0xda28, 0x4895, \
24 {0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 } }
26 namespace dom {
28 class SVGTests : public nsISupports
30 public:
31 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTESTS_IID)
33 SVGTests();
35 friend class mozilla::DOMSVGStringList;
36 typedef mozilla::SVGStringList SVGStringList;
38 /**
39 * Compare the language name(s) in a systemLanguage attribute to the
40 * user's language preferences, as defined in
41 * http://www.w3.org/TR/SVG11/struct.html#SystemLanguageAttribute
42 * We have a match if a language name in the users language preferences
43 * exactly equals one of the language names or exactly equals a prefix of
44 * one of the language names in the systemLanguage attribute.
45 * @returns 2 * the lowest index in the aAcceptLangs that matches + 1
46 * if only the prefix matches, -2 if there's no systemLanguage attribute,
47 * or -1 if no indices match.
48 * XXX This algorithm is O(M*N).
50 int32_t GetBestLanguagePreferenceRank(const nsAString& aAcceptLangs) const;
52 /**
53 * Special value to pass to PassesConditionalProcessingTests to ignore systemLanguage
54 * attributes
56 static const nsString * const kIgnoreSystemLanguage;
58 /**
59 * Check whether the conditional processing attributes requiredFeatures,
60 * requiredExtensions and systemLanguage all "return true" if they apply to
61 * and are specified on the given element. Returns true if this element
62 * should be rendered, false if it should not.
64 * @param aAcceptLangs Optional parameter to pass in the value of the
65 * intl.accept_languages preference if the caller has it cached.
66 * Alternatively, pass in kIgnoreSystemLanguage to skip the systemLanguage
67 * check if the caller is giving that special treatment.
69 bool PassesConditionalProcessingTests(
70 const nsString *aAcceptLangs = nullptr) const;
72 /**
73 * Returns true if the attribute is one of the conditional processing
74 * attributes.
76 bool IsConditionalProcessingAttribute(const nsAtom* aAttribute) const;
78 bool ParseConditionalProcessingAttribute(
79 nsAtom* aAttribute,
80 const nsAString& aValue,
81 nsAttrValue& aResult);
83 /**
84 * Unsets a conditional processing attribute.
86 void UnsetAttr(const nsAtom* aAttribute);
88 nsAtom* GetAttrName(uint8_t aAttrEnum) const;
89 void GetAttrValue(uint8_t aAttrEnum, nsAttrValue &aValue) const;
91 void MaybeInvalidate();
93 // WebIDL
94 already_AddRefed<DOMSVGStringList> RequiredFeatures();
95 already_AddRefed<DOMSVGStringList> RequiredExtensions();
96 already_AddRefed<DOMSVGStringList> SystemLanguage();
97 bool HasExtension(const nsAString& aExtension);
99 virtual nsSVGElement* AsSVGElement() = 0;
101 const nsSVGElement* AsSVGElement() const
103 return const_cast<SVGTests*>(this)->AsSVGElement();
106 protected:
107 virtual ~SVGTests() {}
109 private:
110 enum { FEATURES, EXTENSIONS, LANGUAGE };
111 SVGStringList mStringListAttributes[3];
112 static nsStaticAtom** sStringListNames[3];
115 NS_DEFINE_STATIC_IID_ACCESSOR(SVGTests, MOZILLA_DOMSVGTESTS_IID)
117 } // namespace dom
118 } // namespace mozilla
120 #endif // mozilla_dom_SVGTests_h