DataContainerEvent.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_DataContainerEvent_h_
  6. #define mozilla_dom_DataContainerEvent_h_
  7. #include "mozilla/dom/DataContainerEventBinding.h"
  8. #include "mozilla/dom/Event.h"
  9. #include "nsIDOMDataContainerEvent.h"
  10. #include "nsInterfaceHashtable.h"
  11. namespace mozilla {
  12. namespace dom {
  13. class DataContainerEvent : public Event,
  14. public nsIDOMDataContainerEvent
  15. {
  16. public:
  17. DataContainerEvent(EventTarget* aOwner,
  18. nsPresContext* aPresContext,
  19. WidgetEvent* aEvent);
  20. NS_DECL_ISUPPORTS_INHERITED
  21. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DataContainerEvent, Event)
  22. NS_FORWARD_TO_EVENT
  23. NS_DECL_NSIDOMDATACONTAINEREVENT
  24. virtual JSObject*
  25. WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
  26. {
  27. return DataContainerEventBinding::Wrap(aCx, this, aGivenProto);
  28. }
  29. already_AddRefed<nsIVariant> GetData(const nsAString& aKey)
  30. {
  31. nsCOMPtr<nsIVariant> val;
  32. GetData(aKey, getter_AddRefs(val));
  33. return val.forget();
  34. }
  35. void SetData(JSContext* aCx, const nsAString& aKey,
  36. JS::Handle<JS::Value> aVal, ErrorResult& aRv);
  37. protected:
  38. ~DataContainerEvent() {}
  39. private:
  40. nsInterfaceHashtable<nsStringHashKey, nsIVariant> mData;
  41. };
  42. } // namespace dom
  43. } // namespace mozilla
  44. already_AddRefed<mozilla::dom::DataContainerEvent>
  45. NS_NewDOMDataContainerEvent(mozilla::dom::EventTarget* aOwner,
  46. nsPresContext* aPresContext,
  47. mozilla::WidgetEvent* aEvent);
  48. #endif // mozilla_dom_DataContainerEvent_h_