Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLTableCaptionElement.cpp
blob8b2657b4f3912824b87f99a71154f686df56a039
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/MappedDeclarationsBuilder.h"
10 #include "nsAttrValueInlines.h"
11 #include "nsStyleConsts.h"
12 #include "mozilla/dom/HTMLTableCaptionElementBinding.h"
14 NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption)
16 namespace mozilla::dom {
18 HTMLTableCaptionElement::~HTMLTableCaptionElement() = default;
20 JSObject* HTMLTableCaptionElement::WrapNode(JSContext* aCx,
21 JS::Handle<JSObject*> aGivenProto) {
22 return HTMLTableCaptionElement_Binding::Wrap(aCx, this, aGivenProto);
25 NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement)
27 static const nsAttrValue::EnumTable kCaptionAlignTable[] = {
28 {"top", StyleCaptionSide::Top},
29 {"bottom", StyleCaptionSide::Bottom},
30 {nullptr, 0}};
32 bool HTMLTableCaptionElement::ParseAttribute(
33 int32_t aNamespaceID, nsAtom* aAttribute, const nsAString& aValue,
34 nsIPrincipal* aMaybeScriptedPrincipal, nsAttrValue& aResult) {
35 if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) {
36 return aResult.ParseEnumValue(aValue, kCaptionAlignTable, false);
39 return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
40 aMaybeScriptedPrincipal, aResult);
43 void HTMLTableCaptionElement::MapAttributesIntoRule(
44 MappedDeclarationsBuilder& aBuilder) {
45 if (!aBuilder.PropertyIsSet(eCSSProperty_caption_side)) {
46 const nsAttrValue* value = aBuilder.GetAttr(nsGkAtoms::align);
47 if (value && value->Type() == nsAttrValue::eEnum) {
48 aBuilder.SetKeywordValue(eCSSProperty_caption_side,
49 value->GetEnumValue());
52 nsGenericHTMLElement::MapCommonAttributesInto(aBuilder);
55 NS_IMETHODIMP_(bool)
56 HTMLTableCaptionElement::IsAttributeMapped(const nsAtom* aAttribute) const {
57 static const MappedAttributeEntry attributes[] = {{nsGkAtoms::align},
58 {nullptr}};
60 static const MappedAttributeEntry* const map[] = {
61 attributes,
62 sCommonAttributeMap,
65 return FindAttributeDependence(aAttribute, map);
68 nsMapRuleToAttributesFunc HTMLTableCaptionElement::GetAttributeMappingFunction()
69 const {
70 return &MapAttributesIntoRule;
73 } // namespace mozilla::dom