Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/Attr.h
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
/*
8
 * Implementation of DOM Core's Attr node.
9
 */
10
11
#ifndef mozilla_dom_Attr_h
12
#define mozilla_dom_Attr_h
13
14
#include "mozilla/Attributes.h"
15
#include "nsINode.h"
16
#include "nsString.h"
17
#include "nsCOMPtr.h"
18
#include "nsCycleCollectionParticipant.h"
19
#include "nsStubMutationObserver.h"
20
21
class nsIDocument;
22
23
namespace mozilla {
24
class EventChainPreVisitor;
25
namespace dom {
26
27
// Attribute helper class used to wrap up an attribute with a dom
28
// object that implements the DOM Attr interface.
29
class Attr final : public nsINode
30
{
31
0
  virtual ~Attr() {}
32
33
public:
34
  Attr(nsDOMAttributeMap* aAttrMap,
35
       already_AddRefed<dom::NodeInfo>&& aNodeInfo,
36
       const nsAString& aValue);
37
38
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39
40
  NS_IMPL_FROMNODE_HELPER(Attr, IsAttr())
41
42
  // nsINode interface
43
  virtual void GetTextContentInternal(nsAString& aTextContent,
44
                                      OOMReporter& aError) override;
45
  virtual void SetTextContentInternal(const nsAString& aTextContent,
46
                                      nsIPrincipal* aSubjectPrincipal,
47
                                      ErrorResult& aError) override;
48
  virtual void GetNodeValueInternal(nsAString& aNodeValue) override;
49
  virtual void SetNodeValueInternal(const nsAString& aNodeValue,
50
                                    ErrorResult& aError) override;
51
52
  void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
53
54
  void ConstructUbiNode(void* storage) override;
55
56
  nsDOMAttributeMap* GetMap()
57
0
  {
58
0
    return mAttrMap;
59
0
  }
60
61
  void SetMap(nsDOMAttributeMap *aMap);
62
63
  Element* GetElement() const;
64
65
  /**
66
   * Called when our ownerElement is moved into a new document.
67
   * Updates the nodeinfo of this node.
68
   */
69
  nsresult SetOwnerDocument(nsIDocument* aDocument);
70
71
  // nsINode interface
72
  virtual bool IsNodeOfType(uint32_t aFlags) const override;
73
  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
74
  virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
75
76
  static void Initialize();
77
  static void Shutdown();
78
79
  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(Attr)
80
81
  // WebIDL
82
  virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
83
84
  void GetName(nsAString& aName);
85
  void GetValue(nsAString& aValue);
86
87
  void SetValue(const nsAString& aValue, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv);
88
  void SetValue(const nsAString& aValue, ErrorResult& aRv);
89
90
  bool Specified() const;
91
92
  // XPCOM GetNamespaceURI() is OK
93
  // XPCOM GetPrefix() is OK
94
  // XPCOM GetLocalName() is OK
95
96
  Element* GetOwnerElement(ErrorResult& aRv);
97
98
protected:
99
  virtual Element* GetNameSpaceElement() override
100
0
  {
101
0
    return GetElement();
102
0
  }
103
104
  static bool sInitialized;
105
106
private:
107
  RefPtr<nsDOMAttributeMap> mAttrMap;
108
  nsString mValue;
109
};
110
111
} // namespace dom
112
} // namespace mozilla
113
114
#endif /* mozilla_dom_Attr_h */