Coverage Report

Created: 2018-09-25 14:53

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