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 | /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ |
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/TransitionEvent.h" |
michael@0 | 7 | #include "mozilla/ContentEvents.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 | TransitionEvent::TransitionEvent(EventTarget* aOwner, |
michael@0 | 14 | nsPresContext* aPresContext, |
michael@0 | 15 | InternalTransitionEvent* aEvent) |
michael@0 | 16 | : Event(aOwner, aPresContext, |
michael@0 | 17 | aEvent ? aEvent : new InternalTransitionEvent(false, 0)) |
michael@0 | 18 | { |
michael@0 | 19 | if (aEvent) { |
michael@0 | 20 | mEventIsInternal = false; |
michael@0 | 21 | } |
michael@0 | 22 | else { |
michael@0 | 23 | mEventIsInternal = true; |
michael@0 | 24 | mEvent->time = PR_Now(); |
michael@0 | 25 | } |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | NS_INTERFACE_MAP_BEGIN(TransitionEvent) |
michael@0 | 29 | NS_INTERFACE_MAP_ENTRY(nsIDOMTransitionEvent) |
michael@0 | 30 | NS_INTERFACE_MAP_END_INHERITING(Event) |
michael@0 | 31 | |
michael@0 | 32 | NS_IMPL_ADDREF_INHERITED(TransitionEvent, Event) |
michael@0 | 33 | NS_IMPL_RELEASE_INHERITED(TransitionEvent, Event) |
michael@0 | 34 | |
michael@0 | 35 | // static |
michael@0 | 36 | already_AddRefed<TransitionEvent> |
michael@0 | 37 | TransitionEvent::Constructor(const GlobalObject& aGlobal, |
michael@0 | 38 | const nsAString& aType, |
michael@0 | 39 | const TransitionEventInit& aParam, |
michael@0 | 40 | ErrorResult& aRv) |
michael@0 | 41 | { |
michael@0 | 42 | nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); |
michael@0 | 43 | nsRefPtr<TransitionEvent> e = new TransitionEvent(t, nullptr, nullptr); |
michael@0 | 44 | bool trusted = e->Init(t); |
michael@0 | 45 | |
michael@0 | 46 | aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable); |
michael@0 | 47 | |
michael@0 | 48 | InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent(); |
michael@0 | 49 | internalEvent->propertyName = aParam.mPropertyName; |
michael@0 | 50 | internalEvent->elapsedTime = aParam.mElapsedTime; |
michael@0 | 51 | internalEvent->pseudoElement = aParam.mPseudoElement; |
michael@0 | 52 | |
michael@0 | 53 | e->SetTrusted(trusted); |
michael@0 | 54 | return e.forget(); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | NS_IMETHODIMP |
michael@0 | 58 | TransitionEvent::GetPropertyName(nsAString& aPropertyName) |
michael@0 | 59 | { |
michael@0 | 60 | aPropertyName = mEvent->AsTransitionEvent()->propertyName; |
michael@0 | 61 | return NS_OK; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | NS_IMETHODIMP |
michael@0 | 65 | TransitionEvent::GetElapsedTime(float* aElapsedTime) |
michael@0 | 66 | { |
michael@0 | 67 | *aElapsedTime = ElapsedTime(); |
michael@0 | 68 | return NS_OK; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | float |
michael@0 | 72 | TransitionEvent::ElapsedTime() |
michael@0 | 73 | { |
michael@0 | 74 | return mEvent->AsTransitionEvent()->elapsedTime; |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | NS_IMETHODIMP |
michael@0 | 78 | TransitionEvent::GetPseudoElement(nsAString& aPseudoElement) |
michael@0 | 79 | { |
michael@0 | 80 | aPseudoElement = mEvent->AsTransitionEvent()->pseudoElement; |
michael@0 | 81 | return NS_OK; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | } // namespace dom |
michael@0 | 85 | } // namespace mozilla |
michael@0 | 86 | |
michael@0 | 87 | using namespace mozilla; |
michael@0 | 88 | using namespace mozilla::dom; |
michael@0 | 89 | |
michael@0 | 90 | nsresult |
michael@0 | 91 | NS_NewDOMTransitionEvent(nsIDOMEvent** aInstancePtrResult, |
michael@0 | 92 | EventTarget* aOwner, |
michael@0 | 93 | nsPresContext* aPresContext, |
michael@0 | 94 | InternalTransitionEvent* aEvent) |
michael@0 | 95 | { |
michael@0 | 96 | TransitionEvent *it = new TransitionEvent(aOwner, aPresContext, aEvent); |
michael@0 | 97 | NS_ADDREF(it); |
michael@0 | 98 | *aInstancePtrResult = static_cast<Event*>(it); |
michael@0 | 99 | return NS_OK; |
michael@0 | 100 | } |