Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/html/HTMLBRElement.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/HTMLBRElement.h"
8
#include "mozilla/dom/HTMLBRElementBinding.h"
9
#include "mozilla/MappedDeclarations.h"
10
#include "nsAttrValueInlines.h"
11
#include "nsStyleConsts.h"
12
#include "nsMappedAttributes.h"
13
14
15
NS_IMPL_NS_NEW_HTML_ELEMENT(BR)
16
17
namespace mozilla {
18
namespace dom {
19
20
HTMLBRElement::HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
21
  : nsGenericHTMLElement(std::move(aNodeInfo))
22
0
{
23
0
}
24
25
HTMLBRElement::~HTMLBRElement()
26
0
{
27
0
}
28
29
NS_IMPL_ELEMENT_CLONE(HTMLBRElement)
30
31
static const nsAttrValue::EnumTable kClearTable[] = {
32
  { "left", StyleClear::Left },
33
  { "right", StyleClear::Right },
34
  { "all", StyleClear::Both },
35
  { "both", StyleClear::Both },
36
  { nullptr, 0 }
37
};
38
39
bool
40
HTMLBRElement::ParseAttribute(int32_t aNamespaceID,
41
                              nsAtom* aAttribute,
42
                              const nsAString& aValue,
43
                              nsIPrincipal* aMaybeScriptedPrincipal,
44
                              nsAttrValue& aResult)
45
0
{
46
0
  if (aAttribute == nsGkAtoms::clear && aNamespaceID == kNameSpaceID_None) {
47
0
    return aResult.ParseEnumValue(aValue, kClearTable, false);
48
0
  }
49
0
50
0
  return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
51
0
                                              aMaybeScriptedPrincipal, aResult);
52
0
}
53
54
void
55
HTMLBRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
56
                                     MappedDeclarations& aDecls)
57
0
{
58
0
  if (!aDecls.PropertyIsSet(eCSSProperty_clear)) {
59
0
    const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::clear);
60
0
    if (value && value->Type() == nsAttrValue::eEnum)
61
0
      aDecls.SetKeywordValue(eCSSProperty_clear, value->GetEnumValue());
62
0
  }
63
0
  nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aDecls);
64
0
}
65
66
NS_IMETHODIMP_(bool)
67
HTMLBRElement::IsAttributeMapped(const nsAtom* aAttribute) const
68
0
{
69
0
  static const MappedAttributeEntry attributes[] = {
70
0
    { &nsGkAtoms::clear },
71
0
    { nullptr }
72
0
  };
73
0
74
0
  static const MappedAttributeEntry* const map[] = {
75
0
    attributes,
76
0
    sCommonAttributeMap,
77
0
  };
78
0
79
0
  return FindAttributeDependence(aAttribute, map);
80
0
}
81
82
nsMapRuleToAttributesFunc
83
HTMLBRElement::GetAttributeMappingFunction() const
84
0
{
85
0
  return &MapAttributesIntoRule;
86
0
}
87
88
JSObject*
89
HTMLBRElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
90
0
{
91
0
  return HTMLBRElement_Binding::Wrap(aCx, this, aGivenProto);
92
0
}
93
94
} // namespace dom
95
} // namespace mozilla