CompositionEvent.h (1927B)
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_CompositionEvent_h_ 8 #define mozilla_dom_CompositionEvent_h_ 9 10 #include "mozilla/EventForwards.h" 11 #include "mozilla/dom/CompositionEventBinding.h" 12 #include "mozilla/dom/TextClause.h" 13 #include "mozilla/dom/TypedArray.h" 14 #include "mozilla/dom/UIEvent.h" 15 16 namespace mozilla::dom { 17 18 using TextClauseArray = nsTArray<RefPtr<TextClause>>; 19 20 class CompositionEvent : public UIEvent { 21 public: 22 CompositionEvent(EventTarget* aOwner, nsPresContext* aPresContext, 23 WidgetCompositionEvent* aEvent); 24 25 NS_DECL_ISUPPORTS_INHERITED 26 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CompositionEvent, UIEvent) 27 28 static already_AddRefed<CompositionEvent> Constructor( 29 const GlobalObject& aGlobal, const nsAString& aType, 30 const CompositionEventInit& aParam); 31 32 virtual JSObject* WrapObjectInternal( 33 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override { 34 return CompositionEvent_Binding::Wrap(aCx, this, aGivenProto); 35 } 36 37 void InitCompositionEvent(const nsAString& aType, bool aCanBubble, 38 bool aCancelable, nsGlobalWindowInner* aView, 39 const nsAString& aData); 40 void GetData(nsAString&) const; 41 void GetRanges(TextClauseArray& aRanges); 42 43 protected: 44 ~CompositionEvent() = default; 45 46 nsString mData; 47 TextClauseArray mRanges; 48 }; 49 50 } // namespace mozilla::dom 51 52 already_AddRefed<mozilla::dom::CompositionEvent> NS_NewDOMCompositionEvent( 53 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, 54 mozilla::WidgetCompositionEvent* aEvent); 55 56 #endif // mozilla_dom_CompositionEvent_h_