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 7 #ifndef mozilla_dom_ButtonInputTypes_h__ 8 #define mozilla_dom_ButtonInputTypes_h__ 9 10 #include "mozilla/dom/InputType.h" 11 12 namespace mozilla { 13 namespace dom { 14 15 class ButtonInputTypeBase : public InputType { 16 public: 17 ~ButtonInputTypeBase() override = default; 18 19 protected: ButtonInputTypeBase(HTMLInputElement * aInputElement)20 explicit ButtonInputTypeBase(HTMLInputElement* aInputElement) 21 : InputType(aInputElement) {} 22 }; 23 24 // input type=button 25 class ButtonInputType : public ButtonInputTypeBase { 26 public: Create(HTMLInputElement * aInputElement,void * aMemory)27 static InputType* Create(HTMLInputElement* aInputElement, void* aMemory) { 28 return new (aMemory) ButtonInputType(aInputElement); 29 } 30 31 private: ButtonInputType(HTMLInputElement * aInputElement)32 explicit ButtonInputType(HTMLInputElement* aInputElement) 33 : ButtonInputTypeBase(aInputElement) {} 34 }; 35 36 // input type=image 37 class ImageInputType : public ButtonInputTypeBase { 38 public: Create(HTMLInputElement * aInputElement,void * aMemory)39 static InputType* Create(HTMLInputElement* aInputElement, void* aMemory) { 40 return new (aMemory) ImageInputType(aInputElement); 41 } 42 43 private: ImageInputType(HTMLInputElement * aInputElement)44 explicit ImageInputType(HTMLInputElement* aInputElement) 45 : ButtonInputTypeBase(aInputElement) {} 46 }; 47 48 // input type=reset 49 class ResetInputType : public ButtonInputTypeBase { 50 public: Create(HTMLInputElement * aInputElement,void * aMemory)51 static InputType* Create(HTMLInputElement* aInputElement, void* aMemory) { 52 return new (aMemory) ResetInputType(aInputElement); 53 } 54 55 private: ResetInputType(HTMLInputElement * aInputElement)56 explicit ResetInputType(HTMLInputElement* aInputElement) 57 : ButtonInputTypeBase(aInputElement) {} 58 }; 59 60 // input type=submit 61 class SubmitInputType : public ButtonInputTypeBase { 62 public: Create(HTMLInputElement * aInputElement,void * aMemory)63 static InputType* Create(HTMLInputElement* aInputElement, void* aMemory) { 64 return new (aMemory) SubmitInputType(aInputElement); 65 } 66 67 private: SubmitInputType(HTMLInputElement * aInputElement)68 explicit SubmitInputType(HTMLInputElement* aInputElement) 69 : ButtonInputTypeBase(aInputElement) {} 70 }; 71 72 } // namespace dom 73 } // namespace mozilla 74 75 #endif /* mozilla_dom_ButtonInputTypes_h__ */ 76