Bug 1889091 - Part 4: Remove extra stack pointer move. r=jandem
[gecko.git] / widget / nsIRollupListener.h
blobb52e768a14ea0652850be7bbf08976d77e4341ae
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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 __nsIRollupListener_h__
8 #define __nsIRollupListener_h__
10 #include "nsTArray.h"
11 #include "nsPoint.h"
12 #include "Units.h"
14 class nsIContent;
15 class nsIWidget;
17 class nsIRollupListener {
18 public:
19 enum class FlushViews : bool { No, Yes };
20 enum class AllowAnimations : bool { No, Yes };
21 struct RollupOptions {
22 // aCount is the number of popups in a chain to close. If this is
23 // zero, then all popups are closed.
24 uint32_t mCount = 0;
25 // If this is true, then views should be flushed after the rollup.
26 FlushViews mFlush = FlushViews::No;
27 // This is the mouse pointer position where the event that triggered the
28 // rollup occurred, which may be nullptr.
29 const mozilla::LayoutDeviceIntPoint* mPoint = nullptr;
30 // Whether to allow panel animations.
31 AllowAnimations mAllowAnimations = AllowAnimations::Yes;
34 /**
35 * Notifies the object to rollup, optionally returning the node that
36 * was just rolled up in aLastRolledUp, if non-null.
38 * aLastRolledUp is not addrefed.
40 * Returns true if the event that the caller is processing should be consumed.
42 MOZ_CAN_RUN_SCRIPT_BOUNDARY
43 virtual bool Rollup(const RollupOptions&,
44 nsIContent** aLastRolledUp = nullptr) = 0;
46 /**
47 * Asks the RollupListener if it should rollup on mouse wheel events
49 virtual bool ShouldRollupOnMouseWheelEvent() = 0;
51 /**
52 * Asks the RollupListener if it should consume mouse wheel events
54 virtual bool ShouldConsumeOnMouseWheelEvent() = 0;
56 /**
57 * Asks the RollupListener if it should rollup on mouse activate, eg. X-Mouse
59 virtual bool ShouldRollupOnMouseActivate() = 0;
62 * Retrieve the widgets for open menus and store them in the array
63 * aWidgetChain. The number of menus of the same type should be returned,
64 * for example, if a context menu is open, return only the number of menus
65 * that are part of the context menu chain. This allows closing up only
66 * those menus in different situations. The returned value should be exactly
67 * the same number of widgets added to aWidgetChain.
69 virtual uint32_t GetSubmenuWidgetChain(
70 nsTArray<nsIWidget*>* aWidgetChain) = 0;
72 virtual nsIWidget* GetRollupWidget() = 0;
74 /**
75 * If a native menu is currently shown, closes the menu.
76 * Returns true if a native menu was open.
78 virtual bool RollupNativeMenu() { return false; }
81 #endif /* __nsIRollupListener_h__ */