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