Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HTMLMenuElement.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
#ifndef mozilla_dom_HTMLMenuElement_h
8
#define mozilla_dom_HTMLMenuElement_h
9
10
#include "mozilla/Attributes.h"
11
#include "nsGenericHTMLElement.h"
12
13
class nsIMenuBuilder;
14
15
namespace mozilla {
16
namespace dom {
17
18
class HTMLMenuElement final : public nsGenericHTMLElement
19
{
20
public:
21
  explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
22
23
  NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuElement, menu)
24
25
  // nsISupports
26
  NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuElement, nsGenericHTMLElement)
27
28
  virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
29
                                const nsAttrValue* aValue,
30
                                const nsAttrValue* aOldValue,
31
                                nsIPrincipal* aSubjectPrincipal,
32
                                bool aNotify) override;
33
  virtual bool ParseAttribute(int32_t aNamespaceID,
34
                                nsAtom* aAttribute,
35
                                const nsAString& aValue,
36
                                nsIPrincipal* aMaybeScriptedPrincipal,
37
                                nsAttrValue& aResult) override;
38
39
  virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
40
41
0
  uint8_t GetType() const { return mType; }
42
43
  // WebIDL
44
45
  void GetType(nsAString& aValue)
46
0
  {
47
0
    GetHTMLAttr(nsGkAtoms::type, aValue);
48
0
  }
49
  void SetType(const nsAString& aType, ErrorResult& aError)
50
0
  {
51
0
    SetHTMLAttr(nsGkAtoms::type, aType, aError);
52
0
  }
53
54
  void GetLabel(nsAString& aValue)
55
0
  {
56
0
    GetHTMLAttr(nsGkAtoms::label, aValue);
57
0
  }
58
  void SetLabel(const nsAString& aLabel, ErrorResult& aError)
59
0
  {
60
0
    SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
61
0
  }
62
63
  bool Compact() const
64
0
  {
65
0
    return GetBoolAttr(nsGkAtoms::compact);
66
0
  }
67
  void SetCompact(bool aCompact, ErrorResult& aError)
68
0
  {
69
0
    SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aError);
70
0
  }
71
72
  void SendShowEvent();
73
74
  already_AddRefed<nsIMenuBuilder> CreateBuilder();
75
76
  void Build(nsIMenuBuilder* aBuilder);
77
78
protected:
79
  virtual ~HTMLMenuElement();
80
81
  virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
82
83
84
protected:
85
  static bool CanLoadIcon(nsIContent* aContent, const nsAString& aIcon);
86
87
  void BuildSubmenu(const nsAString& aLabel,
88
                    nsIContent* aContent,
89
                    nsIMenuBuilder* aBuilder);
90
91
  void TraverseContent(nsIContent* aContent,
92
                       nsIMenuBuilder* aBuilder,
93
                       int8_t& aSeparator);
94
95
  void AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator);
96
97
  uint8_t mType;
98
};
99
100
} // namespace dom
101
} // namespace mozilla
102
103
#endif // mozilla_dom_HTMLMenuElement_h