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 CheckableInputTypes_h__ 8 #define CheckableInputTypes_h__ 9 10 #include "InputType.h" 11 12 class CheckableInputTypeBase : public ::InputType { 13 public: ~CheckableInputTypeBase()14 ~CheckableInputTypeBase() override {} 15 16 protected: CheckableInputTypeBase(mozilla::dom::HTMLInputElement * aInputElement)17 explicit CheckableInputTypeBase(mozilla::dom::HTMLInputElement* aInputElement) 18 : InputType(aInputElement) {} 19 }; 20 21 // input type=checkbox 22 class CheckboxInputType : public CheckableInputTypeBase { 23 public: Create(mozilla::dom::HTMLInputElement * aInputElement,void * aMemory)24 static InputType* Create(mozilla::dom::HTMLInputElement* aInputElement, 25 void* aMemory) { 26 return new (aMemory) CheckboxInputType(aInputElement); 27 } 28 29 bool IsValueMissing() const override; 30 31 nsresult GetValueMissingMessage(nsAString& aMessage) override; 32 33 private: CheckboxInputType(mozilla::dom::HTMLInputElement * aInputElement)34 explicit CheckboxInputType(mozilla::dom::HTMLInputElement* aInputElement) 35 : CheckableInputTypeBase(aInputElement) {} 36 }; 37 38 // input type=radio 39 class RadioInputType : public CheckableInputTypeBase { 40 public: Create(mozilla::dom::HTMLInputElement * aInputElement,void * aMemory)41 static InputType* Create(mozilla::dom::HTMLInputElement* aInputElement, 42 void* aMemory) { 43 return new (aMemory) RadioInputType(aInputElement); 44 } 45 46 nsresult GetValueMissingMessage(nsAString& aMessage) override; 47 48 private: RadioInputType(mozilla::dom::HTMLInputElement * aInputElement)49 explicit RadioInputType(mozilla::dom::HTMLInputElement* aInputElement) 50 : CheckableInputTypeBase(aInputElement) {} 51 }; 52 53 #endif /* CheckableInputTypes_h__ */ 54