2009-09-11 16:13:56 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -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/. */
|
2009-09-11 16:13:56 -07:00
|
|
|
|
2010-01-27 12:55:57 -08:00
|
|
|
#include "base/basictypes.h"
|
2012-08-28 05:41:04 -07:00
|
|
|
#include "ipc/IPCMessageUtils.h"
|
2013-09-25 04:21:20 -07:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2010-01-27 12:55:57 -08:00
|
|
|
|
2009-09-11 16:13:56 -07:00
|
|
|
#include "nsDOMScrollAreaEvent.h"
|
2013-09-20 03:21:03 -07:00
|
|
|
#include "mozilla/dom/DOMRect.h"
|
2009-09-11 16:13:56 -07:00
|
|
|
|
2013-09-26 23:20:56 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMScrollAreaEvent::nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext *aPresContext,
|
2013-09-26 23:20:56 -07:00
|
|
|
InternalScrollAreaEvent* aEvent)
|
2013-03-09 03:34:29 -08:00
|
|
|
: nsDOMUIEvent(aOwner, aPresContext, aEvent)
|
2013-03-17 00:55:17 -07:00
|
|
|
, mClientArea(nullptr)
|
2009-09-11 16:13:56 -07:00
|
|
|
{
|
|
|
|
mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMScrollAreaEvent, nsDOMUIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMScrollAreaEvent, nsDOMUIEvent)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMScrollAreaEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
|
|
|
|
|
|
|
|
|
2013-03-17 00:55:17 -07:00
|
|
|
#define FORWARD_GETTER(_name) \
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
nsDOMScrollAreaEvent::Get ## _name(float* aResult) \
|
|
|
|
{ \
|
|
|
|
*aResult = _name(); \
|
|
|
|
return NS_OK; \
|
|
|
|
}
|
2009-09-11 16:13:56 -07:00
|
|
|
|
2013-03-17 00:55:17 -07:00
|
|
|
FORWARD_GETTER(X)
|
|
|
|
FORWARD_GETTER(Y)
|
|
|
|
FORWARD_GETTER(Width)
|
|
|
|
FORWARD_GETTER(Height)
|
2009-09-11 16:13:56 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMScrollAreaEvent::InitScrollAreaEvent(const nsAString &aEventType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2011-04-23 23:54:25 -07:00
|
|
|
nsIDOMWindow *aView,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aDetail,
|
2009-09-11 16:13:56 -07:00
|
|
|
float aX, float aY,
|
|
|
|
float aWidth, float aHeight)
|
|
|
|
{
|
|
|
|
nsresult rv = nsDOMUIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mClientArea.SetRect(aX, aY, aWidth, aHeight);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHODIMP_(void)
|
2010-01-27 12:55:57 -08:00
|
|
|
nsDOMScrollAreaEvent::Serialize(IPC::Message* aMsg,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aSerializeInterfaceType)
|
2010-01-27 12:55:57 -08:00
|
|
|
{
|
|
|
|
if (aSerializeInterfaceType) {
|
|
|
|
IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
nsDOMEvent::Serialize(aMsg, false);
|
2010-01-27 12:55:57 -08:00
|
|
|
|
2013-03-17 00:55:17 -07:00
|
|
|
IPC::WriteParam(aMsg, X());
|
|
|
|
IPC::WriteParam(aMsg, Y());
|
|
|
|
IPC::WriteParam(aMsg, Width());
|
|
|
|
IPC::WriteParam(aMsg, Height());
|
2010-01-27 12:55:57 -08:00
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHODIMP_(bool)
|
2010-01-27 12:55:57 -08:00
|
|
|
nsDOMScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ENSURE_TRUE(nsDOMEvent::Deserialize(aMsg, aIter), false);
|
2010-01-27 12:55:57 -08:00
|
|
|
|
|
|
|
float x, y, width, height;
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false);
|
|
|
|
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false);
|
|
|
|
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false);
|
|
|
|
NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false);
|
2010-01-27 12:55:57 -08:00
|
|
|
mClientArea.SetRect(x, y, width, height);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-01-27 12:55:57 -08:00
|
|
|
}
|
|
|
|
|
2009-09-11 16:13:56 -07:00
|
|
|
nsresult
|
|
|
|
NS_NewDOMScrollAreaEvent(nsIDOMEvent **aInstancePtrResult,
|
2013-03-09 03:34:29 -08:00
|
|
|
mozilla::dom::EventTarget* aOwner,
|
2009-09-11 16:13:56 -07:00
|
|
|
nsPresContext *aPresContext,
|
2013-09-26 23:20:56 -07:00
|
|
|
InternalScrollAreaEvent* aEvent)
|
2009-09-11 16:13:56 -07:00
|
|
|
{
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMScrollAreaEvent* ev =
|
|
|
|
new nsDOMScrollAreaEvent(aOwner, aPresContext, aEvent);
|
2009-09-11 16:13:56 -07:00
|
|
|
return CallQueryInterface(ev, aInstancePtrResult);
|
|
|
|
}
|