Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/image/ScriptedNotificationObserver.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
6
7
#include "ScriptedNotificationObserver.h"
8
#include "imgIScriptedNotificationObserver.h"
9
#include "nsCycleCollectionParticipant.h"
10
#include "nsContentUtils.h"                     // for nsAutoScriptBlocker
11
12
namespace mozilla {
13
namespace image {
14
15
NS_IMPL_CYCLE_COLLECTION(ScriptedNotificationObserver, mInner)
16
17
0
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptedNotificationObserver)
18
0
  NS_INTERFACE_MAP_ENTRY(imgINotificationObserver)
19
0
  NS_INTERFACE_MAP_ENTRY(nsISupports)
20
0
NS_INTERFACE_MAP_END
21
22
NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptedNotificationObserver)
23
NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptedNotificationObserver)
24
25
ScriptedNotificationObserver::ScriptedNotificationObserver(
26
    imgIScriptedNotificationObserver* aInner)
27
: mInner(aInner)
28
0
{ }
29
30
NS_IMETHODIMP
31
ScriptedNotificationObserver::Notify(imgIRequest* aRequest,
32
                                     int32_t aType,
33
                                     const nsIntRect* /*aUnused*/)
34
0
{
35
0
  // For now, we block (other) scripts from running to preserve the historical
36
0
  // behavior from when ScriptedNotificationObserver::Notify was called as part
37
0
  // of the observers list in nsImageLoadingContent::Notify. Now each
38
0
  // ScriptedNotificationObserver has its own imgRequestProxy and thus gets
39
0
  // Notify called directly by imagelib.
40
0
  nsAutoScriptBlocker scriptBlocker;
41
0
42
0
  if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
43
0
    return mInner->SizeAvailable(aRequest);
44
0
  }
45
0
  if (aType == imgINotificationObserver::FRAME_UPDATE) {
46
0
    return mInner->FrameUpdate(aRequest);
47
0
  }
48
0
  if (aType == imgINotificationObserver::FRAME_COMPLETE) {
49
0
    return mInner->FrameComplete(aRequest);
50
0
  }
51
0
  if (aType == imgINotificationObserver::DECODE_COMPLETE) {
52
0
    return mInner->DecodeComplete(aRequest);
53
0
  }
54
0
  if (aType == imgINotificationObserver::LOAD_COMPLETE) {
55
0
    return mInner->LoadComplete(aRequest);
56
0
  }
57
0
  if (aType == imgINotificationObserver::DISCARD) {
58
0
    return mInner->Discard(aRequest);
59
0
  }
60
0
  if (aType == imgINotificationObserver::IS_ANIMATED) {
61
0
    return mInner->IsAnimated(aRequest);
62
0
  }
63
0
  if (aType == imgINotificationObserver::HAS_TRANSPARENCY) {
64
0
    return mInner->HasTransparency(aRequest);
65
0
  }
66
0
  return NS_OK;
67
0
}
68
69
} // namespace image
70
} // namespace mozilla