HTMLDataListElement.h (1770B)
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___ 8 9 #include "nsContentList.h" 10 #include "nsGenericHTMLElement.h" 11 12 namespace mozilla::dom { 13 14 class HTMLDataListElement final : public nsGenericHTMLElement { 15 public: 16 explicit HTMLDataListElement( 17 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) 18 : nsGenericHTMLElement(std::move(aNodeInfo)) { 19 SetFlags(ELEMENT_IS_DATALIST_OR_HAS_DATALIST_ANCESTOR); 20 } 21 22 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLDataListElement, datalist) 23 24 // nsISupports 25 NS_DECL_ISUPPORTS_INHERITED 26 27 nsContentList* Options() { 28 if (!mOptions) { 29 mOptions = new nsContentList(this, MatchOptions, nullptr, nullptr, true); 30 } 31 32 return mOptions; 33 } 34 35 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; 36 37 // This function is used to generate the nsContentList (option elements). 38 static bool MatchOptions(Element* aElement, int32_t aNamespaceID, 39 nsAtom* aAtom, void* aData); 40 41 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLDataListElement, 42 nsGenericHTMLElement) 43 protected: 44 virtual ~HTMLDataListElement(); 45 46 virtual JSObject* WrapNode(JSContext* aCx, 47 JS::Handle<JSObject*> aGivenProto) override; 48 49 // <option>'s list inside the datalist element. 50 RefPtr<nsContentList> mOptions; 51 }; 52 53 } // namespace mozilla::dom 54 55 #endif /* HTMLDataListElement_h___ */