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.
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/TimeEvent.h" |
michael@0 | 7 | #include "mozilla/BasicEvents.h" |
michael@0 | 8 | #include "nsIInterfaceRequestorUtils.h" |
michael@0 | 9 | #include "nsPresContext.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | namespace dom { |
michael@0 | 13 | |
michael@0 | 14 | TimeEvent::TimeEvent(EventTarget* aOwner, |
michael@0 | 15 | nsPresContext* aPresContext, |
michael@0 | 16 | WidgetEvent* aEvent) |
michael@0 | 17 | : Event(aOwner, aPresContext, |
michael@0 | 18 | aEvent ? aEvent : new InternalUIEvent(false, 0)) |
michael@0 | 19 | , mDetail(0) |
michael@0 | 20 | { |
michael@0 | 21 | SetIsDOMBinding(); |
michael@0 | 22 | if (aEvent) { |
michael@0 | 23 | mEventIsInternal = false; |
michael@0 | 24 | } else { |
michael@0 | 25 | mEventIsInternal = true; |
michael@0 | 26 | mEvent->eventStructType = NS_SMIL_TIME_EVENT; |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | if (mEvent->eventStructType == NS_SMIL_TIME_EVENT) { |
michael@0 | 30 | mDetail = mEvent->AsUIEvent()->detail; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | mEvent->mFlags.mBubbles = false; |
michael@0 | 34 | mEvent->mFlags.mCancelable = false; |
michael@0 | 35 | |
michael@0 | 36 | if (mPresContext) { |
michael@0 | 37 | nsISupports* container = mPresContext->GetContainerWeak(); |
michael@0 | 38 | if (container) { |
michael@0 | 39 | nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container); |
michael@0 | 40 | if (window) { |
michael@0 | 41 | mView = do_QueryInterface(window); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | NS_IMPL_CYCLE_COLLECTION_INHERITED(TimeEvent, Event, |
michael@0 | 48 | mView) |
michael@0 | 49 | |
michael@0 | 50 | NS_IMPL_ADDREF_INHERITED(TimeEvent, Event) |
michael@0 | 51 | NS_IMPL_RELEASE_INHERITED(TimeEvent, Event) |
michael@0 | 52 | |
michael@0 | 53 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TimeEvent) |
michael@0 | 54 | NS_INTERFACE_MAP_ENTRY(nsIDOMTimeEvent) |
michael@0 | 55 | NS_INTERFACE_MAP_END_INHERITING(Event) |
michael@0 | 56 | |
michael@0 | 57 | NS_IMETHODIMP |
michael@0 | 58 | TimeEvent::GetView(nsIDOMWindow** aView) |
michael@0 | 59 | { |
michael@0 | 60 | *aView = mView; |
michael@0 | 61 | NS_IF_ADDREF(*aView); |
michael@0 | 62 | return NS_OK; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | NS_IMETHODIMP |
michael@0 | 66 | TimeEvent::GetDetail(int32_t* aDetail) |
michael@0 | 67 | { |
michael@0 | 68 | *aDetail = mDetail; |
michael@0 | 69 | return NS_OK; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | NS_IMETHODIMP |
michael@0 | 73 | TimeEvent::InitTimeEvent(const nsAString& aTypeArg, |
michael@0 | 74 | nsIDOMWindow* aViewArg, |
michael@0 | 75 | int32_t aDetailArg) |
michael@0 | 76 | { |
michael@0 | 77 | nsresult rv = Event::InitEvent(aTypeArg, false /*doesn't bubble*/, |
michael@0 | 78 | false /*can't cancel*/); |
michael@0 | 79 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 80 | |
michael@0 | 81 | mDetail = aDetailArg; |
michael@0 | 82 | mView = aViewArg; |
michael@0 | 83 | |
michael@0 | 84 | return NS_OK; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | } // namespace dom |
michael@0 | 88 | } // namespace mozilla |
michael@0 | 89 | |
michael@0 | 90 | using namespace mozilla; |
michael@0 | 91 | using namespace mozilla::dom; |
michael@0 | 92 | |
michael@0 | 93 | nsresult |
michael@0 | 94 | NS_NewDOMTimeEvent(nsIDOMEvent** aInstancePtrResult, |
michael@0 | 95 | EventTarget* aOwner, |
michael@0 | 96 | nsPresContext* aPresContext, |
michael@0 | 97 | WidgetEvent* aEvent) |
michael@0 | 98 | { |
michael@0 | 99 | TimeEvent* it = new TimeEvent(aOwner, aPresContext, aEvent); |
michael@0 | 100 | NS_ADDREF(it); |
michael@0 | 101 | *aInstancePtrResult = static_cast<Event*>(it); |
michael@0 | 102 | return NS_OK; |
michael@0 | 103 | } |