Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / html / HTMLTableCaptionElement.cpp
blob4370d0acb643af4eb51fd5b0e8588f2c9e358479
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)
14 namespace mozilla {
15 namespace dom {
17 HTMLTableCaptionElement::~HTMLTableCaptionElement()
21 JSObject*
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 },
39 { 0 }
42 bool
43 HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID,
44 nsIAtom* aAttribute,
45 const nsAString& aValue,
46 nsAttrValue& aResult)
48 if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
49 return aResult.ParseEnumValue(aValue, kCaptionAlignTable, false);
52 return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
53 aResult);
56 void
57 HTMLTableCaptionElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
58 nsRuleData* aData)
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);
72 NS_IMETHODIMP_(bool)
73 HTMLTableCaptionElement::IsAttributeMapped(const nsIAtom* aAttribute) const
75 static const MappedAttributeEntry attributes[] = {
76 { &nsGkAtoms::align },
77 { nullptr }
80 static const MappedAttributeEntry* const map[] = {
81 attributes,
82 sCommonAttributeMap,
85 return FindAttributeDependence(aAttribute, map);
88 nsMapRuleToAttributesFunc
89 HTMLTableCaptionElement::GetAttributeMappingFunction() const
91 return &MapAttributesIntoRule;
94 } // namespace dom
95 } // namespace mozilla