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-20 03:21:03 -07:00
|
|
|
#include "mozilla/dom/DOMRect.h"
|
2014-02-28 06:58:43 -08:00
|
|
|
#include "mozilla/dom/ScrollAreaEvent.h"
|
|
|
|
#include "mozilla/ContentEvents.h"
|
2009-09-11 16:13:56 -07:00
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-09-26 23:20:56 -07:00
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalScrollAreaEvent* aEvent)
|
2014-02-28 06:58:43 -08:00
|
|
|
: UIEvent(aOwner, aPresContext, aEvent)
|
2014-09-02 08:47:00 -07:00
|
|
|
, mClientArea(new DOMRect(nullptr))
|
2009-09-11 16:13:56 -07:00
|
|
|
{
|
2014-09-02 08:47:00 -07:00
|
|
|
mClientArea->SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
|
2009-09-11 16:13:56 -07:00
|
|
|
}
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent)
|
2009-09-11 16:13:56 -07:00
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent)
|
2009-09-11 16:13:56 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent)
|
2014-02-28 06:58:43 -08:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2009-09-11 16:13:56 -07:00
|
|
|
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
#define FORWARD_GETTER(_name) \
|
|
|
|
NS_IMETHODIMP \
|
|
|
|
ScrollAreaEvent::Get ## _name(float* aResult) \
|
|
|
|
{ \
|
|
|
|
*aResult = _name(); \
|
|
|
|
return NS_OK; \
|
2013-03-17 00:55:17 -07:00
|
|
|
}
|
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
|
2014-02-28 06:58:43 -08:00
|
|
|
ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* aView,
|
|
|
|
int32_t aDetail,
|
|
|
|
float aX,
|
|
|
|
float aY,
|
|
|
|
float aWidth,
|
|
|
|
float aHeight)
|
2009-09-11 16:13:56 -07:00
|
|
|
{
|
2014-02-28 06:58:43 -08:00
|
|
|
nsresult rv =
|
|
|
|
UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
|
2009-09-11 16:13:56 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2014-09-02 08:47:00 -07:00
|
|
|
mClientArea->SetRect(aX, aY, aWidth, aHeight);
|
2009-09-11 16:13:56 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHODIMP_(void)
|
2014-02-28 06:58:43 -08:00
|
|
|
ScrollAreaEvent::Serialize(IPC::Message* aMsg,
|
|
|
|
bool aSerializeInterfaceType)
|
2010-01-27 12:55:57 -08:00
|
|
|
{
|
|
|
|
if (aSerializeInterfaceType) {
|
|
|
|
IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
|
|
|
|
}
|
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
Event::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)
|
2014-02-28 06:58:43 -08:00
|
|
|
ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
|
2010-01-27 12:55:57 -08:00
|
|
|
{
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_ENSURE_TRUE(Event::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);
|
2014-09-02 08:47:00 -07:00
|
|
|
mClientArea->SetRect(x, y, width, height);
|
2010-01-27 12:55:57 -08:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-01-27 12:55:57 -08:00
|
|
|
}
|
|
|
|
|
2014-02-28 06:58:43 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2009-09-11 16:13:56 -07:00
|
|
|
nsresult
|
2014-02-28 06:58:43 -08:00
|
|
|
NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
2013-09-26 23:20:56 -07:00
|
|
|
InternalScrollAreaEvent* aEvent)
|
2009-09-11 16:13:56 -07:00
|
|
|
{
|
2014-02-28 06:58:43 -08:00
|
|
|
ScrollAreaEvent* ev = new ScrollAreaEvent(aOwner, aPresContext, aEvent);
|
2009-09-11 16:13:56 -07:00
|
|
|
return CallQueryInterface(ev, aInstancePtrResult);
|
|
|
|
}
|