dom/events/ScrollAreaEvent.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "base/basictypes.h"
michael@0 7 #include "ipc/IPCMessageUtils.h"
michael@0 8 #include "mozilla/dom/DOMRect.h"
michael@0 9 #include "mozilla/dom/ScrollAreaEvent.h"
michael@0 10 #include "mozilla/ContentEvents.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace dom {
michael@0 14
michael@0 15 ScrollAreaEvent::ScrollAreaEvent(EventTarget* aOwner,
michael@0 16 nsPresContext* aPresContext,
michael@0 17 InternalScrollAreaEvent* aEvent)
michael@0 18 : UIEvent(aOwner, aPresContext, aEvent)
michael@0 19 , mClientArea(nullptr)
michael@0 20 {
michael@0 21 mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
michael@0 22 }
michael@0 23
michael@0 24 NS_IMPL_ADDREF_INHERITED(ScrollAreaEvent, UIEvent)
michael@0 25 NS_IMPL_RELEASE_INHERITED(ScrollAreaEvent, UIEvent)
michael@0 26
michael@0 27 NS_INTERFACE_MAP_BEGIN(ScrollAreaEvent)
michael@0 28 NS_INTERFACE_MAP_ENTRY(nsIDOMScrollAreaEvent)
michael@0 29 NS_INTERFACE_MAP_END_INHERITING(UIEvent)
michael@0 30
michael@0 31
michael@0 32 #define FORWARD_GETTER(_name) \
michael@0 33 NS_IMETHODIMP \
michael@0 34 ScrollAreaEvent::Get ## _name(float* aResult) \
michael@0 35 { \
michael@0 36 *aResult = _name(); \
michael@0 37 return NS_OK; \
michael@0 38 }
michael@0 39
michael@0 40 FORWARD_GETTER(X)
michael@0 41 FORWARD_GETTER(Y)
michael@0 42 FORWARD_GETTER(Width)
michael@0 43 FORWARD_GETTER(Height)
michael@0 44
michael@0 45 NS_IMETHODIMP
michael@0 46 ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType,
michael@0 47 bool aCanBubble,
michael@0 48 bool aCancelable,
michael@0 49 nsIDOMWindow* aView,
michael@0 50 int32_t aDetail,
michael@0 51 float aX,
michael@0 52 float aY,
michael@0 53 float aWidth,
michael@0 54 float aHeight)
michael@0 55 {
michael@0 56 nsresult rv =
michael@0 57 UIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
michael@0 58 NS_ENSURE_SUCCESS(rv, rv);
michael@0 59
michael@0 60 mClientArea.SetRect(aX, aY, aWidth, aHeight);
michael@0 61
michael@0 62 return NS_OK;
michael@0 63 }
michael@0 64
michael@0 65 NS_IMETHODIMP_(void)
michael@0 66 ScrollAreaEvent::Serialize(IPC::Message* aMsg,
michael@0 67 bool aSerializeInterfaceType)
michael@0 68 {
michael@0 69 if (aSerializeInterfaceType) {
michael@0 70 IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
michael@0 71 }
michael@0 72
michael@0 73 Event::Serialize(aMsg, false);
michael@0 74
michael@0 75 IPC::WriteParam(aMsg, X());
michael@0 76 IPC::WriteParam(aMsg, Y());
michael@0 77 IPC::WriteParam(aMsg, Width());
michael@0 78 IPC::WriteParam(aMsg, Height());
michael@0 79 }
michael@0 80
michael@0 81 NS_IMETHODIMP_(bool)
michael@0 82 ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
michael@0 83 {
michael@0 84 NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
michael@0 85
michael@0 86 float x, y, width, height;
michael@0 87 NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), false);
michael@0 88 NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), false);
michael@0 89 NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), false);
michael@0 90 NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), false);
michael@0 91 mClientArea.SetRect(x, y, width, height);
michael@0 92
michael@0 93 return true;
michael@0 94 }
michael@0 95
michael@0 96 } // namespace dom
michael@0 97 } // namespace mozilla
michael@0 98
michael@0 99 using namespace mozilla;
michael@0 100 using namespace mozilla::dom;
michael@0 101
michael@0 102 nsresult
michael@0 103 NS_NewDOMScrollAreaEvent(nsIDOMEvent** aInstancePtrResult,
michael@0 104 EventTarget* aOwner,
michael@0 105 nsPresContext* aPresContext,
michael@0 106 InternalScrollAreaEvent* aEvent)
michael@0 107 {
michael@0 108 ScrollAreaEvent* ev = new ScrollAreaEvent(aOwner, aPresContext, aEvent);
michael@0 109 return CallQueryInterface(ev, aInstancePtrResult);
michael@0 110 }

mercurial