InputEvent.h (2023B)
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_InputEvent_h_ 8 #define mozilla_dom_InputEvent_h_ 9 10 #include "mozilla/EventForwards.h" 11 #include "mozilla/dom/InputEventBinding.h" 12 #include "mozilla/dom/StaticRange.h" 13 #include "mozilla/dom/UIEvent.h" 14 #include "nsTArray.h" 15 16 namespace mozilla::dom { 17 18 class DataTransfer; 19 20 class InputEvent : public UIEvent { 21 public: 22 InputEvent(EventTarget* aOwner, nsPresContext* aPresContext, 23 InternalEditorInputEvent* aEvent); 24 25 NS_INLINE_DECL_REFCOUNTING_INHERITED(InputEvent, UIEvent) 26 27 static already_AddRefed<InputEvent> Constructor(const GlobalObject& aGlobal, 28 const nsAString& aType, 29 const InputEventInit& aParam); 30 31 virtual JSObject* WrapObjectInternal( 32 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override { 33 return InputEvent_Binding::Wrap(aCx, this, aGivenProto); 34 } 35 36 void GetInputType(nsAString& aInputType); 37 void GetData(nsAString& aData, CallerType aCallerType = CallerType::System); 38 already_AddRefed<DataTransfer> GetDataTransfer( 39 CallerType aCallerType = CallerType::System); 40 void GetTargetRanges(nsTArray<RefPtr<StaticRange>>& aTargetRanges); 41 bool IsComposing(); 42 43 protected: 44 ~InputEvent() = default; 45 46 // mInputTypeValue stores inputType attribute value if the instance is 47 // created by script and not initialized with known inputType value. 48 nsString mInputTypeValue; 49 }; 50 51 } // namespace mozilla::dom 52 53 already_AddRefed<mozilla::dom::InputEvent> NS_NewDOMInputEvent( 54 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, 55 mozilla::InternalEditorInputEvent* aEvent); 56 57 #endif // mozilla_dom_InputEvent_h_