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 #include "mozilla/dom/HTMLHeadingElement.h"
8 #include "mozilla/dom/HTMLHeadingElementBinding.h"
10 #include "mozilla/MappedDeclarationsBuilder.h"
11 #include "nsGkAtoms.h"
13 NS_IMPL_NS_NEW_HTML_ELEMENT(Heading
)
15 namespace mozilla::dom
{
17 HTMLHeadingElement::~HTMLHeadingElement() = default;
19 NS_IMPL_ELEMENT_CLONE(HTMLHeadingElement
)
21 JSObject
* HTMLHeadingElement::WrapNode(JSContext
* aCx
,
22 JS::Handle
<JSObject
*> aGivenProto
) {
23 return HTMLHeadingElement_Binding::Wrap(aCx
, this, aGivenProto
);
26 bool HTMLHeadingElement::ParseAttribute(int32_t aNamespaceID
,
28 const nsAString
& aValue
,
29 nsIPrincipal
* aMaybeScriptedPrincipal
,
30 nsAttrValue
& aResult
) {
31 if (aAttribute
== nsGkAtoms::align
&& aNamespaceID
== kNameSpaceID_None
) {
32 return ParseDivAlignValue(aValue
, aResult
);
35 return nsGenericHTMLElement::ParseAttribute(aNamespaceID
, aAttribute
, aValue
,
36 aMaybeScriptedPrincipal
, aResult
);
39 void HTMLHeadingElement::MapAttributesIntoRule(
40 MappedDeclarationsBuilder
& aBuilder
) {
41 nsGenericHTMLElement::MapDivAlignAttributeInto(aBuilder
);
42 nsGenericHTMLElement::MapCommonAttributesInto(aBuilder
);
46 HTMLHeadingElement::IsAttributeMapped(const nsAtom
* aAttribute
) const {
47 static const MappedAttributeEntry
* const map
[] = {sDivAlignAttributeMap
,
50 return FindAttributeDependence(aAttribute
, map
);
53 nsMapRuleToAttributesFunc
HTMLHeadingElement::GetAttributeMappingFunction()
55 return &MapAttributesIntoRule
;
58 } // namespace mozilla::dom