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/HTMLTableCaptionElement.h"
9 #include "mozilla/MappedDeclarations.h"
10 #include "nsAttrValueInlines.h"
11 #include "nsMappedAttributes.h"
12 #include "mozilla/dom/HTMLTableCaptionElementBinding.h"
14 NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption
)
19 HTMLTableCaptionElement::~HTMLTableCaptionElement()
24 HTMLTableCaptionElement::WrapNode(JSContext
*aCx
, JS::Handle
<JSObject
*> aGivenProto
)
26 return HTMLTableCaptionElement_Binding::Wrap(aCx
, this, aGivenProto
);
29 NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement
)
31 static const nsAttrValue::EnumTable kCaptionAlignTable
[] = {
32 { "left", NS_STYLE_CAPTION_SIDE_LEFT
},
33 { "right", NS_STYLE_CAPTION_SIDE_RIGHT
},
34 { "top", NS_STYLE_CAPTION_SIDE_TOP
},
35 { "bottom", NS_STYLE_CAPTION_SIDE_BOTTOM
},
40 HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID
,
42 const nsAString
& aValue
,
43 nsIPrincipal
* aMaybeScriptedPrincipal
,
46 if (aAttribute
== nsGkAtoms::align
&& aNamespaceID
== kNameSpaceID_None
) {
47 return aResult
.ParseEnumValue(aValue
, kCaptionAlignTable
, false);
50 return nsGenericHTMLElement::ParseAttribute(aNamespaceID
, aAttribute
, aValue
,
51 aMaybeScriptedPrincipal
, aResult
);
55 HTMLTableCaptionElement::MapAttributesIntoRule(const nsMappedAttributes
* aAttributes
,
56 MappedDeclarations
& aDecls
)
58 if (!aDecls
.PropertyIsSet(eCSSProperty_caption_side
)) {
59 const nsAttrValue
* value
= aAttributes
->GetAttr(nsGkAtoms::align
);
60 if (value
&& value
->Type() == nsAttrValue::eEnum
)
61 aDecls
.SetKeywordValue(eCSSProperty_caption_side
, value
->GetEnumValue());
64 nsGenericHTMLElement::MapCommonAttributesInto(aAttributes
, aDecls
);
68 HTMLTableCaptionElement::IsAttributeMapped(const nsAtom
* aAttribute
) const
70 static const MappedAttributeEntry attributes
[] = {
71 { &nsGkAtoms::align
},
75 static const MappedAttributeEntry
* const map
[] = {
80 return FindAttributeDependence(aAttribute
, map
);
83 nsMapRuleToAttributesFunc
84 HTMLTableCaptionElement::GetAttributeMappingFunction() const
86 return &MapAttributesIntoRule
;
90 } // namespace mozilla