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
{
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
) {
43 if (name
== nsGkAtoms::h2
) {
46 if (name
== nsGkAtoms::h3
) {
49 if (name
== nsGkAtoms::h4
) {
52 if (name
== nsGkAtoms::h5
) {
55 MOZ_ASSERT(name
== nsGkAtoms::h6
);
59 NS_IMPL_FROMNODE_HELPER(HTMLHeadingElement
, IsHTMLHeadingElement())
62 virtual ~HTMLHeadingElement();
64 JSObject
* WrapNode(JSContext
*, JS::Handle
<JSObject
*> aGivenProto
) override
;
67 static void MapAttributesIntoRule(const nsMappedAttributes
* aAttributes
,
71 } // namespace mozilla::dom
73 #endif // mozilla_dom_HTMLHeadingElement_h