michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "base/basictypes.h" michael@0: #include "ipc/IPCMessageUtils.h" michael@0: #include "mozilla/dom/DOMRect.h" michael@0: #include "mozilla/dom/ScrollAreaEvent.h" michael@0: #include "mozilla/ContentEvents.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: InternalScrollAreaEvent* aEvent) michael@0: : UIEvent(aOwner, aPresContext, aEvent) michael@0: , mClientArea(nullptr) michael@0: { michael@0: mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect()); michael@0: } michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent) michael@0: NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent) michael@0: NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent) michael@0: NS_INTERFACE_MAP_END_INHERITING(UIEvent) michael@0: michael@0: michael@0: #define FORWARD_GETTER(_name) \ michael@0: NS_IMETHODIMP \ michael@0: ScrollAreaEvent::Get ## _name(float* aResult) \ michael@0: { \ michael@0: *aResult = _name(); \ michael@0: return NS_OK; \ michael@0: } michael@0: michael@0: FORWARD_GETTER(X) michael@0: FORWARD_GETTER(Y) michael@0: FORWARD_GETTER(Width) michael@0: FORWARD_GETTER(Height) michael@0: michael@0: NS_IMETHODIMP michael@0: ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType, michael@0: bool aCanBubble, michael@0: bool aCancelable, michael@0: nsIDOMWindow* aView, michael@0: int32_t aDetail, michael@0: float aX, michael@0: float aY, michael@0: float aWidth, michael@0: float aHeight) michael@0: { michael@0: nsresult rv = michael@0: UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: mClientArea.SetRect(aX, aY, aWidth, aHeight); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP_(void) michael@0: ScrollAreaEvent::Serialize(IPC::Message* aMsg, michael@0: bool aSerializeInterfaceType) michael@0: { michael@0: if (aSerializeInterfaceType) { michael@0: IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent")); michael@0: } michael@0: michael@0: Event::Serialize(aMsg, false); michael@0: michael@0: IPC::WriteParam(aMsg, X()); michael@0: IPC::WriteParam(aMsg, Y()); michael@0: IPC::WriteParam(aMsg, Width()); michael@0: IPC::WriteParam(aMsg, Height()); michael@0: } michael@0: michael@0: NS_IMETHODIMP_(bool) michael@0: ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter) michael@0: { michael@0: NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); michael@0: michael@0: float x, y, width, height; michael@0: NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false); michael@0: NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false); michael@0: NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false); michael@0: NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false); michael@0: mClientArea.SetRect(x, y, width, height); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::dom; michael@0: michael@0: nsresult michael@0: NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult, michael@0: EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: InternalScrollAreaEvent* aEvent) michael@0: { michael@0: ScrollAreaEvent* ev = new ScrollAreaEvent(aOwner, aPresContext, aEvent); michael@0: return CallQueryInterface(ev, aInstancePtrResult); michael@0: }