Bug 1867925 - Mark some storage-access-api tests as intermittent after wpt-sync....
[gecko.git] / widget / nsIWidget.h
blob329815b5bb0284fb3c9581d031133396728cf793
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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 nsIWidget_h__
8 #define nsIWidget_h__
10 #include <cmath>
11 #include <cstdint>
12 #include "imgIContainer.h"
13 #include "ErrorList.h"
14 #include "Units.h"
15 #include "mozilla/AlreadyAddRefed.h"
16 #include "mozilla/Assertions.h"
17 #include "mozilla/Attributes.h"
18 #include "mozilla/EventForwards.h"
19 #include "mozilla/Maybe.h"
20 #include "mozilla/RefPtr.h"
21 #include "mozilla/TimeStamp.h"
22 #include "mozilla/UniquePtr.h"
23 #include "mozilla/gfx/Matrix.h"
24 #include "mozilla/gfx/Rect.h"
25 #include "mozilla/layers/LayersTypes.h"
26 #include "mozilla/layers/ScrollableLayerGuid.h"
27 #include "mozilla/layers/ZoomConstraints.h"
28 #include "mozilla/image/Resolution.h"
29 #include "mozilla/widget/IMEData.h"
30 #include "nsCOMPtr.h"
31 #include "nsColor.h"
32 #include "nsDebug.h"
33 #include "nsID.h"
34 #include "nsIObserver.h"
35 #include "nsISupports.h"
36 #include "nsITheme.h"
37 #include "nsITimer.h"
38 #include "nsIWidgetListener.h"
39 #include "nsRect.h"
40 #include "nsSize.h"
41 #include "nsStringFwd.h"
42 #include "nsTArray.h"
43 #include "nsTHashMap.h"
44 #include "mozilla/widget/InitData.h"
45 #include "nsXULAppAPI.h"
47 // forward declarations
48 class nsIBidiKeyboard;
49 class nsIRollupListener;
50 class nsIContent;
51 class ViewWrapper;
52 class nsIRunnable;
54 namespace mozilla {
55 enum class NativeKeyBindingsType : uint8_t;
56 class VsyncDispatcher;
57 class WidgetGUIEvent;
58 class WidgetInputEvent;
59 class WidgetKeyboardEvent;
60 struct FontRange;
62 enum class StyleWindowShadow : uint8_t;
63 enum class ColorScheme : uint8_t;
64 enum class WindowButtonType : uint8_t;
66 #if defined(MOZ_WIDGET_ANDROID)
67 namespace ipc {
68 class Shmem;
70 #endif // defined(MOZ_WIDGET_ANDROID)
71 namespace dom {
72 class BrowserChild;
73 enum class CallerType : uint32_t;
74 } // namespace dom
75 class WindowRenderer;
76 namespace layers {
77 class AsyncDragMetrics;
78 class Compositor;
79 class CompositorBridgeChild;
80 struct FrameMetrics;
81 class LayerManager;
82 class WebRenderBridgeChild;
83 } // namespace layers
84 namespace widget {
85 class TextEventDispatcher;
86 class TextEventDispatcherListener;
87 class CompositorWidget;
88 class CompositorWidgetInitData;
89 class Screen;
90 } // namespace widget
91 namespace wr {
92 class DisplayListBuilder;
93 class IpcResourceUpdateQueue;
94 enum class RenderRoot : uint8_t;
95 } // namespace wr
96 } // namespace mozilla
98 /**
99 * Callback function that processes events.
101 * The argument is actually a subtype (subclass) of WidgetEvent which carries
102 * platform specific information about the event. Platform specific code
103 * knows how to deal with it.
105 * The return value determines whether or not the default action should take
106 * place.
108 typedef nsEventStatus (*EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
110 // Hide the native window system's real window type so as to avoid
111 // including native window system types and APIs. This is necessary
112 // to ensure cross-platform code.
113 typedef void* nsNativeWidget;
116 * Values for the GetNativeData function
118 #define NS_NATIVE_WINDOW 0
119 #define NS_NATIVE_GRAPHIC 1
120 #define NS_NATIVE_WIDGET 3
121 #define NS_NATIVE_REGION 5
122 #define NS_NATIVE_OFFSETX 6
123 #define NS_NATIVE_OFFSETY 7
124 #define NS_NATIVE_SCREEN 9
125 // The toplevel GtkWidget containing this nsIWidget:
126 #define NS_NATIVE_SHELLWIDGET 10
127 #define NS_NATIVE_OPENGL_CONTEXT 12
128 // This is available only with GetNativeData() in parent process. Anybody
129 // shouldn't access this pointer as a valid pointer since the result may be
130 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
131 // an identifier of distinguishing a text composition is caused by which native
132 // IME context. Note that the result is only valid in the process. So,
133 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
134 #define NS_RAW_NATIVE_IME_CONTEXT 14
135 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
136 #ifdef XP_WIN
137 # define NS_NATIVE_TSF_THREAD_MGR 100
138 # define NS_NATIVE_TSF_CATEGORY_MGR 101
139 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
140 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
141 #endif
142 #if defined(MOZ_WIDGET_GTK)
143 # define NS_NATIVE_EGL_WINDOW 106
144 #endif
145 #ifdef MOZ_WIDGET_ANDROID
146 # define NS_JAVA_SURFACE 100
147 #endif
149 #define MOZ_WIDGET_MAX_SIZE 16384
150 #define MOZ_WIDGET_INVALID_SCALE 0.0
152 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
153 #define NS_IWIDGET_IID \
155 0x06396bf6, 0x2dd8, 0x45e5, { \
156 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
161 * Cursor types.
164 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
165 eCursor_standard,
166 ///(system is busy, usually rendered as a hourglass or watch)
167 eCursor_wait,
168 ///(Selecting something, usually rendered as an IBeam)
169 eCursor_select,
170 ///(can hyper-link, usually rendered as a human hand)
171 eCursor_hyperlink,
172 ///(north/south/west/east edge sizing)
173 eCursor_n_resize,
174 eCursor_s_resize,
175 eCursor_w_resize,
176 eCursor_e_resize,
177 ///(corner sizing)
178 eCursor_nw_resize,
179 eCursor_se_resize,
180 eCursor_ne_resize,
181 eCursor_sw_resize,
182 eCursor_crosshair,
183 eCursor_move,
184 eCursor_help,
185 eCursor_copy, // CSS3
186 eCursor_alias,
187 eCursor_context_menu,
188 eCursor_cell,
189 eCursor_grab,
190 eCursor_grabbing,
191 eCursor_spinning,
192 eCursor_zoom_in,
193 eCursor_zoom_out,
194 eCursor_not_allowed,
195 eCursor_col_resize,
196 eCursor_row_resize,
197 eCursor_no_drop,
198 eCursor_vertical_text,
199 eCursor_all_scroll,
200 eCursor_nesw_resize,
201 eCursor_nwse_resize,
202 eCursor_ns_resize,
203 eCursor_ew_resize,
204 eCursor_none,
205 // This one is used for array sizing, and so better be the last
206 // one in this list...
207 eCursorCount,
209 // ...except for this one.
210 eCursorInvalid = eCursorCount + 1
213 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
214 eZPlacementBottom = 0, // bottom of the window stack
215 eZPlacementBelow, // just below another widget
216 eZPlacementTop // top of the window stack
220 * Before the OS goes to sleep, this topic is notified.
222 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
225 * After the OS wakes up, this topic is notified.
227 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
230 * Before the OS suspends the current process, this topic is notified. Some
231 * OS will kill processes that are suspended instead of resuming them.
232 * For that reason this topic may be useful to safely close down resources.
234 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
237 * After the current process resumes from being suspended, this topic is
238 * notified.
240 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
243 * When an app(-shell) is activated by the OS, this topic is notified.
244 * Currently, this only happens on Mac OSX.
246 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
248 namespace mozilla::widget {
251 * Size constraints for setting the minimum and maximum size of a widget.
252 * Values are in device pixels.
254 struct SizeConstraints {
255 SizeConstraints()
256 : mMaxSize(MOZ_WIDGET_MAX_SIZE, MOZ_WIDGET_MAX_SIZE),
257 mScale(MOZ_WIDGET_INVALID_SCALE) {}
259 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
260 mozilla::LayoutDeviceIntSize aMaxSize,
261 mozilla::DesktopToLayoutDeviceScale aScale)
262 : mMinSize(aMinSize), mMaxSize(aMaxSize), mScale(aScale) {
263 if (mMaxSize.width > MOZ_WIDGET_MAX_SIZE) {
264 mMaxSize.width = MOZ_WIDGET_MAX_SIZE;
266 if (mMaxSize.height > MOZ_WIDGET_MAX_SIZE) {
267 mMaxSize.height = MOZ_WIDGET_MAX_SIZE;
271 mozilla::LayoutDeviceIntSize mMinSize;
272 mozilla::LayoutDeviceIntSize mMaxSize;
275 * The scale used to convert from desktop to device dimensions.
276 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
278 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
279 * with multi-monitor scaling issues in more complete way across
280 * all widget implementations.
282 mozilla::DesktopToLayoutDeviceScale mScale;
285 struct AutoObserverNotifier {
286 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
287 : mObserver(aObserver), mTopic(aTopic) {}
289 void SkipNotification() { mObserver = nullptr; }
291 uint64_t SaveObserver() {
292 if (!mObserver) {
293 return 0;
295 uint64_t observerId = ++sObserverId;
296 sSavedObservers.InsertOrUpdate(observerId, mObserver);
297 SkipNotification();
298 return observerId;
301 ~AutoObserverNotifier() {
302 if (mObserver) {
303 mObserver->Observe(nullptr, mTopic, nullptr);
307 static void NotifySavedObserver(const uint64_t& aObserverId,
308 const char* aTopic) {
309 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
310 if (!observer) {
311 MOZ_ASSERT(aObserverId == 0,
312 "We should always find a saved observer for nonzero IDs");
313 return;
316 sSavedObservers.Remove(aObserverId);
317 observer->Observe(nullptr, aTopic, nullptr);
320 private:
321 nsCOMPtr<nsIObserver> mObserver;
322 const char* mTopic;
324 private:
325 static uint64_t sObserverId;
326 static nsTHashMap<uint64_t, nsCOMPtr<nsIObserver>> sSavedObservers;
329 } // namespace mozilla::widget
332 * The base class for all the widgets. It provides the interface for
333 * all basic and necessary functionality.
335 class nsIWidget : public nsISupports {
336 protected:
337 typedef mozilla::dom::BrowserChild BrowserChild;
339 public:
340 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
341 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
342 typedef mozilla::layers::FrameMetrics FrameMetrics;
343 typedef mozilla::layers::LayerManager LayerManager;
344 typedef mozilla::WindowRenderer WindowRenderer;
345 typedef mozilla::layers::LayersBackend LayersBackend;
346 typedef mozilla::layers::LayersId LayersId;
347 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
348 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
349 typedef mozilla::widget::IMEEnabled IMEEnabled;
350 typedef mozilla::widget::IMEMessage IMEMessage;
351 typedef mozilla::widget::IMENotification IMENotification;
352 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
353 typedef mozilla::widget::IMEState IMEState;
354 typedef mozilla::widget::InputContext InputContext;
355 typedef mozilla::widget::InputContextAction InputContextAction;
356 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
357 typedef mozilla::widget::SizeConstraints SizeConstraints;
358 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
359 typedef mozilla::widget::TextEventDispatcherListener
360 TextEventDispatcherListener;
361 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
362 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
363 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
364 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
365 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
366 typedef mozilla::ScreenIntPoint ScreenIntPoint;
367 typedef mozilla::ScreenIntMargin ScreenIntMargin;
368 typedef mozilla::ScreenIntSize ScreenIntSize;
369 typedef mozilla::ScreenPoint ScreenPoint;
370 typedef mozilla::CSSToScreenScale CSSToScreenScale;
371 typedef mozilla::DesktopIntRect DesktopIntRect;
372 typedef mozilla::DesktopPoint DesktopPoint;
373 typedef mozilla::DesktopIntPoint DesktopIntPoint;
374 typedef mozilla::DesktopRect DesktopRect;
375 typedef mozilla::DesktopSize DesktopSize;
376 typedef mozilla::CSSPoint CSSPoint;
377 typedef mozilla::CSSRect CSSRect;
379 using InitData = mozilla::widget::InitData;
380 using WindowType = mozilla::widget::WindowType;
381 using PopupType = mozilla::widget::PopupType;
382 using PopupLevel = mozilla::widget::PopupLevel;
383 using BorderStyle = mozilla::widget::BorderStyle;
384 using TransparencyMode = mozilla::widget::TransparencyMode;
385 using Screen = mozilla::widget::Screen;
387 // Used in UpdateThemeGeometries.
388 struct ThemeGeometry {
389 // The ThemeGeometryType value for the themed widget, see
390 // nsITheme::ThemeGeometryTypeForWidget.
391 nsITheme::ThemeGeometryType mType;
392 // The device-pixel rect within the window for the themed widget
393 LayoutDeviceIntRect mRect;
395 ThemeGeometry(nsITheme::ThemeGeometryType aType,
396 const LayoutDeviceIntRect& aRect)
397 : mType(aType), mRect(aRect) {}
400 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
402 nsIWidget()
403 : mLastChild(nullptr),
404 mPrevSibling(nullptr),
405 mOnDestroyCalled(false),
406 mWindowType(WindowType::Child),
407 mZIndex(0)
410 ClearNativeTouchSequence(nullptr);
414 * Create and initialize a widget.
416 * All the arguments can be null in which case a top level window
417 * with size 0 is created. The event callback function has to be
418 * provided only if the caller wants to deal with the events this
419 * widget receives. The event callback is basically a preprocess
420 * hook called synchronously. The return value determines whether
421 * the event goes to the default window procedure or it is hidden
422 * to the os. The assumption is that if the event handler returns
423 * false the widget does not see the event. The widget should not
424 * automatically clear the window to the background color. The
425 * calling code must handle paint messages and clear the background
426 * itself.
428 * In practice at least one of aParent and aNativeParent will be null. If
429 * both are null the widget isn't parented (e.g. context menus or
430 * independent top level windows).
432 * The dimensions given in aRect are specified in the parent's
433 * device coordinate system.
434 * This must not be called for parentless widgets such as top-level
435 * windows, which use the desktop pixel coordinate system; a separate
436 * method is provided for these.
438 * @param aParent parent nsIWidget
439 * @param aNativeParent native parent widget
440 * @param aRect the widget dimension
441 * @param aInitData data that is used for widget initialization
444 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
445 nsNativeWidget aNativeParent,
446 const LayoutDeviceIntRect& aRect,
447 InitData* = nullptr) = 0;
450 * As above, but with aRect specified in DesktopPixel units (for top-level
451 * widgets).
452 * Default implementation just converts aRect to device pixels and calls
453 * through to device-pixel Create, but platforms may override this if the
454 * mapping is not straightforward or the native platform needs to use the
455 * desktop pixel values directly.
457 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
458 nsNativeWidget aNativeParent,
459 const DesktopIntRect& aRect,
460 InitData* aInitData = nullptr) {
461 LayoutDeviceIntRect devPixRect =
462 RoundedToInt(aRect * GetDesktopToDeviceScale());
463 return Create(aParent, aNativeParent, devPixRect, aInitData);
467 * Allocate, initialize, and return a widget that is a child of
468 * |this|. The returned widget (if nonnull) has gone through the
469 * equivalent of CreateInstance(widgetCID) + Create(...).
471 * |CreateChild()| lets widget backends decide whether to parent
472 * the new child widget to this, nonnatively parent it, or both.
473 * This interface exists to support the PuppetWidget backend,
474 * which is entirely non-native. All other params are the same as
475 * for |Create()|.
477 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
478 * |nsIWidget*| this, not its native widget (if it exists), when
479 * calling |Create()|. This is a timid hack around poorly
480 * understood code, and shouldn't be used in new code.
482 virtual already_AddRefed<nsIWidget> CreateChild(
483 const LayoutDeviceIntRect& aRect, InitData* = nullptr,
484 bool aForceUseIWidgetParent = false) = 0;
487 * Attach to a top level widget.
489 * In cases where a top level chrome widget is being used as a content
490 * container, attach a secondary listener and update the device
491 * context. The primary widget listener will continue to be called for
492 * notifications relating to the top-level window, whereas other
493 * notifications such as painting and events will instead be called via
494 * the attached listener. SetAttachedWidgetListener should be used to
495 * assign the attached listener.
497 * aUseAttachedEvents if true, events are sent to the attached listener
498 * instead of the normal listener.
500 virtual void AttachViewToTopLevel(bool aUseAttachedEvents) = 0;
503 * Accessor functions to get and set the attached listener. Used by
504 * nsView in connection with AttachViewToTopLevel above.
506 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
507 virtual nsIWidgetListener* GetAttachedWidgetListener() const = 0;
508 virtual void SetPreviouslyAttachedWidgetListener(
509 nsIWidgetListener* aListener) = 0;
510 virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() = 0;
513 * Notifies the root widget of a non-blank paint.
515 virtual void DidGetNonBlankPaint() {}
518 * Accessor functions to get and set the listener which handles various
519 * actions for the widget.
521 //@{
522 virtual nsIWidgetListener* GetWidgetListener() const = 0;
523 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
524 //@}
527 * Close and destroy the internal native window.
528 * This method does not delete the widget.
531 virtual void Destroy() = 0;
534 * Destroyed() returns true if Destroy() has been called already.
535 * Otherwise, false.
537 bool Destroyed() const { return mOnDestroyCalled; }
540 * Reparent a widget
542 * Change the widget's parent. Null parents are allowed.
544 * @param aNewParent new parent
546 virtual void SetParent(nsIWidget* aNewParent) = 0;
549 * Return the parent Widget of this Widget or nullptr if this is a
550 * top level window
552 * @return the parent widget or nullptr if it does not have a parent
555 virtual nsIWidget* GetParent(void) = 0;
558 * Return the top level Widget of this Widget
560 * @return the top level widget
562 virtual nsIWidget* GetTopLevelWidget() = 0;
565 * Return the top (non-sheet) parent of this Widget if it's a sheet,
566 * or nullptr if this isn't a sheet (or some other error occurred).
567 * Sheets are only supported on some platforms (currently only macOS).
569 * @return the top (non-sheet) parent widget or nullptr
572 virtual nsIWidget* GetSheetWindowParent(void) = 0;
575 * Return the physical DPI of the screen containing the window ...
576 * the number of device pixels per inch.
578 virtual float GetDPI() = 0;
581 * Fallback DPI for when there's no widget available.
583 static float GetFallbackDPI();
586 * Return the scaling factor between device pixels and the platform-
587 * dependent "desktop pixels" used to manage window positions on a
588 * potentially multi-screen, mixed-resolution desktop.
590 virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
593 * Return the scaling factor between device pixels and the platform-
594 * dependent "desktop pixels" by looking up the screen by the position
595 * of the widget.
597 virtual mozilla::DesktopToLayoutDeviceScale
598 GetDesktopToDeviceScaleByScreen() = 0;
601 * Return the default scale factor for the window. This is the
602 * default number of device pixels per CSS pixel to use. This should
603 * depend on OS/platform settings such as the Mac's "UI scale factor"
604 * or Windows' "font DPI". This will take into account Gecko preferences
605 * overriding the system setting.
607 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
610 * Fallback default scale for when there's no widget available.
612 static mozilla::CSSToLayoutDeviceScale GetFallbackDefaultScale();
615 * Return the first child of this widget. Will return null if
616 * there are no children.
618 nsIWidget* GetFirstChild() const { return mFirstChild; }
621 * Return the last child of this widget. Will return null if
622 * there are no children.
624 nsIWidget* GetLastChild() const { return mLastChild; }
627 * Return the next sibling of this widget
629 nsIWidget* GetNextSibling() const { return mNextSibling; }
632 * Set the next sibling of this widget
634 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
637 * Return the previous sibling of this widget
639 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
642 * Set the previous sibling of this widget
644 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
647 * Show or hide this widget
649 * @param aState true to show the Widget, false to hide it
652 virtual void Show(bool aState) = 0;
655 * Whether or not a widget must be recreated after being hidden to show
656 * again properly.
658 virtual bool NeedsRecreateToReshow() { return false; }
661 * Make the window modal.
663 virtual void SetModal(bool aModal) = 0;
666 * Make the non-modal window opened by modal window fake-modal, that will
667 * call SetFakeModal(false) on destroy on Cocoa.
669 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
672 * Are we app modal. Currently only implemented on Cocoa.
674 virtual bool IsRunningAppModal() { return false; }
677 * The maximum number of simultaneous touch contacts supported by the device.
678 * In the case of devices with multiple digitizers (e.g. multiple touch
679 * screens), the value will be the maximum of the set of maximum supported
680 * contacts by each individual digitizer.
682 virtual uint32_t GetMaxTouchPoints() const = 0;
685 * Returns whether the window is visible
688 virtual bool IsVisible() const = 0;
691 * Returns whether the window has allocated resources so
692 * we can paint into it.
693 * Recently it's used on Linux/Gtk where we should not paint
694 * to invisible window.
696 virtual bool IsMapped() const { return true; }
699 * Perform platform-dependent sanity check on a potential window position.
700 * This is guaranteed to work only for top-level windows.
702 virtual void ConstrainPosition(DesktopIntPoint&) = 0;
705 * NOTE:
707 * For a top-level window widget, the "parent's coordinate system" is the
708 * "global" display pixel coordinate space, *not* device pixels (which
709 * may be inconsistent between multiple screens, at least in the Mac OS
710 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
711 * following Move and Resize widget APIs.
713 * The display-/device-pixel distinction becomes important for (at least)
714 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
715 * is set to other than 100%.
717 * The Move and Resize methods take floating-point parameters, rather than
718 * integer ones. This is important when manipulating top-level widgets,
719 * where the coordinate system may not be an integral multiple of the
720 * device-pixel space.
724 * Move this widget.
726 * Coordinates refer to the top-left of the widget. For toplevel windows
727 * with decorations, this is the top-left of the titlebar and frame .
729 * @param aX the new x position expressed in the parent's coordinate system
730 * @param aY the new y position expressed in the parent's coordinate system
733 virtual void Move(double aX, double aY) = 0;
736 * Reposition this widget so that the client area has the given offset.
738 * @param aOffset the new offset of the client area expressed as an
739 * offset from the origin of the client area of the parent
740 * widget (for root widgets and popup widgets it is in
741 * screen coordinates)
743 virtual void MoveClient(const DesktopPoint& aOffset) = 0;
746 * Resize this widget. Any size constraints set for the window by a
747 * previous call to SetSizeConstraints will be applied.
749 * @param aWidth the new width expressed in the parent's coordinate system
750 * @param aHeight the new height expressed in the parent's coordinate
751 * system
752 * @param aRepaint whether the widget should be repainted
754 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
757 * Lock the aspect ratio of a Window
759 * @param aShouldLock bool
762 virtual void LockAspectRatio(bool aShouldLock){};
765 * Move or resize this widget. Any size constraints set for the window by
766 * a previous call to SetSizeConstraints will be applied.
768 * @param aX the new x position expressed in the parent's coordinate
769 * system
770 * @param aY the new y position expressed in the parent's coordinate
771 * system
772 * @param aWidth the new width expressed in the parent's coordinate system
773 * @param aHeight the new height expressed in the parent's coordinate
774 * system
775 * @param aRepaint whether the widget should be repainted if the size
776 * changes
779 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
780 bool aRepaint) = 0;
782 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
783 return mozilla::Nothing();
787 * Resize the widget so that the inner client area has the given size.
789 * @param aSize the new size of the client area.
790 * @param aRepaint whether the widget should be repainted
792 virtual void ResizeClient(const DesktopSize& aSize, bool aRepaint) = 0;
795 * Resize and reposition the widget so tht inner client area has the given
796 * offset and size.
798 * @param aRect the new offset and size of the client area. The offset is
799 * expressed as an offset from the origin of the client area
800 * of the parent widget (for root widgets and popup widgets it
801 * is in screen coordinates).
802 * @param aRepaint whether the widget should be repainted
804 virtual void ResizeClient(const DesktopRect& aRect, bool aRepaint) = 0;
807 * Sets the widget's z-index.
809 virtual void SetZIndex(int32_t aZIndex) = 0;
812 * Gets the widget's z-index.
814 int32_t GetZIndex() { return mZIndex; }
817 * Position this widget just behind the given widget. (Used to
818 * control z-order for top-level widgets. Get/SetZIndex by contrast
819 * control z-order for child widgets of other widgets.)
820 * @param aPlacement top, bottom, or below a widget
821 * (if top or bottom, param aWidget is ignored)
822 * @param aWidget widget to place this widget behind
823 * (only if aPlacement is eZPlacementBelow).
824 * null is equivalent to aPlacement of eZPlacementTop
825 * @param aActivate true to activate the widget after placing it
827 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
828 nsIWidget* aWidget, bool aActivate) = 0;
831 * Minimize, maximize or normalize the window size.
832 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
834 virtual void SetSizeMode(nsSizeMode aMode) = 0;
836 virtual void GetWorkspaceID(nsAString& workspaceID) = 0;
838 virtual void MoveToWorkspace(const nsAString& workspaceID) = 0;
841 * Suppress animations that are applied to a window by OS.
843 virtual void SuppressAnimation(bool aSuppress) {}
846 * Return size mode (minimized, maximized, normalized).
847 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
849 virtual nsSizeMode SizeMode() = 0;
852 * Ask whether the window is tiled.
854 virtual bool IsTiled() const = 0;
857 * Ask wether the widget is fully occluded
859 virtual bool IsFullyOccluded() const = 0;
862 * Enable or disable this Widget
864 * @param aState true to enable the Widget, false to disable it.
866 virtual void Enable(bool aState) = 0;
869 * Ask whether the widget is enabled
871 virtual bool IsEnabled() const = 0;
874 * Whether we should request activation of this widget's toplevel window.
876 enum class Raise {
878 Yes,
882 * Request activation of this window or give focus to this widget.
884 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
887 * Get this widget's outside dimensions relative to its parent widget. For
888 * popup widgets the returned rect is in screen coordinates and not
889 * relative to its parent widget.
891 * @return the x, y, width and height of this widget.
893 virtual LayoutDeviceIntRect GetBounds() = 0;
896 * Get this widget's outside dimensions in device coordinates. This
897 * includes any title bar on the window.
899 * @return the x, y, width and height of this widget.
901 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
904 * Similar to GetScreenBounds except that this function will always
905 * get the size when the widget is in the nsSizeMode_Normal size mode
906 * even if the current size mode is not nsSizeMode_Normal.
907 * This method will fail if the size mode is not nsSizeMode_Normal and
908 * the platform doesn't have the ability.
909 * This method will always succeed if the current size mode is
910 * nsSizeMode_Normal.
912 * @param aRect On return it holds the x, y, width and height of
913 * this widget.
915 [[nodiscard]] virtual nsresult GetRestoredBounds(
916 LayoutDeviceIntRect& aRect) = 0;
919 * Get this widget's client area bounds, if the window has a 3D border
920 * appearance this returns the area inside the border. The position is the
921 * position of the client area relative to the client area of the parent
922 * widget (for root widgets and popup widgets it is in screen coordinates).
924 * @return the x, y, width and height of the client area of this widget.
926 virtual LayoutDeviceIntRect GetClientBounds() = 0;
929 * Sets the non-client area dimensions of the window. Pass -1 to restore
930 * the system default frame size for that border. Pass zero to remove
931 * a border, or pass a specific value adjust a border. Units are in
932 * pixels. (DPI dependent)
934 * Platform notes:
935 * Windows: shrinking top non-client height will remove application
936 * icon and window title text. Glass desktops will refuse to set
937 * dimensions between zero and size < system default.
939 virtual nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) = 0;
942 * Sets the region around the edges of the window that can be dragged to
943 * resize the window. All four sides of the window will get the same margin.
945 virtual void SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) = 0;
947 * Get the client offset from the window origin.
949 * @return the x and y of the offset.
951 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
954 * Returns the slop from the screen edges in device pixels.
955 * @see Window.screenEdgeSlop{X,Y}
957 virtual LayoutDeviceIntPoint GetScreenEdgeSlop() { return {}; }
960 * Equivalent to GetClientBounds but only returns the size.
962 virtual LayoutDeviceIntSize GetClientSize() {
963 // Depending on the backend, overloading this method may be useful if
964 // requesting the client offset is expensive.
965 return GetClientBounds().Size();
969 * Set the background color for this widget
971 * @param aColor the new background color
975 virtual void SetBackgroundColor(const nscolor& aColor) {}
978 * If a cursor type is currently cached locally for this widget, clear the
979 * cached cursor to force an update on the next SetCursor call.
982 virtual void ClearCachedCursor() = 0;
984 struct Cursor {
985 // The system cursor chosen by the page. This is used if there's no custom
986 // cursor, or if we fail to use the custom cursor in some way (if the image
987 // fails to load, for example).
988 nsCursor mDefaultCursor = eCursor_standard;
989 // May be null, to represent no custom cursor image.
990 nsCOMPtr<imgIContainer> mContainer;
991 uint32_t mHotspotX = 0;
992 uint32_t mHotspotY = 0;
993 mozilla::ImageResolution mResolution;
995 bool IsCustom() const { return !!mContainer; }
997 bool operator==(const Cursor& aOther) const {
998 return mDefaultCursor == aOther.mDefaultCursor &&
999 mContainer.get() == aOther.mContainer.get() &&
1000 mHotspotX == aOther.mHotspotX && mHotspotY == aOther.mHotspotY &&
1001 mResolution == aOther.mResolution;
1004 bool operator!=(const Cursor& aOther) const { return !(*this == aOther); }
1008 * Sets the cursor for this widget.
1010 virtual void SetCursor(const Cursor&) = 0;
1012 static nsIntSize CustomCursorSize(const Cursor&);
1015 * Get the window type of this widget.
1017 WindowType GetWindowType() const { return mWindowType; }
1020 * Set the transparency mode of the top-level window containing this widget.
1021 * So, e.g., if you call this on the widget for an IFRAME, the top level
1022 * browser window containing the IFRAME actually gets set. Be careful.
1024 * This can fail if the platform doesn't support
1025 * transparency/glass. By default widgets are not
1026 * transparent. This will also fail if the toplevel window is not
1027 * a Mozilla window, e.g., if the widget is in an embedded
1028 * context.
1030 * After transparency/glass has been enabled, the initial alpha channel
1031 * value for all pixels is 1, i.e., opaque.
1032 * If the window is resized then the alpha channel values for
1033 * all pixels are reset to 1.
1034 * Pixel RGB color values are already premultiplied with alpha channel values.
1036 virtual void SetTransparencyMode(TransparencyMode aMode) = 0;
1039 * Get the transparency mode of the top-level window that contains this
1040 * widget.
1042 virtual TransparencyMode GetTransparencyMode() = 0;
1045 * Set the shadow style of the window.
1047 * Ignored on child widgets and on non-Mac platforms.
1049 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) = 0;
1052 * Set the opacity of the window.
1053 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1055 * Ignored on child widgets and on non-Mac platforms.
1057 virtual void SetWindowOpacity(float aOpacity) {}
1060 * Set the transform of the window. Values are in device pixels,
1061 * the origin is the top left corner of the window.
1063 * Ignored on child widgets and on non-Mac platforms.
1065 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1068 * Set the preferred color-scheme for the widget.
1069 * Ignored on non-Mac platforms.
1071 virtual void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) {}
1074 * Set whether the window should ignore mouse events or not, and if it should
1075 * not, what input margin should it use.
1077 * This is only used on popup windows. The margin is only implemented on
1078 * Linux.
1080 struct InputRegion {
1081 bool mFullyTransparent = false;
1082 mozilla::LayoutDeviceIntCoord mMargin = 0;
1084 virtual void SetInputRegion(const InputRegion&) {}
1087 * On macOS, this method shows or hides the pill button in the titlebar
1088 * that's used to collapse the toolbar.
1090 * Ignored on child widgets and on non-Mac platforms.
1092 virtual void SetShowsToolbarButton(bool aShow) = 0;
1095 * On macOS, this method determines whether we tell cocoa that the window
1096 * supports native full screen. If we do so, and another window is in
1097 * native full screen, this window will also appear in native full screen.
1099 * We generally only want to do this for primary application windows.
1101 * Ignored on child widgets and on non-Mac platforms.
1103 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) = 0;
1105 enum WindowAnimationType {
1106 eGenericWindowAnimation,
1107 eDocumentWindowAnimation
1111 * Sets the kind of top-level window animation this widget should have. On
1112 * macOS, this causes a particular kind of animation to be shown when the
1113 * window is first made visible.
1115 * Ignored on child widgets and on non-Mac platforms.
1117 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1120 * Specifies whether the window title should be drawn even if the window
1121 * contents extend into the titlebar. Ignored on windows that don't draw
1122 * in the titlebar. Only implemented on macOS.
1124 virtual void SetDrawsTitle(bool aDrawTitle) {}
1127 * Hide window chrome (borders, buttons) for this widget.
1130 virtual void HideWindowChrome(bool aShouldHide) = 0;
1132 enum FullscreenTransitionStage {
1133 eBeforeFullscreenToggle,
1134 eAfterFullscreenToggle
1138 * Prepares for fullscreen transition and returns whether the widget
1139 * supports fullscreen transition. If this method returns false,
1140 * PerformFullscreenTransition() must never be called. Otherwise,
1141 * caller should call that method twice with "before" and "after"
1142 * stages respectively in order. In the latter case, this method may
1143 * return some data via aData pointer. Caller must pass that data to
1144 * PerformFullscreenTransition() if any, and caller is responsible
1145 * for releasing that data.
1147 virtual bool PrepareForFullscreenTransition(nsISupports** aData) = 0;
1150 * Performs fullscreen transition. This method returns immediately,
1151 * and will post aCallback to the main thread when the transition
1152 * finishes.
1154 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
1155 uint16_t aDuration,
1156 nsISupports* aData,
1157 nsIRunnable* aCallback) = 0;
1160 * Perform any actions needed after the fullscreen transition has ended.
1162 virtual void CleanupFullscreenTransition() = 0;
1165 * Return the screen the widget is in, or null if we don't know.
1167 virtual already_AddRefed<Screen> GetWidgetScreen() = 0;
1170 * Put the toplevel window into or out of fullscreen mode.
1172 * @return NS_OK if the widget is setup properly for fullscreen and
1173 * FullscreenChanged callback has been or will be called. If other
1174 * value is returned, the caller should continue the change itself.
1176 virtual nsresult MakeFullScreen(bool aFullScreen) = 0;
1179 * Same as MakeFullScreen, except that, on systems which natively
1180 * support fullscreen transition, calling this method explicitly
1181 * requests that behavior.
1182 * It is currently only supported on macOS 10.7+.
1184 virtual nsresult MakeFullScreenWithNativeTransition(bool aFullScreen) {
1185 return MakeFullScreen(aFullScreen);
1189 * Invalidate a specified rect for a widget so that it will be repainted
1190 * later.
1192 virtual void Invalidate(const LayoutDeviceIntRect& aRect) = 0;
1194 enum LayerManagerPersistence {
1195 LAYER_MANAGER_CURRENT = 0,
1196 LAYER_MANAGER_PERSISTENT
1200 * Return the widget's LayerManager. The layer tree for that LayerManager is
1201 * what gets rendered to the widget.
1203 * Note that this tries to create a renderer if it doesn't exist.
1205 virtual WindowRenderer* GetWindowRenderer() = 0;
1208 * Returns whether there's an existing window renderer.
1210 virtual bool HasWindowRenderer() const = 0;
1213 * Called before each layer manager transaction to allow any preparation
1214 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1216 * Always called on the main thread.
1218 virtual void PrepareWindowEffects() = 0;
1221 * Called when Gecko knows which themed widgets exist in this window.
1222 * The passed array contains an entry for every themed widget of the right
1223 * type (currently only StyleAppearance::Toolbar) within the window, except
1224 * for themed widgets which are transformed or have effects applied to them
1225 * (e.g. CSS opacity or filters).
1226 * This could sometimes be called during display list construction
1227 * outside of painting.
1228 * If called during painting, it will be called before we actually
1229 * paint anything.
1231 virtual void UpdateThemeGeometries(
1232 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1235 * Informs the widget about the region of the window that is opaque.
1237 * @param aOpaqueRegion the region of the window that is opaque.
1239 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1242 * Informs the widget about the region of the window that is draggable.
1244 virtual void UpdateWindowDraggingRegion(
1245 const LayoutDeviceIntRegion& aRegion) {}
1248 * Tells the widget whether the given input block results in a swipe.
1249 * Should be called in response to a WidgetWheelEvent that has
1250 * mFlags.mCanTriggerSwipe set on it.
1252 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1255 * Internal methods
1258 //@{
1259 virtual void AddChild(nsIWidget* aChild) = 0;
1260 virtual void RemoveChild(nsIWidget* aChild) = 0;
1261 virtual void* GetNativeData(uint32_t aDataType) = 0;
1262 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1264 //@}
1267 * Set the widget's title.
1268 * Must be called after Create.
1270 * @param aTitle string displayed as the title of the widget
1272 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1275 * Set the widget's icon.
1276 * Must be called after Create.
1278 * @param aIconSpec string specifying the icon to use; convention is to
1279 * pass a resource: URL from which a platform-dependent
1280 * resource file name will be constructed
1282 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1285 * Return this widget's origin in screen coordinates.
1287 * @return screen coordinates stored in the x,y members
1289 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1292 * The same as WidgetToScreenOffset(), except in the case of
1293 * PuppetWidget where this method omits the chrome offset.
1295 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1296 return WidgetToScreenOffset();
1300 * For a PuppetWidget, returns the transform from the coordinate
1301 * space of the PuppetWidget to the coordinate space of the
1302 * top-level native widget.
1304 * Identity transform in other cases.
1306 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1307 WidgetToTopLevelWidgetTransform() {
1308 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1311 mozilla::LayoutDeviceIntPoint WidgetToTopLevelWidgetOffset() {
1312 return mozilla::LayoutDeviceIntPoint::Round(
1313 WidgetToTopLevelWidgetTransform().TransformPoint(
1314 mozilla::LayoutDevicePoint()));
1318 * Returns the margins that are applied to go from client sizes to window
1319 * sizes (which includes window borders and titlebar).
1320 * This method should work even when the window is not yet visible.
1322 virtual LayoutDeviceIntMargin ClientToWindowMargin() { return {}; }
1324 LayoutDeviceIntSize ClientToWindowSizeDifference();
1327 * Dispatches an event to the widget
1329 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1330 nsEventStatus& aStatus) = 0;
1333 * Dispatches an event to APZ only.
1334 * No-op in the child process.
1336 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1339 * Dispatch a gecko event for this widget.
1340 * Returns true if it's consumed. Otherwise, false.
1342 virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event) = 0;
1344 // A structure that groups the statuses from APZ dispatch and content
1345 // dispatch.
1346 struct ContentAndAPZEventStatus {
1347 // Either of these may not be set if the event was not dispatched
1348 // to APZ or to content.
1349 nsEventStatus mApzStatus = nsEventStatus_eIgnore;
1350 nsEventStatus mContentStatus = nsEventStatus_eIgnore;
1354 * Dispatches an event that must be handled by APZ first, when APZ is
1355 * enabled. If invoked in the child process, it is forwarded to the
1356 * parent process synchronously.
1358 virtual ContentAndAPZEventStatus DispatchInputEvent(
1359 mozilla::WidgetInputEvent* aEvent) = 0;
1362 * Confirm an APZ-aware event target. This should be used when APZ will
1363 * not need a layers update to process the event.
1365 virtual void SetConfirmedTargetAPZC(
1366 uint64_t aInputBlockId,
1367 const nsTArray<ScrollableLayerGuid>& aTargets) const = 0;
1370 * Returns true if APZ is in use, false otherwise.
1372 virtual bool AsyncPanZoomEnabled() const = 0;
1376 virtual void SwipeFinished() = 0;
1379 * Enables the dropping of files to a widget.
1381 virtual void EnableDragDrop(bool aEnable) = 0;
1382 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1385 * Classify the window for the window manager. Mostly for X11.
1387 * @param xulWinType The window type. Characters other than [A-Za-z0-9_-] are
1388 * converted to '_'. Anything before the first colon is
1389 * assigned to name, anything after it to role. If there's
1390 * no colon, assign the whole thing to both role and name.
1392 * @param xulWinClass The window class. If set, overrides the normal value.
1393 * Otherwise, the program class it used.
1395 * @param xulWinName The window name. If set, overrides the value specified in
1396 * window type. Otherwise, name from window type is used.
1399 virtual void SetWindowClass(const nsAString& xulWinType,
1400 const nsAString& xulWinClass,
1401 const nsAString& xulWinName) = 0;
1404 * Enables/Disables system capture of any and all events that would cause a
1405 * popup to be rolled up. aListener should be set to a non-null value for
1406 * any popups that are not managed by the popup manager.
1407 * @param aDoCapture true enables capture, false disables capture
1410 virtual void CaptureRollupEvents(bool aDoCapture) = 0;
1413 * Bring this window to the user's attention. This is intended to be a more
1414 * gentle notification than popping the window to the top or putting up an
1415 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1416 * the Mac. The notification should be suppressed if the window is already
1417 * in the foreground and should be dismissed when the user brings this window
1418 * to the foreground.
1419 * @param aCycleCount Maximum number of times to animate the window per system
1420 * conventions. If set to -1, cycles indefinitely until
1421 * window is brought into the foreground.
1423 [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) = 0;
1426 * Ask whether there user input events pending. All input events are
1427 * included, including those not targeted at this nsIwidget instance.
1429 virtual bool HasPendingInputEvent() = 0;
1432 * Determine whether the widget shows a resize widget. If it does,
1433 * aResizerRect returns the resizer's rect.
1435 * Returns false on any platform that does not support it.
1437 * @param aResizerRect The resizer's rect in device pixels.
1438 * @return Whether a resize widget is shown.
1440 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1442 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1443 // EnumSet class.
1444 enum Modifiers : uint32_t {
1445 NO_MODIFIERS = 0x00000000,
1446 CAPS_LOCK = 0x00000001, // when CapsLock is active
1447 NUM_LOCK = 0x00000002, // when NumLock is active
1448 SHIFT_L = 0x00000100,
1449 SHIFT_R = 0x00000200,
1450 CTRL_L = 0x00000400,
1451 CTRL_R = 0x00000800,
1452 ALT_L = 0x00001000, // includes Option
1453 ALT_R = 0x00002000,
1454 COMMAND_L = 0x00004000,
1455 COMMAND_R = 0x00008000,
1456 HELP = 0x00010000,
1457 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1458 // AltRight key behavior of keyboard
1459 // layouts which maps AltGr to AltRight
1460 // key.
1461 FUNCTION = 0x00100000,
1462 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1465 * Utility method intended for testing. Dispatches native key events
1466 * to this widget to simulate the press and release of a key.
1467 * @param aNativeKeyboardLayout a *platform-specific* constant.
1468 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1469 * On Windows, it is converted to a hex string and passed to
1470 * LoadKeyboardLayout, see
1471 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1472 * @param aNativeKeyCode a *platform-specific* keycode.
1473 * On Windows, this is the virtual key code.
1474 * @param aModifiers some combination of the above 'Modifiers' flags;
1475 * not all flags will apply to all platforms. Mac ignores the _R
1476 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1477 * FUNCTION.
1478 * @param aCharacters characters that the OS would decide to generate
1479 * from the event. On Windows, this is the charCode passed by
1480 * WM_CHAR.
1481 * @param aUnmodifiedCharacters characters that the OS would decide
1482 * to generate from the event if modifier keys (other than shift)
1483 * were assumed inactive. Needed on Mac, ignored on Windows.
1484 * @param aObserver the observer that will get notified once the events
1485 * have been dispatched.
1486 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1487 * layout is not supported and the event was not fired
1489 virtual nsresult SynthesizeNativeKeyEvent(
1490 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1491 uint32_t aModifierFlags, const nsAString& aCharacters,
1492 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1495 * Utility method intended for testing. Dispatches native mouse events
1496 * may even move the mouse cursor. On Mac the events are guaranteed to
1497 * be sent to the window containing this widget, but on Windows they'll go
1498 * to whatever's topmost on the screen at that position, so for
1499 * cross-platform testing ensure that your window is at the top of the
1500 * z-order.
1501 * @param aPoint screen location of the mouse, in device
1502 * pixels, with origin at the top left
1503 * @param aNativeMessage abstract native message.
1504 * @param aButton Mouse button defined by DOM UI Events.
1505 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1506 * FYI: On Windows, Android and Headless widget on all
1507 * platroms, this hasn't been handled yet.
1508 * @param aObserver the observer that will get notified once the events
1509 * have been dispatched.
1511 enum class NativeMouseMessage : uint32_t {
1512 ButtonDown, // button down
1513 ButtonUp, // button up
1514 Move, // mouse cursor move
1515 EnterWindow, // mouse cursor comes into a window
1516 LeaveWindow, // mouse cursor leaves from a window
1518 virtual nsresult SynthesizeNativeMouseEvent(
1519 LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
1520 mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
1521 nsIObserver* aObserver) = 0;
1524 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1525 * message. aPoint is location in device pixels to which the mouse pointer
1526 * moves to.
1527 * @param aObserver the observer that will get notified once the events
1528 * have been dispatched.
1530 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1531 nsIObserver* aObserver) = 0;
1534 * Utility method intended for testing. Dispatching native mouse scroll
1535 * events may move the mouse cursor.
1537 * @param aPoint Mouse cursor position in screen coordinates.
1538 * In device pixels, the origin at the top left of
1539 * the primary display.
1540 * @param aNativeMessage Platform native message.
1541 * @param aDeltaX The delta value for X direction. If the native
1542 * message doesn't indicate X direction scrolling,
1543 * this may be ignored.
1544 * @param aDeltaY The delta value for Y direction. If the native
1545 * message doesn't indicate Y direction scrolling,
1546 * this may be ignored.
1547 * @param aDeltaZ The delta value for Z direction. If the native
1548 * message doesn't indicate Z direction scrolling,
1549 * this may be ignored.
1550 * @param aModifierFlags Must be values of Modifiers, or zero.
1551 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1552 * document.
1553 * @param aObserver The observer that will get notified once the
1554 * events have been dispatched.
1556 virtual nsresult SynthesizeNativeMouseScrollEvent(
1557 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1558 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1559 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1562 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1563 * touch states in nsIDOMWindowUtils.idl.
1565 enum TouchPointerState {
1566 // The pointer is in a hover state above the digitizer
1567 TOUCH_HOVER = (1 << 0),
1568 // The pointer is in contact with the digitizer
1569 TOUCH_CONTACT = (1 << 1),
1570 // The pointer has been removed from the digitizer detection area
1571 TOUCH_REMOVE = (1 << 2),
1572 // The pointer has been canceled. Will cancel any pending os level
1573 // gestures that would triggered as a result of completion of the
1574 // input sequence. This may not cancel moz platform related events
1575 // that might get tirggered by input already delivered.
1576 TOUCH_CANCEL = (1 << 3),
1578 // ALL_BITS used for validity checking during IPC serialization
1579 ALL_BITS = (1 << 4) - 1
1582 * TouchpadGesturePhase states for SynthesizeNativeTouchPadPinch and
1583 * SynthesizeNativeTouchpadPan. Match phase states in nsIDOMWindowUtils.idl.
1585 enum TouchpadGesturePhase {
1586 PHASE_BEGIN = 0,
1587 PHASE_UPDATE = 1,
1588 PHASE_END = 2
1591 * Create a new or update an existing touch pointer on the digitizer.
1592 * To trigger os level gestures, individual touch points should
1593 * transition through a complete set of touch states which should be
1594 * sent as individual messages.
1596 * @param aPointerId The touch point id to create or update.
1597 * @param aPointerState one or more of the touch states listed above
1598 * @param aPoint coords of this event
1599 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1600 * @param aOrientation 0 -> 359 degree value indicating the
1601 * orientation of the pointer. Use 90 for normal taps.
1602 * @param aObserver The observer that will get notified once the events
1603 * have been dispatched.
1605 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1606 TouchPointerState aPointerState,
1607 LayoutDeviceIntPoint aPoint,
1608 double aPointerPressure,
1609 uint32_t aPointerOrientation,
1610 nsIObserver* aObserver) = 0;
1612 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1614 virtual nsresult SynthesizeNativeTouchPadPinch(
1615 TouchpadGesturePhase aEventPhase, float aScale,
1616 LayoutDeviceIntPoint aPoint, int32_t aModifierFlags) = 0;
1619 * Helper for simulating a simple tap event with one touch point. When
1620 * aLongTap is true, simulates a native long tap with a duration equal to
1621 * ui.click_hold_context_menus.delay. This pref is compatible with the
1622 * apzc long tap duration. Defaults to 1.5 seconds.
1623 * @param aObserver The observer that will get notified once the events
1624 * have been dispatched.
1626 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1627 bool aLongTap,
1628 nsIObserver* aObserver);
1630 virtual nsresult SynthesizeNativePenInput(uint32_t aPointerId,
1631 TouchPointerState aPointerState,
1632 LayoutDeviceIntPoint aPoint,
1633 double aPressure,
1634 uint32_t aRotation, int32_t aTiltX,
1635 int32_t aTiltY, int32_t aButton,
1636 nsIObserver* aObserver) = 0;
1639 * Cancels all active simulated touch input points and pending long taps.
1640 * Native widgets should track existing points such that they can clear the
1641 * digitizer state when this call is made.
1642 * @param aObserver The observer that will get notified once the touch
1643 * sequence has been cleared.
1645 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1648 * Send a native event as if the user double tapped the touchpad with two
1649 * fingers.
1651 virtual nsresult SynthesizeNativeTouchpadDoubleTap(
1652 LayoutDeviceIntPoint aPoint, uint32_t aModifierFlags) = 0;
1655 * See nsIDOMWindowUtils.sendNativeTouchpadPan().
1657 virtual nsresult SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase,
1658 LayoutDeviceIntPoint aPoint,
1659 double aDeltaX, double aDeltaY,
1660 int32_t aModifierFlags,
1661 nsIObserver* aObserver) = 0;
1663 virtual void StartAsyncScrollbarDrag(
1664 const AsyncDragMetrics& aDragMetrics) = 0;
1667 * Notify APZ to start autoscrolling.
1668 * @param aAnchorLocation the location of the autoscroll anchor
1669 * @param aGuid identifies the scroll frame to be autoscrolled
1670 * @return true if APZ has been successfully notified
1672 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1673 const ScrollableLayerGuid& aGuid) = 0;
1676 * Notify APZ to stop autoscrolling.
1677 * @param aGuid identifies the scroll frame which is being autoscrolled.
1679 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid& aGuid) = 0;
1681 virtual LayersId GetRootLayerTreeId() = 0;
1683 // If this widget supports out-of-process compositing, it can override
1684 // this method to provide additional information to the compositor.
1685 virtual void GetCompositorWidgetInitData(
1686 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1689 * Setter/Getter of the system font setting for testing.
1691 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1692 return NS_ERROR_NOT_IMPLEMENTED;
1694 virtual nsresult GetSystemFont(nsCString& aFontName) {
1695 return NS_ERROR_NOT_IMPLEMENTED;
1699 * Wayland specific routines.
1701 virtual LayoutDeviceIntSize GetMoveToRectPopupSize() const {
1702 NS_WARNING("GetLayoutPopupRect implemented only for wayland");
1703 return LayoutDeviceIntSize();
1707 * If this widget uses native pointer lock instead of warp-to-center
1708 * (currently only GTK on Wayland), these methods provide access to that
1709 * functionality.
1711 virtual void SetNativePointerLockCenter(
1712 const LayoutDeviceIntPoint& aLockCenter) {}
1713 virtual void LockNativePointer() {}
1714 virtual void UnlockNativePointer() {}
1717 * Get safe area insets except to cutout.
1718 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1720 virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const {
1721 return mozilla::ScreenIntMargin();
1724 private:
1725 class LongTapInfo {
1726 public:
1727 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1728 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1729 : mPointerId(aPointerId),
1730 mPosition(aPoint),
1731 mDuration(aDuration),
1732 mObserver(aObserver),
1733 mStamp(mozilla::TimeStamp::Now()) {}
1735 int32_t mPointerId;
1736 LayoutDeviceIntPoint mPosition;
1737 mozilla::TimeDuration mDuration;
1738 nsCOMPtr<nsIObserver> mObserver;
1739 mozilla::TimeStamp mStamp;
1742 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1744 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1745 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1747 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1748 nsCOMPtr<nsITimer> mLongTapTimer;
1749 static int32_t sPointerIdCounter;
1751 public:
1753 * If key events have not been handled by content or XBL handlers, they can
1754 * be offered to the system (for custom application shortcuts set in system
1755 * preferences, for example).
1757 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1760 * Activates a native menu item at the position specified by the index
1761 * string. The index string is a string of positive integers separated
1762 * by the "|" (pipe) character. The last integer in the string represents
1763 * the item index in a submenu located using the integers preceding it.
1765 * Example: 1|0|4
1766 * In this string, the first integer represents the top-level submenu
1767 * in the native menu bar. Since the integer is 1, it is the second submeu
1768 * in the native menu bar. Within that, the first item (index 0) is a
1769 * submenu, and we want to activate the 5th item within that submenu.
1771 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1774 * This is used for native menu system testing.
1776 * Updates a native menu at the position specified by the index string.
1777 * The index string is a string of positive integers separated by the "|"
1778 * (pipe) character.
1780 * Example: 1|0|4
1781 * In this string, the first integer represents the top-level submenu
1782 * in the native menu bar. Since the integer is 1, it is the second submeu
1783 * in the native menu bar. Within that, the first item (index 0) is a
1784 * submenu, and we want to update submenu at index 4 within that submenu.
1786 * If this is called with an empty string it forces a full reload of the
1787 * menu system.
1789 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1792 * This is used for testing macOS service menu code.
1794 * @param aResult - the current text selection. Is empty if no selection.
1795 * @return nsresult - whether or not aResult was assigned the selected text.
1797 [[nodiscard]] virtual nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1798 return NS_ERROR_NOT_IMPLEMENTED;
1802 * Notify IME of the specified notification.
1804 * @return If the notification is mouse button event and it's consumed by
1805 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1807 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1810 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1811 * of the widget, in the event that we were not able to observe and respond to
1812 * the initial focus event. This is necessary for the early skeleton UI
1813 * window, which is displayed and receives its initial focus event before we
1814 * can actually respond to it.
1816 virtual void MaybeDispatchInitialFocusEvent() {}
1819 * Notifies the input context changes.
1821 virtual void SetInputContext(const InputContext& aContext,
1822 const InputContextAction& aAction) = 0;
1825 * Get current input context.
1827 virtual InputContext GetInputContext() = 0;
1830 * Get native IME context. This is different from GetNativeData() with
1831 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1832 * process.
1834 virtual NativeIMEContext GetNativeIMEContext() = 0;
1837 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1838 * native (OS-level) event for it. This method allows tests to simulate
1839 * keystrokes that trigger native key bindings (which require a native
1840 * event).
1842 [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
1843 mozilla::WidgetKeyboardEvent& aEvent) = 0;
1846 * Retrieve edit commands when the key combination of aEvent is used
1847 * in platform native applications.
1849 MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
1850 mozilla::NativeKeyBindingsType aType,
1851 const mozilla::WidgetKeyboardEvent& aEvent,
1852 nsTArray<mozilla::CommandInt>& aCommands);
1855 * Retrieves a reference to notification requests of IME. Note that the
1856 * reference is valid while the nsIWidget instance is alive. So, if you
1857 * need to store the reference for a long time, you need to grab the widget
1858 * instance too.
1860 const IMENotificationRequests& IMENotificationRequestsRef();
1863 * Call this method when a dialog is opened which has a default button.
1864 * The button's rectangle should be supplied in aButtonRect.
1866 [[nodiscard]] virtual nsresult OnDefaultButtonLoaded(
1867 const LayoutDeviceIntRect& aButtonRect) = 0;
1870 * Return true if this process shouldn't use platform widgets, and
1871 * so should use PuppetWidgets instead. If this returns true, the
1872 * result of creating and using a platform widget is undefined,
1873 * and likely to end in crashes or other buggy behavior.
1875 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1877 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1879 static already_AddRefed<nsIWidget> CreateChildWindow();
1882 * Allocate and return a "puppet widget" that doesn't directly
1883 * correlate to a platform widget; platform events and data must
1884 * be fed to it. Currently used in content processes. NULL is
1885 * returned if puppet widgets aren't supported in this build
1886 * config, on this platform, or for this process type.
1888 * This function is called "Create" to match CreateInstance().
1889 * The returned widget must still be nsIWidget::Create()d.
1891 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1892 BrowserChild* aBrowserChild);
1894 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1897 * Reparent this widget's native widget.
1898 * @param aNewParent the native widget of aNewParent is the new native
1899 * parent widget
1901 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1904 * Return true if widget has it's own GL context
1906 virtual bool HasGLContext() { return false; }
1909 * Returns true to indicate that this widget paints an opaque background
1910 * that we want to be visible under the page, so layout should not force
1911 * a default background.
1913 virtual bool WidgetPaintsBackground() { return false; }
1915 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1918 * Get the natural bounds of this widget. This method is only
1919 * meaningful for widgets for which Gecko implements screen
1920 * rotation natively. When this is the case, GetBounds() returns
1921 * the widget bounds taking rotation into account, and
1922 * GetNaturalBounds() returns the bounds *not* taking rotation
1923 * into account.
1925 * No code outside of the composition pipeline should know or care
1926 * about this. If you're not an agent of the compositor, you
1927 * probably shouldn't call this method.
1929 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1932 * Set size constraints on the window size such that it is never less than
1933 * the specified minimum size and never larger than the specified maximum
1934 * size. The size constraints are sizes of the outer rectangle including
1935 * the window frame and title bar. Use 0 for an unconstrained minimum size
1936 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1937 * does not necessarily change the size of a window to conform to this size,
1938 * thus Resize should be called afterwards.
1940 * @param aConstraints: the size constraints in device pixels
1942 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1945 * Return the size constraints currently observed by the widget.
1947 * @return the constraints in device pixels
1949 virtual const SizeConstraints GetSizeConstraints() = 0;
1952 * Apply the current size constraints to the given size.
1954 * @param aWidth width to constrain
1955 * @param aHeight height to constrain
1957 virtual void ConstrainSize(int32_t* aWidth, int32_t* aHeight) = 0;
1960 * If this is owned by a BrowserChild, return that. Otherwise return
1961 * null.
1963 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
1966 * If this isn't directly compositing to its window surface,
1967 * return the compositor which is doing that on our behalf.
1969 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
1972 * If there is a remote renderer, pause or resume it.
1974 virtual void PauseOrResumeCompositor(bool aPause);
1977 * Clear WebRender resources
1979 virtual void ClearCachedWebrenderResources() {}
1982 * Clear WebRender animation resources
1984 virtual void ClearWebrenderAnimationResources() {}
1987 * Request fast snapshot at RenderCompositor of WebRender.
1988 * Since readback of Windows DirectComposition is very slow.
1990 virtual bool SetNeedFastSnaphot() { return false; }
1993 * If this widget has its own vsync dispatcher, return it, otherwise return
1994 * nullptr. An example of such a local vsync dispatcher would be Wayland frame
1995 * callbacks.
1997 virtual RefPtr<mozilla::VsyncDispatcher> GetVsyncDispatcher();
2000 * Returns true if the widget requires synchronous repaints on resize,
2001 * false otherwise.
2003 virtual bool SynchronouslyRepaintOnResize() { return true; }
2006 * Some platforms (only cocoa right now) round widget coordinates to the
2007 * nearest even pixels (see bug 892994), this function allows us to
2008 * determine how widget coordinates will be rounded.
2010 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2012 virtual void UpdateZoomConstraints(
2013 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2014 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2017 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2018 * widget. Note that this never returns nullptr.
2020 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2023 * GetNativeTextEventDispatcherListener() returns a
2024 * TextEventDispatcherListener instance which is used when the widget
2025 * instance handles native IME and/or keyboard events.
2027 virtual TextEventDispatcherListener*
2028 GetNativeTextEventDispatcherListener() = 0;
2030 virtual void ZoomToRect(const uint32_t& aPresShellId,
2031 const ScrollableLayerGuid::ViewID& aViewId,
2032 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2035 * LookUpDictionary shows the dictionary for the word around current point.
2037 * @param aText the word to look up dictiorary.
2038 * @param aFontRangeArray text decoration of aText
2039 * @param aIsVertical true if the word is vertical layout
2040 * @param aPoint top-left point of aText
2042 virtual void LookUpDictionary(
2043 const nsAString& aText,
2044 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2045 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2047 virtual void RequestFxrOutput() {
2048 MOZ_ASSERT(false, "This function should only execute in Windows");
2051 #if defined(MOZ_WIDGET_ANDROID)
2053 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2054 * thread.
2056 * @param aMessage message being sent to Android UI thread.
2058 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2061 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2062 * thread
2064 * @param aScrollOffset page scroll offset value in screen pixels.
2065 * @param aZoom current page zoom.
2067 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2068 const CSSToScreenScale& aZoom) = 0;
2071 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2072 * for android robocop tests.
2074 * @param aMem shared memory containing the frame buffer pixels.
2075 * @param aSize size of the buffer in screen pixels.
2077 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2078 const ScreenIntSize& aSize,
2079 bool aNeedsYFlip) = 0;
2081 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2082 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2083 return 0;
2085 #endif
2087 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2090 * Like GetDefaultScale, but taking into account only the system settings
2091 * and ignoring Gecko preferences.
2093 virtual double GetDefaultScaleInternal() { return 1.0; }
2095 using WindowButtonType = mozilla::WindowButtonType;
2098 * Layout uses this to alert the widget to the client rect representing
2099 * the window maximize button. An empty rect indicates there is no
2100 * maximize button (for example, in fullscreen). This is only implemented
2101 * on Windows.
2103 virtual void SetWindowButtonRect(WindowButtonType aButtonType,
2104 const LayoutDeviceIntRect& aClientRect) {}
2106 #ifdef DEBUG
2107 virtual nsresult SetHiDPIMode(bool aHiDPI) {
2108 return NS_ERROR_NOT_IMPLEMENTED;
2110 virtual nsresult RestoreHiDPIMode() { return NS_ERROR_NOT_IMPLEMENTED; }
2111 #endif
2113 protected:
2114 // keep the list of children. We also keep track of our siblings.
2115 // The ownership model is as follows: parent holds a strong ref to
2116 // the first element of the list, and each element holds a strong
2117 // ref to the next element in the list. The prevsibling and
2118 // lastchild pointers are weak, which is fine as long as they are
2119 // maintained properly.
2120 nsCOMPtr<nsIWidget> mFirstChild;
2121 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2122 nsCOMPtr<nsIWidget> mNextSibling;
2123 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2124 // When Destroy() is called, the sub class should set this true.
2125 bool mOnDestroyCalled;
2126 WindowType mWindowType;
2127 int32_t mZIndex;
2130 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2132 #endif // nsIWidget_h__