1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/ScrollAreaEvent.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "base/basictypes.h" 1.10 +#include "ipc/IPCMessageUtils.h" 1.11 +#include "mozilla/dom/DOMRect.h" 1.12 +#include "mozilla/dom/ScrollAreaEvent.h" 1.13 +#include "mozilla/ContentEvents.h" 1.14 + 1.15 +namespace mozilla { 1.16 +namespace dom { 1.17 + 1.18 +ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner, 1.19 + nsPresContext* aPresContext, 1.20 + InternalScrollAreaEvent* aEvent) 1.21 + : UIEvent(aOwner, aPresContext, aEvent) 1.22 + , mClientArea(nullptr) 1.23 +{ 1.24 + mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect()); 1.25 +} 1.26 + 1.27 +NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent) 1.28 +NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent) 1.29 + 1.30 +NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent) 1.31 + NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent) 1.32 +NS_INTERFACE_MAP_END_INHERITING(UIEvent) 1.33 + 1.34 + 1.35 +#define FORWARD_GETTER(_name) \ 1.36 + NS_IMETHODIMP \ 1.37 + ScrollAreaEvent::Get ## _name(float* aResult) \ 1.38 + { \ 1.39 + *aResult = _name(); \ 1.40 + return NS_OK; \ 1.41 + } 1.42 + 1.43 +FORWARD_GETTER(X) 1.44 +FORWARD_GETTER(Y) 1.45 +FORWARD_GETTER(Width) 1.46 +FORWARD_GETTER(Height) 1.47 + 1.48 +NS_IMETHODIMP 1.49 +ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType, 1.50 + bool aCanBubble, 1.51 + bool aCancelable, 1.52 + nsIDOMWindow* aView, 1.53 + int32_t aDetail, 1.54 + float aX, 1.55 + float aY, 1.56 + float aWidth, 1.57 + float aHeight) 1.58 +{ 1.59 + nsresult rv = 1.60 + UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail); 1.61 + NS_ENSURE_SUCCESS(rv, rv); 1.62 + 1.63 + mClientArea.SetRect(aX, aY, aWidth, aHeight); 1.64 + 1.65 + return NS_OK; 1.66 +} 1.67 + 1.68 +NS_IMETHODIMP_(void) 1.69 +ScrollAreaEvent::Serialize(IPC::Message* aMsg, 1.70 + bool aSerializeInterfaceType) 1.71 +{ 1.72 + if (aSerializeInterfaceType) { 1.73 + IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent")); 1.74 + } 1.75 + 1.76 + Event::Serialize(aMsg, false); 1.77 + 1.78 + IPC::WriteParam(aMsg, X()); 1.79 + IPC::WriteParam(aMsg, Y()); 1.80 + IPC::WriteParam(aMsg, Width()); 1.81 + IPC::WriteParam(aMsg, Height()); 1.82 +} 1.83 + 1.84 +NS_IMETHODIMP_(bool) 1.85 +ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter) 1.86 +{ 1.87 + NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); 1.88 + 1.89 + float x, y, width, height; 1.90 + NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false); 1.91 + NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false); 1.92 + NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false); 1.93 + NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false); 1.94 + mClientArea.SetRect(x, y, width, height); 1.95 + 1.96 + return true; 1.97 +} 1.98 + 1.99 +} // namespace dom 1.100 +} // namespace mozilla 1.101 + 1.102 +using namespace mozilla; 1.103 +using namespace mozilla::dom; 1.104 + 1.105 +nsresult 1.106 +NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult, 1.107 + EventTarget* aOwner, 1.108 + nsPresContext* aPresContext, 1.109 + InternalScrollAreaEvent* aEvent) 1.110 +{ 1.111 + ScrollAreaEvent* ev = new ScrollAreaEvent(aOwner, aPresContext, aEvent); 1.112 + return CallQueryInterface(ev, aInstancePtrResult); 1.113 +}