Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / html / HTMLBRElement.cpp
blobfa213e3c6d4238eb0bde077904eb86d58da2d49f
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)
17 namespace mozilla {
18 namespace dom {
20 HTMLBRElement::HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
21 : nsGenericHTMLElement(aNodeInfo)
25 HTMLBRElement::~HTMLBRElement()
29 NS_IMPL_ISUPPORTS_INHERITED(HTMLBRElement, nsGenericHTMLElement,
30 nsIDOMHTMLBRElement)
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 },
42 { 0 }
45 bool
46 HTMLBRElement::ParseAttribute(int32_t aNamespaceID,
47 nsIAtom* aAttribute,
48 const nsAString& aValue,
49 nsAttrValue& aResult)
51 if (aAttribute == nsGkAtoms::clear && aNamespaceID == kNameSpaceID_None) {
52 return aResult.ParseEnumValue(aValue, kClearTable, false);
55 return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
56 aResult);
59 void
60 HTMLBRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
61 nsRuleData* aData)
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);
75 NS_IMETHODIMP_(bool)
76 HTMLBRElement::IsAttributeMapped(const nsIAtom* aAttribute) const
78 static const MappedAttributeEntry attributes[] = {
79 { &nsGkAtoms::clear },
80 { nullptr }
83 static const MappedAttributeEntry* const map[] = {
84 attributes,
85 sCommonAttributeMap,
88 return FindAttributeDependence(aAttribute, map);
91 nsMapRuleToAttributesFunc
92 HTMLBRElement::GetAttributeMappingFunction() const
94 return &MapAttributesIntoRule;
97 JSObject*
98 HTMLBRElement::WrapNode(JSContext *aCx)
100 return HTMLBRElementBinding::Wrap(aCx, this);
103 } // namespace dom
104 } // namespace mozilla