dom/events/SimpleGestureEvent.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 "mozilla/dom/SimpleGestureEvent.h"
michael@0 7 #include "mozilla/TouchEvents.h"
michael@0 8 #include "prtime.h"
michael@0 9
michael@0 10 namespace mozilla {
michael@0 11 namespace dom {
michael@0 12
michael@0 13 SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
michael@0 14 nsPresContext* aPresContext,
michael@0 15 WidgetSimpleGestureEvent* aEvent)
michael@0 16 : MouseEvent(aOwner, aPresContext,
michael@0 17 aEvent ? aEvent :
michael@0 18 new WidgetSimpleGestureEvent(false, 0, nullptr))
michael@0 19 {
michael@0 20 NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
michael@0 21
michael@0 22 if (aEvent) {
michael@0 23 mEventIsInternal = false;
michael@0 24 } else {
michael@0 25 mEventIsInternal = true;
michael@0 26 mEvent->time = PR_Now();
michael@0 27 mEvent->refPoint.x = mEvent->refPoint.y = 0;
michael@0 28 static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
michael@0 29 nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
michael@0 30 }
michael@0 31 }
michael@0 32
michael@0 33 NS_IMPL_ADDREF_INHERITED(SimpleGestureEvent, MouseEvent)
michael@0 34 NS_IMPL_RELEASE_INHERITED(SimpleGestureEvent, MouseEvent)
michael@0 35
michael@0 36 NS_INTERFACE_MAP_BEGIN(SimpleGestureEvent)
michael@0 37 NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
michael@0 38 NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
michael@0 39
michael@0 40 /* attribute unsigned long allowedDirections; */
michael@0 41 uint32_t
michael@0 42 SimpleGestureEvent::AllowedDirections()
michael@0 43 {
michael@0 44 return mEvent->AsSimpleGestureEvent()->allowedDirections;
michael@0 45 }
michael@0 46
michael@0 47 NS_IMETHODIMP
michael@0 48 SimpleGestureEvent::GetAllowedDirections(uint32_t* aAllowedDirections)
michael@0 49 {
michael@0 50 NS_ENSURE_ARG_POINTER(aAllowedDirections);
michael@0 51 *aAllowedDirections = AllowedDirections();
michael@0 52 return NS_OK;
michael@0 53 }
michael@0 54
michael@0 55 NS_IMETHODIMP
michael@0 56 SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
michael@0 57 {
michael@0 58 mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
michael@0 59 return NS_OK;
michael@0 60 }
michael@0 61
michael@0 62 /* readonly attribute unsigned long direction; */
michael@0 63 uint32_t
michael@0 64 SimpleGestureEvent::Direction()
michael@0 65 {
michael@0 66 return mEvent->AsSimpleGestureEvent()->direction;
michael@0 67 }
michael@0 68
michael@0 69 NS_IMETHODIMP
michael@0 70 SimpleGestureEvent::GetDirection(uint32_t* aDirection)
michael@0 71 {
michael@0 72 NS_ENSURE_ARG_POINTER(aDirection);
michael@0 73 *aDirection = Direction();
michael@0 74 return NS_OK;
michael@0 75 }
michael@0 76
michael@0 77 /* readonly attribute float delta; */
michael@0 78 double
michael@0 79 SimpleGestureEvent::Delta()
michael@0 80 {
michael@0 81 return mEvent->AsSimpleGestureEvent()->delta;
michael@0 82 }
michael@0 83
michael@0 84 NS_IMETHODIMP
michael@0 85 SimpleGestureEvent::GetDelta(double* aDelta)
michael@0 86 {
michael@0 87 NS_ENSURE_ARG_POINTER(aDelta);
michael@0 88 *aDelta = Delta();
michael@0 89 return NS_OK;
michael@0 90 }
michael@0 91
michael@0 92 /* readonly attribute unsigned long clickCount; */
michael@0 93 uint32_t
michael@0 94 SimpleGestureEvent::ClickCount()
michael@0 95 {
michael@0 96 return mEvent->AsSimpleGestureEvent()->clickCount;
michael@0 97 }
michael@0 98
michael@0 99 NS_IMETHODIMP
michael@0 100 SimpleGestureEvent::GetClickCount(uint32_t* aClickCount)
michael@0 101 {
michael@0 102 NS_ENSURE_ARG_POINTER(aClickCount);
michael@0 103 *aClickCount = ClickCount();
michael@0 104 return NS_OK;
michael@0 105 }
michael@0 106
michael@0 107 NS_IMETHODIMP
michael@0 108 SimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
michael@0 109 bool aCanBubbleArg,
michael@0 110 bool aCancelableArg,
michael@0 111 nsIDOMWindow* aViewArg,
michael@0 112 int32_t aDetailArg,
michael@0 113 int32_t aScreenX,
michael@0 114 int32_t aScreenY,
michael@0 115 int32_t aClientX,
michael@0 116 int32_t aClientY,
michael@0 117 bool aCtrlKeyArg,
michael@0 118 bool aAltKeyArg,
michael@0 119 bool aShiftKeyArg,
michael@0 120 bool aMetaKeyArg,
michael@0 121 uint16_t aButton,
michael@0 122 nsIDOMEventTarget* aRelatedTarget,
michael@0 123 uint32_t aAllowedDirectionsArg,
michael@0 124 uint32_t aDirectionArg,
michael@0 125 double aDeltaArg,
michael@0 126 uint32_t aClickCountArg)
michael@0 127 {
michael@0 128 nsresult rv =
michael@0 129 MouseEvent::InitMouseEvent(aTypeArg, aCanBubbleArg, aCancelableArg,
michael@0 130 aViewArg, aDetailArg,
michael@0 131 aScreenX, aScreenY, aClientX, aClientY,
michael@0 132 aCtrlKeyArg, aAltKeyArg, aShiftKeyArg,
michael@0 133 aMetaKeyArg, aButton, aRelatedTarget);
michael@0 134 NS_ENSURE_SUCCESS(rv, rv);
michael@0 135
michael@0 136 WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
michael@0 137 simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
michael@0 138 simpleGestureEvent->direction = aDirectionArg;
michael@0 139 simpleGestureEvent->delta = aDeltaArg;
michael@0 140 simpleGestureEvent->clickCount = aClickCountArg;
michael@0 141
michael@0 142 return NS_OK;
michael@0 143 }
michael@0 144
michael@0 145 } // namespace dom
michael@0 146 } // namespace mozilla
michael@0 147
michael@0 148 using namespace mozilla;
michael@0 149 using namespace mozilla::dom;
michael@0 150
michael@0 151 nsresult
michael@0 152 NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
michael@0 153 EventTarget* aOwner,
michael@0 154 nsPresContext* aPresContext,
michael@0 155 WidgetSimpleGestureEvent* aEvent)
michael@0 156 {
michael@0 157 SimpleGestureEvent* it = new SimpleGestureEvent(aOwner, aPresContext, aEvent);
michael@0 158 NS_ADDREF(it);
michael@0 159 *aInstancePtrResult = static_cast<Event*>(it);
michael@0 160 return NS_OK;
michael@0 161 }

mercurial