1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "base/basictypes.h"
7 #include "ipc/IPCMessageUtils.h"
8 #include "mozilla/dom/DOMRect.h"
9 #include "mozilla/dom/ScrollAreaEvent.h"
10 #include "mozilla/ContentEvents.h"
15 ScrollAreaEvent::ScrollAreaEvent(EventTarget
* aOwner
,
16 nsPresContext
* aPresContext
,
17 InternalScrollAreaEvent
* aEvent
)
18 : UIEvent(aOwner
, aPresContext
, aEvent
)
19 , mClientArea(nullptr)
21 mClientArea
.SetLayoutRect(aEvent
? aEvent
->mArea
: nsRect());
24 NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent
, UIEvent
)
25 NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent
, UIEvent
)
27 NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent
)
28 NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent
)
29 NS_INTERFACE_MAP_END_INHERITING(UIEvent
)
32 #define FORWARD_GETTER(_name) \
34 ScrollAreaEvent::Get ## _name(float* aResult) \
43 FORWARD_GETTER(Height
)
46 ScrollAreaEvent::InitScrollAreaEvent(const nsAString
& aEventType
,
57 UIEvent::InitUIEvent(aEventType
, aCanBubble
, aCancelable
, aView
, aDetail
);
58 NS_ENSURE_SUCCESS(rv
, rv
);
60 mClientArea
.SetRect(aX
, aY
, aWidth
, aHeight
);
66 ScrollAreaEvent::Serialize(IPC::Message
* aMsg
,
67 bool aSerializeInterfaceType
)
69 if (aSerializeInterfaceType
) {
70 IPC::WriteParam(aMsg
, NS_LITERAL_STRING("scrollareaevent"));
73 Event::Serialize(aMsg
, false);
75 IPC::WriteParam(aMsg
, X());
76 IPC::WriteParam(aMsg
, Y());
77 IPC::WriteParam(aMsg
, Width());
78 IPC::WriteParam(aMsg
, Height());
82 ScrollAreaEvent::Deserialize(const IPC::Message
* aMsg
, void** aIter
)
84 NS_ENSURE_TRUE(Event::Deserialize(aMsg
, aIter
), false);
86 float x
, y
, width
, height
;
87 NS_ENSURE_TRUE(IPC::ReadParam(aMsg
, aIter
, &x
), false);
88 NS_ENSURE_TRUE(IPC::ReadParam(aMsg
, aIter
, &y
), false);
89 NS_ENSURE_TRUE(IPC::ReadParam(aMsg
, aIter
, &width
), false);
90 NS_ENSURE_TRUE(IPC::ReadParam(aMsg
, aIter
, &height
), false);
91 mClientArea
.SetRect(x
, y
, width
, height
);
97 } // namespace mozilla
99 using namespace mozilla
;
100 using namespace mozilla::dom
;
103 NS_NewDOMScrollAreaEvent(nsIDOMEvent
** aInstancePtrResult
,
105 nsPresContext
* aPresContext
,
106 InternalScrollAreaEvent
* aEvent
)
108 ScrollAreaEvent
* ev
= new ScrollAreaEvent(aOwner
, aPresContext
, aEvent
);
109 return CallQueryInterface(ev
, aInstancePtrResult
);