Backed out changeset 62f7af8fe549 (bug 1843981) for causing valgrind bustage. CLOSED...
[gecko.git] / dom / html / HTMLBRElement.cpp
blob5145c9ea3b3285a72a18ef3c39dbc7d597174649
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/MappedDeclarationsBuilder.h"
10 #include "nsAttrValueInlines.h"
11 #include "nsStyleConsts.h"
13 NS_IMPL_NS_NEW_HTML_ELEMENT(BR)
15 namespace mozilla::dom {
17 HTMLBRElement::HTMLBRElement(
18 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
19 : nsGenericHTMLElement(std::move(aNodeInfo)) {}
21 HTMLBRElement::~HTMLBRElement() = default;
23 NS_IMPL_ELEMENT_CLONE(HTMLBRElement)
25 static const nsAttrValue::EnumTable kClearTable[] = {
26 {"left", StyleClear::Left},
27 {"right", StyleClear::Right},
28 {"all", StyleClear::Both},
29 {"both", StyleClear::Both},
30 {nullptr, 0}};
32 bool HTMLBRElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
33 const nsAString& aValue,
34 nsIPrincipal* aMaybeScriptedPrincipal,
35 nsAttrValue& aResult) {
36 if (aAttribute == nsGkAtoms::clear && aNamespaceID == kNameSpaceID_None) {
37 return aResult.ParseEnumValue(aValue, kClearTable, false);
40 return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
41 aMaybeScriptedPrincipal, aResult);
44 void HTMLBRElement::MapAttributesIntoRule(MappedDeclarationsBuilder& aBuilder) {
45 if (!aBuilder.PropertyIsSet(eCSSProperty_clear)) {
46 const nsAttrValue* value = aBuilder.GetAttr(nsGkAtoms::clear);
47 if (value && value->Type() == nsAttrValue::eEnum) {
48 aBuilder.SetKeywordValue(eCSSProperty_clear, value->GetEnumValue());
51 nsGenericHTMLElement::MapCommonAttributesInto(aBuilder);
54 NS_IMETHODIMP_(bool)
55 HTMLBRElement::IsAttributeMapped(const nsAtom* aAttribute) const {
56 static const MappedAttributeEntry attributes[] = {{nsGkAtoms::clear},
57 {nullptr}};
59 static const MappedAttributeEntry* const map[] = {
60 attributes,
61 sCommonAttributeMap,
64 return FindAttributeDependence(aAttribute, map);
67 nsMapRuleToAttributesFunc HTMLBRElement::GetAttributeMappingFunction() const {
68 return &MapAttributesIntoRule;
71 JSObject* HTMLBRElement::WrapNode(JSContext* aCx,
72 JS::Handle<JSObject*> aGivenProto) {
73 return HTMLBRElement_Binding::Wrap(aCx, this, aGivenProto);
76 } // namespace mozilla::dom