/work/obj-fuzz/dist/include/mozilla/dom/SVGTests.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_SVGTests_h |
8 | | #define mozilla_dom_SVGTests_h |
9 | | |
10 | | #include "nsStringFwd.h" |
11 | | #include "SVGStringList.h" |
12 | | #include "nsCOMPtr.h" |
13 | | |
14 | | class nsAttrValue; |
15 | | class nsAtom; |
16 | | class nsStaticAtom; |
17 | | class nsSVGElement; |
18 | | |
19 | | namespace mozilla { |
20 | | class DOMSVGStringList; |
21 | | |
22 | | #define MOZILLA_DOMSVGTESTS_IID \ |
23 | | { 0x92370da8, 0xda28, 0x4895, \ |
24 | | {0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 } } |
25 | | |
26 | | namespace dom { |
27 | | |
28 | | class SVGTests : public nsISupports |
29 | | { |
30 | | public: |
31 | | NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTESTS_IID) |
32 | | |
33 | | SVGTests(); |
34 | | |
35 | | friend class mozilla::DOMSVGStringList; |
36 | | typedef mozilla::SVGStringList SVGStringList; |
37 | | |
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). |
49 | | */ |
50 | | int32_t GetBestLanguagePreferenceRank(const nsAString& aAcceptLangs) const; |
51 | | |
52 | | /** |
53 | | * Special value to pass to PassesConditionalProcessingTests to ignore systemLanguage |
54 | | * attributes |
55 | | */ |
56 | | static const nsString * const kIgnoreSystemLanguage; |
57 | | |
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. |
63 | | * |
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. |
68 | | */ |
69 | | bool PassesConditionalProcessingTests( |
70 | | const nsString *aAcceptLangs = nullptr) const; |
71 | | |
72 | | /** |
73 | | * Returns true if the attribute is one of the conditional processing |
74 | | * attributes. |
75 | | */ |
76 | | bool IsConditionalProcessingAttribute(const nsAtom* aAttribute) const; |
77 | | |
78 | | bool ParseConditionalProcessingAttribute( |
79 | | nsAtom* aAttribute, |
80 | | const nsAString& aValue, |
81 | | nsAttrValue& aResult); |
82 | | |
83 | | /** |
84 | | * Unsets a conditional processing attribute. |
85 | | */ |
86 | | void UnsetAttr(const nsAtom* aAttribute); |
87 | | |
88 | | nsAtom* GetAttrName(uint8_t aAttrEnum) const; |
89 | | void GetAttrValue(uint8_t aAttrEnum, nsAttrValue &aValue) const; |
90 | | |
91 | | void MaybeInvalidate(); |
92 | | |
93 | | // WebIDL |
94 | | already_AddRefed<DOMSVGStringList> RequiredFeatures(); |
95 | | already_AddRefed<DOMSVGStringList> RequiredExtensions(); |
96 | | already_AddRefed<DOMSVGStringList> SystemLanguage(); |
97 | | bool HasExtension(const nsAString& aExtension); |
98 | | |
99 | | virtual nsSVGElement* AsSVGElement() = 0; |
100 | | |
101 | | const nsSVGElement* AsSVGElement() const |
102 | 0 | { |
103 | 0 | return const_cast<SVGTests*>(this)->AsSVGElement(); |
104 | 0 | } |
105 | | |
106 | | protected: |
107 | 0 | virtual ~SVGTests() {} |
108 | | |
109 | | private: |
110 | | enum { FEATURES, EXTENSIONS, LANGUAGE }; |
111 | | SVGStringList mStringListAttributes[3]; |
112 | | static nsStaticAtom** sStringListNames[3]; |
113 | | }; |
114 | | |
115 | | NS_DEFINE_STATIC_IID_ACCESSOR(SVGTests, MOZILLA_DOMSVGTESTS_IID) |
116 | | |
117 | | } // namespace dom |
118 | | } // namespace mozilla |
119 | | |
120 | | #endif // mozilla_dom_SVGTests_h |