Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / events / InputEventOptions.h
blob94096d759f1dc20e85bd729aeef818e10379bf35
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/. */
7 #ifndef mozilla_InputEventOptions_h
8 #define mozilla_InputEventOptions_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/TextEvents.h"
13 #include "mozilla/dom/DataTransfer.h"
14 #include "mozilla/dom/StaticRange.h"
15 #include "nsString.h"
16 #include "nsTArray.h"
18 namespace mozilla {
20 /**
21 * InputEventOptions is used by nsContentUtils::DispatchInputEvent() to specify
22 * some attributes of InputEvent. It would be nice if this was in
23 * nsContentUtils.h, however, it needs to include StaticRange.h for declaring
24 * this. That would cause unnecessary dependency and makes incremental build
25 * slower when you touch StaticRange.h even though most nsContentUtils.h users
26 * don't use it. Therefore, this struct is declared in separated header file
27 * here.
29 struct MOZ_STACK_CLASS InputEventOptions final {
30 enum class NeverCancelable {
31 No,
32 Yes,
34 InputEventOptions() : mDataTransfer(nullptr), mNeverCancelable(false) {}
35 explicit InputEventOptions(const InputEventOptions& aOther) = delete;
36 InputEventOptions(InputEventOptions&& aOther) = default;
37 explicit InputEventOptions(const nsAString& aData,
38 NeverCancelable aNeverCancelable)
39 : mData(aData),
40 mDataTransfer(nullptr),
41 mNeverCancelable(aNeverCancelable == NeverCancelable::Yes) {}
42 explicit InputEventOptions(dom::DataTransfer* aDataTransfer,
43 NeverCancelable aNeverCancelable)
44 : mDataTransfer(aDataTransfer),
45 mNeverCancelable(aNeverCancelable == NeverCancelable::Yes) {
46 MOZ_ASSERT(mDataTransfer);
47 MOZ_ASSERT(mDataTransfer->IsReadOnly());
49 InputEventOptions(const nsAString& aData,
50 OwningNonNullStaticRangeArray&& aTargetRanges,
51 NeverCancelable aNeverCancelable)
52 : mData(aData),
53 mDataTransfer(nullptr),
54 mTargetRanges(std::move(aTargetRanges)),
55 mNeverCancelable(aNeverCancelable == NeverCancelable::Yes) {}
56 InputEventOptions(dom::DataTransfer* aDataTransfer,
57 OwningNonNullStaticRangeArray&& aTargetRanges,
58 NeverCancelable aNeverCancelable)
59 : mDataTransfer(aDataTransfer),
60 mTargetRanges(std::move(aTargetRanges)),
61 mNeverCancelable(aNeverCancelable == NeverCancelable::Yes) {
62 MOZ_ASSERT(mDataTransfer);
63 MOZ_ASSERT(mDataTransfer->IsReadOnly());
66 nsString mData;
67 dom::DataTransfer* mDataTransfer;
68 OwningNonNullStaticRangeArray mTargetRanges;
69 // If this is set to true, dispatching event won't be cancelable.
70 bool mNeverCancelable;
73 } // namespace mozilla
75 #endif // #ifndef mozilla_InputEventOptions_h