Source code

Revision control

Other Tools

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