Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/PendingFullscreenEvent.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
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
#ifndef mozilla_PendingFullscreenEvent_h_
8
#define mozilla_PendingFullscreenEvent_h_
9
10
#include "nsContentUtils.h"
11
12
class nsIDocument;
13
14
namespace mozilla {
15
16
enum class FullscreenEventType
17
{
18
  Change,
19
  Error,
20
};
21
22
/*
23
 * Class for dispatching a fullscreen event. It should be queued and
24
 * invoked as part of "run the fullscreen steps" algorithm.
25
 */
26
class PendingFullscreenEvent
27
{
28
public:
29
  PendingFullscreenEvent(FullscreenEventType aType,
30
                         nsIDocument* aDocument,
31
                         nsINode* aTarget)
32
    : mDocument(aDocument)
33
    , mTarget(aTarget)
34
    , mType(aType)
35
0
  {
36
0
    MOZ_ASSERT(aDocument);
37
0
    MOZ_ASSERT(aTarget);
38
0
  }
39
40
0
  nsIDocument* Document() const { return mDocument; }
41
42
  void Dispatch()
43
0
  {
44
#ifdef DEBUG
45
    MOZ_ASSERT(!mDispatched);
46
    mDispatched = true;
47
#endif
48
    nsString name;
49
0
    switch (mType) {
50
0
      case FullscreenEventType::Change:
51
0
        name = NS_LITERAL_STRING("fullscreenchange");
52
0
        break;
53
0
      case FullscreenEventType::Error:
54
0
        name = NS_LITERAL_STRING("fullscreenerror");
55
0
        break;
56
0
    }
57
0
    nsINode* target = mTarget->GetComposedDoc() == mDocument
58
0
      ? mTarget.get() : mDocument.get();
59
0
    Unused << nsContentUtils::DispatchTrustedEvent(
60
0
      mDocument, target, name,
61
0
      CanBubble::eYes, Cancelable::eNo, Composed::eYes);
62
0
  }
63
64
private:
65
  nsCOMPtr<nsIDocument> mDocument;
66
  nsCOMPtr<nsINode> mTarget;
67
  FullscreenEventType mType;
68
#ifdef DEBUG
69
  bool mDispatched = false;
70
#endif
71
};
72
73
} // namespace mozilla
74
75
#endif // mozilla_PendingFullscreenEvent_h_