Bug 1795723 - Unified extensions UI should support High Contrast Mode. r=ayeddi,deskt...
[gecko.git] / dom / html / HTMLHeadingElement.h
blob192405e0fc231d158b7f1e39900344078a28664d
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_HTMLHeadingElement_h
8 #define mozilla_dom_HTMLHeadingElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsGenericHTMLElement.h"
13 namespace mozilla::dom {
15 class HTMLHeadingElement final : public nsGenericHTMLElement {
16 public:
17 explicit HTMLHeadingElement(
18 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
19 : nsGenericHTMLElement(std::move(aNodeInfo)) {
20 MOZ_ASSERT(IsHTMLHeadingElement());
23 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
24 const nsAString& aValue,
25 nsIPrincipal* aMaybeScriptedPrincipal,
26 nsAttrValue& aResult) override;
27 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
28 nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
29 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
31 void SetAlign(const nsAString& aAlign, ErrorResult& aError) {
32 return SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
34 void GetAlign(DOMString& aAlign) const {
35 return GetHTMLAttr(nsGkAtoms::align, aAlign);
38 int32_t AccessibilityLevel() const {
39 nsAtom* name = NodeInfo()->NameAtom();
40 if (name == nsGkAtoms::h1) {
41 return 1;
43 if (name == nsGkAtoms::h2) {
44 return 2;
46 if (name == nsGkAtoms::h3) {
47 return 3;
49 if (name == nsGkAtoms::h4) {
50 return 4;
52 if (name == nsGkAtoms::h5) {
53 return 5;
55 MOZ_ASSERT(name == nsGkAtoms::h6);
56 return 6;
59 NS_IMPL_FROMNODE_HELPER(HTMLHeadingElement, IsHTMLHeadingElement())
61 protected:
62 virtual ~HTMLHeadingElement();
64 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
66 private:
67 static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
68 MappedDeclarations&);
71 } // namespace mozilla::dom
73 #endif // mozilla_dom_HTMLHeadingElement_h