Coverage Report

Created: 2018-09-25 14:53

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