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() {}
21 JSObject
* HTMLTableCaptionElement::WrapNode(JSContext
* aCx
,
22 JS::Handle
<JSObject
*> aGivenProto
) {
23 return HTMLTableCaptionElement_Binding::Wrap(aCx
, this, aGivenProto
);
26 NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement
)
28 static const nsAttrValue::EnumTable kCaptionAlignTable
[] = {
29 {"left", NS_STYLE_CAPTION_SIDE_LEFT
},
30 {"right", NS_STYLE_CAPTION_SIDE_RIGHT
},
31 {"top", NS_STYLE_CAPTION_SIDE_TOP
},
32 {"bottom", NS_STYLE_CAPTION_SIDE_BOTTOM
},
35 bool HTMLTableCaptionElement::ParseAttribute(
36 int32_t aNamespaceID
, nsAtom
* aAttribute
, const nsAString
& aValue
,
37 nsIPrincipal
* aMaybeScriptedPrincipal
, nsAttrValue
& aResult
) {
38 if (aAttribute
== nsGkAtoms::align
&& aNamespaceID
== kNameSpaceID_None
) {
39 return aResult
.ParseEnumValue(aValue
, kCaptionAlignTable
, false);
42 return nsGenericHTMLElement::ParseAttribute(aNamespaceID
, aAttribute
, aValue
,
43 aMaybeScriptedPrincipal
, aResult
);
46 void HTMLTableCaptionElement::MapAttributesIntoRule(
47 const nsMappedAttributes
* aAttributes
, MappedDeclarations
& aDecls
) {
48 if (!aDecls
.PropertyIsSet(eCSSProperty_caption_side
)) {
49 const nsAttrValue
* value
= aAttributes
->GetAttr(nsGkAtoms::align
);
50 if (value
&& value
->Type() == nsAttrValue::eEnum
)
51 aDecls
.SetKeywordValue(eCSSProperty_caption_side
, value
->GetEnumValue());
54 nsGenericHTMLElement::MapCommonAttributesInto(aAttributes
, aDecls
);
58 HTMLTableCaptionElement::IsAttributeMapped(const nsAtom
* aAttribute
) const {
59 static const MappedAttributeEntry attributes
[] = {{nsGkAtoms::align
},
62 static const MappedAttributeEntry
* const map
[] = {
67 return FindAttributeDependence(aAttribute
, map
);
70 nsMapRuleToAttributesFunc
HTMLTableCaptionElement::GetAttributeMappingFunction()
72 return &MapAttributesIntoRule
;
76 } // namespace mozilla