1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/HTMLBRElement.h"
7 #include "mozilla/dom/HTMLBRElementBinding.h"
9 #include "nsAttrValueInlines.h"
10 #include "nsStyleConsts.h"
11 #include "nsMappedAttributes.h"
12 #include "nsRuleData.h"
15 NS_IMPL_NS_NEW_HTML_ELEMENT(BR
)
20 HTMLBRElement::HTMLBRElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
)
21 : nsGenericHTMLElement(aNodeInfo
)
25 HTMLBRElement::~HTMLBRElement()
29 NS_IMPL_ISUPPORTS_INHERITED(HTMLBRElement
, nsGenericHTMLElement
,
32 NS_IMPL_ELEMENT_CLONE(HTMLBRElement
)
35 NS_IMPL_STRING_ATTR(HTMLBRElement
, Clear
, clear
)
37 static const nsAttrValue::EnumTable kClearTable
[] = {
38 { "left", NS_STYLE_CLEAR_LEFT
},
39 { "right", NS_STYLE_CLEAR_RIGHT
},
40 { "all", NS_STYLE_CLEAR_BOTH
},
41 { "both", NS_STYLE_CLEAR_BOTH
},
46 HTMLBRElement::ParseAttribute(int32_t aNamespaceID
,
48 const nsAString
& aValue
,
51 if (aAttribute
== nsGkAtoms::clear
&& aNamespaceID
== kNameSpaceID_None
) {
52 return aResult
.ParseEnumValue(aValue
, kClearTable
, false);
55 return nsGenericHTMLElement::ParseAttribute(aNamespaceID
, aAttribute
, aValue
,
60 HTMLBRElement::MapAttributesIntoRule(const nsMappedAttributes
* aAttributes
,
63 if (aData
->mSIDs
& NS_STYLE_INHERIT_BIT(Display
)) {
64 nsCSSValue
* clear
= aData
->ValueForClear();
65 if (clear
->GetUnit() == eCSSUnit_Null
) {
66 const nsAttrValue
* value
= aAttributes
->GetAttr(nsGkAtoms::clear
);
67 if (value
&& value
->Type() == nsAttrValue::eEnum
)
68 clear
->SetIntValue(value
->GetEnumValue(), eCSSUnit_Enumerated
);
72 nsGenericHTMLElement::MapCommonAttributesInto(aAttributes
, aData
);
76 HTMLBRElement::IsAttributeMapped(const nsIAtom
* aAttribute
) const
78 static const MappedAttributeEntry attributes
[] = {
79 { &nsGkAtoms::clear
},
83 static const MappedAttributeEntry
* const map
[] = {
88 return FindAttributeDependence(aAttribute
, map
);
91 nsMapRuleToAttributesFunc
92 HTMLBRElement::GetAttributeMappingFunction() const
94 return &MapAttributesIntoRule
;
98 HTMLBRElement::WrapNode(JSContext
*aCx
)
100 return HTMLBRElementBinding::Wrap(aCx
, this);
104 } // namespace mozilla