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/HTMLTableCaptionElement.h"
7 #include "nsAttrValueInlines.h"
8 #include "nsMappedAttributes.h"
9 #include "nsRuleData.h"
10 #include "mozilla/dom/HTMLTableCaptionElementBinding.h"
12 NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption
)
17 HTMLTableCaptionElement::~HTMLTableCaptionElement()
22 HTMLTableCaptionElement::WrapNode(JSContext
*aCx
)
24 return HTMLTableCaptionElementBinding::Wrap(aCx
, this);
27 NS_IMPL_ISUPPORTS_INHERITED(HTMLTableCaptionElement
, nsGenericHTMLElement
,
28 nsIDOMHTMLTableCaptionElement
)
30 NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement
)
32 NS_IMPL_STRING_ATTR(HTMLTableCaptionElement
, Align
, align
)
34 static const nsAttrValue::EnumTable kCaptionAlignTable
[] = {
35 { "left", NS_STYLE_CAPTION_SIDE_LEFT
},
36 { "right", NS_STYLE_CAPTION_SIDE_RIGHT
},
37 { "top", NS_STYLE_CAPTION_SIDE_TOP
},
38 { "bottom", NS_STYLE_CAPTION_SIDE_BOTTOM
},
43 HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID
,
45 const nsAString
& aValue
,
48 if (aAttribute
== nsGkAtoms::align
&& aNamespaceID
== kNameSpaceID_None
) {
49 return aResult
.ParseEnumValue(aValue
, kCaptionAlignTable
, false);
52 return nsGenericHTMLElement::ParseAttribute(aNamespaceID
, aAttribute
, aValue
,
57 HTMLTableCaptionElement::MapAttributesIntoRule(const nsMappedAttributes
* aAttributes
,
60 if (aData
->mSIDs
& NS_STYLE_INHERIT_BIT(TableBorder
)) {
61 nsCSSValue
* captionSide
= aData
->ValueForCaptionSide();
62 if (captionSide
->GetUnit() == eCSSUnit_Null
) {
63 const nsAttrValue
* value
= aAttributes
->GetAttr(nsGkAtoms::align
);
64 if (value
&& value
->Type() == nsAttrValue::eEnum
)
65 captionSide
->SetIntValue(value
->GetEnumValue(), eCSSUnit_Enumerated
);
69 nsGenericHTMLElement::MapCommonAttributesInto(aAttributes
, aData
);
73 HTMLTableCaptionElement::IsAttributeMapped(const nsIAtom
* aAttribute
) const
75 static const MappedAttributeEntry attributes
[] = {
76 { &nsGkAtoms::align
},
80 static const MappedAttributeEntry
* const map
[] = {
85 return FindAttributeDependence(aAttribute
, map
);
88 nsMapRuleToAttributesFunc
89 HTMLTableCaptionElement::GetAttributeMappingFunction() const
91 return &MapAttributesIntoRule
;
95 } // namespace mozilla