Bug 1265584 [wpt PR 11167] - [Gecko Bug 1265584] Move wptrunner marionette usage...
[gecko.git] / dom / html / HTMLTableCaptionElement.cpp
blobe59c97a3d9ceda1066c116acab1cb228558f10ae
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)
16 namespace mozilla {
17 namespace dom {
19 HTMLTableCaptionElement::~HTMLTableCaptionElement()
23 JSObject*
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 },
36 { nullptr, 0 }
39 bool
40 HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID,
41 nsAtom* aAttribute,
42 const nsAString& aValue,
43 nsIPrincipal* aMaybeScriptedPrincipal,
44 nsAttrValue& aResult)
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);
54 void
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);
67 NS_IMETHODIMP_(bool)
68 HTMLTableCaptionElement::IsAttributeMapped(const nsAtom* aAttribute) const
70 static const MappedAttributeEntry attributes[] = {
71 { &nsGkAtoms::align },
72 { nullptr }
75 static const MappedAttributeEntry* const map[] = {
76 attributes,
77 sCommonAttributeMap,
80 return FindAttributeDependence(aAttribute, map);
83 nsMapRuleToAttributesFunc
84 HTMLTableCaptionElement::GetAttributeMappingFunction() const
86 return &MapAttributesIntoRule;
89 } // namespace dom
90 } // namespace mozilla