2012-10-12 20:11:22 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "ScriptedNotificationObserver.h"
|
|
|
|
#include "imgIScriptedNotificationObserver.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2017-07-19 21:15:12 +03:00
|
|
|
#include "nsContentUtils.h" // for nsAutoScriptBlocker
|
2012-10-12 20:11:22 +04:00
|
|
|
|
2014-07-10 19:00:31 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
2012-10-12 20:11:22 +04:00
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION(ScriptedNotificationObserver, mInner)
|
2012-10-12 20:11:22 +04:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptedNotificationObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(imgINotificationObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptedNotificationObserver)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptedNotificationObserver)
|
|
|
|
|
|
|
|
ScriptedNotificationObserver::ScriptedNotificationObserver(
|
|
|
|
imgIScriptedNotificationObserver* aInner)
|
|
|
|
: mInner(aInner) {}
|
|
|
|
|
2020-03-12 07:25:34 +03:00
|
|
|
void ScriptedNotificationObserver::Notify(imgIRequest* aRequest, int32_t aType,
|
|
|
|
const nsIntRect* /*aUnused*/) {
|
2017-07-19 21:15:12 +03:00
|
|
|
// For now, we block (other) scripts from running to preserve the historical
|
|
|
|
// behavior from when ScriptedNotificationObserver::Notify was called as part
|
|
|
|
// of the observers list in nsImageLoadingContent::Notify. Now each
|
|
|
|
// ScriptedNotificationObserver has its own imgRequestProxy and thus gets
|
|
|
|
// Notify called directly by imagelib.
|
|
|
|
nsAutoScriptBlocker scriptBlocker;
|
|
|
|
|
2015-03-31 20:50:00 +03:00
|
|
|
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->SizeAvailable(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::FRAME_UPDATE) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->FrameUpdate(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::FRAME_COMPLETE) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->FrameComplete(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::DECODE_COMPLETE) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->DecodeComplete(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->LoadComplete(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::DISCARD) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->Discard(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::IS_ANIMATED) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->IsAnimated(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::HAS_TRANSPARENCY) {
|
2020-03-12 07:25:34 +03:00
|
|
|
mInner->HasTransparency(aRequest);
|
|
|
|
return;
|
2015-03-31 20:50:00 +03:00
|
|
|
}
|
2012-10-12 20:11:22 +04:00
|
|
|
}
|
2014-07-10 19:00:31 +04:00
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|