Line data Source code
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 0 : ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner,
17 : nsPresContext* aPresContext,
18 0 : InternalScrollAreaEvent* aEvent)
19 : : UIEvent(aOwner, aPresContext, aEvent)
20 0 : , mClientArea(new DOMRect(nullptr))
21 : {
22 0 : mClientArea->SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
23 0 : }
24 :
25 0 : NS_IMPL_CYCLE_COLLECTION_INHERITED(ScrollAreaEvent, UIEvent,
26 : mClientArea)
27 :
28 0 : NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent)
29 0 : NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent)
30 :
31 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ScrollAreaEvent)
32 0 : NS_INTERFACE_MAP_END_INHERITING(UIEvent)
33 :
34 : void
35 0 : ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
36 : bool aCanBubble,
37 : bool aCancelable,
38 : nsGlobalWindow* aView,
39 : int32_t aDetail,
40 : float aX,
41 : float aY,
42 : float aWidth,
43 : float aHeight)
44 : {
45 0 : NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
46 :
47 0 : UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
48 0 : mClientArea->SetRect(aX, aY, aWidth, aHeight);
49 : }
50 :
51 : NS_IMETHODIMP_(void)
52 0 : ScrollAreaEvent::Serialize(IPC::Message* aMsg,
53 : bool aSerializeInterfaceType)
54 : {
55 0 : if (aSerializeInterfaceType) {
56 0 : IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
57 : }
58 :
59 0 : Event::Serialize(aMsg, false);
60 :
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 : NS_IMETHODIMP_(bool)
68 0 : ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter)
69 : {
70 0 : NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
71 :
72 : 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 :
79 0 : return true;
80 : }
81 :
82 : } // namespace dom
83 : } // namespace mozilla
84 :
85 : using namespace mozilla;
86 : using namespace mozilla::dom;
87 :
88 : already_AddRefed<ScrollAreaEvent>
89 0 : NS_NewDOMScrollAreaEvent(EventTarget* aOwner,
90 : nsPresContext* aPresContext,
91 : InternalScrollAreaEvent* aEvent)
92 : {
93 : RefPtr<ScrollAreaEvent> ev =
94 0 : new ScrollAreaEvent(aOwner, aPresContext, aEvent);
95 0 : return ev.forget();
96 : }
|