Line data Source code
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/. */
6 :
7 : #include "mozilla/dom/HTMLTableCaptionElement.h"
8 :
9 : #include "mozilla/GenericSpecifiedValuesInlines.h"
10 : #include "nsAttrValueInlines.h"
11 : #include "nsMappedAttributes.h"
12 : #include "mozilla/dom/HTMLTableCaptionElementBinding.h"
13 :
14 0 : NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption)
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 0 : HTMLTableCaptionElement::~HTMLTableCaptionElement()
20 : {
21 0 : }
22 :
23 : JSObject*
24 0 : HTMLTableCaptionElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
25 : {
26 0 : return HTMLTableCaptionElementBinding::Wrap(aCx, this, aGivenProto);
27 : }
28 :
29 0 : NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement)
30 :
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 },
36 : { nullptr, 0 }
37 : };
38 :
39 : bool
40 0 : HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID,
41 : nsIAtom* aAttribute,
42 : const nsAString& aValue,
43 : nsAttrValue& aResult)
44 : {
45 0 : if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
46 0 : return aResult.ParseEnumValue(aValue, kCaptionAlignTable, false);
47 : }
48 :
49 0 : return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
50 0 : aResult);
51 : }
52 :
53 : void
54 0 : HTMLTableCaptionElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
55 : GenericSpecifiedValues* aData)
56 : {
57 0 : if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(TableBorder))) {
58 0 : if (!aData->PropertyIsSet(eCSSProperty_caption_side)) {
59 0 : const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align);
60 0 : if (value && value->Type() == nsAttrValue::eEnum)
61 0 : aData->SetKeywordValue(eCSSProperty_caption_side, value->GetEnumValue());
62 : }
63 : }
64 :
65 0 : nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData);
66 0 : }
67 :
68 : NS_IMETHODIMP_(bool)
69 0 : HTMLTableCaptionElement::IsAttributeMapped(const nsIAtom* aAttribute) const
70 : {
71 : static const MappedAttributeEntry attributes[] = {
72 : { &nsGkAtoms::align },
73 : { nullptr }
74 : };
75 :
76 : static const MappedAttributeEntry* const map[] = {
77 : attributes,
78 : sCommonAttributeMap,
79 : };
80 :
81 0 : return FindAttributeDependence(aAttribute, map);
82 : }
83 :
84 : nsMapRuleToAttributesFunc
85 0 : HTMLTableCaptionElement::GetAttributeMappingFunction() const
86 : {
87 0 : return &MapAttributesIntoRule;
88 : }
89 :
90 : } // namespace dom
91 : } // namespace mozilla
|