Bug 1842773 - Part 13: Remove TypedArrayObject::{length,byteLength}Value. r=sfink
[gecko.git] / widget / nsIWidget.h
blob81e952a8c65327bc2ff367790583cae0c3183cf2
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 Panel,
68 Tooltip,
71 #if defined(MOZ_WIDGET_ANDROID)
72 namespace ipc {
73 class Shmem;
75 #endif // defined(MOZ_WIDGET_ANDROID)
76 namespace dom {
77 class BrowserChild;
78 enum class CallerType : uint32_t;
79 } // namespace dom
80 class WindowRenderer;
81 namespace layers {
82 class AsyncDragMetrics;
83 class Compositor;
84 class CompositorBridgeChild;
85 struct FrameMetrics;
86 class LayerManager;
87 class WebRenderBridgeChild;
88 } // namespace layers
89 namespace widget {
90 class TextEventDispatcher;
91 class TextEventDispatcherListener;
92 class CompositorWidget;
93 class CompositorWidgetInitData;
94 class Screen;
95 } // namespace widget
96 namespace wr {
97 class DisplayListBuilder;
98 class IpcResourceUpdateQueue;
99 enum class RenderRoot : uint8_t;
100 } // namespace wr
101 } // namespace mozilla
104 * Callback function that processes events.
106 * The argument is actually a subtype (subclass) of WidgetEvent which carries
107 * platform specific information about the event. Platform specific code
108 * knows how to deal with it.
110 * The return value determines whether or not the default action should take
111 * place.
113 typedef nsEventStatus (*EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
115 // Hide the native window system's real window type so as to avoid
116 // including native window system types and APIs. This is necessary
117 // to ensure cross-platform code.
118 typedef void* nsNativeWidget;
121 * Values for the GetNativeData function
123 #define NS_NATIVE_WINDOW 0
124 #define NS_NATIVE_GRAPHIC 1
125 #define NS_NATIVE_WIDGET 3
126 #define NS_NATIVE_REGION 5
127 #define NS_NATIVE_OFFSETX 6
128 #define NS_NATIVE_OFFSETY 7
129 #define NS_NATIVE_SCREEN 9
130 // The toplevel GtkWidget containing this nsIWidget:
131 #define NS_NATIVE_SHELLWIDGET 10
132 #define NS_NATIVE_OPENGL_CONTEXT 12
133 // This is available only with GetNativeData() in parent process. Anybody
134 // shouldn't access this pointer as a valid pointer since the result may be
135 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
136 // an identifier of distinguishing a text composition is caused by which native
137 // IME context. Note that the result is only valid in the process. So,
138 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
139 #define NS_RAW_NATIVE_IME_CONTEXT 14
140 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
141 #ifdef XP_WIN
142 # define NS_NATIVE_TSF_THREAD_MGR 100
143 # define NS_NATIVE_TSF_CATEGORY_MGR 101
144 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
145 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
146 #endif
147 #if defined(MOZ_WIDGET_GTK)
148 # define NS_NATIVE_EGL_WINDOW 106
149 #endif
150 #ifdef MOZ_WIDGET_ANDROID
151 # define NS_JAVA_SURFACE 100
152 #endif
154 #define MOZ_WIDGET_MAX_SIZE 16384
155 #define MOZ_WIDGET_INVALID_SCALE 0.0
157 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
158 #define NS_IWIDGET_IID \
160 0x06396bf6, 0x2dd8, 0x45e5, { \
161 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
166 * Cursor types.
169 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
170 eCursor_standard,
171 ///(system is busy, usually rendered as a hourglass or watch)
172 eCursor_wait,
173 ///(Selecting something, usually rendered as an IBeam)
174 eCursor_select,
175 ///(can hyper-link, usually rendered as a human hand)
176 eCursor_hyperlink,
177 ///(north/south/west/east edge sizing)
178 eCursor_n_resize,
179 eCursor_s_resize,
180 eCursor_w_resize,
181 eCursor_e_resize,
182 ///(corner sizing)
183 eCursor_nw_resize,
184 eCursor_se_resize,
185 eCursor_ne_resize,
186 eCursor_sw_resize,
187 eCursor_crosshair,
188 eCursor_move,
189 eCursor_help,
190 eCursor_copy, // CSS3
191 eCursor_alias,
192 eCursor_context_menu,
193 eCursor_cell,
194 eCursor_grab,
195 eCursor_grabbing,
196 eCursor_spinning,
197 eCursor_zoom_in,
198 eCursor_zoom_out,
199 eCursor_not_allowed,
200 eCursor_col_resize,
201 eCursor_row_resize,
202 eCursor_no_drop,
203 eCursor_vertical_text,
204 eCursor_all_scroll,
205 eCursor_nesw_resize,
206 eCursor_nwse_resize,
207 eCursor_ns_resize,
208 eCursor_ew_resize,
209 eCursor_none,
210 // This one is used for array sizing, and so better be the last
211 // one in this list...
212 eCursorCount,
214 // ...except for this one.
215 eCursorInvalid = eCursorCount + 1
218 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
219 eZPlacementBottom = 0, // bottom of the window stack
220 eZPlacementBelow, // just below another widget
221 eZPlacementTop // top of the window stack
225 * Before the OS goes to sleep, this topic is notified.
227 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
230 * After the OS wakes up, this topic is notified.
232 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
235 * Before the OS suspends the current process, this topic is notified. Some
236 * OS will kill processes that are suspended instead of resuming them.
237 * For that reason this topic may be useful to safely close down resources.
239 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
242 * After the current process resumes from being suspended, this topic is
243 * notified.
245 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
248 * When an app(-shell) is activated by the OS, this topic is notified.
249 * Currently, this only happens on Mac OSX.
251 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
253 namespace mozilla::widget {
256 * Size constraints for setting the minimum and maximum size of a widget.
257 * Values are in device pixels.
259 struct SizeConstraints {
260 SizeConstraints()
261 : mMaxSize(MOZ_WIDGET_MAX_SIZE, MOZ_WIDGET_MAX_SIZE),
262 mScale(MOZ_WIDGET_INVALID_SCALE) {}
264 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
265 mozilla::LayoutDeviceIntSize aMaxSize,
266 mozilla::DesktopToLayoutDeviceScale aScale)
267 : mMinSize(aMinSize), mMaxSize(aMaxSize), mScale(aScale) {
268 if (mMaxSize.width > MOZ_WIDGET_MAX_SIZE) {
269 mMaxSize.width = MOZ_WIDGET_MAX_SIZE;
271 if (mMaxSize.height > MOZ_WIDGET_MAX_SIZE) {
272 mMaxSize.height = MOZ_WIDGET_MAX_SIZE;
276 mozilla::LayoutDeviceIntSize mMinSize;
277 mozilla::LayoutDeviceIntSize mMaxSize;
280 * The scale used to convert from desktop to device dimensions.
281 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
283 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
284 * with multi-monitor scaling issues in more complete way across
285 * all widget implementations.
287 mozilla::DesktopToLayoutDeviceScale mScale;
290 struct AutoObserverNotifier {
291 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
292 : mObserver(aObserver), mTopic(aTopic) {}
294 void SkipNotification() { mObserver = nullptr; }
296 uint64_t SaveObserver() {
297 if (!mObserver) {
298 return 0;
300 uint64_t observerId = ++sObserverId;
301 sSavedObservers.InsertOrUpdate(observerId, mObserver);
302 SkipNotification();
303 return observerId;
306 ~AutoObserverNotifier() {
307 if (mObserver) {
308 mObserver->Observe(nullptr, mTopic, nullptr);
312 static void NotifySavedObserver(const uint64_t& aObserverId,
313 const char* aTopic) {
314 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
315 if (!observer) {
316 MOZ_ASSERT(aObserverId == 0,
317 "We should always find a saved observer for nonzero IDs");
318 return;
321 sSavedObservers.Remove(aObserverId);
322 observer->Observe(nullptr, aTopic, nullptr);
325 private:
326 nsCOMPtr<nsIObserver> mObserver;
327 const char* mTopic;
329 private:
330 static uint64_t sObserverId;
331 static nsTHashMap<uint64_t, nsCOMPtr<nsIObserver>> sSavedObservers;
334 } // namespace mozilla::widget
337 * The base class for all the widgets. It provides the interface for
338 * all basic and necessary functionality.
340 class nsIWidget : public nsISupports {
341 protected:
342 typedef mozilla::dom::BrowserChild BrowserChild;
344 public:
345 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
346 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
347 typedef mozilla::layers::FrameMetrics FrameMetrics;
348 typedef mozilla::layers::LayerManager LayerManager;
349 typedef mozilla::WindowRenderer WindowRenderer;
350 typedef mozilla::layers::LayersBackend LayersBackend;
351 typedef mozilla::layers::LayersId LayersId;
352 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
353 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
354 typedef mozilla::widget::IMEEnabled IMEEnabled;
355 typedef mozilla::widget::IMEMessage IMEMessage;
356 typedef mozilla::widget::IMENotification IMENotification;
357 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
358 typedef mozilla::widget::IMEState IMEState;
359 typedef mozilla::widget::InputContext InputContext;
360 typedef mozilla::widget::InputContextAction InputContextAction;
361 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
362 typedef mozilla::widget::SizeConstraints SizeConstraints;
363 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
364 typedef mozilla::widget::TextEventDispatcherListener
365 TextEventDispatcherListener;
366 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
367 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
368 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
369 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
370 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
371 typedef mozilla::ScreenIntPoint ScreenIntPoint;
372 typedef mozilla::ScreenIntMargin ScreenIntMargin;
373 typedef mozilla::ScreenIntSize ScreenIntSize;
374 typedef mozilla::ScreenPoint ScreenPoint;
375 typedef mozilla::CSSToScreenScale CSSToScreenScale;
376 typedef mozilla::DesktopIntRect DesktopIntRect;
377 typedef mozilla::DesktopPoint DesktopPoint;
378 typedef mozilla::DesktopIntPoint DesktopIntPoint;
379 typedef mozilla::DesktopRect DesktopRect;
380 typedef mozilla::DesktopSize DesktopSize;
381 typedef mozilla::CSSPoint CSSPoint;
382 typedef mozilla::CSSRect CSSRect;
384 using InitData = mozilla::widget::InitData;
385 using WindowType = mozilla::widget::WindowType;
386 using PopupType = mozilla::widget::PopupType;
387 using PopupLevel = mozilla::widget::PopupLevel;
388 using BorderStyle = mozilla::widget::BorderStyle;
389 using TransparencyMode = mozilla::widget::TransparencyMode;
390 using Screen = mozilla::widget::Screen;
392 // Used in UpdateThemeGeometries.
393 struct ThemeGeometry {
394 // The ThemeGeometryType value for the themed widget, see
395 // nsITheme::ThemeGeometryTypeForWidget.
396 nsITheme::ThemeGeometryType mType;
397 // The device-pixel rect within the window for the themed widget
398 LayoutDeviceIntRect mRect;
400 ThemeGeometry(nsITheme::ThemeGeometryType aType,
401 const LayoutDeviceIntRect& aRect)
402 : mType(aType), mRect(aRect) {}
405 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
407 nsIWidget()
408 : mLastChild(nullptr),
409 mPrevSibling(nullptr),
410 mOnDestroyCalled(false),
411 mWindowType(WindowType::Child),
412 mZIndex(0)
415 ClearNativeTouchSequence(nullptr);
419 * Create and initialize a widget.
421 * All the arguments can be null in which case a top level window
422 * with size 0 is created. The event callback function has to be
423 * provided only if the caller wants to deal with the events this
424 * widget receives. The event callback is basically a preprocess
425 * hook called synchronously. The return value determines whether
426 * the event goes to the default window procedure or it is hidden
427 * to the os. The assumption is that if the event handler returns
428 * false the widget does not see the event. The widget should not
429 * automatically clear the window to the background color. The
430 * calling code must handle paint messages and clear the background
431 * itself.
433 * In practice at least one of aParent and aNativeParent will be null. If
434 * both are null the widget isn't parented (e.g. context menus or
435 * independent top level windows).
437 * The dimensions given in aRect are specified in the parent's
438 * device coordinate system.
439 * This must not be called for parentless widgets such as top-level
440 * windows, which use the desktop pixel coordinate system; a separate
441 * method is provided for these.
443 * @param aParent parent nsIWidget
444 * @param aNativeParent native parent widget
445 * @param aRect the widget dimension
446 * @param aInitData data that is used for widget initialization
449 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
450 nsNativeWidget aNativeParent,
451 const LayoutDeviceIntRect& aRect,
452 InitData* = nullptr) = 0;
455 * As above, but with aRect specified in DesktopPixel units (for top-level
456 * widgets).
457 * Default implementation just converts aRect to device pixels and calls
458 * through to device-pixel Create, but platforms may override this if the
459 * mapping is not straightforward or the native platform needs to use the
460 * desktop pixel values directly.
462 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
463 nsNativeWidget aNativeParent,
464 const DesktopIntRect& aRect,
465 InitData* aInitData = nullptr) {
466 LayoutDeviceIntRect devPixRect =
467 RoundedToInt(aRect * GetDesktopToDeviceScale());
468 return Create(aParent, aNativeParent, devPixRect, aInitData);
472 * Allocate, initialize, and return a widget that is a child of
473 * |this|. The returned widget (if nonnull) has gone through the
474 * equivalent of CreateInstance(widgetCID) + Create(...).
476 * |CreateChild()| lets widget backends decide whether to parent
477 * the new child widget to this, nonnatively parent it, or both.
478 * This interface exists to support the PuppetWidget backend,
479 * which is entirely non-native. All other params are the same as
480 * for |Create()|.
482 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
483 * |nsIWidget*| this, not its native widget (if it exists), when
484 * calling |Create()|. This is a timid hack around poorly
485 * understood code, and shouldn't be used in new code.
487 virtual already_AddRefed<nsIWidget> CreateChild(
488 const LayoutDeviceIntRect& aRect, InitData* = nullptr,
489 bool aForceUseIWidgetParent = false) = 0;
492 * Attach to a top level widget.
494 * In cases where a top level chrome widget is being used as a content
495 * container, attach a secondary listener and update the device
496 * context. The primary widget listener will continue to be called for
497 * notifications relating to the top-level window, whereas other
498 * notifications such as painting and events will instead be called via
499 * the attached listener. SetAttachedWidgetListener should be used to
500 * assign the attached listener.
502 * aUseAttachedEvents if true, events are sent to the attached listener
503 * instead of the normal listener.
505 virtual void AttachViewToTopLevel(bool aUseAttachedEvents) = 0;
508 * Accessor functions to get and set the attached listener. Used by
509 * nsView in connection with AttachViewToTopLevel above.
511 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
512 virtual nsIWidgetListener* GetAttachedWidgetListener() const = 0;
513 virtual void SetPreviouslyAttachedWidgetListener(
514 nsIWidgetListener* aListener) = 0;
515 virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() = 0;
518 * Notifies the root widget of a non-blank paint.
520 virtual void DidGetNonBlankPaint() {}
523 * Accessor functions to get and set the listener which handles various
524 * actions for the widget.
526 //@{
527 virtual nsIWidgetListener* GetWidgetListener() const = 0;
528 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
529 //@}
532 * Close and destroy the internal native window.
533 * This method does not delete the widget.
536 virtual void Destroy() = 0;
539 * Destroyed() returns true if Destroy() has been called already.
540 * Otherwise, false.
542 bool Destroyed() const { return mOnDestroyCalled; }
545 * Reparent a widget
547 * Change the widget's parent. Null parents are allowed.
549 * @param aNewParent new parent
551 virtual void SetParent(nsIWidget* aNewParent) = 0;
554 * Return the parent Widget of this Widget or nullptr if this is a
555 * top level window
557 * @return the parent widget or nullptr if it does not have a parent
560 virtual nsIWidget* GetParent(void) = 0;
563 * Return the top level Widget of this Widget
565 * @return the top level widget
567 virtual nsIWidget* GetTopLevelWidget() = 0;
570 * Return the top (non-sheet) parent of this Widget if it's a sheet,
571 * or nullptr if this isn't a sheet (or some other error occurred).
572 * Sheets are only supported on some platforms (currently only macOS).
574 * @return the top (non-sheet) parent widget or nullptr
577 virtual nsIWidget* GetSheetWindowParent(void) = 0;
580 * Return the physical DPI of the screen containing the window ...
581 * the number of device pixels per inch.
583 virtual float GetDPI() = 0;
586 * Fallback DPI for when there's no widget available.
588 static float GetFallbackDPI();
591 * Return the scaling factor between device pixels and the platform-
592 * dependent "desktop pixels" used to manage window positions on a
593 * potentially multi-screen, mixed-resolution desktop.
595 virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
598 * Return the scaling factor between device pixels and the platform-
599 * dependent "desktop pixels" by looking up the screen by the position
600 * of the widget.
602 virtual mozilla::DesktopToLayoutDeviceScale
603 GetDesktopToDeviceScaleByScreen() = 0;
606 * Return the default scale factor for the window. This is the
607 * default number of device pixels per CSS pixel to use. This should
608 * depend on OS/platform settings such as the Mac's "UI scale factor"
609 * or Windows' "font DPI". This will take into account Gecko preferences
610 * overriding the system setting.
612 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
615 * Fallback default scale for when there's no widget available.
617 static mozilla::CSSToLayoutDeviceScale GetFallbackDefaultScale();
620 * Return the first child of this widget. Will return null if
621 * there are no children.
623 nsIWidget* GetFirstChild() const { return mFirstChild; }
626 * Return the last child of this widget. Will return null if
627 * there are no children.
629 nsIWidget* GetLastChild() const { return mLastChild; }
632 * Return the next sibling of this widget
634 nsIWidget* GetNextSibling() const { return mNextSibling; }
637 * Set the next sibling of this widget
639 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
642 * Return the previous sibling of this widget
644 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
647 * Set the previous sibling of this widget
649 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
652 * Show or hide this widget
654 * @param aState true to show the Widget, false to hide it
657 virtual void Show(bool aState) = 0;
660 * Whether or not a widget must be recreated after being hidden to show
661 * again properly.
663 virtual bool NeedsRecreateToReshow() { return false; }
666 * Make the window modal.
668 virtual void SetModal(bool aModal) = 0;
671 * Make the non-modal window opened by modal window fake-modal, that will
672 * call SetFakeModal(false) on destroy on Cocoa.
674 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
677 * Are we app modal. Currently only implemented on Cocoa.
679 virtual bool IsRunningAppModal() { return false; }
682 * The maximum number of simultaneous touch contacts supported by the device.
683 * In the case of devices with multiple digitizers (e.g. multiple touch
684 * screens), the value will be the maximum of the set of maximum supported
685 * contacts by each individual digitizer.
687 virtual uint32_t GetMaxTouchPoints() const = 0;
690 * Returns whether the window is visible
693 virtual bool IsVisible() const = 0;
696 * Returns whether the window has allocated resources so
697 * we can paint into it.
698 * Recently it's used on Linux/Gtk where we should not paint
699 * to invisible window.
701 virtual bool IsMapped() const { return true; }
704 * Perform platform-dependent sanity check on a potential window position.
705 * This is guaranteed to work only for top-level windows.
707 virtual void ConstrainPosition(DesktopIntPoint&) = 0;
710 * NOTE:
712 * For a top-level window widget, the "parent's coordinate system" is the
713 * "global" display pixel coordinate space, *not* device pixels (which
714 * may be inconsistent between multiple screens, at least in the Mac OS
715 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
716 * following Move and Resize widget APIs.
718 * The display-/device-pixel distinction becomes important for (at least)
719 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
720 * is set to other than 100%.
722 * The Move and Resize methods take floating-point parameters, rather than
723 * integer ones. This is important when manipulating top-level widgets,
724 * where the coordinate system may not be an integral multiple of the
725 * device-pixel space.
729 * Move this widget.
731 * Coordinates refer to the top-left of the widget. For toplevel windows
732 * with decorations, this is the top-left of the titlebar and frame .
734 * @param aX the new x position expressed in the parent's coordinate system
735 * @param aY the new y position expressed in the parent's coordinate system
738 virtual void Move(double aX, double aY) = 0;
741 * Reposition this widget so that the client area has the given offset.
743 * @param aOffset the new offset of the client area expressed as an
744 * offset from the origin of the client area of the parent
745 * widget (for root widgets and popup widgets it is in
746 * screen coordinates)
748 virtual void MoveClient(const DesktopPoint& aOffset) = 0;
751 * Resize this widget. Any size constraints set for the window by a
752 * previous call to SetSizeConstraints will be applied.
754 * @param aWidth the new width expressed in the parent's coordinate system
755 * @param aHeight the new height expressed in the parent's coordinate
756 * system
757 * @param aRepaint whether the widget should be repainted
759 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
762 * Lock the aspect ratio of a Window
764 * @param aShouldLock bool
767 virtual void LockAspectRatio(bool aShouldLock){};
770 * Move or resize this widget. Any size constraints set for the window by
771 * a previous call to SetSizeConstraints will be applied.
773 * @param aX the new x position expressed in the parent's coordinate
774 * system
775 * @param aY the new y position expressed in the parent's coordinate
776 * system
777 * @param aWidth the new width expressed in the parent's coordinate system
778 * @param aHeight the new height expressed in the parent's coordinate
779 * system
780 * @param aRepaint whether the widget should be repainted if the size
781 * changes
784 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
785 bool aRepaint) = 0;
787 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
788 return mozilla::Nothing();
792 * Resize the widget so that the inner client area has the given size.
794 * @param aSize the new size of the client area.
795 * @param aRepaint whether the widget should be repainted
797 virtual void ResizeClient(const DesktopSize& aSize, bool aRepaint) = 0;
800 * Resize and reposition the widget so tht inner client area has the given
801 * offset and size.
803 * @param aRect the new offset and size of the client area. The offset is
804 * expressed as an offset from the origin of the client area
805 * of the parent widget (for root widgets and popup widgets it
806 * is in screen coordinates).
807 * @param aRepaint whether the widget should be repainted
809 virtual void ResizeClient(const DesktopRect& aRect, bool aRepaint) = 0;
812 * Sets the widget's z-index.
814 virtual void SetZIndex(int32_t aZIndex) = 0;
817 * Gets the widget's z-index.
819 int32_t GetZIndex() { return mZIndex; }
822 * Position this widget just behind the given widget. (Used to
823 * control z-order for top-level widgets. Get/SetZIndex by contrast
824 * control z-order for child widgets of other widgets.)
825 * @param aPlacement top, bottom, or below a widget
826 * (if top or bottom, param aWidget is ignored)
827 * @param aWidget widget to place this widget behind
828 * (only if aPlacement is eZPlacementBelow).
829 * null is equivalent to aPlacement of eZPlacementTop
830 * @param aActivate true to activate the widget after placing it
832 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
833 nsIWidget* aWidget, bool aActivate) = 0;
836 * Minimize, maximize or normalize the window size.
837 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
839 virtual void SetSizeMode(nsSizeMode aMode) = 0;
841 virtual void GetWorkspaceID(nsAString& workspaceID) = 0;
843 virtual void MoveToWorkspace(const nsAString& workspaceID) = 0;
846 * Suppress animations that are applied to a window by OS.
848 virtual void SuppressAnimation(bool aSuppress) {}
851 * Return size mode (minimized, maximized, normalized).
852 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
854 virtual nsSizeMode SizeMode() = 0;
857 * Ask whether the window is tiled.
859 virtual bool IsTiled() const = 0;
862 * Ask wether the widget is fully occluded
864 virtual bool IsFullyOccluded() const = 0;
867 * Enable or disable this Widget
869 * @param aState true to enable the Widget, false to disable it.
871 virtual void Enable(bool aState) = 0;
874 * Ask whether the widget is enabled
876 virtual bool IsEnabled() const = 0;
879 * Whether we should request activation of this widget's toplevel window.
881 enum class Raise {
883 Yes,
887 * Request activation of this window or give focus to this widget.
889 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
892 * Get this widget's outside dimensions relative to its parent widget. For
893 * popup widgets the returned rect is in screen coordinates and not
894 * relative to its parent widget.
896 * @return the x, y, width and height of this widget.
898 virtual LayoutDeviceIntRect GetBounds() = 0;
901 * Get this widget's outside dimensions in device coordinates. This
902 * includes any title bar on the window.
904 * @return the x, y, width and height of this widget.
906 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
909 * Similar to GetScreenBounds except that this function will always
910 * get the size when the widget is in the nsSizeMode_Normal size mode
911 * even if the current size mode is not nsSizeMode_Normal.
912 * This method will fail if the size mode is not nsSizeMode_Normal and
913 * the platform doesn't have the ability.
914 * This method will always succeed if the current size mode is
915 * nsSizeMode_Normal.
917 * @param aRect On return it holds the x, y, width and height of
918 * this widget.
920 [[nodiscard]] virtual nsresult GetRestoredBounds(
921 LayoutDeviceIntRect& aRect) = 0;
924 * Get this widget's client area bounds, if the window has a 3D border
925 * appearance this returns the area inside the border. The position is the
926 * position of the client area relative to the client area of the parent
927 * widget (for root widgets and popup widgets it is in screen coordinates).
929 * @return the x, y, width and height of the client area of this widget.
931 virtual LayoutDeviceIntRect GetClientBounds() = 0;
934 * Sets the non-client area dimensions of the window. Pass -1 to restore
935 * the system default frame size for that border. Pass zero to remove
936 * a border, or pass a specific value adjust a border. Units are in
937 * pixels. (DPI dependent)
939 * Platform notes:
940 * Windows: shrinking top non-client height will remove application
941 * icon and window title text. Glass desktops will refuse to set
942 * dimensions between zero and size < system default.
944 virtual nsresult SetNonClientMargins(const LayoutDeviceIntMargin&) = 0;
947 * Sets the region around the edges of the window that can be dragged to
948 * resize the window. All four sides of the window will get the same margin.
950 virtual void SetResizeMargin(mozilla::LayoutDeviceIntCoord aResizeMargin) = 0;
952 * Get the client offset from the window origin.
954 * @return the x and y of the offset.
956 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
959 * Returns the slop from the screen edges in device pixels.
960 * @see Window.screenEdgeSlop{X,Y}
962 virtual LayoutDeviceIntPoint GetScreenEdgeSlop() { return {}; }
965 * Equivalent to GetClientBounds but only returns the size.
967 virtual LayoutDeviceIntSize GetClientSize() {
968 // Depending on the backend, overloading this method may be useful if
969 // requesting the client offset is expensive.
970 return GetClientBounds().Size();
974 * Set the background color for this widget
976 * @param aColor the new background color
980 virtual void SetBackgroundColor(const nscolor& aColor) {}
983 * If a cursor type is currently cached locally for this widget, clear the
984 * cached cursor to force an update on the next SetCursor call.
987 virtual void ClearCachedCursor() = 0;
989 struct Cursor {
990 // The system cursor chosen by the page. This is used if there's no custom
991 // cursor, or if we fail to use the custom cursor in some way (if the image
992 // fails to load, for example).
993 nsCursor mDefaultCursor = eCursor_standard;
994 // May be null, to represent no custom cursor image.
995 nsCOMPtr<imgIContainer> mContainer;
996 uint32_t mHotspotX = 0;
997 uint32_t mHotspotY = 0;
998 mozilla::ImageResolution mResolution;
1000 bool IsCustom() const { return !!mContainer; }
1002 bool operator==(const Cursor& aOther) const {
1003 return mDefaultCursor == aOther.mDefaultCursor &&
1004 mContainer.get() == aOther.mContainer.get() &&
1005 mHotspotX == aOther.mHotspotX && mHotspotY == aOther.mHotspotY &&
1006 mResolution == aOther.mResolution;
1009 bool operator!=(const Cursor& aOther) const { return !(*this == aOther); }
1013 * Sets the cursor for this widget.
1015 virtual void SetCursor(const Cursor&) = 0;
1017 virtual void SetCustomCursorAllowed(bool) = 0;
1019 static nsIntSize CustomCursorSize(const Cursor&);
1022 * Get the window type of this widget.
1024 WindowType GetWindowType() const { return mWindowType; }
1027 * Set the transparency mode of the top-level window containing this widget.
1028 * So, e.g., if you call this on the widget for an IFRAME, the top level
1029 * browser window containing the IFRAME actually gets set. Be careful.
1031 * This can fail if the platform doesn't support
1032 * transparency/glass. By default widgets are not
1033 * transparent. This will also fail if the toplevel window is not
1034 * a Mozilla window, e.g., if the widget is in an embedded
1035 * context.
1037 * After transparency/glass has been enabled, the initial alpha channel
1038 * value for all pixels is 1, i.e., opaque.
1039 * If the window is resized then the alpha channel values for
1040 * all pixels are reset to 1.
1041 * Pixel RGB color values are already premultiplied with alpha channel values.
1043 virtual void SetTransparencyMode(TransparencyMode aMode) = 0;
1046 * Get the transparency mode of the top-level window that contains this
1047 * widget.
1049 virtual TransparencyMode GetTransparencyMode() = 0;
1052 * Set the shadow style of the window.
1054 * Ignored on child widgets and on non-Mac platforms.
1056 virtual void SetWindowShadowStyle(mozilla::WindowShadow aStyle) = 0;
1059 * Set the opacity of the window.
1060 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1062 * Ignored on child widgets and on non-Mac platforms.
1064 virtual void SetWindowOpacity(float aOpacity) {}
1067 * Set the transform of the window. Values are in device pixels,
1068 * the origin is the top left corner of the window.
1070 * Ignored on child widgets and on non-Mac platforms.
1072 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1075 * Set the preferred color-scheme for the widget.
1076 * Ignored on non-Mac platforms.
1078 virtual void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) {}
1081 * Set whether the window should ignore mouse events or not, and if it should
1082 * not, what input margin should it use.
1084 * This is only used on popup windows. The margin is only implemented on
1085 * Linux.
1087 struct InputRegion {
1088 bool mFullyTransparent = false;
1089 mozilla::LayoutDeviceIntCoord mMargin = 0;
1091 virtual void SetInputRegion(const InputRegion&) {}
1094 * On macOS, this method shows or hides the pill button in the titlebar
1095 * that's used to collapse the toolbar.
1097 * Ignored on child widgets and on non-Mac platforms.
1099 virtual void SetShowsToolbarButton(bool aShow) = 0;
1102 * On macOS, this method determines whether we tell cocoa that the window
1103 * supports native full screen. If we do so, and another window is in
1104 * native full screen, this window will also appear in native full screen.
1106 * We generally only want to do this for primary application windows.
1108 * Ignored on child widgets and on non-Mac platforms.
1110 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) = 0;
1112 enum WindowAnimationType {
1113 eGenericWindowAnimation,
1114 eDocumentWindowAnimation
1118 * Sets the kind of top-level window animation this widget should have. On
1119 * macOS, this causes a particular kind of animation to be shown when the
1120 * window is first made visible.
1122 * Ignored on child widgets and on non-Mac platforms.
1124 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1127 * Specifies whether the window title should be drawn even if the window
1128 * contents extend into the titlebar. Ignored on windows that don't draw
1129 * in the titlebar. Only implemented on macOS.
1131 virtual void SetDrawsTitle(bool aDrawTitle) {}
1134 * Hide window chrome (borders, buttons) for this widget.
1137 virtual void HideWindowChrome(bool aShouldHide) = 0;
1139 enum FullscreenTransitionStage {
1140 eBeforeFullscreenToggle,
1141 eAfterFullscreenToggle
1145 * Prepares for fullscreen transition and returns whether the widget
1146 * supports fullscreen transition. If this method returns false,
1147 * PerformFullscreenTransition() must never be called. Otherwise,
1148 * caller should call that method twice with "before" and "after"
1149 * stages respectively in order. In the latter case, this method may
1150 * return some data via aData pointer. Caller must pass that data to
1151 * PerformFullscreenTransition() if any, and caller is responsible
1152 * for releasing that data.
1154 virtual bool PrepareForFullscreenTransition(nsISupports** aData) = 0;
1157 * Performs fullscreen transition. This method returns immediately,
1158 * and will post aCallback to the main thread when the transition
1159 * finishes.
1161 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
1162 uint16_t aDuration,
1163 nsISupports* aData,
1164 nsIRunnable* aCallback) = 0;
1167 * Perform any actions needed after the fullscreen transition has ended.
1169 virtual void CleanupFullscreenTransition() = 0;
1172 * Return the screen the widget is in, or null if we don't know.
1174 virtual already_AddRefed<Screen> GetWidgetScreen() = 0;
1177 * Put the toplevel window into or out of fullscreen mode.
1179 * @return NS_OK if the widget is setup properly for fullscreen and
1180 * FullscreenChanged callback has been or will be called. If other
1181 * value is returned, the caller should continue the change itself.
1183 virtual nsresult MakeFullScreen(bool aFullScreen) = 0;
1186 * Same as MakeFullScreen, except that, on systems which natively
1187 * support fullscreen transition, calling this method explicitly
1188 * requests that behavior.
1189 * It is currently only supported on macOS 10.7+.
1191 virtual nsresult MakeFullScreenWithNativeTransition(bool aFullScreen) {
1192 return MakeFullScreen(aFullScreen);
1196 * Invalidate a specified rect for a widget so that it will be repainted
1197 * later.
1199 virtual void Invalidate(const LayoutDeviceIntRect& aRect) = 0;
1201 enum LayerManagerPersistence {
1202 LAYER_MANAGER_CURRENT = 0,
1203 LAYER_MANAGER_PERSISTENT
1207 * Return the widget's LayerManager. The layer tree for that LayerManager is
1208 * what gets rendered to the widget.
1210 * Note that this tries to create a renderer if it doesn't exist.
1212 virtual WindowRenderer* GetWindowRenderer() = 0;
1215 * Returns whether there's an existing window renderer.
1217 virtual bool HasWindowRenderer() const = 0;
1220 * Called before each layer manager transaction to allow any preparation
1221 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1223 * Always called on the main thread.
1225 virtual void PrepareWindowEffects() = 0;
1228 * Called when Gecko knows which themed widgets exist in this window.
1229 * The passed array contains an entry for every themed widget of the right
1230 * type (currently only StyleAppearance::Toolbar) within the window, except
1231 * for themed widgets which are transformed or have effects applied to them
1232 * (e.g. CSS opacity or filters).
1233 * This could sometimes be called during display list construction
1234 * outside of painting.
1235 * If called during painting, it will be called before we actually
1236 * paint anything.
1238 virtual void UpdateThemeGeometries(
1239 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1242 * Informs the widget about the region of the window that is opaque.
1244 * @param aOpaqueRegion the region of the window that is opaque.
1246 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1249 * Informs the widget about the region of the window that is draggable.
1251 virtual void UpdateWindowDraggingRegion(
1252 const LayoutDeviceIntRegion& aRegion) {}
1255 * Tells the widget whether the given input block results in a swipe.
1256 * Should be called in response to a WidgetWheelEvent that has
1257 * mFlags.mCanTriggerSwipe set on it.
1259 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1262 * Internal methods
1265 //@{
1266 virtual void AddChild(nsIWidget* aChild) = 0;
1267 virtual void RemoveChild(nsIWidget* aChild) = 0;
1268 virtual void* GetNativeData(uint32_t aDataType) = 0;
1269 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1271 //@}
1274 * Set the widget's title.
1275 * Must be called after Create.
1277 * @param aTitle string displayed as the title of the widget
1279 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1282 * Set the widget's icon.
1283 * Must be called after Create.
1285 * @param aIconSpec string specifying the icon to use; convention is to
1286 * pass a resource: URL from which a platform-dependent
1287 * resource file name will be constructed
1289 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1292 * Return this widget's origin in screen coordinates.
1294 * @return screen coordinates stored in the x,y members
1296 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1299 * The same as WidgetToScreenOffset(), except in the case of
1300 * PuppetWidget where this method omits the chrome offset.
1302 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1303 return WidgetToScreenOffset();
1307 * For a PuppetWidget, returns the transform from the coordinate
1308 * space of the PuppetWidget to the coordinate space of the
1309 * top-level native widget.
1311 * Identity transform in other cases.
1313 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1314 WidgetToTopLevelWidgetTransform() {
1315 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1318 mozilla::LayoutDeviceIntPoint WidgetToTopLevelWidgetOffset() {
1319 return mozilla::LayoutDeviceIntPoint::Round(
1320 WidgetToTopLevelWidgetTransform().TransformPoint(
1321 mozilla::LayoutDevicePoint()));
1325 * Returns the margins that are applied to go from client sizes to window
1326 * sizes (which includes window borders and titlebar).
1327 * This method should work even when the window is not yet visible.
1329 virtual LayoutDeviceIntMargin ClientToWindowMargin() { return {}; }
1331 LayoutDeviceIntSize ClientToWindowSizeDifference();
1334 * Dispatches an event to the widget
1336 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1337 nsEventStatus& aStatus) = 0;
1340 * Dispatches an event to APZ only.
1341 * No-op in the child process.
1343 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1346 * Dispatch a gecko event for this widget.
1347 * Returns true if it's consumed. Otherwise, false.
1349 virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent& event) = 0;
1351 // A structure that groups the statuses from APZ dispatch and content
1352 // dispatch.
1353 struct ContentAndAPZEventStatus {
1354 // Either of these may not be set if the event was not dispatched
1355 // to APZ or to content.
1356 nsEventStatus mApzStatus = nsEventStatus_eIgnore;
1357 nsEventStatus mContentStatus = nsEventStatus_eIgnore;
1361 * Dispatches an event that must be handled by APZ first, when APZ is
1362 * enabled. If invoked in the child process, it is forwarded to the
1363 * parent process synchronously.
1365 virtual ContentAndAPZEventStatus DispatchInputEvent(
1366 mozilla::WidgetInputEvent* aEvent) = 0;
1369 * Confirm an APZ-aware event target. This should be used when APZ will
1370 * not need a layers update to process the event.
1372 virtual void SetConfirmedTargetAPZC(
1373 uint64_t aInputBlockId,
1374 const nsTArray<ScrollableLayerGuid>& aTargets) const = 0;
1377 * Returns true if APZ is in use, false otherwise.
1379 virtual bool AsyncPanZoomEnabled() const = 0;
1383 virtual void SwipeFinished() = 0;
1386 * Enables the dropping of files to a widget.
1388 virtual void EnableDragDrop(bool aEnable) = 0;
1389 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1392 * Classify the window for the window manager. Mostly for X11.
1394 * @param xulWinType The window type. Characters other than [A-Za-z0-9_-] are
1395 * converted to '_'. Anything before the first colon is
1396 * assigned to name, anything after it to role. If there's
1397 * no colon, assign the whole thing to both role and name.
1399 * @param xulWinClass The window class. If set, overrides the normal value.
1400 * Otherwise, the program class it used.
1402 * @param xulWinName The window name. If set, overrides the value specified in
1403 * window type. Otherwise, name from window type is used.
1406 virtual void SetWindowClass(const nsAString& xulWinType,
1407 const nsAString& xulWinClass,
1408 const nsAString& xulWinName) = 0;
1411 * Enables/Disables system capture of any and all events that would cause a
1412 * popup to be rolled up. aListener should be set to a non-null value for
1413 * any popups that are not managed by the popup manager.
1414 * @param aDoCapture true enables capture, false disables capture
1417 virtual void CaptureRollupEvents(bool aDoCapture) = 0;
1420 * Bring this window to the user's attention. This is intended to be a more
1421 * gentle notification than popping the window to the top or putting up an
1422 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1423 * the Mac. The notification should be suppressed if the window is already
1424 * in the foreground and should be dismissed when the user brings this window
1425 * to the foreground.
1426 * @param aCycleCount Maximum number of times to animate the window per system
1427 * conventions. If set to -1, cycles indefinitely until
1428 * window is brought into the foreground.
1430 [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) = 0;
1433 * Ask whether there user input events pending. All input events are
1434 * included, including those not targeted at this nsIwidget instance.
1436 virtual bool HasPendingInputEvent() = 0;
1439 * Determine whether the widget shows a resize widget. If it does,
1440 * aResizerRect returns the resizer's rect.
1442 * Returns false on any platform that does not support it.
1444 * @param aResizerRect The resizer's rect in device pixels.
1445 * @return Whether a resize widget is shown.
1447 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1449 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1450 // EnumSet class.
1451 enum Modifiers : uint32_t {
1452 NO_MODIFIERS = 0x00000000,
1453 CAPS_LOCK = 0x00000001, // when CapsLock is active
1454 NUM_LOCK = 0x00000002, // when NumLock is active
1455 SHIFT_L = 0x00000100,
1456 SHIFT_R = 0x00000200,
1457 CTRL_L = 0x00000400,
1458 CTRL_R = 0x00000800,
1459 ALT_L = 0x00001000, // includes Option
1460 ALT_R = 0x00002000,
1461 COMMAND_L = 0x00004000,
1462 COMMAND_R = 0x00008000,
1463 HELP = 0x00010000,
1464 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1465 // AltRight key behavior of keyboard
1466 // layouts which maps AltGr to AltRight
1467 // key.
1468 FUNCTION = 0x00100000,
1469 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1472 * Utility method intended for testing. Dispatches native key events
1473 * to this widget to simulate the press and release of a key.
1474 * @param aNativeKeyboardLayout a *platform-specific* constant.
1475 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1476 * On Windows, it is converted to a hex string and passed to
1477 * LoadKeyboardLayout, see
1478 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1479 * @param aNativeKeyCode a *platform-specific* keycode.
1480 * On Windows, this is the virtual key code.
1481 * @param aModifiers some combination of the above 'Modifiers' flags;
1482 * not all flags will apply to all platforms. Mac ignores the _R
1483 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1484 * FUNCTION.
1485 * @param aCharacters characters that the OS would decide to generate
1486 * from the event. On Windows, this is the charCode passed by
1487 * WM_CHAR.
1488 * @param aUnmodifiedCharacters characters that the OS would decide
1489 * to generate from the event if modifier keys (other than shift)
1490 * were assumed inactive. Needed on Mac, ignored on Windows.
1491 * @param aObserver the observer that will get notified once the events
1492 * have been dispatched.
1493 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1494 * layout is not supported and the event was not fired
1496 virtual nsresult SynthesizeNativeKeyEvent(
1497 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1498 uint32_t aModifierFlags, const nsAString& aCharacters,
1499 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1502 * Utility method intended for testing. Dispatches native mouse events
1503 * may even move the mouse cursor. On Mac the events are guaranteed to
1504 * be sent to the window containing this widget, but on Windows they'll go
1505 * to whatever's topmost on the screen at that position, so for
1506 * cross-platform testing ensure that your window is at the top of the
1507 * z-order.
1508 * @param aPoint screen location of the mouse, in device
1509 * pixels, with origin at the top left
1510 * @param aNativeMessage abstract native message.
1511 * @param aButton Mouse button defined by DOM UI Events.
1512 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1513 * FYI: On Windows, Android and Headless widget on all
1514 * platroms, this hasn't been handled yet.
1515 * @param aObserver the observer that will get notified once the events
1516 * have been dispatched.
1518 enum class NativeMouseMessage : uint32_t {
1519 ButtonDown, // button down
1520 ButtonUp, // button up
1521 Move, // mouse cursor move
1522 EnterWindow, // mouse cursor comes into a window
1523 LeaveWindow, // mouse cursor leaves from a window
1525 virtual nsresult SynthesizeNativeMouseEvent(
1526 LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
1527 mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
1528 nsIObserver* aObserver) = 0;
1531 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1532 * message. aPoint is location in device pixels to which the mouse pointer
1533 * moves to.
1534 * @param aObserver the observer that will get notified once the events
1535 * have been dispatched.
1537 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1538 nsIObserver* aObserver) = 0;
1541 * Utility method intended for testing. Dispatching native mouse scroll
1542 * events may move the mouse cursor.
1544 * @param aPoint Mouse cursor position in screen coordinates.
1545 * In device pixels, the origin at the top left of
1546 * the primary display.
1547 * @param aNativeMessage Platform native message.
1548 * @param aDeltaX The delta value for X direction. If the native
1549 * message doesn't indicate X direction scrolling,
1550 * this may be ignored.
1551 * @param aDeltaY The delta value for Y direction. If the native
1552 * message doesn't indicate Y direction scrolling,
1553 * this may be ignored.
1554 * @param aDeltaZ The delta value for Z direction. If the native
1555 * message doesn't indicate Z direction scrolling,
1556 * this may be ignored.
1557 * @param aModifierFlags Must be values of Modifiers, or zero.
1558 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1559 * document.
1560 * @param aObserver The observer that will get notified once the
1561 * events have been dispatched.
1563 virtual nsresult SynthesizeNativeMouseScrollEvent(
1564 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1565 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1566 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1569 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1570 * touch states in nsIDOMWindowUtils.idl.
1572 enum TouchPointerState {
1573 // The pointer is in a hover state above the digitizer
1574 TOUCH_HOVER = (1 << 0),
1575 // The pointer is in contact with the digitizer
1576 TOUCH_CONTACT = (1 << 1),
1577 // The pointer has been removed from the digitizer detection area
1578 TOUCH_REMOVE = (1 << 2),
1579 // The pointer has been canceled. Will cancel any pending os level
1580 // gestures that would triggered as a result of completion of the
1581 // input sequence. This may not cancel moz platform related events
1582 // that might get tirggered by input already delivered.
1583 TOUCH_CANCEL = (1 << 3),
1585 // ALL_BITS used for validity checking during IPC serialization
1586 ALL_BITS = (1 << 4) - 1
1589 * TouchpadGesturePhase states for SynthesizeNativeTouchPadPinch and
1590 * SynthesizeNativeTouchpadPan. Match phase states in nsIDOMWindowUtils.idl.
1592 enum TouchpadGesturePhase {
1593 PHASE_BEGIN = 0,
1594 PHASE_UPDATE = 1,
1595 PHASE_END = 2
1598 * Create a new or update an existing touch pointer on the digitizer.
1599 * To trigger os level gestures, individual touch points should
1600 * transition through a complete set of touch states which should be
1601 * sent as individual messages.
1603 * @param aPointerId The touch point id to create or update.
1604 * @param aPointerState one or more of the touch states listed above
1605 * @param aPoint coords of this event
1606 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1607 * @param aOrientation 0 -> 359 degree value indicating the
1608 * orientation of the pointer. Use 90 for normal taps.
1609 * @param aObserver The observer that will get notified once the events
1610 * have been dispatched.
1612 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1613 TouchPointerState aPointerState,
1614 LayoutDeviceIntPoint aPoint,
1615 double aPointerPressure,
1616 uint32_t aPointerOrientation,
1617 nsIObserver* aObserver) = 0;
1619 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1621 virtual nsresult SynthesizeNativeTouchPadPinch(
1622 TouchpadGesturePhase aEventPhase, float aScale,
1623 LayoutDeviceIntPoint aPoint, int32_t aModifierFlags) = 0;
1626 * Helper for simulating a simple tap event with one touch point. When
1627 * aLongTap is true, simulates a native long tap with a duration equal to
1628 * ui.click_hold_context_menus.delay. This pref is compatible with the
1629 * apzc long tap duration. Defaults to 1.5 seconds.
1630 * @param aObserver The observer that will get notified once the events
1631 * have been dispatched.
1633 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1634 bool aLongTap,
1635 nsIObserver* aObserver);
1637 virtual nsresult SynthesizeNativePenInput(uint32_t aPointerId,
1638 TouchPointerState aPointerState,
1639 LayoutDeviceIntPoint aPoint,
1640 double aPressure,
1641 uint32_t aRotation, int32_t aTiltX,
1642 int32_t aTiltY, int32_t aButton,
1643 nsIObserver* aObserver) = 0;
1646 * Cancels all active simulated touch input points and pending long taps.
1647 * Native widgets should track existing points such that they can clear the
1648 * digitizer state when this call is made.
1649 * @param aObserver The observer that will get notified once the touch
1650 * sequence has been cleared.
1652 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1655 * Send a native event as if the user double tapped the touchpad with two
1656 * fingers.
1658 virtual nsresult SynthesizeNativeTouchpadDoubleTap(
1659 LayoutDeviceIntPoint aPoint, uint32_t aModifierFlags) = 0;
1662 * See nsIDOMWindowUtils.sendNativeTouchpadPan().
1664 virtual nsresult SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase,
1665 LayoutDeviceIntPoint aPoint,
1666 double aDeltaX, double aDeltaY,
1667 int32_t aModifierFlags,
1668 nsIObserver* aObserver) = 0;
1670 virtual void StartAsyncScrollbarDrag(
1671 const AsyncDragMetrics& aDragMetrics) = 0;
1674 * Notify APZ to start autoscrolling.
1675 * @param aAnchorLocation the location of the autoscroll anchor
1676 * @param aGuid identifies the scroll frame to be autoscrolled
1677 * @return true if APZ has been successfully notified
1679 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1680 const ScrollableLayerGuid& aGuid) = 0;
1683 * Notify APZ to stop autoscrolling.
1684 * @param aGuid identifies the scroll frame which is being autoscrolled.
1686 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid& aGuid) = 0;
1688 virtual LayersId GetRootLayerTreeId() = 0;
1690 // If this widget supports out-of-process compositing, it can override
1691 // this method to provide additional information to the compositor.
1692 virtual void GetCompositorWidgetInitData(
1693 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1696 * Setter/Getter of the system font setting for testing.
1698 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1699 return NS_ERROR_NOT_IMPLEMENTED;
1701 virtual nsresult GetSystemFont(nsCString& aFontName) {
1702 return NS_ERROR_NOT_IMPLEMENTED;
1706 * Wayland specific routines.
1708 virtual LayoutDeviceIntSize GetMoveToRectPopupSize() const {
1709 NS_WARNING("GetLayoutPopupRect implemented only for wayland");
1710 return LayoutDeviceIntSize();
1714 * If this widget uses native pointer lock instead of warp-to-center
1715 * (currently only GTK on Wayland), these methods provide access to that
1716 * functionality.
1718 virtual void SetNativePointerLockCenter(
1719 const LayoutDeviceIntPoint& aLockCenter) {}
1720 virtual void LockNativePointer() {}
1721 virtual void UnlockNativePointer() {}
1724 * Get safe area insets except to cutout.
1725 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1727 virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const {
1728 return mozilla::ScreenIntMargin();
1731 private:
1732 class LongTapInfo {
1733 public:
1734 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1735 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1736 : mPointerId(aPointerId),
1737 mPosition(aPoint),
1738 mDuration(aDuration),
1739 mObserver(aObserver),
1740 mStamp(mozilla::TimeStamp::Now()) {}
1742 int32_t mPointerId;
1743 LayoutDeviceIntPoint mPosition;
1744 mozilla::TimeDuration mDuration;
1745 nsCOMPtr<nsIObserver> mObserver;
1746 mozilla::TimeStamp mStamp;
1749 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1751 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1752 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1754 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1755 nsCOMPtr<nsITimer> mLongTapTimer;
1756 static int32_t sPointerIdCounter;
1758 public:
1760 * If key events have not been handled by content or XBL handlers, they can
1761 * be offered to the system (for custom application shortcuts set in system
1762 * preferences, for example).
1764 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1767 * Activates a native menu item at the position specified by the index
1768 * string. The index string is a string of positive integers separated
1769 * by the "|" (pipe) character. The last integer in the string represents
1770 * the item index in a submenu located using the integers preceding it.
1772 * Example: 1|0|4
1773 * In this string, the first integer represents the top-level submenu
1774 * in the native menu bar. Since the integer is 1, it is the second submeu
1775 * in the native menu bar. Within that, the first item (index 0) is a
1776 * submenu, and we want to activate the 5th item within that submenu.
1778 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1781 * This is used for native menu system testing.
1783 * Updates a native menu at the position specified by the index string.
1784 * The index string is a string of positive integers separated by the "|"
1785 * (pipe) character.
1787 * Example: 1|0|4
1788 * In this string, the first integer represents the top-level submenu
1789 * in the native menu bar. Since the integer is 1, it is the second submeu
1790 * in the native menu bar. Within that, the first item (index 0) is a
1791 * submenu, and we want to update submenu at index 4 within that submenu.
1793 * If this is called with an empty string it forces a full reload of the
1794 * menu system.
1796 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1799 * This is used for testing macOS service menu code.
1801 * @param aResult - the current text selection. Is empty if no selection.
1802 * @return nsresult - whether or not aResult was assigned the selected text.
1804 [[nodiscard]] virtual nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1805 return NS_ERROR_NOT_IMPLEMENTED;
1809 * Notify IME of the specified notification.
1811 * @return If the notification is mouse button event and it's consumed by
1812 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1814 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1817 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1818 * of the widget, in the event that we were not able to observe and respond to
1819 * the initial focus event. This is necessary for the early skeleton UI
1820 * window, which is displayed and receives its initial focus event before we
1821 * can actually respond to it.
1823 virtual void MaybeDispatchInitialFocusEvent() {}
1826 * Notifies the input context changes.
1828 virtual void SetInputContext(const InputContext& aContext,
1829 const InputContextAction& aAction) = 0;
1832 * Get current input context.
1834 virtual InputContext GetInputContext() = 0;
1837 * Get native IME context. This is different from GetNativeData() with
1838 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1839 * process.
1841 virtual NativeIMEContext GetNativeIMEContext() = 0;
1844 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1845 * native (OS-level) event for it. This method allows tests to simulate
1846 * keystrokes that trigger native key bindings (which require a native
1847 * event).
1849 [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
1850 mozilla::WidgetKeyboardEvent& aEvent) = 0;
1853 * Retrieve edit commands when the key combination of aEvent is used
1854 * in platform native applications.
1856 MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
1857 mozilla::NativeKeyBindingsType aType,
1858 const mozilla::WidgetKeyboardEvent& aEvent,
1859 nsTArray<mozilla::CommandInt>& aCommands);
1862 * Retrieves a reference to notification requests of IME. Note that the
1863 * reference is valid while the nsIWidget instance is alive. So, if you
1864 * need to store the reference for a long time, you need to grab the widget
1865 * instance too.
1867 const IMENotificationRequests& IMENotificationRequestsRef();
1870 * Call this method when a dialog is opened which has a default button.
1871 * The button's rectangle should be supplied in aButtonRect.
1873 [[nodiscard]] virtual nsresult OnDefaultButtonLoaded(
1874 const LayoutDeviceIntRect& aButtonRect) = 0;
1877 * Return true if this process shouldn't use platform widgets, and
1878 * so should use PuppetWidgets instead. If this returns true, the
1879 * result of creating and using a platform widget is undefined,
1880 * and likely to end in crashes or other buggy behavior.
1882 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1884 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1886 static already_AddRefed<nsIWidget> CreateChildWindow();
1889 * Allocate and return a "puppet widget" that doesn't directly
1890 * correlate to a platform widget; platform events and data must
1891 * be fed to it. Currently used in content processes. NULL is
1892 * returned if puppet widgets aren't supported in this build
1893 * config, on this platform, or for this process type.
1895 * This function is called "Create" to match CreateInstance().
1896 * The returned widget must still be nsIWidget::Create()d.
1898 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1899 BrowserChild* aBrowserChild);
1901 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1904 * Reparent this widget's native widget.
1905 * @param aNewParent the native widget of aNewParent is the new native
1906 * parent widget
1908 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1911 * Return true if widget has it's own GL context
1913 virtual bool HasGLContext() { return false; }
1916 * Returns true to indicate that this widget paints an opaque background
1917 * that we want to be visible under the page, so layout should not force
1918 * a default background.
1920 virtual bool WidgetPaintsBackground() { return false; }
1922 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1925 * Get the natural bounds of this widget. This method is only
1926 * meaningful for widgets for which Gecko implements screen
1927 * rotation natively. When this is the case, GetBounds() returns
1928 * the widget bounds taking rotation into account, and
1929 * GetNaturalBounds() returns the bounds *not* taking rotation
1930 * into account.
1932 * No code outside of the composition pipeline should know or care
1933 * about this. If you're not an agent of the compositor, you
1934 * probably shouldn't call this method.
1936 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1939 * Set size constraints on the window size such that it is never less than
1940 * the specified minimum size and never larger than the specified maximum
1941 * size. The size constraints are sizes of the outer rectangle including
1942 * the window frame and title bar. Use 0 for an unconstrained minimum size
1943 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1944 * does not necessarily change the size of a window to conform to this size,
1945 * thus Resize should be called afterwards.
1947 * @param aConstraints: the size constraints in device pixels
1949 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1952 * Return the size constraints currently observed by the widget.
1954 * @return the constraints in device pixels
1956 virtual const SizeConstraints GetSizeConstraints() = 0;
1959 * Apply the current size constraints to the given size.
1961 * @param aWidth width to constrain
1962 * @param aHeight height to constrain
1964 virtual void ConstrainSize(int32_t* aWidth, int32_t* aHeight) = 0;
1967 * If this is owned by a BrowserChild, return that. Otherwise return
1968 * null.
1970 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
1973 * If this isn't directly compositing to its window surface,
1974 * return the compositor which is doing that on our behalf.
1976 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
1979 * If there is a remote renderer, pause or resume it.
1981 virtual void PauseOrResumeCompositor(bool aPause);
1984 * Clear WebRender resources
1986 virtual void ClearCachedWebrenderResources() {}
1989 * Clear WebRender animation resources
1991 virtual void ClearWebrenderAnimationResources() {}
1994 * Request fast snapshot at RenderCompositor of WebRender.
1995 * Since readback of Windows DirectComposition is very slow.
1997 virtual bool SetNeedFastSnaphot() { return false; }
2000 * If this widget has its own vsync dispatcher, return it, otherwise return
2001 * nullptr. An example of such a local vsync dispatcher would be Wayland frame
2002 * callbacks.
2004 virtual RefPtr<mozilla::VsyncDispatcher> GetVsyncDispatcher();
2007 * Returns true if the widget requires synchronous repaints on resize,
2008 * false otherwise.
2010 virtual bool SynchronouslyRepaintOnResize() { return true; }
2013 * Some platforms (only cocoa right now) round widget coordinates to the
2014 * nearest even pixels (see bug 892994), this function allows us to
2015 * determine how widget coordinates will be rounded.
2017 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2019 virtual void UpdateZoomConstraints(
2020 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2021 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2024 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2025 * widget. Note that this never returns nullptr.
2027 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2030 * GetNativeTextEventDispatcherListener() returns a
2031 * TextEventDispatcherListener instance which is used when the widget
2032 * instance handles native IME and/or keyboard events.
2034 virtual TextEventDispatcherListener*
2035 GetNativeTextEventDispatcherListener() = 0;
2038 * Trigger an animation to zoom to the given |aRect|.
2039 * |aRect| should be relative to the layout viewport of the widget's root
2040 * document
2042 virtual void ZoomToRect(const uint32_t& aPresShellId,
2043 const ScrollableLayerGuid::ViewID& aViewId,
2044 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2047 * LookUpDictionary shows the dictionary for the word around current point.
2049 * @param aText the word to look up dictiorary.
2050 * @param aFontRangeArray text decoration of aText
2051 * @param aIsVertical true if the word is vertical layout
2052 * @param aPoint top-left point of aText
2054 virtual void LookUpDictionary(
2055 const nsAString& aText,
2056 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2057 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2059 virtual void RequestFxrOutput() {
2060 MOZ_ASSERT(false, "This function should only execute in Windows");
2063 #if defined(MOZ_WIDGET_ANDROID)
2065 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2066 * thread.
2068 * @param aMessage message being sent to Android UI thread.
2070 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2073 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2074 * thread
2076 * @param aScrollOffset page scroll offset value in screen pixels.
2077 * @param aZoom current page zoom.
2079 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2080 const CSSToScreenScale& aZoom) = 0;
2083 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2084 * for android robocop tests.
2086 * @param aMem shared memory containing the frame buffer pixels.
2087 * @param aSize size of the buffer in screen pixels.
2089 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2090 const ScreenIntSize& aSize,
2091 bool aNeedsYFlip) = 0;
2093 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2094 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2095 return 0;
2097 #endif
2099 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2102 * Like GetDefaultScale, but taking into account only the system settings
2103 * and ignoring Gecko preferences.
2105 virtual double GetDefaultScaleInternal() { return 1.0; }
2107 using WindowButtonType = mozilla::WindowButtonType;
2110 * Layout uses this to alert the widget to the client rect representing
2111 * the window maximize button. An empty rect indicates there is no
2112 * maximize button (for example, in fullscreen). This is only implemented
2113 * on Windows.
2115 virtual void SetWindowButtonRect(WindowButtonType aButtonType,
2116 const LayoutDeviceIntRect& aClientRect) {}
2118 #ifdef DEBUG
2119 virtual nsresult SetHiDPIMode(bool aHiDPI) {
2120 return NS_ERROR_NOT_IMPLEMENTED;
2122 virtual nsresult RestoreHiDPIMode() { return NS_ERROR_NOT_IMPLEMENTED; }
2123 #endif
2125 protected:
2126 // keep the list of children. We also keep track of our siblings.
2127 // The ownership model is as follows: parent holds a strong ref to
2128 // the first element of the list, and each element holds a strong
2129 // ref to the next element in the list. The prevsibling and
2130 // lastchild pointers are weak, which is fine as long as they are
2131 // maintained properly.
2132 nsCOMPtr<nsIWidget> mFirstChild;
2133 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2134 nsCOMPtr<nsIWidget> mNextSibling;
2135 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2136 // When Destroy() is called, the sub class should set this true.
2137 bool mOnDestroyCalled;
2138 WindowType mWindowType;
2139 int32_t mZIndex;
2142 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2144 #endif // nsIWidget_h__