Bug 1761003 [wpt PR 33324] - Add comment pointing to followup bug, and fix typos...
[gecko.git] / widget / nsIWidget.h
blob499fa38f4cee014d87315f5206b65b6ed9fbad93
1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIWidget_h__
7 #define nsIWidget_h__
9 #include <cmath>
10 #include <cstdint>
11 #include "ErrorList.h"
12 #include "Units.h"
13 #include "mozilla/AlreadyAddRefed.h"
14 #include "mozilla/Assertions.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/EventForwards.h"
17 #include "mozilla/Maybe.h"
18 #include "mozilla/RefPtr.h"
19 #include "mozilla/TimeStamp.h"
20 #include "mozilla/UniquePtr.h"
21 #include "mozilla/gfx/Matrix.h"
22 #include "mozilla/gfx/Rect.h"
23 #include "mozilla/layers/LayersTypes.h"
24 #include "mozilla/layers/ScrollableLayerGuid.h"
25 #include "mozilla/layers/ZoomConstraints.h"
26 #include "mozilla/image/Resolution.h"
27 #include "mozilla/widget/IMEData.h"
28 #include "nsCOMPtr.h"
29 #include "nsColor.h"
30 #include "nsDebug.h"
31 #include "nsID.h"
32 #include "nsIObserver.h"
33 #include "nsISupports.h"
34 #include "nsITheme.h"
35 #include "nsITimer.h"
36 #include "nsIWidgetListener.h"
37 #include "nsRect.h"
38 #include "nsSize.h"
39 #include "nsStringFwd.h"
40 #include "nsTArray.h"
41 #include "nsTHashMap.h"
42 #include "nsWidgetInitData.h"
43 #include "nsXULAppAPI.h"
45 #ifdef MOZ_IS_GCC
46 # include "VsyncSource.h"
47 #endif
49 // forward declarations
50 class nsIBidiKeyboard;
51 class nsIRollupListener;
52 class imgIContainer;
53 class nsIContent;
54 class ViewWrapper;
55 class nsIScreen;
56 class nsIRunnable;
58 namespace mozilla {
59 enum class NativeKeyBindingsType : uint8_t;
60 class WidgetGUIEvent;
61 class WidgetInputEvent;
62 class WidgetKeyboardEvent;
63 struct FontRange;
65 enum class StyleWindowShadow : uint8_t;
66 enum class ColorScheme : uint8_t;
68 #if defined(MOZ_WIDGET_ANDROID)
69 namespace ipc {
70 class Shmem;
72 #endif // defined(MOZ_WIDGET_ANDROID)
73 namespace dom {
74 class BrowserChild;
75 enum class CallerType : uint32_t;
76 } // namespace dom
77 class WindowRenderer;
78 namespace layers {
79 class AsyncDragMetrics;
80 class Compositor;
81 class CompositorBridgeChild;
82 struct FrameMetrics;
83 class LayerManager;
84 class WebRenderBridgeChild;
85 } // namespace layers
86 namespace gfx {
87 class VsyncSource;
88 } // namespace gfx
89 namespace widget {
90 class TextEventDispatcher;
91 class TextEventDispatcherListener;
92 class CompositorWidget;
93 class CompositorWidgetInitData;
94 } // namespace widget
95 namespace wr {
96 class DisplayListBuilder;
97 class IpcResourceUpdateQueue;
98 enum class RenderRoot : uint8_t;
99 } // namespace wr
100 } // namespace mozilla
103 * Callback function that processes events.
105 * The argument is actually a subtype (subclass) of WidgetEvent which carries
106 * platform specific information about the event. Platform specific code
107 * knows how to deal with it.
109 * The return value determines whether or not the default action should take
110 * place.
112 typedef nsEventStatus (*EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
114 // Hide the native window system's real window type so as to avoid
115 // including native window system types and APIs. This is necessary
116 // to ensure cross-platform code.
117 typedef void* nsNativeWidget;
120 * Flags for the GetNativeData and SetNativeData functions
122 #define NS_NATIVE_WINDOW 0
123 #define NS_NATIVE_GRAPHIC 1
124 #define NS_NATIVE_TMP_WINDOW 2
125 #define NS_NATIVE_WIDGET 3
126 #define NS_NATIVE_DISPLAY 4
127 #define NS_NATIVE_REGION 5
128 #define NS_NATIVE_OFFSETX 6
129 #define NS_NATIVE_OFFSETY 7
130 #define NS_NATIVE_SCREEN 9
131 // The toplevel GtkWidget containing this nsIWidget:
132 #define NS_NATIVE_SHELLWIDGET 10
133 #define NS_NATIVE_OPENGL_CONTEXT 12
134 // This is available only with GetNativeData() in parent process. Anybody
135 // shouldn't access this pointer as a valid pointer since the result may be
136 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
137 // an identifier of distinguishing a text composition is caused by which native
138 // IME context. Note that the result is only valid in the process. So,
139 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
140 #define NS_RAW_NATIVE_IME_CONTEXT 14
141 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
142 #ifdef XP_WIN
143 # define NS_NATIVE_TSF_THREAD_MGR 100
144 # define NS_NATIVE_TSF_CATEGORY_MGR 101
145 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
146 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
147 #endif
148 #if defined(MOZ_WIDGET_GTK)
149 # define NS_NATIVE_EGL_WINDOW 106
150 #endif
151 #ifdef MOZ_WIDGET_ANDROID
152 # define NS_JAVA_SURFACE 100
153 # define NS_PRESENTATION_WINDOW 101
154 # define NS_PRESENTATION_SURFACE 102
155 #endif
157 #define MOZ_WIDGET_MAX_SIZE 16384
158 #define MOZ_WIDGET_INVALID_SCALE 0.0
160 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
161 #define NS_IWIDGET_IID \
163 0x06396bf6, 0x2dd8, 0x45e5, { \
164 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
169 * Transparency modes
172 enum nsTransparencyMode {
173 eTransparencyOpaque = 0, // Fully opaque
174 eTransparencyTransparent, // Parts of the window may be transparent
175 eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass
176 // effect applied
177 eTransparencyBorderlessGlass // As above, but without a border around the
178 // opaque areas when there would otherwise be
179 // one with eTransparencyGlass
180 // If you add to the end here, you must update the serialization code in
181 // WidgetMessageUtils.h
185 * Cursor types.
188 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
189 eCursor_standard,
190 ///(system is busy, usually rendered as a hourglass or watch)
191 eCursor_wait,
192 ///(Selecting something, usually rendered as an IBeam)
193 eCursor_select,
194 ///(can hyper-link, usually rendered as a human hand)
195 eCursor_hyperlink,
196 ///(north/south/west/east edge sizing)
197 eCursor_n_resize,
198 eCursor_s_resize,
199 eCursor_w_resize,
200 eCursor_e_resize,
201 ///(corner sizing)
202 eCursor_nw_resize,
203 eCursor_se_resize,
204 eCursor_ne_resize,
205 eCursor_sw_resize,
206 eCursor_crosshair,
207 eCursor_move,
208 eCursor_help,
209 eCursor_copy, // CSS3
210 eCursor_alias,
211 eCursor_context_menu,
212 eCursor_cell,
213 eCursor_grab,
214 eCursor_grabbing,
215 eCursor_spinning,
216 eCursor_zoom_in,
217 eCursor_zoom_out,
218 eCursor_not_allowed,
219 eCursor_col_resize,
220 eCursor_row_resize,
221 eCursor_no_drop,
222 eCursor_vertical_text,
223 eCursor_all_scroll,
224 eCursor_nesw_resize,
225 eCursor_nwse_resize,
226 eCursor_ns_resize,
227 eCursor_ew_resize,
228 eCursor_none,
229 // This one is used for array sizing, and so better be the last
230 // one in this list...
231 eCursorCount,
233 // ...except for this one.
234 eCursorInvalid = eCursorCount + 1
237 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
238 eZPlacementBottom = 0, // bottom of the window stack
239 eZPlacementBelow, // just below another widget
240 eZPlacementTop // top of the window stack
244 * Before the OS goes to sleep, this topic is notified.
246 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
249 * After the OS wakes up, this topic is notified.
251 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
254 * Before the OS suspends the current process, this topic is notified. Some
255 * OS will kill processes that are suspended instead of resuming them.
256 * For that reason this topic may be useful to safely close down resources.
258 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
261 * After the current process resumes from being suspended, this topic is
262 * notified.
264 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
267 * When an app(-shell) is activated by the OS, this topic is notified.
268 * Currently, this only happens on Mac OSX.
270 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
272 namespace mozilla {
273 namespace widget {
276 * Size constraints for setting the minimum and maximum size of a widget.
277 * Values are in device pixels.
279 struct SizeConstraints {
280 SizeConstraints()
281 : mMaxSize(MOZ_WIDGET_MAX_SIZE, MOZ_WIDGET_MAX_SIZE),
282 mScale(MOZ_WIDGET_INVALID_SCALE) {}
284 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
285 mozilla::LayoutDeviceIntSize aMaxSize,
286 mozilla::DesktopToLayoutDeviceScale aScale)
287 : mMinSize(aMinSize), mMaxSize(aMaxSize), mScale(aScale) {
288 if (mMaxSize.width > MOZ_WIDGET_MAX_SIZE) {
289 mMaxSize.width = MOZ_WIDGET_MAX_SIZE;
291 if (mMaxSize.height > MOZ_WIDGET_MAX_SIZE) {
292 mMaxSize.height = MOZ_WIDGET_MAX_SIZE;
296 mozilla::LayoutDeviceIntSize mMinSize;
297 mozilla::LayoutDeviceIntSize mMaxSize;
300 * The scale used to convert from desktop to device dimensions.
301 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
303 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
304 * with multi-monitor scaling issues in more complete way across
305 * all widget implementations.
307 mozilla::DesktopToLayoutDeviceScale mScale;
310 struct AutoObserverNotifier {
311 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
312 : mObserver(aObserver), mTopic(aTopic) {}
314 void SkipNotification() { mObserver = nullptr; }
316 uint64_t SaveObserver() {
317 if (!mObserver) {
318 return 0;
320 uint64_t observerId = ++sObserverId;
321 sSavedObservers.InsertOrUpdate(observerId, mObserver);
322 SkipNotification();
323 return observerId;
326 ~AutoObserverNotifier() {
327 if (mObserver) {
328 mObserver->Observe(nullptr, mTopic, nullptr);
332 static void NotifySavedObserver(const uint64_t& aObserverId,
333 const char* aTopic) {
334 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
335 if (!observer) {
336 MOZ_ASSERT(aObserverId == 0,
337 "We should always find a saved observer for nonzero IDs");
338 return;
341 sSavedObservers.Remove(aObserverId);
342 observer->Observe(nullptr, aTopic, nullptr);
345 private:
346 nsCOMPtr<nsIObserver> mObserver;
347 const char* mTopic;
349 private:
350 static uint64_t sObserverId;
351 static nsTHashMap<uint64_t, nsCOMPtr<nsIObserver>> sSavedObservers;
354 } // namespace widget
355 } // namespace mozilla
358 * The base class for all the widgets. It provides the interface for
359 * all basic and necessary functionality.
361 class nsIWidget : public nsISupports {
362 protected:
363 typedef mozilla::dom::BrowserChild BrowserChild;
365 public:
366 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
367 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
368 typedef mozilla::layers::FrameMetrics FrameMetrics;
369 typedef mozilla::layers::LayerManager LayerManager;
370 typedef mozilla::WindowRenderer WindowRenderer;
371 typedef mozilla::layers::LayersBackend LayersBackend;
372 typedef mozilla::layers::LayersId LayersId;
373 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
374 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
375 typedef mozilla::widget::IMEEnabled IMEEnabled;
376 typedef mozilla::widget::IMEMessage IMEMessage;
377 typedef mozilla::widget::IMENotification IMENotification;
378 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
379 typedef mozilla::widget::IMEState IMEState;
380 typedef mozilla::widget::InputContext InputContext;
381 typedef mozilla::widget::InputContextAction InputContextAction;
382 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
383 typedef mozilla::widget::SizeConstraints SizeConstraints;
384 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
385 typedef mozilla::widget::TextEventDispatcherListener
386 TextEventDispatcherListener;
387 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
388 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
389 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
390 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
391 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
392 typedef mozilla::ScreenIntPoint ScreenIntPoint;
393 typedef mozilla::ScreenIntMargin ScreenIntMargin;
394 typedef mozilla::ScreenIntSize ScreenIntSize;
395 typedef mozilla::ScreenPoint ScreenPoint;
396 typedef mozilla::CSSToScreenScale CSSToScreenScale;
397 typedef mozilla::DesktopIntRect DesktopIntRect;
398 typedef mozilla::DesktopPoint DesktopPoint;
399 typedef mozilla::DesktopRect DesktopRect;
400 typedef mozilla::DesktopSize DesktopSize;
401 typedef mozilla::CSSPoint CSSPoint;
402 typedef mozilla::CSSRect CSSRect;
404 enum class WindowButtonType {
405 Minimize,
406 Maximize,
407 Close,
408 Count,
411 // Used in UpdateThemeGeometries.
412 struct ThemeGeometry {
413 // The ThemeGeometryType value for the themed widget, see
414 // nsITheme::ThemeGeometryTypeForWidget.
415 nsITheme::ThemeGeometryType mType;
416 // The device-pixel rect within the window for the themed widget
417 LayoutDeviceIntRect mRect;
419 ThemeGeometry(nsITheme::ThemeGeometryType aType,
420 const LayoutDeviceIntRect& aRect)
421 : mType(aType), mRect(aRect) {}
424 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
426 nsIWidget()
427 : mLastChild(nullptr),
428 mPrevSibling(nullptr),
429 mOnDestroyCalled(false),
430 mWindowType(eWindowType_child),
431 mZIndex(0)
434 ClearNativeTouchSequence(nullptr);
438 * Create and initialize a widget.
440 * All the arguments can be null in which case a top level window
441 * with size 0 is created. The event callback function has to be
442 * provided only if the caller wants to deal with the events this
443 * widget receives. The event callback is basically a preprocess
444 * hook called synchronously. The return value determines whether
445 * the event goes to the default window procedure or it is hidden
446 * to the os. The assumption is that if the event handler returns
447 * false the widget does not see the event. The widget should not
448 * automatically clear the window to the background color. The
449 * calling code must handle paint messages and clear the background
450 * itself.
452 * In practice at least one of aParent and aNativeParent will be null. If
453 * both are null the widget isn't parented (e.g. context menus or
454 * independent top level windows).
456 * The dimensions given in aRect are specified in the parent's
457 * device coordinate system.
458 * This must not be called for parentless widgets such as top-level
459 * windows, which use the desktop pixel coordinate system; a separate
460 * method is provided for these.
462 * @param aParent parent nsIWidget
463 * @param aNativeParent native parent widget
464 * @param aRect the widget dimension
465 * @param aInitData data that is used for widget initialization
468 [[nodiscard]] virtual nsresult Create(
469 nsIWidget* aParent, nsNativeWidget aNativeParent,
470 const LayoutDeviceIntRect& aRect,
471 nsWidgetInitData* aInitData = nullptr) = 0;
474 * As above, but with aRect specified in DesktopPixel units (for top-level
475 * widgets).
476 * Default implementation just converts aRect to device pixels and calls
477 * through to device-pixel Create, but platforms may override this if the
478 * mapping is not straightforward or the native platform needs to use the
479 * desktop pixel values directly.
481 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
482 nsNativeWidget aNativeParent,
483 const DesktopIntRect& aRect,
484 nsWidgetInitData* aInitData = nullptr) {
485 LayoutDeviceIntRect devPixRect =
486 RoundedToInt(aRect * GetDesktopToDeviceScale());
487 return Create(aParent, aNativeParent, devPixRect, aInitData);
491 * Allocate, initialize, and return a widget that is a child of
492 * |this|. The returned widget (if nonnull) has gone through the
493 * equivalent of CreateInstance(widgetCID) + Create(...).
495 * |CreateChild()| lets widget backends decide whether to parent
496 * the new child widget to this, nonnatively parent it, or both.
497 * This interface exists to support the PuppetWidget backend,
498 * which is entirely non-native. All other params are the same as
499 * for |Create()|.
501 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
502 * |nsIWidget*| this, not its native widget (if it exists), when
503 * calling |Create()|. This is a timid hack around poorly
504 * understood code, and shouldn't be used in new code.
506 virtual already_AddRefed<nsIWidget> CreateChild(
507 const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData = nullptr,
508 bool aForceUseIWidgetParent = false) = 0;
511 * Attach to a top level widget.
513 * In cases where a top level chrome widget is being used as a content
514 * container, attach a secondary listener and update the device
515 * context. The primary widget listener will continue to be called for
516 * notifications relating to the top-level window, whereas other
517 * notifications such as painting and events will instead be called via
518 * the attached listener. SetAttachedWidgetListener should be used to
519 * assign the attached listener.
521 * aUseAttachedEvents if true, events are sent to the attached listener
522 * instead of the normal listener.
524 virtual void AttachViewToTopLevel(bool aUseAttachedEvents) = 0;
527 * Accessor functions to get and set the attached listener. Used by
528 * nsView in connection with AttachViewToTopLevel above.
530 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
531 virtual nsIWidgetListener* GetAttachedWidgetListener() const = 0;
532 virtual void SetPreviouslyAttachedWidgetListener(
533 nsIWidgetListener* aListener) = 0;
534 virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() = 0;
537 * Notifies the root widget of a non-blank paint.
539 virtual void DidGetNonBlankPaint() {}
542 * Accessor functions to get and set the listener which handles various
543 * actions for the widget.
545 //@{
546 virtual nsIWidgetListener* GetWidgetListener() const = 0;
547 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
548 //@}
551 * Close and destroy the internal native window.
552 * This method does not delete the widget.
555 virtual void Destroy() = 0;
558 * Destroyed() returns true if Destroy() has been called already.
559 * Otherwise, false.
561 bool Destroyed() const { return mOnDestroyCalled; }
564 * Reparent a widget
566 * Change the widget's parent. Null parents are allowed.
568 * @param aNewParent new parent
570 virtual void SetParent(nsIWidget* aNewParent) = 0;
573 * Return the parent Widget of this Widget or nullptr if this is a
574 * top level window
576 * @return the parent widget or nullptr if it does not have a parent
579 virtual nsIWidget* GetParent(void) = 0;
582 * Return the top level Widget of this Widget
584 * @return the top level widget
586 virtual nsIWidget* GetTopLevelWidget() = 0;
589 * Return the top (non-sheet) parent of this Widget if it's a sheet,
590 * or nullptr if this isn't a sheet (or some other error occurred).
591 * Sheets are only supported on some platforms (currently only macOS).
593 * @return the top (non-sheet) parent widget or nullptr
596 virtual nsIWidget* GetSheetWindowParent(void) = 0;
599 * Return the physical DPI of the screen containing the window ...
600 * the number of device pixels per inch.
602 virtual float GetDPI() = 0;
605 * Return the scaling factor between device pixels and the platform-
606 * dependent "desktop pixels" used to manage window positions on a
607 * potentially multi-screen, mixed-resolution desktop.
609 virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
612 * Return the scaling factor between device pixels and the platform-
613 * dependent "desktop pixels" by looking up the screen by the position
614 * of the widget.
616 virtual mozilla::DesktopToLayoutDeviceScale
617 GetDesktopToDeviceScaleByScreen() = 0;
620 * Return the default scale factor for the window. This is the
621 * default number of device pixels per CSS pixel to use. This should
622 * depend on OS/platform settings such as the Mac's "UI scale factor"
623 * or Windows' "font DPI". This will take into account Gecko preferences
624 * overriding the system setting.
626 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
629 * Return the first child of this widget. Will return null if
630 * there are no children.
632 nsIWidget* GetFirstChild() const { return mFirstChild; }
635 * Return the last child of this widget. Will return null if
636 * there are no children.
638 nsIWidget* GetLastChild() const { return mLastChild; }
641 * Return the next sibling of this widget
643 nsIWidget* GetNextSibling() const { return mNextSibling; }
646 * Set the next sibling of this widget
648 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
651 * Return the previous sibling of this widget
653 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
656 * Set the previous sibling of this widget
658 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
661 * Show or hide this widget
663 * @param aState true to show the Widget, false to hide it
666 virtual void Show(bool aState) = 0;
669 * Whether or not a widget must be recreated after being hidden to show
670 * again properly.
672 virtual bool NeedsRecreateToReshow() { return false; }
675 * Make the window modal.
677 virtual void SetModal(bool aModal) = 0;
680 * Make the non-modal window opened by modal window fake-modal, that will
681 * call SetFakeModal(false) on destroy on Cocoa.
683 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
686 * Are we app modal. Currently only implemented on Cocoa.
688 virtual bool IsRunningAppModal() { return false; }
691 * The maximum number of simultaneous touch contacts supported by the device.
692 * In the case of devices with multiple digitizers (e.g. multiple touch
693 * screens), the value will be the maximum of the set of maximum supported
694 * contacts by each individual digitizer.
696 virtual uint32_t GetMaxTouchPoints() const = 0;
699 * Returns whether the window is visible
702 virtual bool IsVisible() const = 0;
705 * Perform platform-dependent sanity check on a potential window position.
706 * This is guaranteed to work only for top-level windows.
708 * @param aAllowSlop: if true, allow the window to slop offscreen;
709 * the window should be partially visible. if false,
710 * force the entire window onscreen (or at least
711 * the upper-left corner, if it's too large).
712 * @param aX in: an x position expressed in screen coordinates.
713 * out: the x position constrained to fit on the screen(s).
714 * @param aY in: an y position expressed in screen coordinates.
715 * out: the y position constrained to fit on the screen(s).
718 virtual void ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) = 0;
721 * NOTE:
723 * For a top-level window widget, the "parent's coordinate system" is the
724 * "global" display pixel coordinate space, *not* device pixels (which
725 * may be inconsistent between multiple screens, at least in the Mac OS
726 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
727 * following Move and Resize widget APIs.
729 * The display-/device-pixel distinction becomes important for (at least)
730 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
731 * is set to other than 100%.
733 * The Move and Resize methods take floating-point parameters, rather than
734 * integer ones. This is important when manipulating top-level widgets,
735 * where the coordinate system may not be an integral multiple of the
736 * device-pixel space.
740 * Move this widget.
742 * Coordinates refer to the top-left of the widget. For toplevel windows
743 * with decorations, this is the top-left of the titlebar and frame .
745 * @param aX the new x position expressed in the parent's coordinate system
746 * @param aY the new y position expressed in the parent's coordinate system
749 virtual void Move(double aX, double aY) = 0;
752 * Reposition this widget so that the client area has the given offset.
754 * @param aOffset the new offset of the client area expressed as an
755 * offset from the origin of the client area of the parent
756 * widget (for root widgets and popup widgets it is in
757 * screen coordinates)
759 virtual void MoveClient(const DesktopPoint& aOffset) = 0;
762 * Resize this widget. Any size constraints set for the window by a
763 * previous call to SetSizeConstraints will be applied.
765 * @param aWidth the new width expressed in the parent's coordinate system
766 * @param aHeight the new height expressed in the parent's coordinate
767 * system
768 * @param aRepaint whether the widget should be repainted
770 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
773 * Lock the aspect ratio of a Window
775 * @param aShouldLock bool
778 virtual void LockAspectRatio(bool aShouldLock){};
781 * Move or resize this widget. Any size constraints set for the window by
782 * a previous call to SetSizeConstraints will be applied.
784 * @param aX the new x position expressed in the parent's coordinate
785 * system
786 * @param aY the new y position expressed in the parent's coordinate
787 * system
788 * @param aWidth the new width expressed in the parent's coordinate system
789 * @param aHeight the new height expressed in the parent's coordinate
790 * system
791 * @param aRepaint whether the widget should be repainted if the size
792 * changes
795 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
796 bool aRepaint) = 0;
798 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
799 return mozilla::Nothing();
803 * Resize the widget so that the inner client area has the given size.
805 * @param aSize the new size of the client area.
806 * @param aRepaint whether the widget should be repainted
808 virtual void ResizeClient(const DesktopSize& aSize, bool aRepaint) = 0;
811 * Resize and reposition the widget so tht inner client area has the given
812 * offset and size.
814 * @param aRect the new offset and size of the client area. The offset is
815 * expressed as an offset from the origin of the client area
816 * of the parent widget (for root widgets and popup widgets it
817 * is in screen coordinates).
818 * @param aRepaint whether the widget should be repainted
820 virtual void ResizeClient(const DesktopRect& aRect, bool aRepaint) = 0;
823 * Sets the widget's z-index.
825 virtual void SetZIndex(int32_t aZIndex) = 0;
828 * Gets the widget's z-index.
830 int32_t GetZIndex() { return mZIndex; }
833 * Position this widget just behind the given widget. (Used to
834 * control z-order for top-level widgets. Get/SetZIndex by contrast
835 * control z-order for child widgets of other widgets.)
836 * @param aPlacement top, bottom, or below a widget
837 * (if top or bottom, param aWidget is ignored)
838 * @param aWidget widget to place this widget behind
839 * (only if aPlacement is eZPlacementBelow).
840 * null is equivalent to aPlacement of eZPlacementTop
841 * @param aActivate true to activate the widget after placing it
843 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
844 nsIWidget* aWidget, bool aActivate) = 0;
847 * Minimize, maximize or normalize the window size.
848 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
850 virtual void SetSizeMode(nsSizeMode aMode) = 0;
852 virtual void GetWorkspaceID(nsAString& workspaceID) = 0;
854 virtual void MoveToWorkspace(const nsAString& workspaceID) = 0;
857 * Suppress animations that are applied to a window by OS.
859 virtual void SuppressAnimation(bool aSuppress) {}
862 * Return size mode (minimized, maximized, normalized).
863 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
865 virtual nsSizeMode SizeMode() = 0;
868 * Ask whether the window is tiled.
870 virtual bool IsTiled() const = 0;
873 * Ask wether the widget is fully occluded
875 virtual bool IsFullyOccluded() const = 0;
878 * Enable or disable this Widget
880 * @param aState true to enable the Widget, false to disable it.
882 virtual void Enable(bool aState) = 0;
885 * Ask whether the widget is enabled
887 virtual bool IsEnabled() const = 0;
890 * Whether we should request activation of this widget's toplevel window.
892 enum class Raise {
894 Yes,
898 * Request activation of this window or give focus to this widget.
900 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
903 * Get this widget's outside dimensions relative to its parent widget. For
904 * popup widgets the returned rect is in screen coordinates and not
905 * relative to its parent widget.
907 * @return the x, y, width and height of this widget.
909 virtual LayoutDeviceIntRect GetBounds() = 0;
912 * Get this widget's outside dimensions in device coordinates. This
913 * includes any title bar on the window.
915 * @return the x, y, width and height of this widget.
917 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
920 * Similar to GetScreenBounds except that this function will always
921 * get the size when the widget is in the nsSizeMode_Normal size mode
922 * even if the current size mode is not nsSizeMode_Normal.
923 * This method will fail if the size mode is not nsSizeMode_Normal and
924 * the platform doesn't have the ability.
925 * This method will always succeed if the current size mode is
926 * nsSizeMode_Normal.
928 * @param aRect On return it holds the x, y, width and height of
929 * this widget.
931 [[nodiscard]] virtual nsresult GetRestoredBounds(
932 LayoutDeviceIntRect& aRect) = 0;
935 * Get this widget's client area bounds, if the window has a 3D border
936 * appearance this returns the area inside the border. The position is the
937 * position of the client area relative to the client area of the parent
938 * widget (for root widgets and popup widgets it is in screen coordinates).
940 * @return the x, y, width and height of the client area of this widget.
942 virtual LayoutDeviceIntRect GetClientBounds() = 0;
945 * Sets the non-client area dimensions of the window. Pass -1 to restore
946 * the system default frame size for that border. Pass zero to remove
947 * a border, or pass a specific value adjust a border. Units are in
948 * pixels. (DPI dependent)
950 * Platform notes:
951 * Windows: shrinking top non-client height will remove application
952 * icon and window title text. Glass desktops will refuse to set
953 * dimensions between zero and size < system default.
955 virtual nsresult SetNonClientMargins(LayoutDeviceIntMargin& aMargins) = 0;
958 * Sets the region around the edges of the window that can be dragged to
959 * resize the window. All four sides of the window will get the same margin.
961 virtual void SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) = 0;
963 * Get the client offset from the window origin.
965 * @return the x and y of the offset.
967 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
970 * Equivalent to GetClientBounds but only returns the size.
972 virtual LayoutDeviceIntSize GetClientSize() {
973 // Depending on the backend, overloading this method may be useful if
974 // requesting the client offset is expensive.
975 return GetClientBounds().Size();
979 * Set the background color for this widget
981 * @param aColor the new background color
985 virtual void SetBackgroundColor(const nscolor& aColor) {}
988 * If a cursor type is currently cached locally for this widget, clear the
989 * cached cursor to force an update on the next SetCursor call.
992 virtual void ClearCachedCursor() = 0;
994 struct Cursor {
995 // The system cursor chosen by the page. This is used if there's no custom
996 // cursor, or if we fail to use the custom cursor in some way (if the image
997 // fails to load, for example).
998 nsCursor mDefaultCursor = eCursor_standard;
999 // May be null, to represent no custom cursor image.
1000 nsCOMPtr<imgIContainer> mContainer;
1001 uint32_t mHotspotX = 0;
1002 uint32_t mHotspotY = 0;
1003 mozilla::ImageResolution mResolution;
1005 bool IsCustom() const { return !!mContainer; }
1007 bool operator==(const Cursor& aOther) const {
1008 return mDefaultCursor == aOther.mDefaultCursor &&
1009 mContainer.get() == aOther.mContainer.get() &&
1010 mHotspotX == aOther.mHotspotX && mHotspotY == aOther.mHotspotY &&
1011 mResolution == aOther.mResolution;
1014 bool operator!=(const Cursor& aOther) const { return !(*this == aOther); }
1018 * Sets the cursor for this widget.
1020 virtual void SetCursor(const Cursor&) = 0;
1022 static nsIntSize CustomCursorSize(const Cursor&);
1025 * Get the window type of this widget.
1027 nsWindowType WindowType() { return mWindowType; }
1030 * Set the transparency mode of the top-level window containing this widget.
1031 * So, e.g., if you call this on the widget for an IFRAME, the top level
1032 * browser window containing the IFRAME actually gets set. Be careful.
1034 * This can fail if the platform doesn't support
1035 * transparency/glass. By default widgets are not
1036 * transparent. This will also fail if the toplevel window is not
1037 * a Mozilla window, e.g., if the widget is in an embedded
1038 * context.
1040 * After transparency/glass has been enabled, the initial alpha channel
1041 * value for all pixels is 1, i.e., opaque.
1042 * If the window is resized then the alpha channel values for
1043 * all pixels are reset to 1.
1044 * Pixel RGB color values are already premultiplied with alpha channel values.
1046 virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
1049 * Get the transparency mode of the top-level window that contains this
1050 * widget.
1052 virtual nsTransparencyMode GetTransparencyMode() = 0;
1055 * Set the shadow style of the window.
1057 * Ignored on child widgets and on non-Mac platforms.
1059 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) = 0;
1062 * Set the opacity of the window.
1063 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1065 * Ignored on child widgets and on non-Mac platforms.
1067 virtual void SetWindowOpacity(float aOpacity) {}
1070 * Set the transform of the window. Values are in device pixels,
1071 * the origin is the top left corner of the window.
1073 * Ignored on child widgets and on non-Mac platforms.
1075 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1078 * Set the preferred color-scheme for the widget.
1079 * Ignored on non-Mac platforms.
1081 virtual void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) {}
1084 * Set whether the window should ignore mouse events or not.
1086 * This is only used on popup windows.
1088 virtual void SetWindowMouseTransparent(bool aIsTransparent) {}
1091 * On macOS, this method shows or hides the pill button in the titlebar
1092 * that's used to collapse the toolbar.
1094 * Ignored on child widgets and on non-Mac platforms.
1096 virtual void SetShowsToolbarButton(bool aShow) = 0;
1099 * On macOS, this method determines whether we tell cocoa that the window
1100 * supports native full screen. If we do so, and another window is in
1101 * native full screen, this window will also appear in native full screen.
1103 * We generally only want to do this for primary application windows.
1105 * Ignored on child widgets and on non-Mac platforms.
1107 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) = 0;
1109 enum WindowAnimationType {
1110 eGenericWindowAnimation,
1111 eDocumentWindowAnimation
1115 * Sets the kind of top-level window animation this widget should have. On
1116 * macOS, this causes a particular kind of animation to be shown when the
1117 * window is first made visible.
1119 * Ignored on child widgets and on non-Mac platforms.
1121 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1124 * Specifies whether the window title should be drawn even if the window
1125 * contents extend into the titlebar. Ignored on windows that don't draw
1126 * in the titlebar. Only implemented on macOS.
1128 virtual void SetDrawsTitle(bool aDrawTitle) {}
1131 * Hide window chrome (borders, buttons) for this widget.
1134 virtual void HideWindowChrome(bool aShouldHide) = 0;
1136 enum FullscreenTransitionStage {
1137 eBeforeFullscreenToggle,
1138 eAfterFullscreenToggle
1142 * Prepares for fullscreen transition and returns whether the widget
1143 * supports fullscreen transition. If this method returns false,
1144 * PerformFullscreenTransition() must never be called. Otherwise,
1145 * caller should call that method twice with "before" and "after"
1146 * stages respectively in order. In the latter case, this method may
1147 * return some data via aData pointer. Caller must pass that data to
1148 * PerformFullscreenTransition() if any, and caller is responsible
1149 * for releasing that data.
1151 virtual bool PrepareForFullscreenTransition(nsISupports** aData) = 0;
1154 * Performs fullscreen transition. This method returns immediately,
1155 * and will post aCallback to the main thread when the transition
1156 * finishes.
1158 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
1159 uint16_t aDuration,
1160 nsISupports* aData,
1161 nsIRunnable* aCallback) = 0;
1164 * Perform any actions needed after the fullscreen transition has ended.
1166 virtual void CleanupFullscreenTransition() = 0;
1169 * Return the screen the widget is in, or null if we don't know.
1171 virtual already_AddRefed<nsIScreen> GetWidgetScreen() = 0;
1174 * Put the toplevel window into or out of fullscreen mode.
1176 * @return NS_OK if the widget is setup properly for fullscreen and
1177 * FullscreenChanged callback has been or will be called. If other
1178 * value is returned, the caller should continue the change itself.
1180 virtual nsresult MakeFullScreen(bool aFullScreen) = 0;
1183 * Same as MakeFullScreen, except that, on systems which natively
1184 * support fullscreen transition, calling this method explicitly
1185 * requests that behavior.
1186 * It is currently only supported on macOS 10.7+.
1188 virtual nsresult MakeFullScreenWithNativeTransition(bool aFullScreen) {
1189 return MakeFullScreen(aFullScreen);
1193 * Invalidate a specified rect for a widget so that it will be repainted
1194 * later.
1196 virtual void Invalidate(const LayoutDeviceIntRect& aRect) = 0;
1198 enum LayerManagerPersistence {
1199 LAYER_MANAGER_CURRENT = 0,
1200 LAYER_MANAGER_PERSISTENT
1204 * Return the widget's LayerManager. The layer tree for that
1205 * LayerManager is what gets rendered to the widget.
1207 virtual WindowRenderer* GetWindowRenderer() = 0;
1210 * Called before each layer manager transaction to allow any preparation
1211 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1213 * Always called on the main thread.
1215 virtual void PrepareWindowEffects() = 0;
1218 * Called on the main thread at the end of WebRender display list building.
1220 virtual void AddWindowOverlayWebRenderCommands(
1221 mozilla::layers::WebRenderBridgeChild* aWrBridge,
1222 mozilla::wr::DisplayListBuilder& aBuilder,
1223 mozilla::wr::IpcResourceUpdateQueue& aResources) {}
1226 * Called when Gecko knows which themed widgets exist in this window.
1227 * The passed array contains an entry for every themed widget of the right
1228 * type (currently only StyleAppearance::Toolbar) within the window, except
1229 * for themed widgets which are transformed or have effects applied to them
1230 * (e.g. CSS opacity or filters).
1231 * This could sometimes be called during display list construction
1232 * outside of painting.
1233 * If called during painting, it will be called before we actually
1234 * paint anything.
1236 virtual void UpdateThemeGeometries(
1237 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1240 * Informs the widget about the region of the window that is opaque.
1242 * @param aOpaqueRegion the region of the window that is opaque.
1244 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1247 * Informs the widget about the region of the window that is draggable.
1249 virtual void UpdateWindowDraggingRegion(
1250 const LayoutDeviceIntRegion& aRegion) {}
1253 * Tells the widget whether the given input block results in a swipe.
1254 * Should be called in response to a WidgetWheelEvent that has
1255 * mFlags.mCanTriggerSwipe set on it.
1257 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1260 * Internal methods
1263 //@{
1264 virtual void AddChild(nsIWidget* aChild) = 0;
1265 virtual void RemoveChild(nsIWidget* aChild) = 0;
1266 virtual void* GetNativeData(uint32_t aDataType) = 0;
1267 virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal) = 0;
1268 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1270 //@}
1273 * Set the widget's title.
1274 * Must be called after Create.
1276 * @param aTitle string displayed as the title of the widget
1278 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1281 * Set the widget's icon.
1282 * Must be called after Create.
1284 * @param aIconSpec string specifying the icon to use; convention is to
1285 * pass a resource: URL from which a platform-dependent
1286 * resource file name will be constructed
1288 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1291 * Return this widget's origin in screen coordinates.
1293 * @return screen coordinates stored in the x,y members
1295 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1298 * The same as WidgetToScreenOffset(), except in the case of
1299 * PuppetWidget where this method omits the chrome offset.
1301 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1302 return WidgetToScreenOffset();
1306 * For a PuppetWidget, returns the transform from the coordinate
1307 * space of the PuppetWidget to the coordinate space of the
1308 * top-level native widget.
1310 * Identity transform in other cases.
1312 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1313 WidgetToTopLevelWidgetTransform() {
1314 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1318 * Given the specified client size, return the corresponding window size,
1319 * which includes the area for the borders and titlebar. This method
1320 * should work even when the window is not yet visible.
1322 virtual LayoutDeviceIntSize ClientToWindowSize(
1323 const LayoutDeviceIntSize& aClientSize) = 0;
1326 * Dispatches an event to the widget
1328 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1329 nsEventStatus& aStatus) = 0;
1332 * Dispatches an event to APZ only.
1333 * No-op in the child process.
1335 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1338 * Dispatch a gecko event for this widget.
1339 * Returns true if it's consumed. Otherwise, false.
1341 virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event) = 0;
1343 // A structure that groups the statuses from APZ dispatch and content
1344 // dispatch.
1345 struct ContentAndAPZEventStatus {
1346 // Either of these may not be set if the event was not dispatched
1347 // to APZ or to content.
1348 nsEventStatus mApzStatus = nsEventStatus_eIgnore;
1349 nsEventStatus mContentStatus = nsEventStatus_eIgnore;
1353 * Dispatches an event that must be handled by APZ first, when APZ is
1354 * enabled. If invoked in the child process, it is forwarded to the
1355 * parent process synchronously.
1357 virtual ContentAndAPZEventStatus DispatchInputEvent(
1358 mozilla::WidgetInputEvent* aEvent) = 0;
1361 * Confirm an APZ-aware event target. This should be used when APZ will
1362 * not need a layers update to process the event.
1364 virtual void SetConfirmedTargetAPZC(
1365 uint64_t aInputBlockId,
1366 const nsTArray<ScrollableLayerGuid>& aTargets) const = 0;
1369 * Returns true if APZ is in use, false otherwise.
1371 virtual bool AsyncPanZoomEnabled() const = 0;
1375 virtual void SwipeFinished() = 0;
1378 * Enables the dropping of files to a widget.
1380 virtual void EnableDragDrop(bool aEnable) = 0;
1381 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1384 * Enables/Disables system mouse capture.
1385 * @param aCapture true enables mouse capture, false disables mouse capture
1388 virtual void CaptureMouse(bool aCapture) = 0;
1391 * Classify the window for the window manager. Mostly for X11.
1393 virtual void SetWindowClass(const nsAString& xulWinType) = 0;
1396 * Enables/Disables system capture of any and all events that would cause a
1397 * popup to be rolled up. aListener should be set to a non-null value for
1398 * any popups that are not managed by the popup manager.
1399 * @param aDoCapture true enables capture, false disables capture
1402 virtual void CaptureRollupEvents(nsIRollupListener* aListener,
1403 bool aDoCapture) = 0;
1406 * Bring this window to the user's attention. This is intended to be a more
1407 * gentle notification than popping the window to the top or putting up an
1408 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1409 * the Mac. The notification should be suppressed if the window is already
1410 * in the foreground and should be dismissed when the user brings this window
1411 * to the foreground.
1412 * @param aCycleCount Maximum number of times to animate the window per system
1413 * conventions. If set to -1, cycles indefinitely until
1414 * window is brought into the foreground.
1416 [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) = 0;
1419 * Ask whether there user input events pending. All input events are
1420 * included, including those not targeted at this nsIwidget instance.
1422 virtual bool HasPendingInputEvent() = 0;
1425 * If set to true, the window will draw its contents into the titlebar
1426 * instead of below it.
1428 * Ignored on any platform that does not support it. Ignored by widgets that
1429 * do not represent windows.
1430 * May result in a resize event, so should only be called from places where
1431 * reflow and painting is allowed.
1433 * @param aState Whether drawing into the titlebar should be activated.
1435 virtual void SetDrawsInTitlebar(bool aState) = 0;
1438 * Determine whether the widget shows a resize widget. If it does,
1439 * aResizerRect returns the resizer's rect.
1441 * Returns false on any platform that does not support it.
1443 * @param aResizerRect The resizer's rect in device pixels.
1444 * @return Whether a resize widget is shown.
1446 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1449 * Begin a window resizing drag, based on the event passed in.
1451 [[nodiscard]] virtual nsresult BeginResizeDrag(
1452 mozilla::WidgetGUIEvent* aEvent, int32_t aHorizontal,
1453 int32_t aVertical) = 0;
1455 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1456 // EnumSet class.
1457 enum Modifiers : uint32_t {
1458 NO_MODIFIERS = 0x00000000,
1459 CAPS_LOCK = 0x00000001, // when CapsLock is active
1460 NUM_LOCK = 0x00000002, // when NumLock is active
1461 SHIFT_L = 0x00000100,
1462 SHIFT_R = 0x00000200,
1463 CTRL_L = 0x00000400,
1464 CTRL_R = 0x00000800,
1465 ALT_L = 0x00001000, // includes Option
1466 ALT_R = 0x00002000,
1467 COMMAND_L = 0x00004000,
1468 COMMAND_R = 0x00008000,
1469 HELP = 0x00010000,
1470 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1471 // AltRight key behavior of keyboard
1472 // layouts which maps AltGr to AltRight
1473 // key.
1474 FUNCTION = 0x00100000,
1475 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1478 * Utility method intended for testing. Dispatches native key events
1479 * to this widget to simulate the press and release of a key.
1480 * @param aNativeKeyboardLayout a *platform-specific* constant.
1481 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1482 * On Windows, it is converted to a hex string and passed to
1483 * LoadKeyboardLayout, see
1484 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1485 * @param aNativeKeyCode a *platform-specific* keycode.
1486 * On Windows, this is the virtual key code.
1487 * @param aModifiers some combination of the above 'Modifiers' flags;
1488 * not all flags will apply to all platforms. Mac ignores the _R
1489 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1490 * FUNCTION.
1491 * @param aCharacters characters that the OS would decide to generate
1492 * from the event. On Windows, this is the charCode passed by
1493 * WM_CHAR.
1494 * @param aUnmodifiedCharacters characters that the OS would decide
1495 * to generate from the event if modifier keys (other than shift)
1496 * were assumed inactive. Needed on Mac, ignored on Windows.
1497 * @param aObserver the observer that will get notified once the events
1498 * have been dispatched.
1499 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1500 * layout is not supported and the event was not fired
1502 virtual nsresult SynthesizeNativeKeyEvent(
1503 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1504 uint32_t aModifierFlags, const nsAString& aCharacters,
1505 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1508 * Utility method intended for testing. Dispatches native mouse events
1509 * may even move the mouse cursor. On Mac the events are guaranteed to
1510 * be sent to the window containing this widget, but on Windows they'll go
1511 * to whatever's topmost on the screen at that position, so for
1512 * cross-platform testing ensure that your window is at the top of the
1513 * z-order.
1514 * @param aPoint screen location of the mouse, in device
1515 * pixels, with origin at the top left
1516 * @param aNativeMessage abstract native message.
1517 * @param aButton Mouse button defined by DOM UI Events.
1518 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1519 * FYI: On Windows, Android and Headless widget on all
1520 * platroms, this hasn't been handled yet.
1521 * @param aObserver the observer that will get notified once the events
1522 * have been dispatched.
1524 enum class NativeMouseMessage : uint32_t {
1525 ButtonDown, // button down
1526 ButtonUp, // button up
1527 Move, // mouse cursor move
1528 EnterWindow, // mouse cursor comes into a window
1529 LeaveWindow, // mouse cursor leaves from a window
1531 virtual nsresult SynthesizeNativeMouseEvent(
1532 LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
1533 mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
1534 nsIObserver* aObserver) = 0;
1537 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1538 * message. aPoint is location in device pixels to which the mouse pointer
1539 * moves to.
1540 * @param aObserver the observer that will get notified once the events
1541 * have been dispatched.
1543 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1544 nsIObserver* aObserver) = 0;
1547 * Utility method intended for testing. Dispatching native mouse scroll
1548 * events may move the mouse cursor.
1550 * @param aPoint Mouse cursor position in screen coordinates.
1551 * In device pixels, the origin at the top left of
1552 * the primary display.
1553 * @param aNativeMessage Platform native message.
1554 * @param aDeltaX The delta value for X direction. If the native
1555 * message doesn't indicate X direction scrolling,
1556 * this may be ignored.
1557 * @param aDeltaY The delta value for Y direction. If the native
1558 * message doesn't indicate Y direction scrolling,
1559 * this may be ignored.
1560 * @param aDeltaZ The delta value for Z direction. If the native
1561 * message doesn't indicate Z direction scrolling,
1562 * this may be ignored.
1563 * @param aModifierFlags Must be values of Modifiers, or zero.
1564 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1565 * document.
1566 * @param aObserver The observer that will get notified once the
1567 * events have been dispatched.
1569 virtual nsresult SynthesizeNativeMouseScrollEvent(
1570 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1571 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1572 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1575 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1576 * touch states in nsIDOMWindowUtils.idl.
1578 enum TouchPointerState {
1579 // The pointer is in a hover state above the digitizer
1580 TOUCH_HOVER = (1 << 0),
1581 // The pointer is in contact with the digitizer
1582 TOUCH_CONTACT = (1 << 1),
1583 // The pointer has been removed from the digitizer detection area
1584 TOUCH_REMOVE = (1 << 2),
1585 // The pointer has been canceled. Will cancel any pending os level
1586 // gestures that would triggered as a result of completion of the
1587 // input sequence. This may not cancel moz platform related events
1588 // that might get tirggered by input already delivered.
1589 TOUCH_CANCEL = (1 << 3),
1591 // ALL_BITS used for validity checking during IPC serialization
1592 ALL_BITS = (1 << 4) - 1
1595 * TouchpadGesturePhase states for SynthesizeNativeTouchPadPinch and
1596 * SynthesizeNativeTouchpadPan. Match phase states in nsIDOMWindowUtils.idl.
1598 enum TouchpadGesturePhase {
1599 PHASE_BEGIN = 0,
1600 PHASE_UPDATE = 1,
1601 PHASE_END = 2
1604 * Create a new or update an existing touch pointer on the digitizer.
1605 * To trigger os level gestures, individual touch points should
1606 * transition through a complete set of touch states which should be
1607 * sent as individual messages.
1609 * @param aPointerId The touch point id to create or update.
1610 * @param aPointerState one or more of the touch states listed above
1611 * @param aPoint coords of this event
1612 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1613 * @param aOrientation 0 -> 359 degree value indicating the
1614 * orientation of the pointer. Use 90 for normal taps.
1615 * @param aObserver The observer that will get notified once the events
1616 * have been dispatched.
1618 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1619 TouchPointerState aPointerState,
1620 LayoutDeviceIntPoint aPoint,
1621 double aPointerPressure,
1622 uint32_t aPointerOrientation,
1623 nsIObserver* aObserver) = 0;
1625 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1627 virtual nsresult SynthesizeNativeTouchPadPinch(
1628 TouchpadGesturePhase aEventPhase, float aScale,
1629 LayoutDeviceIntPoint aPoint, int32_t aModifierFlags) = 0;
1632 * Helper for simulating a simple tap event with one touch point. When
1633 * aLongTap is true, simulates a native long tap with a duration equal to
1634 * ui.click_hold_context_menus.delay. This pref is compatible with the
1635 * apzc long tap duration. Defaults to 1.5 seconds.
1636 * @param aObserver The observer that will get notified once the events
1637 * have been dispatched.
1639 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1640 bool aLongTap,
1641 nsIObserver* aObserver);
1643 virtual nsresult SynthesizeNativePenInput(uint32_t aPointerId,
1644 TouchPointerState aPointerState,
1645 LayoutDeviceIntPoint aPoint,
1646 double aPressure,
1647 uint32_t aRotation, int32_t aTiltX,
1648 int32_t aTiltY, int32_t aButton,
1649 nsIObserver* aObserver) = 0;
1652 * Cancels all active simulated touch input points and pending long taps.
1653 * Native widgets should track existing points such that they can clear the
1654 * digitizer state when this call is made.
1655 * @param aObserver The observer that will get notified once the touch
1656 * sequence has been cleared.
1658 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1661 * Send a native event as if the user double tapped the touchpad with two
1662 * fingers.
1664 virtual nsresult SynthesizeNativeTouchpadDoubleTap(
1665 LayoutDeviceIntPoint aPoint, uint32_t aModifierFlags) = 0;
1668 * See nsIDOMWindowUtils.sendNativeTouchpadPan().
1670 virtual nsresult SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase,
1671 LayoutDeviceIntPoint aPoint,
1672 double aDeltaX, double aDeltaY,
1673 int32_t aModifierFlags) = 0;
1675 virtual void StartAsyncScrollbarDrag(
1676 const AsyncDragMetrics& aDragMetrics) = 0;
1679 * Notify APZ to start autoscrolling.
1680 * @param aAnchorLocation the location of the autoscroll anchor
1681 * @param aGuid identifies the scroll frame to be autoscrolled
1682 * @return true if APZ has been successfully notified
1684 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1685 const ScrollableLayerGuid& aGuid) = 0;
1688 * Notify APZ to stop autoscrolling.
1689 * @param aGuid identifies the scroll frame which is being autoscrolled.
1691 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid& aGuid) = 0;
1693 virtual LayersId GetRootLayerTreeId() = 0;
1695 // If this widget supports out-of-process compositing, it can override
1696 // this method to provide additional information to the compositor.
1697 virtual void GetCompositorWidgetInitData(
1698 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1701 * Setter/Getter of the system font setting for testing.
1703 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1704 return NS_ERROR_NOT_IMPLEMENTED;
1706 virtual nsresult GetSystemFont(nsCString& aFontName) {
1707 return NS_ERROR_NOT_IMPLEMENTED;
1711 * Wayland specific routines.
1713 virtual LayoutDeviceIntSize GetMoveToRectPopupSize() const {
1714 NS_WARNING("GetLayoutPopupRect implemented only for wayland");
1715 return LayoutDeviceIntSize();
1719 * If this widget uses native pointer lock instead of warp-to-center
1720 * (currently only GTK on Wayland), these methods provide access to that
1721 * functionality.
1723 virtual void SetNativePointerLockCenter(
1724 const LayoutDeviceIntPoint& aLockCenter) {}
1725 virtual void LockNativePointer() {}
1726 virtual void UnlockNativePointer() {}
1729 * Get safe area insets except to cutout.
1730 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1732 virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const {
1733 return mozilla::ScreenIntMargin();
1736 private:
1737 class LongTapInfo {
1738 public:
1739 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1740 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1741 : mPointerId(aPointerId),
1742 mPosition(aPoint),
1743 mDuration(aDuration),
1744 mObserver(aObserver),
1745 mStamp(mozilla::TimeStamp::Now()) {}
1747 int32_t mPointerId;
1748 LayoutDeviceIntPoint mPosition;
1749 mozilla::TimeDuration mDuration;
1750 nsCOMPtr<nsIObserver> mObserver;
1751 mozilla::TimeStamp mStamp;
1754 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1756 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1757 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1759 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1760 nsCOMPtr<nsITimer> mLongTapTimer;
1761 static int32_t sPointerIdCounter;
1763 public:
1765 * If key events have not been handled by content or XBL handlers, they can
1766 * be offered to the system (for custom application shortcuts set in system
1767 * preferences, for example).
1769 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1772 * Activates a native menu item at the position specified by the index
1773 * string. The index string is a string of positive integers separated
1774 * by the "|" (pipe) character. The last integer in the string represents
1775 * the item index in a submenu located using the integers preceding it.
1777 * Example: 1|0|4
1778 * In this string, the first integer represents the top-level submenu
1779 * in the native menu bar. Since the integer is 1, it is the second submeu
1780 * in the native menu bar. Within that, the first item (index 0) is a
1781 * submenu, and we want to activate the 5th item within that submenu.
1783 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1786 * This is used for native menu system testing.
1788 * Updates a native menu at the position specified by the index string.
1789 * The index string is a string of positive integers separated by the "|"
1790 * (pipe) character.
1792 * Example: 1|0|4
1793 * In this string, the first integer represents the top-level submenu
1794 * in the native menu bar. Since the integer is 1, it is the second submeu
1795 * in the native menu bar. Within that, the first item (index 0) is a
1796 * submenu, and we want to update submenu at index 4 within that submenu.
1798 * If this is called with an empty string it forces a full reload of the
1799 * menu system.
1801 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1804 * This is used for testing macOS service menu code.
1806 * @param aResult - the current text selection. Is empty if no selection.
1807 * @return nsresult - whether or not aResult was assigned the selected text.
1809 [[nodiscard]] virtual nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1810 return NS_ERROR_NOT_IMPLEMENTED;
1814 * Notify IME of the specified notification.
1816 * @return If the notification is mouse button event and it's consumed by
1817 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1819 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1822 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1823 * of the widget, in the event that we were not able to observe and respond to
1824 * the initial focus event. This is necessary for the early skeleton UI
1825 * window, which is displayed and receives its initial focus event before we
1826 * can actually respond to it.
1828 virtual void MaybeDispatchInitialFocusEvent() {}
1831 * Notifies the input context changes.
1833 virtual void SetInputContext(const InputContext& aContext,
1834 const InputContextAction& aAction) = 0;
1837 * Get current input context.
1839 virtual InputContext GetInputContext() = 0;
1842 * Get native IME context. This is different from GetNativeData() with
1843 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1844 * process.
1846 virtual NativeIMEContext GetNativeIMEContext() = 0;
1849 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1850 * native (OS-level) event for it. This method allows tests to simulate
1851 * keystrokes that trigger native key bindings (which require a native
1852 * event).
1854 [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
1855 mozilla::WidgetKeyboardEvent& aEvent) = 0;
1858 * Retrieve edit commands when the key combination of aEvent is used
1859 * in platform native applications.
1861 MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
1862 mozilla::NativeKeyBindingsType aType,
1863 const mozilla::WidgetKeyboardEvent& aEvent,
1864 nsTArray<mozilla::CommandInt>& aCommands);
1867 * Retrieves a reference to notification requests of IME. Note that the
1868 * reference is valid while the nsIWidget instance is alive. So, if you
1869 * need to store the reference for a long time, you need to grab the widget
1870 * instance too.
1872 const IMENotificationRequests& IMENotificationRequestsRef();
1875 * Call this method when a dialog is opened which has a default button.
1876 * The button's rectangle should be supplied in aButtonRect.
1878 [[nodiscard]] virtual nsresult OnDefaultButtonLoaded(
1879 const LayoutDeviceIntRect& aButtonRect) = 0;
1882 * Return true if this process shouldn't use platform widgets, and
1883 * so should use PuppetWidgets instead. If this returns true, the
1884 * result of creating and using a platform widget is undefined,
1885 * and likely to end in crashes or other buggy behavior.
1887 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1889 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1891 static already_AddRefed<nsIWidget> CreateChildWindow();
1894 * Allocate and return a "puppet widget" that doesn't directly
1895 * correlate to a platform widget; platform events and data must
1896 * be fed to it. Currently used in content processes. NULL is
1897 * returned if puppet widgets aren't supported in this build
1898 * config, on this platform, or for this process type.
1900 * This function is called "Create" to match CreateInstance().
1901 * The returned widget must still be nsIWidget::Create()d.
1903 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1904 BrowserChild* aBrowserChild);
1906 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1909 * Reparent this widget's native widget.
1910 * @param aNewParent the native widget of aNewParent is the new native
1911 * parent widget
1913 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1916 * Return true if widget has it's own GL context
1918 virtual bool HasGLContext() { return false; }
1921 * Returns true to indicate that this widget paints an opaque background
1922 * that we want to be visible under the page, so layout should not force
1923 * a default background.
1925 virtual bool WidgetPaintsBackground() { return false; }
1927 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1930 * Get the natural bounds of this widget. This method is only
1931 * meaningful for widgets for which Gecko implements screen
1932 * rotation natively. When this is the case, GetBounds() returns
1933 * the widget bounds taking rotation into account, and
1934 * GetNaturalBounds() returns the bounds *not* taking rotation
1935 * into account.
1937 * No code outside of the composition pipeline should know or care
1938 * about this. If you're not an agent of the compositor, you
1939 * probably shouldn't call this method.
1941 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1944 * Set size constraints on the window size such that it is never less than
1945 * the specified minimum size and never larger than the specified maximum
1946 * size. The size constraints are sizes of the outer rectangle including
1947 * the window frame and title bar. Use 0 for an unconstrained minimum size
1948 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1949 * does not necessarily change the size of a window to conform to this size,
1950 * thus Resize should be called afterwards.
1952 * @param aConstraints: the size constraints in device pixels
1954 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1957 * Return the size constraints currently observed by the widget.
1959 * @return the constraints in device pixels
1961 virtual const SizeConstraints GetSizeConstraints() = 0;
1964 * Apply the current size constraints to the given size.
1966 * @param aWidth width to constrain
1967 * @param aHeight height to constrain
1969 virtual void ConstrainSize(int32_t* aWidth, int32_t* aHeight) = 0;
1972 * If this is owned by a BrowserChild, return that. Otherwise return
1973 * null.
1975 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
1978 * If this isn't directly compositing to its window surface,
1979 * return the compositor which is doing that on our behalf.
1981 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
1984 * Clear WebRender resources
1986 virtual void ClearCachedWebrenderResources() {}
1989 * If this widget has its own vsync source, return it, otherwise return
1990 * nullptr. An example of such local source would be Wayland frame callbacks.
1992 virtual RefPtr<mozilla::gfx::VsyncSource> GetVsyncSource() { return nullptr; }
1995 * Returns true if the widget requires synchronous repaints on resize,
1996 * false otherwise.
1998 virtual bool SynchronouslyRepaintOnResize() { return true; }
2001 * Some platforms (only cocoa right now) round widget coordinates to the
2002 * nearest even pixels (see bug 892994), this function allows us to
2003 * determine how widget coordinates will be rounded.
2005 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2007 virtual void UpdateZoomConstraints(
2008 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2009 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2012 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2013 * widget. Note that this never returns nullptr.
2015 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2018 * GetNativeTextEventDispatcherListener() returns a
2019 * TextEventDispatcherListener instance which is used when the widget
2020 * instance handles native IME and/or keyboard events.
2022 virtual TextEventDispatcherListener*
2023 GetNativeTextEventDispatcherListener() = 0;
2025 virtual void ZoomToRect(const uint32_t& aPresShellId,
2026 const ScrollableLayerGuid::ViewID& aViewId,
2027 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2030 * LookUpDictionary shows the dictionary for the word around current point.
2032 * @param aText the word to look up dictiorary.
2033 * @param aFontRangeArray text decoration of aText
2034 * @param aIsVertical true if the word is vertical layout
2035 * @param aPoint top-left point of aText
2037 virtual void LookUpDictionary(
2038 const nsAString& aText,
2039 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2040 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2042 virtual void RequestFxrOutput() {
2043 MOZ_ASSERT(false, "This function should only execute in Windows");
2046 #if defined(MOZ_WIDGET_ANDROID)
2048 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2049 * thread.
2051 * @param aMessage message being sent to Android UI thread.
2053 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2056 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2057 * thread
2059 * @param aScrollOffset page scroll offset value in screen pixels.
2060 * @param aZoom current page zoom.
2062 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2063 const CSSToScreenScale& aZoom) = 0;
2066 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2067 * for android robocop tests.
2069 * @param aMem shared memory containing the frame buffer pixels.
2070 * @param aSize size of the buffer in screen pixels.
2072 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2073 const ScreenIntSize& aSize,
2074 bool aNeedsYFlip) = 0;
2076 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2077 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2078 return 0;
2080 #endif
2082 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2085 * Like GetDefaultScale, but taking into account only the system settings
2086 * and ignoring Gecko preferences.
2088 virtual double GetDefaultScaleInternal() { return 1.0; }
2091 * Layout uses this to alert the widget to the client rect representing
2092 * the window maximize button. An empty rect indicates there is no
2093 * maximize button (for example, in fullscreen). This is only implemented
2094 * on Windows.
2096 virtual void SetWindowButtonRect(WindowButtonType aButtonType,
2097 const LayoutDeviceIntRect& aClientRect) {}
2099 protected:
2100 // keep the list of children. We also keep track of our siblings.
2101 // The ownership model is as follows: parent holds a strong ref to
2102 // the first element of the list, and each element holds a strong
2103 // ref to the next element in the list. The prevsibling and
2104 // lastchild pointers are weak, which is fine as long as they are
2105 // maintained properly.
2106 nsCOMPtr<nsIWidget> mFirstChild;
2107 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2108 nsCOMPtr<nsIWidget> mNextSibling;
2109 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2110 // When Destroy() is called, the sub class should set this true.
2111 bool mOnDestroyCalled;
2112 nsWindowType mWindowType;
2113 int32_t mZIndex;
2116 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2118 #endif // nsIWidget_h__