Bug 1494333 - index crons just like artifacts r=Callek
[gecko.git] / dom / html / HTMLBRElement.cpp
blobfd2e7406b86c56852d3bfdb16a289492ae9586a0
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)
17 namespace mozilla {
18 namespace dom {
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 },
36 { nullptr, 0 }
39 bool
40 HTMLBRElement::ParseAttribute(int32_t aNamespaceID,
41 nsAtom* aAttribute,
42 const nsAString& aValue,
43 nsIPrincipal* aMaybeScriptedPrincipal,
44 nsAttrValue& aResult)
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);
54 void
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);
66 NS_IMETHODIMP_(bool)
67 HTMLBRElement::IsAttributeMapped(const nsAtom* aAttribute) const
69 static const MappedAttributeEntry attributes[] = {
70 { nsGkAtoms::clear },
71 { nullptr }
74 static const MappedAttributeEntry* const map[] = {
75 attributes,
76 sCommonAttributeMap,
79 return FindAttributeDependence(aAttribute, map);
82 nsMapRuleToAttributesFunc
83 HTMLBRElement::GetAttributeMappingFunction() const
85 return &MapAttributesIntoRule;
88 JSObject*
89 HTMLBRElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
91 return HTMLBRElement_Binding::Wrap(aCx, this, aGivenProto);
94 } // namespace dom
95 } // namespace mozilla