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"
21 class DOMSVGStringList
;
24 #define MOZILLA_DOMSVGTESTS_IID \
26 0x92370da8, 0xda28, 0x4895, { \
27 0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 \
35 class SVGTests
: public nsISupports
{
37 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTESTS_IID
)
41 friend class dom::DOMSVGStringList
;
42 using SVGStringList
= mozilla::SVGStringList
;
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;
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;
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;
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;
85 * Returns true if the attribute is one of the conditional processing
88 bool IsConditionalProcessingAttribute(const nsAtom
* aAttribute
) const;
90 bool ParseConditionalProcessingAttribute(nsAtom
* aAttribute
,
91 const nsAString
& aValue
,
92 nsAttrValue
& aResult
);
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();
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();
117 virtual ~SVGTests() = default;
120 enum { EXTENSIONS
, LANGUAGE
};
121 SVGStringList mStringListAttributes
[2];
122 static nsStaticAtom
* const sStringListNames
[2];
125 NS_DEFINE_STATIC_IID_ACCESSOR(SVGTests
, MOZILLA_DOMSVGTESTS_IID
)
128 } // namespace mozilla
130 #endif // DOM_SVG_SVGTESTS_H_