Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_dom_HTMLDetailsElement_h
7 : #define mozilla_dom_HTMLDetailsElement_h
8 :
9 : #include "mozilla/AsyncEventDispatcher.h"
10 : #include "mozilla/Attributes.h"
11 : #include "nsGenericHTMLElement.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : // HTMLDetailsElement implements the <details> tag, which is used as a
17 : // disclosure widget from which the user can obtain additional information or
18 : // controls. Please see the spec for more information.
19 : // https://html.spec.whatwg.org/multipage/forms.html#the-details-element
20 : //
21 : class HTMLDetailsElement final : public nsGenericHTMLElement
22 : {
23 : public:
24 : using NodeInfo = mozilla::dom::NodeInfo;
25 :
26 0 : explicit HTMLDetailsElement(already_AddRefed<NodeInfo>& aNodeInfo)
27 0 : : nsGenericHTMLElement(aNodeInfo)
28 : {
29 0 : }
30 :
31 1300 : NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLDetailsElement, details)
32 :
33 : nsIContent* GetFirstSummary() const;
34 :
35 : nsresult Clone(NodeInfo* aNodeInfo, nsINode** aResult,
36 : bool aPreallocateChildren) const override;
37 :
38 : nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
39 : int32_t aModType) const override;
40 :
41 : nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
42 : const nsAttrValueOrString* aValue,
43 : bool aNotify) override;
44 :
45 : // HTMLDetailsElement WebIDL
46 0 : bool Open() const { return GetBoolAttr(nsGkAtoms::open); }
47 :
48 0 : void SetOpen(bool aOpen, ErrorResult& aError)
49 : {
50 0 : SetHTMLBoolAttr(nsGkAtoms::open, aOpen, aError);
51 0 : }
52 :
53 0 : void ToggleOpen()
54 : {
55 0 : ErrorResult rv;
56 0 : SetOpen(!Open(), rv);
57 0 : rv.SuppressException();
58 0 : }
59 :
60 : virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
61 :
62 : protected:
63 : virtual ~HTMLDetailsElement();
64 :
65 : JSObject* WrapNode(JSContext* aCx,
66 : JS::Handle<JSObject*> aGivenProto) override;
67 :
68 : RefPtr<AsyncEventDispatcher> mToggleEventDispatcher;
69 : };
70 :
71 : } // namespace dom
72 : } // namespace mozilla
73 :
74 : #endif /* mozilla_dom_HTMLDetailsElement_h */
|