1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "ScriptedNotificationObserver.h"
8 #include "imgIScriptedNotificationObserver.h"
9 #include "nsCycleCollectionParticipant.h"
10 #include "nsContentUtils.h" // for nsAutoScriptBlocker
15 NS_IMPL_CYCLE_COLLECTION(ScriptedNotificationObserver
, mInner
)
17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptedNotificationObserver
)
18 NS_INTERFACE_MAP_ENTRY(imgINotificationObserver
)
19 NS_INTERFACE_MAP_ENTRY(nsISupports
)
22 NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptedNotificationObserver
)
23 NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptedNotificationObserver
)
25 ScriptedNotificationObserver::ScriptedNotificationObserver(
26 imgIScriptedNotificationObserver
* aInner
)
29 void ScriptedNotificationObserver::Notify(imgIRequest
* aRequest
, int32_t aType
,
30 const nsIntRect
* /*aUnused*/) {
31 // For now, we block (other) scripts from running to preserve the historical
32 // behavior from when ScriptedNotificationObserver::Notify was called as part
33 // of the observers list in nsImageLoadingContent::Notify. Now each
34 // ScriptedNotificationObserver has its own imgRequestProxy and thus gets
35 // Notify called directly by imagelib.
36 nsAutoScriptBlocker scriptBlocker
;
38 if (aType
== imgINotificationObserver::SIZE_AVAILABLE
) {
39 mInner
->SizeAvailable(aRequest
);
42 if (aType
== imgINotificationObserver::FRAME_UPDATE
) {
43 mInner
->FrameUpdate(aRequest
);
46 if (aType
== imgINotificationObserver::FRAME_COMPLETE
) {
47 mInner
->FrameComplete(aRequest
);
50 if (aType
== imgINotificationObserver::DECODE_COMPLETE
) {
51 mInner
->DecodeComplete(aRequest
);
54 if (aType
== imgINotificationObserver::LOAD_COMPLETE
) {
55 mInner
->LoadComplete(aRequest
);
58 if (aType
== imgINotificationObserver::DISCARD
) {
59 mInner
->Discard(aRequest
);
62 if (aType
== imgINotificationObserver::IS_ANIMATED
) {
63 mInner
->IsAnimated(aRequest
);
66 if (aType
== imgINotificationObserver::HAS_TRANSPARENCY
) {
67 mInner
->HasTransparency(aRequest
);
73 } // namespace mozilla