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 #ifndef HTMLDataListElement_h___
7 #define HTMLDataListElement_h___
9 #include "mozilla/Attributes.h"
10 #include "nsGenericHTMLElement.h"
11 #include "nsContentList.h"
13 namespace mozilla::dom
{
15 class HTMLDataListElement final
: public nsGenericHTMLElement
{
17 explicit HTMLDataListElement(
18 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
19 : nsGenericHTMLElement(std::move(aNodeInfo
)) {
20 SetFlags(ELEMENT_IS_DATALIST_OR_HAS_DATALIST_ANCESTOR
);
23 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLDataListElement
, datalist
)
26 NS_DECL_ISUPPORTS_INHERITED
28 nsContentList
* Options() {
30 mOptions
= new nsContentList(this, MatchOptions
, nullptr, nullptr, true);
36 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
38 // This function is used to generate the nsContentList (option elements).
39 static bool MatchOptions(Element
* aElement
, int32_t aNamespaceID
,
40 nsAtom
* aAtom
, void* aData
);
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLDataListElement
,
45 virtual ~HTMLDataListElement();
47 virtual JSObject
* WrapNode(JSContext
* aCx
,
48 JS::Handle
<JSObject
*> aGivenProto
) override
;
50 // <option>'s list inside the datalist element.
51 RefPtr
<nsContentList
> mOptions
;
54 } // namespace mozilla::dom
56 #endif /* HTMLDataListElement_h___ */