2011-07-17 12:09:13 -07:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-03-30 21:42:20 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-11-26 22:16:40 -08:00
|
|
|
|
2011-07-17 12:09:13 -07:00
|
|
|
#ifndef mozilla_dom_workers_eventtarget_h__
|
|
|
|
#define mozilla_dom_workers_eventtarget_h__
|
2008-11-26 22:16:40 -08:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
#include "mozilla/dom/workers/bindings/DOMBindingBase.h"
|
2008-11-26 22:16:40 -08:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
// I hate having to export this...
|
|
|
|
#include "mozilla/dom/workers/bindings/EventListenerManager.h"
|
2011-07-12 09:32:14 -07:00
|
|
|
|
2012-05-02 21:35:38 -07:00
|
|
|
#include "mozilla/dom/Nullable.h"
|
2012-05-05 18:15:11 -07:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2012-03-30 21:42:20 -07:00
|
|
|
|
2012-05-02 21:35:38 -07:00
|
|
|
using namespace mozilla::dom;
|
2011-07-12 09:32:14 -07:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
BEGIN_WORKERS_NAMESPACE
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
class EventTarget : public DOMBindingBase
|
2008-11-26 22:16:40 -08:00
|
|
|
{
|
2012-03-30 21:42:20 -07:00
|
|
|
EventListenerManager mListenerManager;
|
2011-07-17 12:09:13 -07:00
|
|
|
|
|
|
|
protected:
|
2012-03-30 21:42:20 -07:00
|
|
|
EventTarget(JSContext* aCx)
|
|
|
|
: DOMBindingBase(aCx)
|
|
|
|
{ }
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
virtual ~EventTarget()
|
|
|
|
{ }
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2011-07-12 11:25:53 -07:00
|
|
|
public:
|
2012-03-30 21:42:20 -07:00
|
|
|
virtual void
|
|
|
|
_Trace(JSTracer* aTrc) MOZ_OVERRIDE;
|
2008-11-26 22:16:40 -08:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
virtual void
|
2012-03-19 07:34:55 -07:00
|
|
|
_Finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
|
2011-07-12 09:32:14 -07:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
void
|
|
|
|
AddEventListener(const nsAString& aType, JSObject* aListener,
|
2012-05-05 18:15:11 -07:00
|
|
|
bool aCapture, Nullable<bool> aWantsUntrusted,
|
|
|
|
ErrorResult& aRv);
|
2011-07-17 12:09:13 -07:00
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
void
|
|
|
|
RemoveEventListener(const nsAString& aType, JSObject* aListener,
|
2012-05-05 18:15:11 -07:00
|
|
|
bool aCapture, ErrorResult& aRv);
|
2011-07-17 12:09:13 -07:00
|
|
|
|
|
|
|
bool
|
2012-05-05 18:15:11 -07:00
|
|
|
DispatchEvent(JSObject* aEvent, ErrorResult& aRv) const
|
2011-07-17 12:09:13 -07:00
|
|
|
{
|
2012-03-30 21:42:20 -07:00
|
|
|
return mListenerManager.DispatchEvent(GetJSContext(), *this, aEvent, aRv);
|
2011-07-17 12:09:13 -07:00
|
|
|
}
|
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
JSObject*
|
2012-05-05 18:15:11 -07:00
|
|
|
GetEventListener(const nsAString& aType, ErrorResult& aRv) const;
|
2012-03-30 21:42:20 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
SetEventListener(const nsAString& aType, JSObject* aListener,
|
2012-05-05 18:15:11 -07:00
|
|
|
ErrorResult& aRv);
|
2012-03-30 21:42:20 -07:00
|
|
|
|
2011-07-17 12:09:13 -07:00
|
|
|
bool
|
2012-03-30 21:42:20 -07:00
|
|
|
HasListeners() const
|
2011-07-17 12:09:13 -07:00
|
|
|
{
|
2012-03-30 21:42:20 -07:00
|
|
|
return mListenerManager.HasListeners();
|
2011-07-17 12:09:13 -07:00
|
|
|
}
|
2011-07-12 11:25:53 -07:00
|
|
|
};
|
2011-07-12 09:32:14 -07:00
|
|
|
|
2011-07-17 12:09:13 -07:00
|
|
|
END_WORKERS_NAMESPACE
|
|
|
|
|
2012-03-30 21:42:20 -07:00
|
|
|
#endif // mozilla_dom_workers_eventtarget_h__
|