Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xbl/nsXBLEventHandler.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 nsXBLEventHandler_h__
8
#define nsXBLEventHandler_h__
9
10
#include "mozilla/Attributes.h"
11
#include "nsCOMPtr.h"
12
#include "nsIDOMEventListener.h"
13
#include "nsTArray.h"
14
15
class nsAtom;
16
class nsXBLPrototypeHandler;
17
18
namespace mozilla {
19
struct IgnoreModifierState;
20
namespace dom {
21
class Event;
22
class KeyboardEvent;
23
} // namespace dom
24
} // namespace mozilla
25
26
class nsXBLEventHandler : public nsIDOMEventListener
27
{
28
public:
29
  explicit nsXBLEventHandler(nsXBLPrototypeHandler* aHandler);
30
31
  NS_DECL_ISUPPORTS
32
33
  NS_DECL_NSIDOMEVENTLISTENER
34
35
protected:
36
  virtual ~nsXBLEventHandler();
37
  nsXBLPrototypeHandler* mProtoHandler;
38
39
private:
40
  nsXBLEventHandler();
41
  virtual bool EventMatched(mozilla::dom::Event* aEvent)
42
0
  {
43
0
    return true;
44
0
  }
45
};
46
47
class nsXBLMouseEventHandler : public nsXBLEventHandler
48
{
49
public:
50
  explicit nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler);
51
  virtual ~nsXBLMouseEventHandler();
52
53
private:
54
  bool EventMatched(mozilla::dom::Event* aEvent) override;
55
};
56
57
class nsXBLKeyEventHandler : public nsIDOMEventListener
58
{
59
  typedef mozilla::IgnoreModifierState IgnoreModifierState;
60
61
public:
62
  nsXBLKeyEventHandler(nsAtom* aEventType, uint8_t aPhase, uint8_t aType);
63
64
  NS_DECL_ISUPPORTS
65
66
  NS_DECL_NSIDOMEVENTLISTENER
67
68
  void AddProtoHandler(nsXBLPrototypeHandler* aProtoHandler)
69
0
  {
70
0
    mProtoHandlers.AppendElement(aProtoHandler);
71
0
  }
72
73
  bool Matches(nsAtom* aEventType, uint8_t aPhase, uint8_t aType) const
74
0
  {
75
0
    return (mEventType == aEventType && mPhase == aPhase && mType == aType);
76
0
  }
77
78
  void GetEventName(nsAString& aString) const
79
0
  {
80
0
    mEventType->ToString(aString);
81
0
  }
82
83
  uint8_t GetPhase() const
84
0
  {
85
0
    return mPhase;
86
0
  }
87
88
  uint8_t GetType() const
89
0
  {
90
0
    return mType;
91
0
  }
92
93
  void SetIsBoundToChrome(bool aIsBoundToChrome)
94
0
  {
95
0
    mIsBoundToChrome = aIsBoundToChrome;
96
0
  }
97
98
  void SetUsingContentXBLScope(bool aUsingContentXBLScope)
99
0
  {
100
0
    mUsingContentXBLScope = aUsingContentXBLScope;
101
0
  }
102
103
private:
104
  nsXBLKeyEventHandler();
105
  virtual ~nsXBLKeyEventHandler();
106
107
  bool ExecuteMatchedHandlers(mozilla::dom::KeyboardEvent* aEvent, uint32_t aCharCode,
108
                              const IgnoreModifierState& aIgnoreModifierState);
109
110
  nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
111
  RefPtr<nsAtom> mEventType;
112
  uint8_t mPhase;
113
  uint8_t mType;
114
  bool mIsBoundToChrome;
115
  bool mUsingContentXBLScope;
116
};
117
118
already_AddRefed<nsXBLEventHandler>
119
NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
120
                      nsAtom* aEventType);
121
122
#endif