Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLDetailsElement.h
blob2c7ed56d98fce476b67ce0fd77615ea0b80827fb
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_HTMLDetailsElement_h
8 #define mozilla_dom_HTMLDetailsElement_h
10 #include "mozilla/AsyncEventDispatcher.h"
11 #include "mozilla/Attributes.h"
12 #include "nsGenericHTMLElement.h"
14 namespace mozilla::dom {
16 class HTMLSummaryElement;
18 // HTMLDetailsElement implements the <details> tag, which is used as a
19 // disclosure widget from which the user can obtain additional information or
20 // controls. Please see the spec for more information.
21 // https://html.spec.whatwg.org/multipage/forms.html#the-details-element
23 class HTMLDetailsElement final : public nsGenericHTMLElement {
24 public:
25 using NodeInfo = mozilla::dom::NodeInfo;
27 explicit HTMLDetailsElement(already_AddRefed<NodeInfo>&& aNodeInfo);
29 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLDetailsElement, details)
31 HTMLSummaryElement* GetFirstSummary() const;
33 nsresult Clone(NodeInfo* aNodeInfo, nsINode** aResult) const override;
35 void AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
36 const nsAttrValue* aValue, const nsAttrValue* aOldValue,
37 nsIPrincipal* aMaybeScriptedPrincipal,
38 bool aNotify) override;
40 bool IsInteractiveHTMLContent() const override { return true; }
42 // HTMLDetailsElement WebIDL
43 bool Open() const { return GetBoolAttr(nsGkAtoms::open); }
45 void SetOpen(bool aOpen, ErrorResult& aError) {
46 SetHTMLBoolAttr(nsGkAtoms::open, aOpen, aError);
49 void ToggleOpen() { SetOpen(!Open(), IgnoreErrors()); }
51 virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
53 void HandleInvokeInternal(nsAtom* aAction, ErrorResult& aRv) override;
55 protected:
56 virtual ~HTMLDetailsElement();
57 void SetupShadowTree();
59 JSObject* WrapNode(JSContext* aCx,
60 JS::Handle<JSObject*> aGivenProto) override;
62 RefPtr<AsyncEventDispatcher> mToggleEventDispatcher;
65 } // namespace mozilla::dom
67 #endif /* mozilla_dom_HTMLDetailsElement_h */