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/HTMLBRElement.h"
8 #include "mozilla/dom/HTMLBRElementBinding.h"
9 #include "mozilla/MappedDeclarations.h"
10 #include "nsAttrValueInlines.h"
11 #include "nsStyleConsts.h"
12 #include "nsMappedAttributes.h"
15 NS_IMPL_NS_NEW_HTML_ELEMENT(BR
)
20 HTMLBRElement::HTMLBRElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
21 : nsGenericHTMLElement(std::move(aNodeInfo
))
25 HTMLBRElement::~HTMLBRElement()
29 NS_IMPL_ELEMENT_CLONE(HTMLBRElement
)
31 static const nsAttrValue::EnumTable kClearTable
[] = {
32 { "left", StyleClear::Left
},
33 { "right", StyleClear::Right
},
34 { "all", StyleClear::Both
},
35 { "both", StyleClear::Both
},
40 HTMLBRElement::ParseAttribute(int32_t aNamespaceID
,
42 const nsAString
& aValue
,
43 nsIPrincipal
* aMaybeScriptedPrincipal
,
46 if (aAttribute
== nsGkAtoms::clear
&& aNamespaceID
== kNameSpaceID_None
) {
47 return aResult
.ParseEnumValue(aValue
, kClearTable
, false);
50 return nsGenericHTMLElement::ParseAttribute(aNamespaceID
, aAttribute
, aValue
,
51 aMaybeScriptedPrincipal
, aResult
);
55 HTMLBRElement::MapAttributesIntoRule(const nsMappedAttributes
* aAttributes
,
56 MappedDeclarations
& aDecls
)
58 if (!aDecls
.PropertyIsSet(eCSSProperty_clear
)) {
59 const nsAttrValue
* value
= aAttributes
->GetAttr(nsGkAtoms::clear
);
60 if (value
&& value
->Type() == nsAttrValue::eEnum
)
61 aDecls
.SetKeywordValue(eCSSProperty_clear
, value
->GetEnumValue());
63 nsGenericHTMLElement::MapCommonAttributesInto(aAttributes
, aDecls
);
67 HTMLBRElement::IsAttributeMapped(const nsAtom
* aAttribute
) const
69 static const MappedAttributeEntry attributes
[] = {
74 static const MappedAttributeEntry
* const map
[] = {
79 return FindAttributeDependence(aAttribute
, map
);
82 nsMapRuleToAttributesFunc
83 HTMLBRElement::GetAttributeMappingFunction() const
85 return &MapAttributesIntoRule
;
89 HTMLBRElement::WrapNode(JSContext
*aCx
, JS::Handle
<JSObject
*> aGivenProto
)
91 return HTMLBRElement_Binding::Wrap(aCx
, this, aGivenProto
);
95 } // namespace mozilla