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
{
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 nsresult
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
;
54 virtual ~HTMLDetailsElement();
55 void SetupShadowTree();
57 JSObject
* WrapNode(JSContext
* aCx
,
58 JS::Handle
<JSObject
*> aGivenProto
) override
;
60 RefPtr
<AsyncEventDispatcher
> mToggleEventDispatcher
;
63 } // namespace mozilla::dom
65 #endif /* mozilla_dom_HTMLDetailsElement_h */