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"
22 class DOMSVGStringList
;
23 class SVGSwitchElement
;
26 #define MOZILLA_DOMSVGTESTS_IID \
28 0x92370da8, 0xda28, 0x4895, { \
29 0x9b, 0x1b, 0xe0, 0x06, 0x0d, 0xb7, 0x3f, 0xc3 \
37 class SVGTests
: public nsISupports
{
39 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOMSVGTESTS_IID
)
43 friend class dom::DOMSVGStringList
;
44 using SVGStringList
= mozilla::SVGStringList
;
47 * Find the active switch child using BCP 47 rules.
49 static nsIContent
* FindActiveSwitchChild(
50 const dom::SVGSwitchElement
* aSwitch
);
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;
61 * Returns true if the attribute is one of the conditional processing
64 bool IsConditionalProcessingAttribute(const nsAtom
* aAttribute
) const;
66 bool ParseConditionalProcessingAttribute(nsAtom
* aAttribute
,
67 const nsAString
& aValue
,
68 nsAttrValue
& aResult
);
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();
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();
93 virtual ~SVGTests() = default;
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
)
112 } // namespace mozilla
114 #endif // DOM_SVG_SVGTESTS_H_