2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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)
|
2014-09-02 19:47:00 +04:00
|
|
|
, mClientArea(new DOMRect(nullptr))
|
2009-09-12 03:13:56 +04:00
|
|
|
{
|
2014-09-02 19:47:00 +04:00
|
|
|
mClientArea->SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
|
2009-09-12 03:13:56 +04:00
|
|
|
}
|
|
|
|
|
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)
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2009-09-12 03:13:56 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
void
|
2014-02-28 18:58:43 +04:00
|
|
|
ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsGlobalWindow* aView,
|
2014-02-28 18:58:43 +04:00
|
|
|
int32_t aDetail,
|
|
|
|
float aX,
|
|
|
|
float aY,
|
|
|
|
float aWidth,
|
|
|
|
float aHeight)
|
2009-09-12 03:13:56 +04:00
|
|
|
{
|
2016-10-30 22:30:06 +03:00
|
|
|
NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
|
2014-09-02 19:47:00 +04:00
|
|
|
mClientArea->SetRect(aX, aY, aWidth, aHeight);
|
2009-09-12 03:13:56 +04:00
|
|
|
}
|
|
|
|
|
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)
|
2016-04-21 07:09:15 +03:00
|
|
|
ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* 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);
|
2014-09-02 19:47:00 +04:00
|
|
|
mClientArea->SetRect(x, y, width, height);
|
2010-01-27 23:55:57 +03:00
|
|
|
|
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;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<ScrollAreaEvent>
|
|
|
|
NS_NewDOMScrollAreaEvent(EventTarget* aOwner,
|
2014-02-28 18:58:43 +04:00
|
|
|
nsPresContext* aPresContext,
|
2013-09-27 10:20:56 +04:00
|
|
|
InternalScrollAreaEvent* aEvent)
|
2009-09-12 03:13:56 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ScrollAreaEvent> ev =
|
2015-08-12 14:39:31 +03:00
|
|
|
new ScrollAreaEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return ev.forget();
|
2009-09-12 03:13:56 +04:00
|
|
|
}
|