Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/layers/FocusTarget.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_layers_FocusTarget_h
8
#define mozilla_layers_FocusTarget_h
9
10
#include <stdint.h> // for int32_t, uint32_t
11
12
#include "FrameMetrics.h"        // for FrameMetrics::ViewID
13
#include "mozilla/DefineEnum.h"  // for MOZ_DEFINE_ENUM
14
#include "mozilla/Variant.h"     // for Variant
15
16
class nsIPresShell;
17
18
namespace mozilla {
19
namespace layers {
20
21
/**
22
 * This class is used for communicating information about the currently focused
23
 * element of a document and the scrollable frames to use when keyboard scrolling
24
 * it. It is created on the main thread at paint-time, but is then passed over
25
 * IPC to the compositor/APZ code.
26
 */
27
class FocusTarget final
28
{
29
public:
30
  struct ScrollTargets
31
  {
32
    FrameMetrics::ViewID mHorizontal;
33
    FrameMetrics::ViewID mVertical;
34
35
    bool operator==(const ScrollTargets& aRhs) const
36
0
    {
37
0
      return mHorizontal == aRhs.mHorizontal &&
38
0
             mVertical == aRhs.mVertical;
39
0
    }
40
  };
41
42
  // We need this to represent the case where mData has no focus target data
43
  // because we can't have an empty variant
44
  struct NoFocusTarget {
45
    bool operator==(const NoFocusTarget& aRhs) const
46
0
    {
47
0
     return true;
48
0
    }
49
  };
50
51
  FocusTarget();
52
53
  /**
54
   * Construct a focus target for the specified top level PresShell
55
   */
56
  FocusTarget(nsIPresShell* aRootPresShell,
57
              uint64_t aFocusSequenceNumber);
58
59
  bool operator==(const FocusTarget& aRhs) const;
60
61
  const char* Type() const;
62
63
public:
64
  // The content sequence number recorded at the time of this class's creation
65
  uint64_t mSequenceNumber;
66
67
  // Whether there are keydown, keypress, or keyup event listeners
68
  // in the event target chain of the focused element
69
  bool mFocusHasKeyEventListeners;
70
71
  mozilla::Variant<LayersId, ScrollTargets, NoFocusTarget> mData;
72
};
73
74
} // namespace layers
75
} // namespace mozilla
76
77
#endif // mozilla_layers_FocusTarget_h