CompositionEvent.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_CompositionEvent_h_
  6. #define mozilla_dom_CompositionEvent_h_
  7. #include "mozilla/dom/CompositionEventBinding.h"
  8. #include "mozilla/dom/TextClause.h"
  9. #include "mozilla/dom/TypedArray.h"
  10. #include "mozilla/dom/UIEvent.h"
  11. #include "mozilla/EventForwards.h"
  12. namespace mozilla {
  13. namespace dom {
  14. typedef nsTArray<RefPtr<TextClause>> TextClauseArray;
  15. class CompositionEvent : public UIEvent
  16. {
  17. public:
  18. CompositionEvent(EventTarget* aOwner,
  19. nsPresContext* aPresContext,
  20. WidgetCompositionEvent* aEvent);
  21. NS_DECL_ISUPPORTS_INHERITED
  22. NS_FORWARD_TO_UIEVENT
  23. virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
  24. {
  25. return CompositionEventBinding::Wrap(aCx, this, aGivenProto);
  26. }
  27. void InitCompositionEvent(const nsAString& aType,
  28. bool aCanBubble,
  29. bool aCancelable,
  30. nsGlobalWindow* aView,
  31. const nsAString& aData,
  32. const nsAString& aLocale);
  33. void GetData(nsAString&) const;
  34. void GetLocale(nsAString&) const;
  35. void GetRanges(TextClauseArray& aRanges);
  36. protected:
  37. ~CompositionEvent() {}
  38. nsString mData;
  39. nsString mLocale;
  40. TextClauseArray mRanges;
  41. };
  42. } // namespace dom
  43. } // namespace mozilla
  44. already_AddRefed<mozilla::dom::CompositionEvent>
  45. NS_NewDOMCompositionEvent(mozilla::dom::EventTarget* aOwner,
  46. nsPresContext* aPresContext,
  47. mozilla::WidgetCompositionEvent* aEvent);
  48. #endif // mozilla_dom_CompositionEvent_h_