2012-10-12 16:11:22 +00: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 18:15:12 +00:00
|
|
|
#include "nsContentUtils.h" // for nsAutoScriptBlocker
|
2012-10-12 16:11:22 +00:00
|
|
|
|
2014-07-10 15:00:31 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
2012-10-12 16:11:22 +00:00
|
|
|
|
2014-04-25 16:49:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION(ScriptedNotificationObserver, mInner)
|
2012-10-12 16:11:22 +00: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)
|
2015-03-31 17:50:00 +00:00
|
|
|
{ }
|
2012-10-12 16:11:22 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ScriptedNotificationObserver::Notify(imgIRequest* aRequest,
|
|
|
|
int32_t aType,
|
|
|
|
const nsIntRect* /*aUnused*/)
|
|
|
|
{
|
2017-07-19 18:15:12 +00: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 17:50:00 +00:00
|
|
|
if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
|
2012-10-12 16:11:23 +00:00
|
|
|
return mInner->SizeAvailable(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::FRAME_UPDATE) {
|
2012-10-12 16:11:23 +00:00
|
|
|
return mInner->FrameUpdate(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::FRAME_COMPLETE) {
|
2012-10-12 16:11:23 +00:00
|
|
|
return mInner->FrameComplete(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::DECODE_COMPLETE) {
|
2012-10-12 16:11:23 +00:00
|
|
|
return mInner->DecodeComplete(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
|
2012-10-12 16:11:23 +00:00
|
|
|
return mInner->LoadComplete(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::DISCARD) {
|
2012-10-12 16:11:22 +00:00
|
|
|
return mInner->Discard(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::IS_ANIMATED) {
|
2012-10-12 16:11:22 +00:00
|
|
|
return mInner->IsAnimated(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
|
|
|
if (aType == imgINotificationObserver::HAS_TRANSPARENCY) {
|
2014-11-17 19:16:45 +00:00
|
|
|
return mInner->HasTransparency(aRequest);
|
2015-03-31 17:50:00 +00:00
|
|
|
}
|
2012-10-12 16:11:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-07-10 15:00:31 +00:00
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|