Tue, 06 Jan 2015 21:39:09 +0100
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.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/TimeEvent.h"
7 #include "mozilla/BasicEvents.h"
8 #include "nsIInterfaceRequestorUtils.h"
9 #include "nsPresContext.h"
11 namespace mozilla {
12 namespace dom {
14 TimeEvent::TimeEvent(EventTarget* aOwner,
15 nsPresContext* aPresContext,
16 WidgetEvent* aEvent)
17 : Event(aOwner, aPresContext,
18 aEvent ? aEvent : new InternalUIEvent(false, 0))
19 , mDetail(0)
20 {
21 SetIsDOMBinding();
22 if (aEvent) {
23 mEventIsInternal = false;
24 } else {
25 mEventIsInternal = true;
26 mEvent->eventStructType = NS_SMIL_TIME_EVENT;
27 }
29 if (mEvent->eventStructType == NS_SMIL_TIME_EVENT) {
30 mDetail = mEvent->AsUIEvent()->detail;
31 }
33 mEvent->mFlags.mBubbles = false;
34 mEvent->mFlags.mCancelable = false;
36 if (mPresContext) {
37 nsISupports* container = mPresContext->GetContainerWeak();
38 if (container) {
39 nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
40 if (window) {
41 mView = do_QueryInterface(window);
42 }
43 }
44 }
45 }
47 NS_IMPL_CYCLE_COLLECTION_INHERITED(TimeEvent, Event,
48 mView)
50 NS_IMPL_ADDREF_INHERITED(TimeEvent, Event)
51 NS_IMPL_RELEASE_INHERITED(TimeEvent, Event)
53 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TimeEvent)
54 NS_INTERFACE_MAP_ENTRY(nsIDOMTimeEvent)
55 NS_INTERFACE_MAP_END_INHERITING(Event)
57 NS_IMETHODIMP
58 TimeEvent::GetView(nsIDOMWindow** aView)
59 {
60 *aView = mView;
61 NS_IF_ADDREF(*aView);
62 return NS_OK;
63 }
65 NS_IMETHODIMP
66 TimeEvent::GetDetail(int32_t* aDetail)
67 {
68 *aDetail = mDetail;
69 return NS_OK;
70 }
72 NS_IMETHODIMP
73 TimeEvent::InitTimeEvent(const nsAString& aTypeArg,
74 nsIDOMWindow* aViewArg,
75 int32_t aDetailArg)
76 {
77 nsresult rv = Event::InitEvent(aTypeArg, false /*doesn't bubble*/,
78 false /*can't cancel*/);
79 NS_ENSURE_SUCCESS(rv, rv);
81 mDetail = aDetailArg;
82 mView = aViewArg;
84 return NS_OK;
85 }
87 } // namespace dom
88 } // namespace mozilla
90 using namespace mozilla;
91 using namespace mozilla::dom;
93 nsresult
94 NS_NewDOMTimeEvent(nsIDOMEvent** aInstancePtrResult,
95 EventTarget* aOwner,
96 nsPresContext* aPresContext,
97 WidgetEvent* aEvent)
98 {
99 TimeEvent* it = new TimeEvent(aOwner, aPresContext, aEvent);
100 NS_ADDREF(it);
101 *aInstancePtrResult = static_cast<Event*>(it);
102 return NS_OK;
103 }