/src/mozilla-central/dom/events/ScrollAreaEvent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "base/basictypes.h" |
8 | | #include "ipc/IPCMessageUtils.h" |
9 | | #include "mozilla/dom/DOMRect.h" |
10 | | #include "mozilla/dom/ScrollAreaEvent.h" |
11 | | #include "mozilla/ContentEvents.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner, |
17 | | nsPresContext* aPresContext, |
18 | | InternalScrollAreaEvent* aEvent) |
19 | | : UIEvent(aOwner, aPresContext, aEvent) |
20 | | , mClientArea(new DOMRect(nullptr)) |
21 | 0 | { |
22 | 0 | mClientArea->SetLayoutRect(aEvent ? aEvent->mArea : nsRect()); |
23 | 0 | } |
24 | | |
25 | | NS_IMPL_CYCLE_COLLECTION_INHERITED(ScrollAreaEvent, UIEvent, |
26 | | mClientArea) |
27 | | |
28 | | NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent) |
29 | | NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent) |
30 | | |
31 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScrollAreaEvent) |
32 | 0 | NS_INTERFACE_MAP_END_INHERITING(UIEvent) |
33 | | |
34 | | void |
35 | | ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType, |
36 | | bool aCanBubble, |
37 | | bool aCancelable, |
38 | | nsGlobalWindowInner* aView, |
39 | | int32_t aDetail, |
40 | | float aX, |
41 | | float aY, |
42 | | float aWidth, |
43 | | float aHeight) |
44 | 0 | { |
45 | 0 | NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched); |
46 | 0 |
|
47 | 0 | UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail); |
48 | 0 | mClientArea->SetRect(aX, aY, aWidth, aHeight); |
49 | 0 | } |
50 | | |
51 | | void |
52 | | ScrollAreaEvent::Serialize(IPC::Message* aMsg, |
53 | | bool aSerializeInterfaceType) |
54 | 0 | { |
55 | 0 | if (aSerializeInterfaceType) { |
56 | 0 | IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent")); |
57 | 0 | } |
58 | 0 |
|
59 | 0 | Event::Serialize(aMsg, false); |
60 | 0 |
|
61 | 0 | IPC::WriteParam(aMsg, X()); |
62 | 0 | IPC::WriteParam(aMsg, Y()); |
63 | 0 | IPC::WriteParam(aMsg, Width()); |
64 | 0 | IPC::WriteParam(aMsg, Height()); |
65 | 0 | } |
66 | | |
67 | | bool |
68 | | ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) |
69 | 0 | { |
70 | 0 | NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); |
71 | 0 |
|
72 | 0 | float x, y, width, height; |
73 | 0 | NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false); |
74 | 0 | NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false); |
75 | 0 | NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false); |
76 | 0 | NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false); |
77 | 0 | mClientArea->SetRect(x, y, width, height); |
78 | 0 |
|
79 | 0 | return true; |
80 | 0 | } |
81 | | |
82 | | } // namespace dom |
83 | | } // namespace mozilla |
84 | | |
85 | | using namespace mozilla; |
86 | | using namespace mozilla::dom; |
87 | | |
88 | | already_AddRefed<ScrollAreaEvent> |
89 | | NS_NewDOMScrollAreaEvent(EventTarget* aOwner, |
90 | | nsPresContext* aPresContext, |
91 | | InternalScrollAreaEvent* aEvent) |
92 | 0 | { |
93 | 0 | RefPtr<ScrollAreaEvent> ev = |
94 | 0 | new ScrollAreaEvent(aOwner, aPresContext, aEvent); |
95 | 0 | return ev.forget(); |
96 | 0 | } |