/work/obj-fuzz/dist/include/mozilla/dom/HTMLSharedElement.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_HTMLSharedElement_h |
8 | | #define mozilla_dom_HTMLSharedElement_h |
9 | | |
10 | | #include "nsGenericHTMLElement.h" |
11 | | |
12 | | #include "nsGkAtoms.h" |
13 | | |
14 | | #include "mozilla/Attributes.h" |
15 | | #include "mozilla/Assertions.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | class HTMLSharedElement final : public nsGenericHTMLElement |
21 | | { |
22 | | public: |
23 | | explicit HTMLSharedElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) |
24 | | : nsGenericHTMLElement(std::move(aNodeInfo)) |
25 | 0 | { |
26 | 0 | if (mNodeInfo->Equals(nsGkAtoms::head) || |
27 | 0 | mNodeInfo->Equals(nsGkAtoms::html)) { |
28 | 0 | SetHasWeirdParserInsertionMode(); |
29 | 0 | } |
30 | 0 | } |
31 | | |
32 | | // nsIContent |
33 | | virtual void DoneAddingChildren(bool aHaveNotified) override; |
34 | | |
35 | | virtual bool ParseAttribute(int32_t aNamespaceID, |
36 | | nsAtom* aAttribute, |
37 | | const nsAString& aValue, |
38 | | nsIPrincipal* aMaybeScriptedPrincipal, |
39 | | nsAttrValue& aResult) override; |
40 | | |
41 | | virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
42 | | nsIContent* aBindingParent) override; |
43 | | |
44 | | virtual void UnbindFromTree(bool aDeep = true, |
45 | | bool aNullParent = true) override; |
46 | | |
47 | | virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override; |
48 | | NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; |
49 | | |
50 | | virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; |
51 | | |
52 | | // WebIDL API |
53 | | // HTMLParamElement |
54 | | void GetName(DOMString& aValue) |
55 | 0 | { |
56 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
57 | 0 | GetHTMLAttr(nsGkAtoms::name, aValue); |
58 | 0 | } |
59 | | void SetName(const nsAString& aValue, ErrorResult& aResult) |
60 | 0 | { |
61 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
62 | 0 | SetHTMLAttr(nsGkAtoms::name, aValue, aResult); |
63 | 0 | } |
64 | | void GetValue(DOMString& aValue) |
65 | 0 | { |
66 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
67 | 0 | GetHTMLAttr(nsGkAtoms::value, aValue); |
68 | 0 | } |
69 | | void SetValue(const nsAString& aValue, ErrorResult& aResult) |
70 | 0 | { |
71 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
72 | 0 | SetHTMLAttr(nsGkAtoms::value, aValue, aResult); |
73 | 0 | } |
74 | | void GetType(DOMString& aValue) |
75 | 0 | { |
76 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
77 | 0 | GetHTMLAttr(nsGkAtoms::type, aValue); |
78 | 0 | } |
79 | | void SetType(const nsAString& aValue, ErrorResult& aResult) |
80 | 0 | { |
81 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
82 | 0 | SetHTMLAttr(nsGkAtoms::type, aValue, aResult); |
83 | 0 | } |
84 | | void GetValueType(DOMString& aValue) |
85 | 0 | { |
86 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
87 | 0 | GetHTMLAttr(nsGkAtoms::valuetype, aValue); |
88 | 0 | } |
89 | | void SetValueType(const nsAString& aValue, ErrorResult& aResult) |
90 | 0 | { |
91 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param)); |
92 | 0 | SetHTMLAttr(nsGkAtoms::valuetype, aValue, aResult); |
93 | 0 | } |
94 | | |
95 | | // HTMLBaseElement |
96 | | void GetTarget(DOMString& aValue) |
97 | 0 | { |
98 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base)); |
99 | 0 | GetHTMLAttr(nsGkAtoms::target, aValue); |
100 | 0 | } |
101 | | void SetTarget(const nsAString& aValue, ErrorResult& aResult) |
102 | 0 | { |
103 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base)); |
104 | 0 | SetHTMLAttr(nsGkAtoms::target, aValue, aResult); |
105 | 0 | } |
106 | | |
107 | | void GetHref(nsAString& aValue); |
108 | | void SetHref(const nsAString& aValue, ErrorResult& aResult) |
109 | 0 | { |
110 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base)); |
111 | 0 | SetHTMLAttr(nsGkAtoms::href, aValue, aResult); |
112 | 0 | } |
113 | | |
114 | | // HTMLDirectoryElement |
115 | | bool Compact() const |
116 | 0 | { |
117 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::dir)); |
118 | 0 | return GetBoolAttr(nsGkAtoms::compact); |
119 | 0 | } |
120 | | void SetCompact(bool aCompact, ErrorResult& aResult) |
121 | 0 | { |
122 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::dir)); |
123 | 0 | SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aResult); |
124 | 0 | } |
125 | | |
126 | | // HTMLQuoteElement |
127 | | void GetCite(nsString& aCite) |
128 | 0 | { |
129 | 0 | GetHTMLURIAttr(nsGkAtoms::cite, aCite); |
130 | 0 | } |
131 | | |
132 | | void SetCite(const nsAString& aValue, ErrorResult& aResult) |
133 | 0 | { |
134 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::q) || |
135 | 0 | mNodeInfo->Equals(nsGkAtoms::blockquote)); |
136 | 0 | SetHTMLAttr(nsGkAtoms::cite, aValue, aResult); |
137 | 0 | } |
138 | | |
139 | | // HTMLHtmlElement |
140 | | void GetVersion(DOMString& aValue) |
141 | 0 | { |
142 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html)); |
143 | 0 | GetHTMLAttr(nsGkAtoms::version, aValue); |
144 | 0 | } |
145 | | void SetVersion(const nsAString& aValue, ErrorResult& aResult) |
146 | 0 | { |
147 | 0 | MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html)); |
148 | 0 | SetHTMLAttr(nsGkAtoms::version, aValue, aResult); |
149 | 0 | } |
150 | | |
151 | | protected: |
152 | | virtual ~HTMLSharedElement(); |
153 | | |
154 | | virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
155 | | |
156 | | virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, |
157 | | const nsAttrValue* aValue, |
158 | | const nsAttrValue* aOldValue, |
159 | | nsIPrincipal* aSubjectPrincipal, |
160 | | bool aNotify) override; |
161 | | }; |
162 | | |
163 | | } // namespace dom |
164 | | } // namespace mozilla |
165 | | |
166 | | #endif // mozilla_dom_HTMLSharedElement_h |