Backed out changeset 0a133d5fd155 (bug 1864534) for causing screenshot related failur...
[gecko.git] / widget / nsIWidget.h
blob03e587d45516c61ba41462eff087c45604c6ca20
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;
61 enum class ColorScheme : uint8_t;
62 enum class WindowButtonType : uint8_t;
64 enum class WindowShadow : uint8_t {
65 None,
66 Menu,
67 Tooltip,
70 #if defined(MOZ_WIDGET_ANDROID)
71 namespace ipc {
72 class Shmem;
74 #endif // defined(MOZ_WIDGET_ANDROID)
75 namespace dom {
76 class BrowserChild;
77 enum class CallerType : uint32_t;
78 } // namespace dom
79 class WindowRenderer;
80 namespace layers {
81 class AsyncDragMetrics;
82 class Compositor;
83 class CompositorBridgeChild;
84 struct FrameMetrics;
85 class LayerManager;
86 class WebRenderBridgeChild;
87 } // namespace layers
88 namespace widget {
89 class TextEventDispatcher;
90 class TextEventDispatcherListener;
91 class CompositorWidget;
92 class CompositorWidgetInitData;
93 class Screen;
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 * Values for the GetNativeData function
122 #define NS_NATIVE_WINDOW 0
123 #define NS_NATIVE_GRAPHIC 1
124 #define NS_NATIVE_WIDGET 3
125 #define NS_NATIVE_REGION 5
126 #define NS_NATIVE_OFFSETX 6
127 #define NS_NATIVE_OFFSETY 7
128 #define NS_NATIVE_SCREEN 9
129 // The toplevel GtkWidget containing this nsIWidget:
130 #define NS_NATIVE_SHELLWIDGET 10
131 #define NS_NATIVE_OPENGL_CONTEXT 12
132 // This is available only with GetNativeData() in parent process. Anybody
133 // shouldn't access this pointer as a valid pointer since the result may be
134 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
135 // an identifier of distinguishing a text composition is caused by which native
136 // IME context. Note that the result is only valid in the process. So,
137 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
138 #define NS_RAW_NATIVE_IME_CONTEXT 14
139 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
140 #ifdef XP_WIN
141 # define NS_NATIVE_TSF_THREAD_MGR 100
142 # define NS_NATIVE_TSF_CATEGORY_MGR 101
143 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
144 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
145 #endif
146 #if defined(MOZ_WIDGET_GTK)
147 # define NS_NATIVE_EGL_WINDOW 106
148 #endif
149 #ifdef MOZ_WIDGET_ANDROID
150 # define NS_JAVA_SURFACE 100
151 #endif
153 #define MOZ_WIDGET_MAX_SIZE 16384
154 #define MOZ_WIDGET_INVALID_SCALE 0.0
156 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
157 #define NS_IWIDGET_IID \
159 0x06396bf6, 0x2dd8, 0x45e5, { \
160 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
165 * Cursor types.
168 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
169 eCursor_standard,
170 ///(system is busy, usually rendered as a hourglass or watch)
171 eCursor_wait,
172 ///(Selecting something, usually rendered as an IBeam)
173 eCursor_select,
174 ///(can hyper-link, usually rendered as a human hand)
175 eCursor_hyperlink,
176 ///(north/south/west/east edge sizing)
177 eCursor_n_resize,
178 eCursor_s_resize,
179 eCursor_w_resize,
180 eCursor_e_resize,
181 ///(corner sizing)
182 eCursor_nw_resize,
183 eCursor_se_resize,
184 eCursor_ne_resize,
185 eCursor_sw_resize,
186 eCursor_crosshair,
187 eCursor_move,
188 eCursor_help,
189 eCursor_copy, // CSS3
190 eCursor_alias,
191 eCursor_context_menu,
192 eCursor_cell,
193 eCursor_grab,
194 eCursor_grabbing,
195 eCursor_spinning,
196 eCursor_zoom_in,
197 eCursor_zoom_out,
198 eCursor_not_allowed,
199 eCursor_col_resize,
200 eCursor_row_resize,
201 eCursor_no_drop,
202 eCursor_vertical_text,
203 eCursor_all_scroll,
204 eCursor_nesw_resize,
205 eCursor_nwse_resize,
206 eCursor_ns_resize,
207 eCursor_ew_resize,
208 eCursor_none,
209 // This one is used for array sizing, and so better be the last
210 // one in this list...
211 eCursorCount,
213 // ...except for this one.
214 eCursorInvalid = eCursorCount + 1
217 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
218 eZPlacementBottom = 0, // bottom of the window stack
219 eZPlacementBelow, // just below another widget
220 eZPlacementTop // top of the window stack
224 * Before the OS goes to sleep, this topic is notified.
226 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
229 * After the OS wakes up, this topic is notified.
231 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
234 * Before the OS suspends the current process, this topic is notified. Some
235 * OS will kill processes that are suspended instead of resuming them.
236 * For that reason this topic may be useful to safely close down resources.
238 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
241 * After the current process resumes from being suspended, this topic is
242 * notified.
244 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
247 * When an app(-shell) is activated by the OS, this topic is notified.
248 * Currently, this only happens on Mac OSX.
250 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
252 namespace mozilla::widget {
255 * Size constraints for setting the minimum and maximum size of a widget.
256 * Values are in device pixels.
258 struct SizeConstraints {
259 SizeConstraints()
260 : mMaxSize(MOZ_WIDGET_MAX_SIZE, MOZ_WIDGET_MAX_SIZE),
261 mScale(MOZ_WIDGET_INVALID_SCALE) {}
263 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
264 mozilla::LayoutDeviceIntSize aMaxSize,
265 mozilla::DesktopToLayoutDeviceScale aScale)
266 : mMinSize(aMinSize), mMaxSize(aMaxSize), mScale(aScale) {
267 if (mMaxSize.width > MOZ_WIDGET_MAX_SIZE) {
268 mMaxSize.width = MOZ_WIDGET_MAX_SIZE;
270 if (mMaxSize.height > MOZ_WIDGET_MAX_SIZE) {
271 mMaxSize.height = MOZ_WIDGET_MAX_SIZE;
275 mozilla::LayoutDeviceIntSize mMinSize;
276 mozilla::LayoutDeviceIntSize mMaxSize;
279 * The scale used to convert from desktop to device dimensions.
280 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
282 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
283 * with multi-monitor scaling issues in more complete way across
284 * all widget implementations.
286 mozilla::DesktopToLayoutDeviceScale mScale;
289 struct AutoObserverNotifier {
290 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
291 : mObserver(aObserver), mTopic(aTopic) {}
293 void SkipNotification() { mObserver = nullptr; }
295 uint64_t SaveObserver() {
296 if (!mObserver) {
297 return 0;
299 uint64_t observerId = ++sObserverId;
300 sSavedObservers.InsertOrUpdate(observerId, mObserver);
301 SkipNotification();
302 return observerId;
305 ~AutoObserverNotifier() {
306 if (mObserver) {
307 mObserver->Observe(nullptr, mTopic, nullptr);
311 static void NotifySavedObserver(const uint64_t& aObserverId,
312 const char* aTopic) {
313 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
314 if (!observer) {
315 MOZ_ASSERT(aObserverId == 0,
316 "We should always find a saved observer for nonzero IDs");
317 return;
320 sSavedObservers.Remove(aObserverId);
321 observer->Observe(nullptr, aTopic, nullptr);
324 private:
325 nsCOMPtr<nsIObserver> mObserver;
326 const char* mTopic;
328 private:
329 static uint64_t sObserverId;
330 static nsTHashMap<uint64_t, nsCOMPtr<nsIObserver>> sSavedObservers;
333 } // namespace mozilla::widget
336 * The base class for all the widgets. It provides the interface for
337 * all basic and necessary functionality.
339 class nsIWidget : public nsISupports {
340 protected:
341 typedef mozilla::dom::BrowserChild BrowserChild;
343 public:
344 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
345 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
346 typedef mozilla::layers::FrameMetrics FrameMetrics;
347 typedef mozilla::layers::LayerManager LayerManager;
348 typedef mozilla::WindowRenderer WindowRenderer;
349 typedef mozilla::layers::LayersBackend LayersBackend;
350 typedef mozilla::layers::LayersId LayersId;
351 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
352 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
353 typedef mozilla::widget::IMEEnabled IMEEnabled;
354 typedef mozilla::widget::IMEMessage IMEMessage;
355 typedef mozilla::widget::IMENotification IMENotification;
356 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
357 typedef mozilla::widget::IMEState IMEState;
358 typedef mozilla::widget::InputContext InputContext;
359 typedef mozilla::widget::InputContextAction InputContextAction;
360 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
361 typedef mozilla::widget::SizeConstraints SizeConstraints;
362 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
363 typedef mozilla::widget::TextEventDispatcherListener
364 TextEventDispatcherListener;
365 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
366 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
367 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
368 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
369 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
370 typedef mozilla::ScreenIntPoint ScreenIntPoint;
371 typedef mozilla::ScreenIntMargin ScreenIntMargin;
372 typedef mozilla::ScreenIntSize ScreenIntSize;
373 typedef mozilla::ScreenPoint ScreenPoint;
374 typedef mozilla::CSSToScreenScale CSSToScreenScale;
375 typedef mozilla::DesktopIntRect DesktopIntRect;
376 typedef mozilla::DesktopPoint DesktopPoint;
377 typedef mozilla::DesktopIntPoint DesktopIntPoint;
378 typedef mozilla::DesktopRect DesktopRect;
379 typedef mozilla::DesktopSize DesktopSize;
380 typedef mozilla::CSSPoint CSSPoint;
381 typedef mozilla::CSSRect CSSRect;
383 using InitData = mozilla::widget::InitData;
384 using WindowType = mozilla::widget::WindowType;
385 using PopupType = mozilla::widget::PopupType;
386 using PopupLevel = mozilla::widget::PopupLevel;
387 using BorderStyle = mozilla::widget::BorderStyle;
388 using TransparencyMode = mozilla::widget::TransparencyMode;
389 using Screen = mozilla::widget::Screen;
391 // Used in UpdateThemeGeometries.
392 struct ThemeGeometry {
393 // The ThemeGeometryType value for the themed widget, see
394 // nsITheme::ThemeGeometryTypeForWidget.
395 nsITheme::ThemeGeometryType mType;
396 // The device-pixel rect within the window for the themed widget
397 LayoutDeviceIntRect mRect;
399 ThemeGeometry(nsITheme::ThemeGeometryType aType,
400 const LayoutDeviceIntRect& aRect)
401 : mType(aType), mRect(aRect) {}
404 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
406 nsIWidget()
407 : mLastChild(nullptr),
408 mPrevSibling(nullptr),
409 mOnDestroyCalled(false),
410 mWindowType(WindowType::Child),
411 mZIndex(0)
414 ClearNativeTouchSequence(nullptr);
418 * Create and initialize a widget.
420 * All the arguments can be null in which case a top level window
421 * with size 0 is created. The event callback function has to be
422 * provided only if the caller wants to deal with the events this
423 * widget receives. The event callback is basically a preprocess
424 * hook called synchronously. The return value determines whether
425 * the event goes to the default window procedure or it is hidden
426 * to the os. The assumption is that if the event handler returns
427 * false the widget does not see the event. The widget should not
428 * automatically clear the window to the background color. The
429 * calling code must handle paint messages and clear the background
430 * itself.
432 * In practice at least one of aParent and aNativeParent will be null. If
433 * both are null the widget isn't parented (e.g. context menus or
434 * independent top level windows).
436 * The dimensions given in aRect are specified in the parent's
437 * device coordinate system.
438 * This must not be called for parentless widgets such as top-level
439 * windows, which use the desktop pixel coordinate system; a separate
440 * method is provided for these.
442 * @param aParent parent nsIWidget
443 * @param aNativeParent native parent widget
444 * @param aRect the widget dimension
445 * @param aInitData data that is used for widget initialization
448 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
449 nsNativeWidget aNativeParent,
450 const LayoutDeviceIntRect& aRect,
451 InitData* = nullptr) = 0;
454 * As above, but with aRect specified in DesktopPixel units (for top-level
455 * widgets).
456 * Default implementation just converts aRect to device pixels and calls
457 * through to device-pixel Create, but platforms may override this if the
458 * mapping is not straightforward or the native platform needs to use the
459 * desktop pixel values directly.
461 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
462 nsNativeWidget aNativeParent,
463 const DesktopIntRect& aRect,
464 InitData* aInitData = nullptr) {
465 LayoutDeviceIntRect devPixRect =
466 RoundedToInt(aRect * GetDesktopToDeviceScale());
467 return Create(aParent, aNativeParent, devPixRect, aInitData);
471 * Allocate, initialize, and return a widget that is a child of
472 * |this|. The returned widget (if nonnull) has gone through the
473 * equivalent of CreateInstance(widgetCID) + Create(...).
475 * |CreateChild()| lets widget backends decide whether to parent
476 * the new child widget to this, nonnatively parent it, or both.
477 * This interface exists to support the PuppetWidget backend,
478 * which is entirely non-native. All other params are the same as
479 * for |Create()|.
481 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
482 * |nsIWidget*| this, not its native widget (if it exists), when
483 * calling |Create()|. This is a timid hack around poorly
484 * understood code, and shouldn't be used in new code.
486 virtual already_AddRefed<nsIWidget> CreateChild(
487 const LayoutDeviceIntRect& aRect, InitData* = nullptr,
488 bool aForceUseIWidgetParent = false) = 0;
491 * Attach to a top level widget.
493 * In cases where a top level chrome widget is being used as a content
494 * container, attach a secondary listener and update the device
495 * context. The primary widget listener will continue to be called for
496 * notifications relating to the top-level window, whereas other
497 * notifications such as painting and events will instead be called via
498 * the attached listener. SetAttachedWidgetListener should be used to
499 * assign the attached listener.
501 * aUseAttachedEvents if true, events are sent to the attached listener
502 * instead of the normal listener.
504 virtual void AttachViewToTopLevel(bool aUseAttachedEvents) = 0;
507 * Accessor functions to get and set the attached listener. Used by
508 * nsView in connection with AttachViewToTopLevel above.
510 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
511 virtual nsIWidgetListener* GetAttachedWidgetListener() const = 0;
512 virtual void SetPreviouslyAttachedWidgetListener(
513 nsIWidgetListener* aListener) = 0;
514 virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() = 0;
517 * Notifies the root widget of a non-blank paint.
519 virtual void DidGetNonBlankPaint() {}
522 * Accessor functions to get and set the listener which handles various
523 * actions for the widget.
525 //@{
526 virtual nsIWidgetListener* GetWidgetListener() const = 0;
527 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
528 //@}
531 * Close and destroy the internal native window.
532 * This method does not delete the widget.
535 virtual void Destroy() = 0;
538 * Destroyed() returns true if Destroy() has been called already.
539 * Otherwise, false.
541 bool Destroyed() const { return mOnDestroyCalled; }
544 * Reparent a widget
546 * Change the widget's parent. Null parents are allowed.
548 * @param aNewParent new parent
550 virtual void SetParent(nsIWidget* aNewParent) = 0;
553 * Return the parent Widget of this Widget or nullptr if this is a
554 * top level window
556 * @return the parent widget or nullptr if it does not have a parent
559 virtual nsIWidget* GetParent(void) = 0;
562 * Return the top level Widget of this Widget
564 * @return the top level widget
566 virtual nsIWidget* GetTopLevelWidget() = 0;
569 * Return the top (non-sheet) parent of this Widget if it's a sheet,
570 * or nullptr if this isn't a sheet (or some other error occurred).
571 * Sheets are only supported on some platforms (currently only macOS).
573 * @return the top (non-sheet) parent widget or nullptr
576 virtual nsIWidget* GetSheetWindowParent(void) = 0;
579 * Return the physical DPI of the screen containing the window ...
580 * the number of device pixels per inch.
582 virtual float GetDPI() = 0;
585 * Fallback DPI for when there's no widget available.
587 static float GetFallbackDPI();
590 * Return the scaling factor between device pixels and the platform-
591 * dependent "desktop pixels" used to manage window positions on a
592 * potentially multi-screen, mixed-resolution desktop.
594 virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
597 * Return the scaling factor between device pixels and the platform-
598 * dependent "desktop pixels" by looking up the screen by the position
599 * of the widget.
601 virtual mozilla::DesktopToLayoutDeviceScale
602 GetDesktopToDeviceScaleByScreen() = 0;
605 * Return the default scale factor for the window. This is the
606 * default number of device pixels per CSS pixel to use. This should
607 * depend on OS/platform settings such as the Mac's "UI scale factor"
608 * or Windows' "font DPI". This will take into account Gecko preferences
609 * overriding the system setting.
611 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
614 * Fallback default scale for when there's no widget available.
616 static mozilla::CSSToLayoutDeviceScale GetFallbackDefaultScale();
619 * Return the first child of this widget. Will return null if
620 * there are no children.
622 nsIWidget* GetFirstChild() const { return mFirstChild; }
625 * Return the last child of this widget. Will return null if
626 * there are no children.
628 nsIWidget* GetLastChild() const { return mLastChild; }
631 * Return the next sibling of this widget
633 nsIWidget* GetNextSibling() const { return mNextSibling; }
636 * Set the next sibling of this widget
638 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
641 * Return the previous sibling of this widget
643 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
646 * Set the previous sibling of this widget
648 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
651 * Show or hide this widget
653 * @param aState true to show the Widget, false to hide it
656 virtual void Show(bool aState) = 0;
659 * Whether or not a widget must be recreated after being hidden to show
660 * again properly.
662 virtual bool NeedsRecreateToReshow() { return false; }
665 * Make the window modal.
667 virtual void SetModal(bool aModal) = 0;
670 * Make the non-modal window opened by modal window fake-modal, that will
671 * call SetFakeModal(false) on destroy on Cocoa.
673 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
676 * Are we app modal. Currently only implemented on Cocoa.
678 virtual bool IsRunningAppModal() { return false; }
681 * The maximum number of simultaneous touch contacts supported by the device.
682 * In the case of devices with multiple digitizers (e.g. multiple touch
683 * screens), the value will be the maximum of the set of maximum supported
684 * contacts by each individual digitizer.
686 virtual uint32_t GetMaxTouchPoints() const = 0;
689 * Returns whether the window is visible
692 virtual bool IsVisible() const = 0;
695 * Returns whether the window has allocated resources so
696 * we can paint into it.
697 * Recently it's used on Linux/Gtk where we should not paint
698 * to invisible window.
700 virtual bool IsMapped() const { return true; }
703 * Perform platform-dependent sanity check on a potential window position.
704 * This is guaranteed to work only for top-level windows.
706 virtual void ConstrainPosition(DesktopIntPoint&) = 0;
709 * NOTE:
711 * For a top-level window widget, the "parent's coordinate system" is the
712 * "global" display pixel coordinate space, *not* device pixels (which
713 * may be inconsistent between multiple screens, at least in the Mac OS
714 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
715 * following Move and Resize widget APIs.
717 * The display-/device-pixel distinction becomes important for (at least)
718 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
719 * is set to other than 100%.
721 * The Move and Resize methods take floating-point parameters, rather than
722 * integer ones. This is important when manipulating top-level widgets,
723 * where the coordinate system may not be an integral multiple of the
724 * device-pixel space.
728 * Move this widget.
730 * Coordinates refer to the top-left of the widget. For toplevel windows
731 * with decorations, this is the top-left of the titlebar and frame .
733 * @param aX the new x position expressed in the parent's coordinate system
734 * @param aY the new y position expressed in the parent's coordinate system
737 virtual void Move(double aX, double aY) = 0;
740 * Reposition this widget so that the client area has the given offset.
742 * @param aOffset the new offset of the client area expressed as an
743 * offset from the origin of the client area of the parent
744 * widget (for root widgets and popup widgets it is in
745 * screen coordinates)
747 virtual void MoveClient(const DesktopPoint& aOffset) = 0;
750 * Resize this widget. Any size constraints set for the window by a
751 * previous call to SetSizeConstraints will be applied.
753 * @param aWidth the new width expressed in the parent's coordinate system
754 * @param aHeight the new height expressed in the parent's coordinate
755 * system
756 * @param aRepaint whether the widget should be repainted
758 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
761 * Lock the aspect ratio of a Window
763 * @param aShouldLock bool
766 virtual void LockAspectRatio(bool aShouldLock){};
769 * Move or resize this widget. Any size constraints set for the window by
770 * a previous call to SetSizeConstraints will be applied.
772 * @param aX the new x position expressed in the parent's coordinate
773 * system
774 * @param aY the new y position expressed in the parent's coordinate
775 * system
776 * @param aWidth the new width expressed in the parent's coordinate system
777 * @param aHeight the new height expressed in the parent's coordinate
778 * system
779 * @param aRepaint whether the widget should be repainted if the size
780 * changes
783 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
784 bool aRepaint) = 0;
786 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
787 return mozilla::Nothing();
791 * Resize the widget so that the inner client area has the given size.
793 * @param aSize the new size of the client area.
794 * @param aRepaint whether the widget should be repainted
796 virtual void ResizeClient(const DesktopSize& aSize, bool aRepaint) = 0;
799 * Resize and reposition the widget so tht inner client area has the given
800 * offset and size.
802 * @param aRect the new offset and size of the client area. The offset is
803 * expressed as an offset from the origin of the client area
804 * of the parent widget (for root widgets and popup widgets it
805 * is in screen coordinates).
806 * @param aRepaint whether the widget should be repainted
808 virtual void ResizeClient(const DesktopRect& aRect, bool aRepaint) = 0;
811 * Sets the widget's z-index.
813 virtual void SetZIndex(int32_t aZIndex) = 0;
816 * Gets the widget's z-index.
818 int32_t GetZIndex() { return mZIndex; }
821 * Position this widget just behind the given widget. (Used to
822 * control z-order for top-level widgets. Get/SetZIndex by contrast
823 * control z-order for child widgets of other widgets.)
824 * @param aPlacement top, bottom, or below a widget
825 * (if top or bottom, param aWidget is ignored)
826 * @param aWidget widget to place this widget behind
827 * (only if aPlacement is eZPlacementBelow).
828 * null is equivalent to aPlacement of eZPlacementTop
829 * @param aActivate true to activate the widget after placing it
831 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
832 nsIWidget* aWidget, bool aActivate) = 0;
835 * Minimize, maximize or normalize the window size.
836 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
838 virtual void SetSizeMode(nsSizeMode aMode) = 0;
840 virtual void GetWorkspaceID(nsAString& workspaceID) = 0;
842 virtual void MoveToWorkspace(const nsAString& workspaceID) = 0;
845 * Suppress animations that are applied to a window by OS.
847 virtual void SuppressAnimation(bool aSuppress) {}
850 * Return size mode (minimized, maximized, normalized).
851 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
853 virtual nsSizeMode SizeMode() = 0;
856 * Ask whether the window is tiled.
858 virtual bool IsTiled() const = 0;
861 * Ask wether the widget is fully occluded
863 virtual bool IsFullyOccluded() const = 0;
866 * Enable or disable this Widget
868 * @param aState true to enable the Widget, false to disable it.
870 virtual void Enable(bool aState) = 0;
873 * Ask whether the widget is enabled
875 virtual bool IsEnabled() const = 0;
878 * Whether we should request activation of this widget's toplevel window.
880 enum class Raise {
882 Yes,
886 * Request activation of this window or give focus to this widget.
888 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
891 * Get this widget's outside dimensions relative to its parent widget. For
892 * popup widgets the returned rect is in screen coordinates and not
893 * relative to its parent widget.
895 * @return the x, y, width and height of this widget.
897 virtual LayoutDeviceIntRect GetBounds() = 0;
900 * Get this widget's outside dimensions in device coordinates. This
901 * includes any title bar on the window.
903 * @return the x, y, width and height of this widget.
905 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
908 * Similar to GetScreenBounds except that this function will always
909 * get the size when the widget is in the nsSizeMode_Normal size mode
910 * even if the current size mode is not nsSizeMode_Normal.
911 * This method will fail if the size mode is not nsSizeMode_Normal and
912 * the platform doesn't have the ability.
913 * This method will always succeed if the current size mode is
914 * nsSizeMode_Normal.
916 * @param aRect On return it holds the x, y, width and height of
917 * this widget.
919 [[nodiscard]] virtual nsresult GetRestoredBounds(
920 LayoutDeviceIntRect& aRect) = 0;
923 * Get this widget's client area bounds, if the window has a 3D border
924 * appearance this returns the area inside the border. The position is the
925 * position of the client area relative to the client area of the parent
926 * widget (for root widgets and popup widgets it is in screen coordinates).
928 * @return the x, y, width and height of the client area of this widget.
930 virtual LayoutDeviceIntRect GetClientBounds() = 0;
933 * Sets the non-client area dimensions of the window. Pass -1 to restore
934 * the system default frame size for that border. Pass zero to remove
935 * a border, or pass a specific value adjust a border. Units are in
936 * pixels. (DPI dependent)
938 * Platform notes:
939 * Windows: shrinking top non-client height will remove application
940 * icon and window title text. Glass desktops will refuse to set
941 * dimensions between zero and size < system default.
943 virtual nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) = 0;
946 * Sets the region around the edges of the window that can be dragged to
947 * resize the window. All four sides of the window will get the same margin.
949 virtual void SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) = 0;
951 * Get the client offset from the window origin.
953 * @return the x and y of the offset.
955 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
958 * Returns the slop from the screen edges in device pixels.
959 * @see Window.screenEdgeSlop{X,Y}
961 virtual LayoutDeviceIntPoint GetScreenEdgeSlop() { return {}; }
964 * Equivalent to GetClientBounds but only returns the size.
966 virtual LayoutDeviceIntSize GetClientSize() {
967 // Depending on the backend, overloading this method may be useful if
968 // requesting the client offset is expensive.
969 return GetClientBounds().Size();
973 * Set the background color for this widget
975 * @param aColor the new background color
979 virtual void SetBackgroundColor(const nscolor& aColor) {}
982 * If a cursor type is currently cached locally for this widget, clear the
983 * cached cursor to force an update on the next SetCursor call.
986 virtual void ClearCachedCursor() = 0;
988 struct Cursor {
989 // The system cursor chosen by the page. This is used if there's no custom
990 // cursor, or if we fail to use the custom cursor in some way (if the image
991 // fails to load, for example).
992 nsCursor mDefaultCursor = eCursor_standard;
993 // May be null, to represent no custom cursor image.
994 nsCOMPtr<imgIContainer> mContainer;
995 uint32_t mHotspotX = 0;
996 uint32_t mHotspotY = 0;
997 mozilla::ImageResolution mResolution;
999 bool IsCustom() const { return !!mContainer; }
1001 bool operator==(const Cursor& aOther) const {
1002 return mDefaultCursor == aOther.mDefaultCursor &&
1003 mContainer.get() == aOther.mContainer.get() &&
1004 mHotspotX == aOther.mHotspotX && mHotspotY == aOther.mHotspotY &&
1005 mResolution == aOther.mResolution;
1008 bool operator!=(const Cursor& aOther) const { return !(*this == aOther); }
1012 * Sets the cursor for this widget.
1014 virtual void SetCursor(const Cursor&) = 0;
1016 static nsIntSize CustomCursorSize(const Cursor&);
1019 * Get the window type of this widget.
1021 WindowType GetWindowType() const { return mWindowType; }
1024 * Set the transparency mode of the top-level window containing this widget.
1025 * So, e.g., if you call this on the widget for an IFRAME, the top level
1026 * browser window containing the IFRAME actually gets set. Be careful.
1028 * This can fail if the platform doesn't support
1029 * transparency/glass. By default widgets are not
1030 * transparent. This will also fail if the toplevel window is not
1031 * a Mozilla window, e.g., if the widget is in an embedded
1032 * context.
1034 * After transparency/glass has been enabled, the initial alpha channel
1035 * value for all pixels is 1, i.e., opaque.
1036 * If the window is resized then the alpha channel values for
1037 * all pixels are reset to 1.
1038 * Pixel RGB color values are already premultiplied with alpha channel values.
1040 virtual void SetTransparencyMode(TransparencyMode aMode) = 0;
1043 * Get the transparency mode of the top-level window that contains this
1044 * widget.
1046 virtual TransparencyMode GetTransparencyMode() = 0;
1049 * Set the shadow style of the window.
1051 * Ignored on child widgets and on non-Mac platforms.
1053 virtual void SetWindowShadowStyle(mozilla::WindowShadow aStyle) = 0;
1056 * Set the opacity of the window.
1057 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1059 * Ignored on child widgets and on non-Mac platforms.
1061 virtual void SetWindowOpacity(float aOpacity) {}
1064 * Set the transform of the window. Values are in device pixels,
1065 * the origin is the top left corner of the window.
1067 * Ignored on child widgets and on non-Mac platforms.
1069 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1072 * Set the preferred color-scheme for the widget.
1073 * Ignored on non-Mac platforms.
1075 virtual void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) {}
1078 * Set whether the window should ignore mouse events or not, and if it should
1079 * not, what input margin should it use.
1081 * This is only used on popup windows. The margin is only implemented on
1082 * Linux.
1084 struct InputRegion {
1085 bool mFullyTransparent = false;
1086 mozilla::LayoutDeviceIntCoord mMargin = 0;
1088 virtual void SetInputRegion(const InputRegion&) {}
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<Screen> 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 LayerManager is
1205 * what gets rendered to the widget.
1207 * Note that this tries to create a renderer if it doesn't exist.
1209 virtual WindowRenderer* GetWindowRenderer() = 0;
1212 * Returns whether there's an existing window renderer.
1214 virtual bool HasWindowRenderer() const = 0;
1217 * Called before each layer manager transaction to allow any preparation
1218 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1220 * Always called on the main thread.
1222 virtual void PrepareWindowEffects() = 0;
1225 * Called when Gecko knows which themed widgets exist in this window.
1226 * The passed array contains an entry for every themed widget of the right
1227 * type (currently only StyleAppearance::Toolbar) within the window, except
1228 * for themed widgets which are transformed or have effects applied to them
1229 * (e.g. CSS opacity or filters).
1230 * This could sometimes be called during display list construction
1231 * outside of painting.
1232 * If called during painting, it will be called before we actually
1233 * paint anything.
1235 virtual void UpdateThemeGeometries(
1236 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1239 * Informs the widget about the region of the window that is opaque.
1241 * @param aOpaqueRegion the region of the window that is opaque.
1243 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1246 * Informs the widget about the region of the window that is draggable.
1248 virtual void UpdateWindowDraggingRegion(
1249 const LayoutDeviceIntRegion& aRegion) {}
1252 * Tells the widget whether the given input block results in a swipe.
1253 * Should be called in response to a WidgetWheelEvent that has
1254 * mFlags.mCanTriggerSwipe set on it.
1256 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1259 * Internal methods
1262 //@{
1263 virtual void AddChild(nsIWidget* aChild) = 0;
1264 virtual void RemoveChild(nsIWidget* aChild) = 0;
1265 virtual void* GetNativeData(uint32_t aDataType) = 0;
1266 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1268 //@}
1271 * Set the widget's title.
1272 * Must be called after Create.
1274 * @param aTitle string displayed as the title of the widget
1276 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1279 * Set the widget's icon.
1280 * Must be called after Create.
1282 * @param aIconSpec string specifying the icon to use; convention is to
1283 * pass a resource: URL from which a platform-dependent
1284 * resource file name will be constructed
1286 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1289 * Return this widget's origin in screen coordinates.
1291 * @return screen coordinates stored in the x,y members
1293 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1296 * The same as WidgetToScreenOffset(), except in the case of
1297 * PuppetWidget where this method omits the chrome offset.
1299 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1300 return WidgetToScreenOffset();
1304 * For a PuppetWidget, returns the transform from the coordinate
1305 * space of the PuppetWidget to the coordinate space of the
1306 * top-level native widget.
1308 * Identity transform in other cases.
1310 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1311 WidgetToTopLevelWidgetTransform() {
1312 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1315 mozilla::LayoutDeviceIntPoint WidgetToTopLevelWidgetOffset() {
1316 return mozilla::LayoutDeviceIntPoint::Round(
1317 WidgetToTopLevelWidgetTransform().TransformPoint(
1318 mozilla::LayoutDevicePoint()));
1322 * Returns the margins that are applied to go from client sizes to window
1323 * sizes (which includes window borders and titlebar).
1324 * This method should work even when the window is not yet visible.
1326 virtual LayoutDeviceIntMargin ClientToWindowMargin() { return {}; }
1328 LayoutDeviceIntSize ClientToWindowSizeDifference();
1331 * Dispatches an event to the widget
1333 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1334 nsEventStatus& aStatus) = 0;
1337 * Dispatches an event to APZ only.
1338 * No-op in the child process.
1340 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1343 * Dispatch a gecko event for this widget.
1344 * Returns true if it's consumed. Otherwise, false.
1346 virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event) = 0;
1348 // A structure that groups the statuses from APZ dispatch and content
1349 // dispatch.
1350 struct ContentAndAPZEventStatus {
1351 // Either of these may not be set if the event was not dispatched
1352 // to APZ or to content.
1353 nsEventStatus mApzStatus = nsEventStatus_eIgnore;
1354 nsEventStatus mContentStatus = nsEventStatus_eIgnore;
1358 * Dispatches an event that must be handled by APZ first, when APZ is
1359 * enabled. If invoked in the child process, it is forwarded to the
1360 * parent process synchronously.
1362 virtual ContentAndAPZEventStatus DispatchInputEvent(
1363 mozilla::WidgetInputEvent* aEvent) = 0;
1366 * Confirm an APZ-aware event target. This should be used when APZ will
1367 * not need a layers update to process the event.
1369 virtual void SetConfirmedTargetAPZC(
1370 uint64_t aInputBlockId,
1371 const nsTArray<ScrollableLayerGuid>& aTargets) const = 0;
1374 * Returns true if APZ is in use, false otherwise.
1376 virtual bool AsyncPanZoomEnabled() const = 0;
1380 virtual void SwipeFinished() = 0;
1383 * Enables the dropping of files to a widget.
1385 virtual void EnableDragDrop(bool aEnable) = 0;
1386 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1389 * Classify the window for the window manager. Mostly for X11.
1391 * @param xulWinType The window type. Characters other than [A-Za-z0-9_-] are
1392 * converted to '_'. Anything before the first colon is
1393 * assigned to name, anything after it to role. If there's
1394 * no colon, assign the whole thing to both role and name.
1396 * @param xulWinClass The window class. If set, overrides the normal value.
1397 * Otherwise, the program class it used.
1399 * @param xulWinName The window name. If set, overrides the value specified in
1400 * window type. Otherwise, name from window type is used.
1403 virtual void SetWindowClass(const nsAString& xulWinType,
1404 const nsAString& xulWinClass,
1405 const nsAString& xulWinName) = 0;
1408 * Enables/Disables system capture of any and all events that would cause a
1409 * popup to be rolled up. aListener should be set to a non-null value for
1410 * any popups that are not managed by the popup manager.
1411 * @param aDoCapture true enables capture, false disables capture
1414 virtual void CaptureRollupEvents(bool aDoCapture) = 0;
1417 * Bring this window to the user's attention. This is intended to be a more
1418 * gentle notification than popping the window to the top or putting up an
1419 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1420 * the Mac. The notification should be suppressed if the window is already
1421 * in the foreground and should be dismissed when the user brings this window
1422 * to the foreground.
1423 * @param aCycleCount Maximum number of times to animate the window per system
1424 * conventions. If set to -1, cycles indefinitely until
1425 * window is brought into the foreground.
1427 [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) = 0;
1430 * Ask whether there user input events pending. All input events are
1431 * included, including those not targeted at this nsIwidget instance.
1433 virtual bool HasPendingInputEvent() = 0;
1436 * Determine whether the widget shows a resize widget. If it does,
1437 * aResizerRect returns the resizer's rect.
1439 * Returns false on any platform that does not support it.
1441 * @param aResizerRect The resizer's rect in device pixels.
1442 * @return Whether a resize widget is shown.
1444 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1446 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1447 // EnumSet class.
1448 enum Modifiers : uint32_t {
1449 NO_MODIFIERS = 0x00000000,
1450 CAPS_LOCK = 0x00000001, // when CapsLock is active
1451 NUM_LOCK = 0x00000002, // when NumLock is active
1452 SHIFT_L = 0x00000100,
1453 SHIFT_R = 0x00000200,
1454 CTRL_L = 0x00000400,
1455 CTRL_R = 0x00000800,
1456 ALT_L = 0x00001000, // includes Option
1457 ALT_R = 0x00002000,
1458 COMMAND_L = 0x00004000,
1459 COMMAND_R = 0x00008000,
1460 HELP = 0x00010000,
1461 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1462 // AltRight key behavior of keyboard
1463 // layouts which maps AltGr to AltRight
1464 // key.
1465 FUNCTION = 0x00100000,
1466 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1469 * Utility method intended for testing. Dispatches native key events
1470 * to this widget to simulate the press and release of a key.
1471 * @param aNativeKeyboardLayout a *platform-specific* constant.
1472 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1473 * On Windows, it is converted to a hex string and passed to
1474 * LoadKeyboardLayout, see
1475 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1476 * @param aNativeKeyCode a *platform-specific* keycode.
1477 * On Windows, this is the virtual key code.
1478 * @param aModifiers some combination of the above 'Modifiers' flags;
1479 * not all flags will apply to all platforms. Mac ignores the _R
1480 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1481 * FUNCTION.
1482 * @param aCharacters characters that the OS would decide to generate
1483 * from the event. On Windows, this is the charCode passed by
1484 * WM_CHAR.
1485 * @param aUnmodifiedCharacters characters that the OS would decide
1486 * to generate from the event if modifier keys (other than shift)
1487 * were assumed inactive. Needed on Mac, ignored on Windows.
1488 * @param aObserver the observer that will get notified once the events
1489 * have been dispatched.
1490 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1491 * layout is not supported and the event was not fired
1493 virtual nsresult SynthesizeNativeKeyEvent(
1494 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1495 uint32_t aModifierFlags, const nsAString& aCharacters,
1496 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1499 * Utility method intended for testing. Dispatches native mouse events
1500 * may even move the mouse cursor. On Mac the events are guaranteed to
1501 * be sent to the window containing this widget, but on Windows they'll go
1502 * to whatever's topmost on the screen at that position, so for
1503 * cross-platform testing ensure that your window is at the top of the
1504 * z-order.
1505 * @param aPoint screen location of the mouse, in device
1506 * pixels, with origin at the top left
1507 * @param aNativeMessage abstract native message.
1508 * @param aButton Mouse button defined by DOM UI Events.
1509 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1510 * FYI: On Windows, Android and Headless widget on all
1511 * platroms, this hasn't been handled yet.
1512 * @param aObserver the observer that will get notified once the events
1513 * have been dispatched.
1515 enum class NativeMouseMessage : uint32_t {
1516 ButtonDown, // button down
1517 ButtonUp, // button up
1518 Move, // mouse cursor move
1519 EnterWindow, // mouse cursor comes into a window
1520 LeaveWindow, // mouse cursor leaves from a window
1522 virtual nsresult SynthesizeNativeMouseEvent(
1523 LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
1524 mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
1525 nsIObserver* aObserver) = 0;
1528 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1529 * message. aPoint is location in device pixels to which the mouse pointer
1530 * moves to.
1531 * @param aObserver the observer that will get notified once the events
1532 * have been dispatched.
1534 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1535 nsIObserver* aObserver) = 0;
1538 * Utility method intended for testing. Dispatching native mouse scroll
1539 * events may move the mouse cursor.
1541 * @param aPoint Mouse cursor position in screen coordinates.
1542 * In device pixels, the origin at the top left of
1543 * the primary display.
1544 * @param aNativeMessage Platform native message.
1545 * @param aDeltaX The delta value for X direction. If the native
1546 * message doesn't indicate X direction scrolling,
1547 * this may be ignored.
1548 * @param aDeltaY The delta value for Y direction. If the native
1549 * message doesn't indicate Y direction scrolling,
1550 * this may be ignored.
1551 * @param aDeltaZ The delta value for Z direction. If the native
1552 * message doesn't indicate Z direction scrolling,
1553 * this may be ignored.
1554 * @param aModifierFlags Must be values of Modifiers, or zero.
1555 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1556 * document.
1557 * @param aObserver The observer that will get notified once the
1558 * events have been dispatched.
1560 virtual nsresult SynthesizeNativeMouseScrollEvent(
1561 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1562 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1563 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1566 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1567 * touch states in nsIDOMWindowUtils.idl.
1569 enum TouchPointerState {
1570 // The pointer is in a hover state above the digitizer
1571 TOUCH_HOVER = (1 << 0),
1572 // The pointer is in contact with the digitizer
1573 TOUCH_CONTACT = (1 << 1),
1574 // The pointer has been removed from the digitizer detection area
1575 TOUCH_REMOVE = (1 << 2),
1576 // The pointer has been canceled. Will cancel any pending os level
1577 // gestures that would triggered as a result of completion of the
1578 // input sequence. This may not cancel moz platform related events
1579 // that might get tirggered by input already delivered.
1580 TOUCH_CANCEL = (1 << 3),
1582 // ALL_BITS used for validity checking during IPC serialization
1583 ALL_BITS = (1 << 4) - 1
1586 * TouchpadGesturePhase states for SynthesizeNativeTouchPadPinch and
1587 * SynthesizeNativeTouchpadPan. Match phase states in nsIDOMWindowUtils.idl.
1589 enum TouchpadGesturePhase {
1590 PHASE_BEGIN = 0,
1591 PHASE_UPDATE = 1,
1592 PHASE_END = 2
1595 * Create a new or update an existing touch pointer on the digitizer.
1596 * To trigger os level gestures, individual touch points should
1597 * transition through a complete set of touch states which should be
1598 * sent as individual messages.
1600 * @param aPointerId The touch point id to create or update.
1601 * @param aPointerState one or more of the touch states listed above
1602 * @param aPoint coords of this event
1603 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1604 * @param aOrientation 0 -> 359 degree value indicating the
1605 * orientation of the pointer. Use 90 for normal taps.
1606 * @param aObserver The observer that will get notified once the events
1607 * have been dispatched.
1609 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1610 TouchPointerState aPointerState,
1611 LayoutDeviceIntPoint aPoint,
1612 double aPointerPressure,
1613 uint32_t aPointerOrientation,
1614 nsIObserver* aObserver) = 0;
1616 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1618 virtual nsresult SynthesizeNativeTouchPadPinch(
1619 TouchpadGesturePhase aEventPhase, float aScale,
1620 LayoutDeviceIntPoint aPoint, int32_t aModifierFlags) = 0;
1623 * Helper for simulating a simple tap event with one touch point. When
1624 * aLongTap is true, simulates a native long tap with a duration equal to
1625 * ui.click_hold_context_menus.delay. This pref is compatible with the
1626 * apzc long tap duration. Defaults to 1.5 seconds.
1627 * @param aObserver The observer that will get notified once the events
1628 * have been dispatched.
1630 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1631 bool aLongTap,
1632 nsIObserver* aObserver);
1634 virtual nsresult SynthesizeNativePenInput(uint32_t aPointerId,
1635 TouchPointerState aPointerState,
1636 LayoutDeviceIntPoint aPoint,
1637 double aPressure,
1638 uint32_t aRotation, int32_t aTiltX,
1639 int32_t aTiltY, int32_t aButton,
1640 nsIObserver* aObserver) = 0;
1643 * Cancels all active simulated touch input points and pending long taps.
1644 * Native widgets should track existing points such that they can clear the
1645 * digitizer state when this call is made.
1646 * @param aObserver The observer that will get notified once the touch
1647 * sequence has been cleared.
1649 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1652 * Send a native event as if the user double tapped the touchpad with two
1653 * fingers.
1655 virtual nsresult SynthesizeNativeTouchpadDoubleTap(
1656 LayoutDeviceIntPoint aPoint, uint32_t aModifierFlags) = 0;
1659 * See nsIDOMWindowUtils.sendNativeTouchpadPan().
1661 virtual nsresult SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase,
1662 LayoutDeviceIntPoint aPoint,
1663 double aDeltaX, double aDeltaY,
1664 int32_t aModifierFlags,
1665 nsIObserver* aObserver) = 0;
1667 virtual void StartAsyncScrollbarDrag(
1668 const AsyncDragMetrics& aDragMetrics) = 0;
1671 * Notify APZ to start autoscrolling.
1672 * @param aAnchorLocation the location of the autoscroll anchor
1673 * @param aGuid identifies the scroll frame to be autoscrolled
1674 * @return true if APZ has been successfully notified
1676 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1677 const ScrollableLayerGuid& aGuid) = 0;
1680 * Notify APZ to stop autoscrolling.
1681 * @param aGuid identifies the scroll frame which is being autoscrolled.
1683 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid& aGuid) = 0;
1685 virtual LayersId GetRootLayerTreeId() = 0;
1687 // If this widget supports out-of-process compositing, it can override
1688 // this method to provide additional information to the compositor.
1689 virtual void GetCompositorWidgetInitData(
1690 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1693 * Setter/Getter of the system font setting for testing.
1695 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1696 return NS_ERROR_NOT_IMPLEMENTED;
1698 virtual nsresult GetSystemFont(nsCString& aFontName) {
1699 return NS_ERROR_NOT_IMPLEMENTED;
1703 * Wayland specific routines.
1705 virtual LayoutDeviceIntSize GetMoveToRectPopupSize() const {
1706 NS_WARNING("GetLayoutPopupRect implemented only for wayland");
1707 return LayoutDeviceIntSize();
1711 * If this widget uses native pointer lock instead of warp-to-center
1712 * (currently only GTK on Wayland), these methods provide access to that
1713 * functionality.
1715 virtual void SetNativePointerLockCenter(
1716 const LayoutDeviceIntPoint& aLockCenter) {}
1717 virtual void LockNativePointer() {}
1718 virtual void UnlockNativePointer() {}
1721 * Get safe area insets except to cutout.
1722 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1724 virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const {
1725 return mozilla::ScreenIntMargin();
1728 private:
1729 class LongTapInfo {
1730 public:
1731 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1732 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1733 : mPointerId(aPointerId),
1734 mPosition(aPoint),
1735 mDuration(aDuration),
1736 mObserver(aObserver),
1737 mStamp(mozilla::TimeStamp::Now()) {}
1739 int32_t mPointerId;
1740 LayoutDeviceIntPoint mPosition;
1741 mozilla::TimeDuration mDuration;
1742 nsCOMPtr<nsIObserver> mObserver;
1743 mozilla::TimeStamp mStamp;
1746 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1748 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1749 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1751 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1752 nsCOMPtr<nsITimer> mLongTapTimer;
1753 static int32_t sPointerIdCounter;
1755 public:
1757 * If key events have not been handled by content or XBL handlers, they can
1758 * be offered to the system (for custom application shortcuts set in system
1759 * preferences, for example).
1761 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1764 * Activates a native menu item at the position specified by the index
1765 * string. The index string is a string of positive integers separated
1766 * by the "|" (pipe) character. The last integer in the string represents
1767 * the item index in a submenu located using the integers preceding it.
1769 * Example: 1|0|4
1770 * In this string, the first integer represents the top-level submenu
1771 * in the native menu bar. Since the integer is 1, it is the second submeu
1772 * in the native menu bar. Within that, the first item (index 0) is a
1773 * submenu, and we want to activate the 5th item within that submenu.
1775 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1778 * This is used for native menu system testing.
1780 * Updates a native menu at the position specified by the index string.
1781 * The index string is a string of positive integers separated by the "|"
1782 * (pipe) character.
1784 * Example: 1|0|4
1785 * In this string, the first integer represents the top-level submenu
1786 * in the native menu bar. Since the integer is 1, it is the second submeu
1787 * in the native menu bar. Within that, the first item (index 0) is a
1788 * submenu, and we want to update submenu at index 4 within that submenu.
1790 * If this is called with an empty string it forces a full reload of the
1791 * menu system.
1793 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1796 * This is used for testing macOS service menu code.
1798 * @param aResult - the current text selection. Is empty if no selection.
1799 * @return nsresult - whether or not aResult was assigned the selected text.
1801 [[nodiscard]] virtual nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1802 return NS_ERROR_NOT_IMPLEMENTED;
1806 * Notify IME of the specified notification.
1808 * @return If the notification is mouse button event and it's consumed by
1809 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1811 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1814 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1815 * of the widget, in the event that we were not able to observe and respond to
1816 * the initial focus event. This is necessary for the early skeleton UI
1817 * window, which is displayed and receives its initial focus event before we
1818 * can actually respond to it.
1820 virtual void MaybeDispatchInitialFocusEvent() {}
1823 * Notifies the input context changes.
1825 virtual void SetInputContext(const InputContext& aContext,
1826 const InputContextAction& aAction) = 0;
1829 * Get current input context.
1831 virtual InputContext GetInputContext() = 0;
1834 * Get native IME context. This is different from GetNativeData() with
1835 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1836 * process.
1838 virtual NativeIMEContext GetNativeIMEContext() = 0;
1841 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1842 * native (OS-level) event for it. This method allows tests to simulate
1843 * keystrokes that trigger native key bindings (which require a native
1844 * event).
1846 [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
1847 mozilla::WidgetKeyboardEvent& aEvent) = 0;
1850 * Retrieve edit commands when the key combination of aEvent is used
1851 * in platform native applications.
1853 MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
1854 mozilla::NativeKeyBindingsType aType,
1855 const mozilla::WidgetKeyboardEvent& aEvent,
1856 nsTArray<mozilla::CommandInt>& aCommands);
1859 * Retrieves a reference to notification requests of IME. Note that the
1860 * reference is valid while the nsIWidget instance is alive. So, if you
1861 * need to store the reference for a long time, you need to grab the widget
1862 * instance too.
1864 const IMENotificationRequests& IMENotificationRequestsRef();
1867 * Call this method when a dialog is opened which has a default button.
1868 * The button's rectangle should be supplied in aButtonRect.
1870 [[nodiscard]] virtual nsresult OnDefaultButtonLoaded(
1871 const LayoutDeviceIntRect& aButtonRect) = 0;
1874 * Return true if this process shouldn't use platform widgets, and
1875 * so should use PuppetWidgets instead. If this returns true, the
1876 * result of creating and using a platform widget is undefined,
1877 * and likely to end in crashes or other buggy behavior.
1879 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1881 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1883 static already_AddRefed<nsIWidget> CreateChildWindow();
1886 * Allocate and return a "puppet widget" that doesn't directly
1887 * correlate to a platform widget; platform events and data must
1888 * be fed to it. Currently used in content processes. NULL is
1889 * returned if puppet widgets aren't supported in this build
1890 * config, on this platform, or for this process type.
1892 * This function is called "Create" to match CreateInstance().
1893 * The returned widget must still be nsIWidget::Create()d.
1895 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1896 BrowserChild* aBrowserChild);
1898 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1901 * Reparent this widget's native widget.
1902 * @param aNewParent the native widget of aNewParent is the new native
1903 * parent widget
1905 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1908 * Return true if widget has it's own GL context
1910 virtual bool HasGLContext() { return false; }
1913 * Returns true to indicate that this widget paints an opaque background
1914 * that we want to be visible under the page, so layout should not force
1915 * a default background.
1917 virtual bool WidgetPaintsBackground() { return false; }
1919 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1922 * Get the natural bounds of this widget. This method is only
1923 * meaningful for widgets for which Gecko implements screen
1924 * rotation natively. When this is the case, GetBounds() returns
1925 * the widget bounds taking rotation into account, and
1926 * GetNaturalBounds() returns the bounds *not* taking rotation
1927 * into account.
1929 * No code outside of the composition pipeline should know or care
1930 * about this. If you're not an agent of the compositor, you
1931 * probably shouldn't call this method.
1933 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1936 * Set size constraints on the window size such that it is never less than
1937 * the specified minimum size and never larger than the specified maximum
1938 * size. The size constraints are sizes of the outer rectangle including
1939 * the window frame and title bar. Use 0 for an unconstrained minimum size
1940 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1941 * does not necessarily change the size of a window to conform to this size,
1942 * thus Resize should be called afterwards.
1944 * @param aConstraints: the size constraints in device pixels
1946 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1949 * Return the size constraints currently observed by the widget.
1951 * @return the constraints in device pixels
1953 virtual const SizeConstraints GetSizeConstraints() = 0;
1956 * Apply the current size constraints to the given size.
1958 * @param aWidth width to constrain
1959 * @param aHeight height to constrain
1961 virtual void ConstrainSize(int32_t* aWidth, int32_t* aHeight) = 0;
1964 * If this is owned by a BrowserChild, return that. Otherwise return
1965 * null.
1967 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
1970 * If this isn't directly compositing to its window surface,
1971 * return the compositor which is doing that on our behalf.
1973 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
1976 * If there is a remote renderer, pause or resume it.
1978 virtual void PauseOrResumeCompositor(bool aPause);
1981 * Clear WebRender resources
1983 virtual void ClearCachedWebrenderResources() {}
1986 * Clear WebRender animation resources
1988 virtual void ClearWebrenderAnimationResources() {}
1991 * Request fast snapshot at RenderCompositor of WebRender.
1992 * Since readback of Windows DirectComposition is very slow.
1994 virtual bool SetNeedFastSnaphot() { return false; }
1997 * If this widget has its own vsync dispatcher, return it, otherwise return
1998 * nullptr. An example of such a local vsync dispatcher would be Wayland frame
1999 * callbacks.
2001 virtual RefPtr<mozilla::VsyncDispatcher> GetVsyncDispatcher();
2004 * Returns true if the widget requires synchronous repaints on resize,
2005 * false otherwise.
2007 virtual bool SynchronouslyRepaintOnResize() { return true; }
2010 * Some platforms (only cocoa right now) round widget coordinates to the
2011 * nearest even pixels (see bug 892994), this function allows us to
2012 * determine how widget coordinates will be rounded.
2014 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2016 virtual void UpdateZoomConstraints(
2017 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2018 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2021 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2022 * widget. Note that this never returns nullptr.
2024 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2027 * GetNativeTextEventDispatcherListener() returns a
2028 * TextEventDispatcherListener instance which is used when the widget
2029 * instance handles native IME and/or keyboard events.
2031 virtual TextEventDispatcherListener*
2032 GetNativeTextEventDispatcherListener() = 0;
2034 virtual void ZoomToRect(const uint32_t& aPresShellId,
2035 const ScrollableLayerGuid::ViewID& aViewId,
2036 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2039 * LookUpDictionary shows the dictionary for the word around current point.
2041 * @param aText the word to look up dictiorary.
2042 * @param aFontRangeArray text decoration of aText
2043 * @param aIsVertical true if the word is vertical layout
2044 * @param aPoint top-left point of aText
2046 virtual void LookUpDictionary(
2047 const nsAString& aText,
2048 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2049 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2051 virtual void RequestFxrOutput() {
2052 MOZ_ASSERT(false, "This function should only execute in Windows");
2055 #if defined(MOZ_WIDGET_ANDROID)
2057 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2058 * thread.
2060 * @param aMessage message being sent to Android UI thread.
2062 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2065 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2066 * thread
2068 * @param aScrollOffset page scroll offset value in screen pixels.
2069 * @param aZoom current page zoom.
2071 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2072 const CSSToScreenScale& aZoom) = 0;
2075 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2076 * for android robocop tests.
2078 * @param aMem shared memory containing the frame buffer pixels.
2079 * @param aSize size of the buffer in screen pixels.
2081 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2082 const ScreenIntSize& aSize,
2083 bool aNeedsYFlip) = 0;
2085 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2086 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2087 return 0;
2089 #endif
2091 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2094 * Like GetDefaultScale, but taking into account only the system settings
2095 * and ignoring Gecko preferences.
2097 virtual double GetDefaultScaleInternal() { return 1.0; }
2099 using WindowButtonType = mozilla::WindowButtonType;
2102 * Layout uses this to alert the widget to the client rect representing
2103 * the window maximize button. An empty rect indicates there is no
2104 * maximize button (for example, in fullscreen). This is only implemented
2105 * on Windows.
2107 virtual void SetWindowButtonRect(WindowButtonType aButtonType,
2108 const LayoutDeviceIntRect& aClientRect) {}
2110 #ifdef DEBUG
2111 virtual nsresult SetHiDPIMode(bool aHiDPI) {
2112 return NS_ERROR_NOT_IMPLEMENTED;
2114 virtual nsresult RestoreHiDPIMode() { return NS_ERROR_NOT_IMPLEMENTED; }
2115 #endif
2117 protected:
2118 // keep the list of children. We also keep track of our siblings.
2119 // The ownership model is as follows: parent holds a strong ref to
2120 // the first element of the list, and each element holds a strong
2121 // ref to the next element in the list. The prevsibling and
2122 // lastchild pointers are weak, which is fine as long as they are
2123 // maintained properly.
2124 nsCOMPtr<nsIWidget> mFirstChild;
2125 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2126 nsCOMPtr<nsIWidget> mNextSibling;
2127 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2128 // When Destroy() is called, the sub class should set this true.
2129 bool mOnDestroyCalled;
2130 WindowType mWindowType;
2131 int32_t mZIndex;
2134 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2136 #endif // nsIWidget_h__