Bug 1732219 - Add API for fetching the preview image. r=geckoview-reviewers,agi,mconley
[gecko.git] / dom / html / HTMLHeadingElement.h
blob4c656d5cd79251ce2e1fa7f5bf0f009e24502276
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 {
14 namespace dom {
16 class HTMLHeadingElement final : public nsGenericHTMLElement {
17 public:
18 explicit HTMLHeadingElement(
19 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
20 : nsGenericHTMLElement(std::move(aNodeInfo)) {
21 MOZ_ASSERT(IsHTMLHeadingElement());
24 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
25 const nsAString& aValue,
26 nsIPrincipal* aMaybeScriptedPrincipal,
27 nsAttrValue& aResult) override;
28 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
29 nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
30 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
32 void SetAlign(const nsAString& aAlign, ErrorResult& aError) {
33 return SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
35 void GetAlign(DOMString& aAlign) const {
36 return GetHTMLAttr(nsGkAtoms::align, aAlign);
39 int32_t AccessibilityLevel() const {
40 nsAtom* name = NodeInfo()->NameAtom();
41 if (name == nsGkAtoms::h1) {
42 return 1;
44 if (name == nsGkAtoms::h2) {
45 return 2;
47 if (name == nsGkAtoms::h3) {
48 return 3;
50 if (name == nsGkAtoms::h4) {
51 return 4;
53 if (name == nsGkAtoms::h5) {
54 return 5;
56 MOZ_ASSERT(name == nsGkAtoms::h6);
57 return 6;
60 NS_IMPL_FROMNODE_HELPER(HTMLHeadingElement, IsHTMLHeadingElement())
62 protected:
63 virtual ~HTMLHeadingElement();
65 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
67 private:
68 static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
69 MappedDeclarations&);
72 } // namespace dom
73 } // namespace mozilla
75 #endif // mozilla_dom_HTMLHeadingElement_h