Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLSharedElement.h
blob8e9e15648e6e45df53c9658d932320e4f9b54f5d
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/. */
7 #ifndef mozilla_dom_HTMLSharedElement_h
8 #define mozilla_dom_HTMLSharedElement_h
10 #include "nsGenericHTMLElement.h"
12 #include "nsGkAtoms.h"
14 #include "mozilla/Attributes.h"
15 #include "mozilla/Assertions.h"
17 namespace mozilla::dom {
19 class HTMLSharedElement final : public nsGenericHTMLElement {
20 public:
21 explicit HTMLSharedElement(
22 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
23 : nsGenericHTMLElement(std::move(aNodeInfo)) {
24 if (mNodeInfo->Equals(nsGkAtoms::head) ||
25 mNodeInfo->Equals(nsGkAtoms::html)) {
26 SetHasWeirdParserInsertionMode();
30 // nsIContent
31 void DoneAddingChildren(bool aHaveNotified) override;
33 nsresult BindToTree(BindContext&, nsINode& aParent) override;
35 void UnbindFromTree(UnbindContext&) override;
37 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
39 // WebIDL API
40 // HTMLParamElement
41 void GetName(DOMString& aValue) {
42 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
43 GetHTMLAttr(nsGkAtoms::name, aValue);
45 void SetName(const nsAString& aValue, ErrorResult& aResult) {
46 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
47 SetHTMLAttr(nsGkAtoms::name, aValue, aResult);
49 void GetValue(DOMString& aValue) {
50 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
51 GetHTMLAttr(nsGkAtoms::value, aValue);
53 void SetValue(const nsAString& aValue, ErrorResult& aResult) {
54 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
55 SetHTMLAttr(nsGkAtoms::value, aValue, aResult);
57 void GetType(DOMString& aValue) {
58 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
59 GetHTMLAttr(nsGkAtoms::type, aValue);
61 void SetType(const nsAString& aValue, ErrorResult& aResult) {
62 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
63 SetHTMLAttr(nsGkAtoms::type, aValue, aResult);
65 void GetValueType(DOMString& aValue) {
66 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
67 GetHTMLAttr(nsGkAtoms::valuetype, aValue);
69 void SetValueType(const nsAString& aValue, ErrorResult& aResult) {
70 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::param));
71 SetHTMLAttr(nsGkAtoms::valuetype, aValue, aResult);
74 // HTMLBaseElement
75 void GetTarget(DOMString& aValue) {
76 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base));
77 GetHTMLAttr(nsGkAtoms::target, aValue);
79 void SetTarget(const nsAString& aValue, ErrorResult& aResult) {
80 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base));
81 SetHTMLAttr(nsGkAtoms::target, aValue, aResult);
84 void GetHref(nsAString& aValue);
85 void SetHref(const nsAString& aValue, ErrorResult& aResult) {
86 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base));
87 SetHTMLAttr(nsGkAtoms::href, aValue, aResult);
90 // HTMLDirectoryElement
91 bool Compact() const {
92 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::dir));
93 return GetBoolAttr(nsGkAtoms::compact);
95 void SetCompact(bool aCompact, ErrorResult& aResult) {
96 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::dir));
97 SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aResult);
100 // HTMLQuoteElement
101 void GetCite(nsString& aCite) { GetHTMLURIAttr(nsGkAtoms::cite, aCite); }
103 void SetCite(const nsAString& aValue, ErrorResult& aResult) {
104 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::q) ||
105 mNodeInfo->Equals(nsGkAtoms::blockquote));
106 SetHTMLAttr(nsGkAtoms::cite, aValue, aResult);
109 // HTMLHtmlElement
110 void GetVersion(DOMString& aValue) {
111 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
112 GetHTMLAttr(nsGkAtoms::version, aValue);
114 void SetVersion(const nsAString& aValue, ErrorResult& aResult) {
115 MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::html));
116 SetHTMLAttr(nsGkAtoms::version, aValue, aResult);
119 protected:
120 virtual ~HTMLSharedElement();
122 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
124 void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
125 const nsAttrValue* aValue, const nsAttrValue* aOldValue,
126 nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
129 } // namespace mozilla::dom
131 #endif // mozilla_dom_HTMLSharedElement_h