Bug 1737746 - Use Permission spec's PermissionState r=mt,peterv
[gecko.git] / widget / nsIWidget.h
blob85d883098098163e9568aa64fc044fea84d13606
1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIWidget_h__
7 #define nsIWidget_h__
9 #include <cmath>
10 #include <cstdint>
11 #include "ErrorList.h"
12 #include "Units.h"
13 #include "mozilla/AlreadyAddRefed.h"
14 #include "mozilla/Assertions.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/EventForwards.h"
17 #include "mozilla/Maybe.h"
18 #include "mozilla/RefPtr.h"
19 #include "mozilla/TimeStamp.h"
20 #include "mozilla/UniquePtr.h"
21 #include "mozilla/gfx/Matrix.h"
22 #include "mozilla/gfx/Rect.h"
23 #include "mozilla/layers/LayersTypes.h"
24 #include "mozilla/layers/ScrollableLayerGuid.h"
25 #include "mozilla/layers/ZoomConstraints.h"
26 #include "mozilla/image/Resolution.h"
27 #include "mozilla/widget/IMEData.h"
28 #include "nsCOMPtr.h"
29 #include "nsColor.h"
30 #include "nsDebug.h"
31 #include "nsID.h"
32 #include "nsIObserver.h"
33 #include "nsISupports.h"
34 #include "nsITheme.h"
35 #include "nsITimer.h"
36 #include "nsIWidgetListener.h"
37 #include "nsRect.h"
38 #include "nsSize.h"
39 #include "nsStringFwd.h"
40 #include "nsTArray.h"
41 #include "nsTHashMap.h"
42 #include "nsWidgetInitData.h"
43 #include "nsXULAppAPI.h"
45 #ifdef MOZ_IS_GCC
46 # include "VsyncSource.h"
47 #endif
49 // forward declarations
50 class nsIBidiKeyboard;
51 class nsIRollupListener;
52 class imgIContainer;
53 class nsIContent;
54 class ViewWrapper;
55 class nsIScreen;
56 class nsIRunnable;
58 namespace mozilla {
59 class NativeEventData;
60 class WidgetGUIEvent;
61 class WidgetInputEvent;
62 class WidgetKeyboardEvent;
63 struct FontRange;
65 enum class StyleWindowShadow : uint8_t;
66 enum class ColorScheme : uint8_t;
68 #if defined(MOZ_WIDGET_ANDROID)
69 namespace ipc {
70 class Shmem;
72 #endif // defined(MOZ_WIDGET_ANDROID)
73 namespace dom {
74 class BrowserChild;
75 enum class CallerType : uint32_t;
76 } // namespace dom
77 class WindowRenderer;
78 namespace layers {
79 class AsyncDragMetrics;
80 class Compositor;
81 class CompositorBridgeChild;
82 struct FrameMetrics;
83 class LayerManager;
84 class WebRenderBridgeChild;
85 } // namespace layers
86 namespace gfx {
87 class VsyncSource;
88 } // namespace gfx
89 namespace widget {
90 class TextEventDispatcher;
91 class TextEventDispatcherListener;
92 class CompositorWidget;
93 class CompositorWidgetInitData;
94 } // namespace widget
95 namespace wr {
96 class DisplayListBuilder;
97 class IpcResourceUpdateQueue;
98 enum class RenderRoot : uint8_t;
99 } // namespace wr
100 } // namespace mozilla
103 * Callback function that processes events.
105 * The argument is actually a subtype (subclass) of WidgetEvent which carries
106 * platform specific information about the event. Platform specific code
107 * knows how to deal with it.
109 * The return value determines whether or not the default action should take
110 * place.
112 typedef nsEventStatus (*EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
114 // Hide the native window system's real window type so as to avoid
115 // including native window system types and APIs. This is necessary
116 // to ensure cross-platform code.
117 typedef void* nsNativeWidget;
120 * Flags for the GetNativeData and SetNativeData functions
122 #define NS_NATIVE_WINDOW 0
123 #define NS_NATIVE_GRAPHIC 1
124 #define NS_NATIVE_TMP_WINDOW 2
125 #define NS_NATIVE_WIDGET 3
126 #define NS_NATIVE_DISPLAY 4
127 #define NS_NATIVE_REGION 5
128 #define NS_NATIVE_OFFSETX 6
129 #define NS_NATIVE_OFFSETY 7
130 #define NS_NATIVE_SCREEN 9
131 // The toplevel GtkWidget containing this nsIWidget:
132 #define NS_NATIVE_SHELLWIDGET 10
133 #define NS_NATIVE_OPENGL_CONTEXT 12
134 // This is available only with GetNativeData() in parent process. Anybody
135 // shouldn't access this pointer as a valid pointer since the result may be
136 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
137 // an identifier of distinguishing a text composition is caused by which native
138 // IME context. Note that the result is only valid in the process. So,
139 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
140 #define NS_RAW_NATIVE_IME_CONTEXT 14
141 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
142 #ifdef XP_WIN
143 # define NS_NATIVE_TSF_THREAD_MGR 100
144 # define NS_NATIVE_TSF_CATEGORY_MGR 101
145 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
146 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
147 #endif
148 #if defined(MOZ_WIDGET_GTK)
149 # define NS_NATIVE_EGL_WINDOW 106
150 #endif
151 #ifdef MOZ_WIDGET_ANDROID
152 # define NS_JAVA_SURFACE 100
153 # define NS_PRESENTATION_WINDOW 101
154 # define NS_PRESENTATION_SURFACE 102
155 #endif
157 #define MOZ_WIDGET_MAX_SIZE 16384
158 #define MOZ_WIDGET_INVALID_SCALE 0.0
160 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
161 #define NS_IWIDGET_IID \
163 0x06396bf6, 0x2dd8, 0x45e5, { \
164 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
169 * Transparency modes
172 enum nsTransparencyMode {
173 eTransparencyOpaque = 0, // Fully opaque
174 eTransparencyTransparent, // Parts of the window may be transparent
175 eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass
176 // effect applied
177 eTransparencyBorderlessGlass // As above, but without a border around the
178 // opaque areas when there would otherwise be
179 // one with eTransparencyGlass
180 // If you add to the end here, you must update the serialization code in
181 // WidgetMessageUtils.h
185 * Cursor types.
188 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
189 eCursor_standard,
190 ///(system is busy, usually rendered as a hourglass or watch)
191 eCursor_wait,
192 ///(Selecting something, usually rendered as an IBeam)
193 eCursor_select,
194 ///(can hyper-link, usually rendered as a human hand)
195 eCursor_hyperlink,
196 ///(north/south/west/east edge sizing)
197 eCursor_n_resize,
198 eCursor_s_resize,
199 eCursor_w_resize,
200 eCursor_e_resize,
201 ///(corner sizing)
202 eCursor_nw_resize,
203 eCursor_se_resize,
204 eCursor_ne_resize,
205 eCursor_sw_resize,
206 eCursor_crosshair,
207 eCursor_move,
208 eCursor_help,
209 eCursor_copy, // CSS3
210 eCursor_alias,
211 eCursor_context_menu,
212 eCursor_cell,
213 eCursor_grab,
214 eCursor_grabbing,
215 eCursor_spinning,
216 eCursor_zoom_in,
217 eCursor_zoom_out,
218 eCursor_not_allowed,
219 eCursor_col_resize,
220 eCursor_row_resize,
221 eCursor_no_drop,
222 eCursor_vertical_text,
223 eCursor_all_scroll,
224 eCursor_nesw_resize,
225 eCursor_nwse_resize,
226 eCursor_ns_resize,
227 eCursor_ew_resize,
228 eCursor_none,
229 // This one is used for array sizing, and so better be the last
230 // one in this list...
231 eCursorCount,
233 // ...except for this one.
234 eCursorInvalid = eCursorCount + 1
237 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
238 eZPlacementBottom = 0, // bottom of the window stack
239 eZPlacementBelow, // just below another widget
240 eZPlacementTop // top of the window stack
244 * Before the OS goes to sleep, this topic is notified.
246 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
249 * After the OS wakes up, this topic is notified.
251 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
254 * Before the OS suspends the current process, this topic is notified. Some
255 * OS will kill processes that are suspended instead of resuming them.
256 * For that reason this topic may be useful to safely close down resources.
258 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
261 * After the current process resumes from being suspended, this topic is
262 * notified.
264 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
267 * When an app(-shell) is activated by the OS, this topic is notified.
268 * Currently, this only happens on Mac OSX.
270 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
272 namespace mozilla {
273 namespace widget {
276 * Size constraints for setting the minimum and maximum size of a widget.
277 * Values are in device pixels.
279 struct SizeConstraints {
280 SizeConstraints()
281 : mMaxSize(MOZ_WIDGET_MAX_SIZE, MOZ_WIDGET_MAX_SIZE),
282 mScale(MOZ_WIDGET_INVALID_SCALE) {}
284 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
285 mozilla::LayoutDeviceIntSize aMaxSize,
286 mozilla::DesktopToLayoutDeviceScale aScale)
287 : mMinSize(aMinSize), mMaxSize(aMaxSize), mScale(aScale) {
288 if (mMaxSize.width > MOZ_WIDGET_MAX_SIZE) {
289 mMaxSize.width = MOZ_WIDGET_MAX_SIZE;
291 if (mMaxSize.height > MOZ_WIDGET_MAX_SIZE) {
292 mMaxSize.height = MOZ_WIDGET_MAX_SIZE;
296 mozilla::LayoutDeviceIntSize mMinSize;
297 mozilla::LayoutDeviceIntSize mMaxSize;
300 * The scale used to convert from desktop to device dimensions.
301 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
303 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
304 * with multi-monitor scaling issues in more complete way across
305 * all widget implementations.
307 mozilla::DesktopToLayoutDeviceScale mScale;
310 struct AutoObserverNotifier {
311 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
312 : mObserver(aObserver), mTopic(aTopic) {}
314 void SkipNotification() { mObserver = nullptr; }
316 uint64_t SaveObserver() {
317 if (!mObserver) {
318 return 0;
320 uint64_t observerId = ++sObserverId;
321 sSavedObservers.InsertOrUpdate(observerId, mObserver);
322 SkipNotification();
323 return observerId;
326 ~AutoObserverNotifier() {
327 if (mObserver) {
328 mObserver->Observe(nullptr, mTopic, nullptr);
332 static void NotifySavedObserver(const uint64_t& aObserverId,
333 const char* aTopic) {
334 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
335 if (!observer) {
336 MOZ_ASSERT(aObserverId == 0,
337 "We should always find a saved observer for nonzero IDs");
338 return;
341 sSavedObservers.Remove(aObserverId);
342 observer->Observe(nullptr, aTopic, nullptr);
345 private:
346 nsCOMPtr<nsIObserver> mObserver;
347 const char* mTopic;
349 private:
350 static uint64_t sObserverId;
351 static nsTHashMap<uint64_t, nsCOMPtr<nsIObserver>> sSavedObservers;
354 } // namespace widget
355 } // namespace mozilla
358 * The base class for all the widgets. It provides the interface for
359 * all basic and necessary functionality.
361 class nsIWidget : public nsISupports {
362 protected:
363 typedef mozilla::dom::BrowserChild BrowserChild;
365 public:
366 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
367 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
368 typedef mozilla::layers::FrameMetrics FrameMetrics;
369 typedef mozilla::layers::LayerManager LayerManager;
370 typedef mozilla::WindowRenderer WindowRenderer;
371 typedef mozilla::layers::LayersBackend LayersBackend;
372 typedef mozilla::layers::LayersId LayersId;
373 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
374 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
375 typedef mozilla::widget::IMEEnabled IMEEnabled;
376 typedef mozilla::widget::IMEMessage IMEMessage;
377 typedef mozilla::widget::IMENotification IMENotification;
378 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
379 typedef mozilla::widget::IMEState IMEState;
380 typedef mozilla::widget::InputContext InputContext;
381 typedef mozilla::widget::InputContextAction InputContextAction;
382 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
383 typedef mozilla::widget::SizeConstraints SizeConstraints;
384 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
385 typedef mozilla::widget::TextEventDispatcherListener
386 TextEventDispatcherListener;
387 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
388 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
389 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
390 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
391 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
392 typedef mozilla::ScreenIntPoint ScreenIntPoint;
393 typedef mozilla::ScreenIntMargin ScreenIntMargin;
394 typedef mozilla::ScreenIntSize ScreenIntSize;
395 typedef mozilla::ScreenPoint ScreenPoint;
396 typedef mozilla::CSSToScreenScale CSSToScreenScale;
397 typedef mozilla::DesktopIntRect DesktopIntRect;
398 typedef mozilla::DesktopPoint DesktopPoint;
399 typedef mozilla::DesktopRect DesktopRect;
400 typedef mozilla::DesktopSize DesktopSize;
401 typedef mozilla::CSSPoint CSSPoint;
402 typedef mozilla::CSSRect CSSRect;
404 enum class WindowButtonType {
405 Minimize,
406 Maximize,
407 Close,
408 Count,
411 // Used in UpdateThemeGeometries.
412 struct ThemeGeometry {
413 // The ThemeGeometryType value for the themed widget, see
414 // nsITheme::ThemeGeometryTypeForWidget.
415 nsITheme::ThemeGeometryType mType;
416 // The device-pixel rect within the window for the themed widget
417 LayoutDeviceIntRect mRect;
419 ThemeGeometry(nsITheme::ThemeGeometryType aType,
420 const LayoutDeviceIntRect& aRect)
421 : mType(aType), mRect(aRect) {}
424 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
426 nsIWidget()
427 : mLastChild(nullptr),
428 mPrevSibling(nullptr),
429 mOnDestroyCalled(false),
430 mWindowType(eWindowType_child),
431 mZIndex(0)
434 ClearNativeTouchSequence(nullptr);
438 * Create and initialize a widget.
440 * All the arguments can be null in which case a top level window
441 * with size 0 is created. The event callback function has to be
442 * provided only if the caller wants to deal with the events this
443 * widget receives. The event callback is basically a preprocess
444 * hook called synchronously. The return value determines whether
445 * the event goes to the default window procedure or it is hidden
446 * to the os. The assumption is that if the event handler returns
447 * false the widget does not see the event. The widget should not
448 * automatically clear the window to the background color. The
449 * calling code must handle paint messages and clear the background
450 * itself.
452 * In practice at least one of aParent and aNativeParent will be null. If
453 * both are null the widget isn't parented (e.g. context menus or
454 * independent top level windows).
456 * The dimensions given in aRect are specified in the parent's
457 * device coordinate system.
458 * This must not be called for parentless widgets such as top-level
459 * windows, which use the desktop pixel coordinate system; a separate
460 * method is provided for these.
462 * @param aParent parent nsIWidget
463 * @param aNativeParent native parent widget
464 * @param aRect the widget dimension
465 * @param aInitData data that is used for widget initialization
468 [[nodiscard]] virtual nsresult Create(
469 nsIWidget* aParent, nsNativeWidget aNativeParent,
470 const LayoutDeviceIntRect& aRect,
471 nsWidgetInitData* aInitData = nullptr) = 0;
474 * As above, but with aRect specified in DesktopPixel units (for top-level
475 * widgets).
476 * Default implementation just converts aRect to device pixels and calls
477 * through to device-pixel Create, but platforms may override this if the
478 * mapping is not straightforward or the native platform needs to use the
479 * desktop pixel values directly.
481 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
482 nsNativeWidget aNativeParent,
483 const DesktopIntRect& aRect,
484 nsWidgetInitData* aInitData = nullptr) {
485 LayoutDeviceIntRect devPixRect =
486 RoundedToInt(aRect * GetDesktopToDeviceScale());
487 return Create(aParent, aNativeParent, devPixRect, aInitData);
491 * Allocate, initialize, and return a widget that is a child of
492 * |this|. The returned widget (if nonnull) has gone through the
493 * equivalent of CreateInstance(widgetCID) + Create(...).
495 * |CreateChild()| lets widget backends decide whether to parent
496 * the new child widget to this, nonnatively parent it, or both.
497 * This interface exists to support the PuppetWidget backend,
498 * which is entirely non-native. All other params are the same as
499 * for |Create()|.
501 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
502 * |nsIWidget*| this, not its native widget (if it exists), when
503 * calling |Create()|. This is a timid hack around poorly
504 * understood code, and shouldn't be used in new code.
506 virtual already_AddRefed<nsIWidget> CreateChild(
507 const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData = nullptr,
508 bool aForceUseIWidgetParent = false) = 0;
511 * Attach to a top level widget.
513 * In cases where a top level chrome widget is being used as a content
514 * container, attach a secondary listener and update the device
515 * context. The primary widget listener will continue to be called for
516 * notifications relating to the top-level window, whereas other
517 * notifications such as painting and events will instead be called via
518 * the attached listener. SetAttachedWidgetListener should be used to
519 * assign the attached listener.
521 * aUseAttachedEvents if true, events are sent to the attached listener
522 * instead of the normal listener.
524 virtual void AttachViewToTopLevel(bool aUseAttachedEvents) = 0;
527 * Accessor functions to get and set the attached listener. Used by
528 * nsView in connection with AttachViewToTopLevel above.
530 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
531 virtual nsIWidgetListener* GetAttachedWidgetListener() const = 0;
532 virtual void SetPreviouslyAttachedWidgetListener(
533 nsIWidgetListener* aListener) = 0;
534 virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() = 0;
537 * Accessor functions to get and set the listener which handles various
538 * actions for the widget.
540 //@{
541 virtual nsIWidgetListener* GetWidgetListener() const = 0;
542 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
543 //@}
546 * Close and destroy the internal native window.
547 * This method does not delete the widget.
550 virtual void Destroy() = 0;
553 * Destroyed() returns true if Destroy() has been called already.
554 * Otherwise, false.
556 bool Destroyed() const { return mOnDestroyCalled; }
559 * Reparent a widget
561 * Change the widget's parent. Null parents are allowed.
563 * @param aNewParent new parent
565 virtual void SetParent(nsIWidget* aNewParent) = 0;
568 * Return the parent Widget of this Widget or nullptr if this is a
569 * top level window
571 * @return the parent widget or nullptr if it does not have a parent
574 virtual nsIWidget* GetParent(void) = 0;
577 * Return the top level Widget of this Widget
579 * @return the top level widget
581 virtual nsIWidget* GetTopLevelWidget() = 0;
584 * Return the top (non-sheet) parent of this Widget if it's a sheet,
585 * or nullptr if this isn't a sheet (or some other error occurred).
586 * Sheets are only supported on some platforms (currently only macOS).
588 * @return the top (non-sheet) parent widget or nullptr
591 virtual nsIWidget* GetSheetWindowParent(void) = 0;
594 * Return the physical DPI of the screen containing the window ...
595 * the number of device pixels per inch.
597 virtual float GetDPI() = 0;
600 * Return the scaling factor between device pixels and the platform-
601 * dependent "desktop pixels" used to manage window positions on a
602 * potentially multi-screen, mixed-resolution desktop.
604 virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
607 * Return the scaling factor between device pixels and the platform-
608 * dependent "desktop pixels" by looking up the screen by the position
609 * of the widget.
611 virtual mozilla::DesktopToLayoutDeviceScale
612 GetDesktopToDeviceScaleByScreen() = 0;
615 * Return the default scale factor for the window. This is the
616 * default number of device pixels per CSS pixel to use. This should
617 * depend on OS/platform settings such as the Mac's "UI scale factor"
618 * or Windows' "font DPI". This will take into account Gecko preferences
619 * overriding the system setting.
621 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
624 * Return the first child of this widget. Will return null if
625 * there are no children.
627 nsIWidget* GetFirstChild() const { return mFirstChild; }
630 * Return the last child of this widget. Will return null if
631 * there are no children.
633 nsIWidget* GetLastChild() const { return mLastChild; }
636 * Return the next sibling of this widget
638 nsIWidget* GetNextSibling() const { return mNextSibling; }
641 * Set the next sibling of this widget
643 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
646 * Return the previous sibling of this widget
648 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
651 * Set the previous sibling of this widget
653 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
656 * Show or hide this widget
658 * @param aState true to show the Widget, false to hide it
661 virtual void Show(bool aState) = 0;
664 * Whether or not a widget must be recreated after being hidden to show
665 * again properly.
667 virtual bool NeedsRecreateToReshow() { return false; }
670 * Make the window modal.
672 virtual void SetModal(bool aModal) = 0;
675 * Make the non-modal window opened by modal window fake-modal, that will
676 * call SetFakeModal(false) on destroy on Cocoa.
678 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
681 * Are we app modal. Currently only implemented on Cocoa.
683 virtual bool IsRunningAppModal() { return false; }
686 * The maximum number of simultaneous touch contacts supported by the device.
687 * In the case of devices with multiple digitizers (e.g. multiple touch
688 * screens), the value will be the maximum of the set of maximum supported
689 * contacts by each individual digitizer.
691 virtual uint32_t GetMaxTouchPoints() const = 0;
694 * Returns whether the window is visible
697 virtual bool IsVisible() const = 0;
700 * Perform platform-dependent sanity check on a potential window position.
701 * This is guaranteed to work only for top-level windows.
703 * @param aAllowSlop: if true, allow the window to slop offscreen;
704 * the window should be partially visible. if false,
705 * force the entire window onscreen (or at least
706 * the upper-left corner, if it's too large).
707 * @param aX in: an x position expressed in screen coordinates.
708 * out: the x position constrained to fit on the screen(s).
709 * @param aY in: an y position expressed in screen coordinates.
710 * out: the y position constrained to fit on the screen(s).
713 virtual void ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) = 0;
716 * NOTE:
718 * For a top-level window widget, the "parent's coordinate system" is the
719 * "global" display pixel coordinate space, *not* device pixels (which
720 * may be inconsistent between multiple screens, at least in the Mac OS
721 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
722 * following Move and Resize widget APIs.
724 * The display-/device-pixel distinction becomes important for (at least)
725 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
726 * is set to other than 100%.
728 * The Move and Resize methods take floating-point parameters, rather than
729 * integer ones. This is important when manipulating top-level widgets,
730 * where the coordinate system may not be an integral multiple of the
731 * device-pixel space.
735 * Move this widget.
737 * Coordinates refer to the top-left of the widget. For toplevel windows
738 * with decorations, this is the top-left of the titlebar and frame .
740 * @param aX the new x position expressed in the parent's coordinate system
741 * @param aY the new y position expressed in the parent's coordinate system
744 virtual void Move(double aX, double aY) = 0;
747 * Reposition this widget so that the client area has the given offset.
749 * @param aOffset the new offset of the client area expressed as an
750 * offset from the origin of the client area of the parent
751 * widget (for root widgets and popup widgets it is in
752 * screen coordinates)
754 virtual void MoveClient(const DesktopPoint& aOffset) = 0;
757 * Resize this widget. Any size constraints set for the window by a
758 * previous call to SetSizeConstraints will be applied.
760 * @param aWidth the new width expressed in the parent's coordinate system
761 * @param aHeight the new height expressed in the parent's coordinate
762 * system
763 * @param aRepaint whether the widget should be repainted
765 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
768 * Lock the aspect ratio of a Window
770 * @param aShouldLock bool
773 virtual void LockAspectRatio(bool aShouldLock){};
776 * Move or resize this widget. Any size constraints set for the window by
777 * a previous call to SetSizeConstraints will be applied.
779 * @param aX the new x position expressed in the parent's coordinate
780 * system
781 * @param aY the new y position expressed in the parent's coordinate
782 * system
783 * @param aWidth the new width expressed in the parent's coordinate system
784 * @param aHeight the new height expressed in the parent's coordinate
785 * system
786 * @param aRepaint whether the widget should be repainted if the size
787 * changes
790 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
791 bool aRepaint) = 0;
793 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
794 return mozilla::Nothing();
798 * Resize the widget so that the inner client area has the given size.
800 * @param aSize the new size of the client area.
801 * @param aRepaint whether the widget should be repainted
803 virtual void ResizeClient(const DesktopSize& aSize, bool aRepaint) = 0;
806 * Resize and reposition the widget so tht inner client area has the given
807 * offset and size.
809 * @param aRect the new offset and size of the client area. The offset is
810 * expressed as an offset from the origin of the client area
811 * of the parent widget (for root widgets and popup widgets it
812 * is in screen coordinates).
813 * @param aRepaint whether the widget should be repainted
815 virtual void ResizeClient(const DesktopRect& aRect, bool aRepaint) = 0;
818 * Sets the widget's z-index.
820 virtual void SetZIndex(int32_t aZIndex) = 0;
823 * Gets the widget's z-index.
825 int32_t GetZIndex() { return mZIndex; }
828 * Position this widget just behind the given widget. (Used to
829 * control z-order for top-level widgets. Get/SetZIndex by contrast
830 * control z-order for child widgets of other widgets.)
831 * @param aPlacement top, bottom, or below a widget
832 * (if top or bottom, param aWidget is ignored)
833 * @param aWidget widget to place this widget behind
834 * (only if aPlacement is eZPlacementBelow).
835 * null is equivalent to aPlacement of eZPlacementTop
836 * @param aActivate true to activate the widget after placing it
838 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
839 nsIWidget* aWidget, bool aActivate) = 0;
842 * Minimize, maximize or normalize the window size.
843 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
845 virtual void SetSizeMode(nsSizeMode aMode) = 0;
847 virtual void GetWorkspaceID(nsAString& workspaceID) = 0;
849 virtual void MoveToWorkspace(const nsAString& workspaceID) = 0;
852 * Suppress animations that are applied to a window by OS.
854 virtual void SuppressAnimation(bool aSuppress) {}
857 * Return size mode (minimized, maximized, normalized).
858 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
860 virtual nsSizeMode SizeMode() = 0;
863 * Ask whether the window is tiled.
865 virtual bool IsTiled() const = 0;
868 * Ask wether the widget is fully occluded
870 virtual bool IsFullyOccluded() const = 0;
873 * Enable or disable this Widget
875 * @param aState true to enable the Widget, false to disable it.
877 virtual void Enable(bool aState) = 0;
880 * Ask whether the widget is enabled
882 virtual bool IsEnabled() const = 0;
885 * Whether we should request activation of this widget's toplevel window.
887 enum class Raise {
889 Yes,
893 * Request activation of this window or give focus to this widget.
895 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
898 * Get this widget's outside dimensions relative to its parent widget. For
899 * popup widgets the returned rect is in screen coordinates and not
900 * relative to its parent widget.
902 * @return the x, y, width and height of this widget.
904 virtual LayoutDeviceIntRect GetBounds() = 0;
907 * Get this widget's outside dimensions in device coordinates. This
908 * includes any title bar on the window.
910 * @return the x, y, width and height of this widget.
912 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
915 * Similar to GetScreenBounds except that this function will always
916 * get the size when the widget is in the nsSizeMode_Normal size mode
917 * even if the current size mode is not nsSizeMode_Normal.
918 * This method will fail if the size mode is not nsSizeMode_Normal and
919 * the platform doesn't have the ability.
920 * This method will always succeed if the current size mode is
921 * nsSizeMode_Normal.
923 * @param aRect On return it holds the x, y, width and height of
924 * this widget.
926 [[nodiscard]] virtual nsresult GetRestoredBounds(
927 LayoutDeviceIntRect& aRect) = 0;
930 * Get this widget's client area bounds, if the window has a 3D border
931 * appearance this returns the area inside the border. The position is the
932 * position of the client area relative to the client area of the parent
933 * widget (for root widgets and popup widgets it is in screen coordinates).
935 * @return the x, y, width and height of the client area of this widget.
937 virtual LayoutDeviceIntRect GetClientBounds() = 0;
940 * Sets the non-client area dimensions of the window. Pass -1 to restore
941 * the system default frame size for that border. Pass zero to remove
942 * a border, or pass a specific value adjust a border. Units are in
943 * pixels. (DPI dependent)
945 * Platform notes:
946 * Windows: shrinking top non-client height will remove application
947 * icon and window title text. Glass desktops will refuse to set
948 * dimensions between zero and size < system default.
950 virtual nsresult SetNonClientMargins(LayoutDeviceIntMargin& aMargins) = 0;
953 * Get the client offset from the window origin.
955 * @return the x and y of the offset.
957 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
960 * Equivalent to GetClientBounds but only returns the size.
962 virtual LayoutDeviceIntSize GetClientSize() {
963 // Depending on the backend, overloading this method may be useful if
964 // requesting the client offset is expensive.
965 return GetClientBounds().Size();
969 * Set the background color for this widget
971 * @param aColor the new background color
975 virtual void SetBackgroundColor(const nscolor& aColor) {}
978 * If a cursor type is currently cached locally for this widget, clear the
979 * cached cursor to force an update on the next SetCursor call.
982 virtual void ClearCachedCursor() = 0;
984 struct Cursor {
985 // The system cursor chosen by the page. This is used if there's no custom
986 // cursor, or if we fail to use the custom cursor in some way (if the image
987 // fails to load, for example).
988 nsCursor mDefaultCursor = eCursor_standard;
989 // May be null, to represent no custom cursor image.
990 nsCOMPtr<imgIContainer> mContainer;
991 uint32_t mHotspotX = 0;
992 uint32_t mHotspotY = 0;
993 mozilla::ImageResolution mResolution;
995 bool IsCustom() const { return !!mContainer; }
997 bool operator==(const Cursor& aOther) const {
998 return mDefaultCursor == aOther.mDefaultCursor &&
999 mContainer.get() == aOther.mContainer.get() &&
1000 mHotspotX == aOther.mHotspotX && mHotspotY == aOther.mHotspotY &&
1001 mResolution == aOther.mResolution;
1004 bool operator!=(const Cursor& aOther) const { return !(*this == aOther); }
1008 * Sets the cursor for this widget.
1010 virtual void SetCursor(const Cursor&) = 0;
1012 static nsIntSize CustomCursorSize(const Cursor&);
1015 * Get the window type of this widget.
1017 nsWindowType WindowType() { return mWindowType; }
1020 * Set the transparency mode of the top-level window containing this widget.
1021 * So, e.g., if you call this on the widget for an IFRAME, the top level
1022 * browser window containing the IFRAME actually gets set. Be careful.
1024 * This can fail if the platform doesn't support
1025 * transparency/glass. By default widgets are not
1026 * transparent. This will also fail if the toplevel window is not
1027 * a Mozilla window, e.g., if the widget is in an embedded
1028 * context.
1030 * After transparency/glass has been enabled, the initial alpha channel
1031 * value for all pixels is 1, i.e., opaque.
1032 * If the window is resized then the alpha channel values for
1033 * all pixels are reset to 1.
1034 * Pixel RGB color values are already premultiplied with alpha channel values.
1036 virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
1039 * Get the transparency mode of the top-level window that contains this
1040 * widget.
1042 virtual nsTransparencyMode GetTransparencyMode() = 0;
1045 * Set the shadow style of the window.
1047 * Ignored on child widgets and on non-Mac platforms.
1049 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) = 0;
1052 * Set the opacity of the window.
1053 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1055 * Ignored on child widgets and on non-Mac platforms.
1057 virtual void SetWindowOpacity(float aOpacity) {}
1060 * Set the transform of the window. Values are in device pixels,
1061 * the origin is the top left corner of the window.
1063 * Ignored on child widgets and on non-Mac platforms.
1065 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1068 * Set the preferred color-scheme for the widget.
1069 * Ignored on non-Mac platforms.
1071 virtual void SetColorScheme(const mozilla::Maybe<mozilla::ColorScheme>&) {}
1074 * Set whether the window should ignore mouse events or not.
1076 * This is only used on popup windows.
1078 virtual void SetWindowMouseTransparent(bool aIsTransparent) {}
1081 * On macOS, this method shows or hides the pill button in the titlebar
1082 * that's used to collapse the toolbar.
1084 * Ignored on child widgets and on non-Mac platforms.
1086 virtual void SetShowsToolbarButton(bool aShow) = 0;
1089 * On macOS, this method determines whether we tell cocoa that the window
1090 * supports native full screen. If we do so, and another window is in
1091 * native full screen, this window will also appear in native full screen.
1093 * We generally only want to do this for primary application windows.
1095 * Ignored on child widgets and on non-Mac platforms.
1097 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) = 0;
1099 enum WindowAnimationType {
1100 eGenericWindowAnimation,
1101 eDocumentWindowAnimation
1105 * Sets the kind of top-level window animation this widget should have. On
1106 * macOS, this causes a particular kind of animation to be shown when the
1107 * window is first made visible.
1109 * Ignored on child widgets and on non-Mac platforms.
1111 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1114 * Specifies whether the window title should be drawn even if the window
1115 * contents extend into the titlebar. Ignored on windows that don't draw
1116 * in the titlebar. Only implemented on macOS.
1118 virtual void SetDrawsTitle(bool aDrawTitle) {}
1121 * Hide window chrome (borders, buttons) for this widget.
1124 virtual void HideWindowChrome(bool aShouldHide) = 0;
1126 enum FullscreenTransitionStage {
1127 eBeforeFullscreenToggle,
1128 eAfterFullscreenToggle
1132 * Prepares for fullscreen transition and returns whether the widget
1133 * supports fullscreen transition. If this method returns false,
1134 * PerformFullscreenTransition() must never be called. Otherwise,
1135 * caller should call that method twice with "before" and "after"
1136 * stages respectively in order. In the latter case, this method may
1137 * return some data via aData pointer. Caller must pass that data to
1138 * PerformFullscreenTransition() if any, and caller is responsible
1139 * for releasing that data.
1141 virtual bool PrepareForFullscreenTransition(nsISupports** aData) = 0;
1144 * Performs fullscreen transition. This method returns immediately,
1145 * and will post aCallback to the main thread when the transition
1146 * finishes.
1148 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
1149 uint16_t aDuration,
1150 nsISupports* aData,
1151 nsIRunnable* aCallback) = 0;
1154 * Perform any actions needed after the fullscreen transition has ended.
1156 virtual void CleanupFullscreenTransition() = 0;
1159 * Return the screen the widget is in, or null if we don't know.
1161 virtual already_AddRefed<nsIScreen> GetWidgetScreen() = 0;
1164 * Put the toplevel window into or out of fullscreen mode.
1165 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1166 * if possible. (If not, it behaves as if aTargetScreen is null.)
1167 * If !aFullScreen, aTargetScreen is ignored.
1168 * aTargetScreen support is currently only implemented on Windows.
1170 * @return NS_OK if the widget is setup properly for fullscreen and
1171 * FullscreenChanged callback has been or will be called. If other
1172 * value is returned, the caller should continue the change itself.
1174 virtual nsresult MakeFullScreen(bool aFullScreen,
1175 nsIScreen* aTargetScreen = nullptr) = 0;
1178 * Same as MakeFullScreen, except that, on systems which natively
1179 * support fullscreen transition, calling this method explicitly
1180 * requests that behavior.
1181 * It is currently only supported on macOS 10.7+.
1183 virtual nsresult MakeFullScreenWithNativeTransition(
1184 bool aFullScreen, nsIScreen* aTargetScreen = nullptr) {
1185 return MakeFullScreen(aFullScreen, aTargetScreen);
1189 * Invalidate a specified rect for a widget so that it will be repainted
1190 * later.
1192 virtual void Invalidate(const LayoutDeviceIntRect& aRect) = 0;
1194 enum LayerManagerPersistence {
1195 LAYER_MANAGER_CURRENT = 0,
1196 LAYER_MANAGER_PERSISTENT
1200 * Return the widget's LayerManager. The layer tree for that
1201 * LayerManager is what gets rendered to the widget.
1203 virtual WindowRenderer* GetWindowRenderer() = 0;
1206 * Called before each layer manager transaction to allow any preparation
1207 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1209 * Always called on the main thread.
1211 virtual void PrepareWindowEffects() = 0;
1214 * Called on the main thread at the end of WebRender display list building.
1216 virtual void AddWindowOverlayWebRenderCommands(
1217 mozilla::layers::WebRenderBridgeChild* aWrBridge,
1218 mozilla::wr::DisplayListBuilder& aBuilder,
1219 mozilla::wr::IpcResourceUpdateQueue& aResources) {}
1222 * Called when Gecko knows which themed widgets exist in this window.
1223 * The passed array contains an entry for every themed widget of the right
1224 * type (currently only StyleAppearance::Toolbar) within the window, except
1225 * for themed widgets which are transformed or have effects applied to them
1226 * (e.g. CSS opacity or filters).
1227 * This could sometimes be called during display list construction
1228 * outside of painting.
1229 * If called during painting, it will be called before we actually
1230 * paint anything.
1232 virtual void UpdateThemeGeometries(
1233 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1236 * Informs the widget about the region of the window that is opaque.
1238 * @param aOpaqueRegion the region of the window that is opaque.
1240 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1243 * Informs the widget about the region of the window that is draggable.
1245 virtual void UpdateWindowDraggingRegion(
1246 const LayoutDeviceIntRegion& aRegion) {}
1249 * Tells the widget whether the given input block results in a swipe.
1250 * Should be called in response to a WidgetWheelEvent that has
1251 * mFlags.mCanTriggerSwipe set on it.
1253 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1256 * Internal methods
1259 //@{
1260 virtual void AddChild(nsIWidget* aChild) = 0;
1261 virtual void RemoveChild(nsIWidget* aChild) = 0;
1262 virtual void* GetNativeData(uint32_t aDataType) = 0;
1263 virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal) = 0;
1264 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1266 //@}
1269 * Set the widget's title.
1270 * Must be called after Create.
1272 * @param aTitle string displayed as the title of the widget
1274 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1277 * Set the widget's icon.
1278 * Must be called after Create.
1280 * @param aIconSpec string specifying the icon to use; convention is to
1281 * pass a resource: URL from which a platform-dependent
1282 * resource file name will be constructed
1284 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1287 * Return this widget's origin in screen coordinates.
1289 * @return screen coordinates stored in the x,y members
1291 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1294 * The same as WidgetToScreenOffset(), except in the case of
1295 * PuppetWidget where this method omits the chrome offset.
1297 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1298 return WidgetToScreenOffset();
1302 * For a PuppetWidget, returns the transform from the coordinate
1303 * space of the PuppetWidget to the coordinate space of the
1304 * top-level native widget.
1306 * Identity transform in other cases.
1308 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1309 WidgetToTopLevelWidgetTransform() {
1310 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1314 * Given the specified client size, return the corresponding window size,
1315 * which includes the area for the borders and titlebar. This method
1316 * should work even when the window is not yet visible.
1318 virtual LayoutDeviceIntSize ClientToWindowSize(
1319 const LayoutDeviceIntSize& aClientSize) = 0;
1322 * Dispatches an event to the widget
1324 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1325 nsEventStatus& aStatus) = 0;
1328 * Dispatches an event to APZ only.
1329 * No-op in the child process.
1331 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1333 // A structure that groups the statuses from APZ dispatch and content
1334 // dispatch.
1335 struct ContentAndAPZEventStatus {
1336 // Either of these may not be set if the event was not dispatched
1337 // to APZ or to content.
1338 nsEventStatus mApzStatus = nsEventStatus_eIgnore;
1339 nsEventStatus mContentStatus = nsEventStatus_eIgnore;
1343 * Dispatches an event that must be handled by APZ first, when APZ is
1344 * enabled. If invoked in the child process, it is forwarded to the
1345 * parent process synchronously.
1347 virtual ContentAndAPZEventStatus DispatchInputEvent(
1348 mozilla::WidgetInputEvent* aEvent) = 0;
1351 * Confirm an APZ-aware event target. This should be used when APZ will
1352 * not need a layers update to process the event.
1354 virtual void SetConfirmedTargetAPZC(
1355 uint64_t aInputBlockId,
1356 const nsTArray<ScrollableLayerGuid>& aTargets) const = 0;
1359 * Returns true if APZ is in use, false otherwise.
1361 virtual bool AsyncPanZoomEnabled() const = 0;
1364 * Enables the dropping of files to a widget.
1366 virtual void EnableDragDrop(bool aEnable) = 0;
1367 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1370 * Enables/Disables system mouse capture.
1371 * @param aCapture true enables mouse capture, false disables mouse capture
1374 virtual void CaptureMouse(bool aCapture) = 0;
1377 * Classify the window for the window manager. Mostly for X11.
1379 virtual void SetWindowClass(const nsAString& xulWinType) = 0;
1382 * Enables/Disables system capture of any and all events that would cause a
1383 * popup to be rolled up. aListener should be set to a non-null value for
1384 * any popups that are not managed by the popup manager.
1385 * @param aDoCapture true enables capture, false disables capture
1388 virtual void CaptureRollupEvents(nsIRollupListener* aListener,
1389 bool aDoCapture) = 0;
1392 * Bring this window to the user's attention. This is intended to be a more
1393 * gentle notification than popping the window to the top or putting up an
1394 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1395 * the Mac. The notification should be suppressed if the window is already
1396 * in the foreground and should be dismissed when the user brings this window
1397 * to the foreground.
1398 * @param aCycleCount Maximum number of times to animate the window per system
1399 * conventions. If set to -1, cycles indefinitely until
1400 * window is brought into the foreground.
1402 [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) = 0;
1405 * Ask whether there user input events pending. All input events are
1406 * included, including those not targeted at this nsIwidget instance.
1408 virtual bool HasPendingInputEvent() = 0;
1411 * If set to true, the window will draw its contents into the titlebar
1412 * instead of below it.
1414 * Ignored on any platform that does not support it. Ignored by widgets that
1415 * do not represent windows.
1416 * May result in a resize event, so should only be called from places where
1417 * reflow and painting is allowed.
1419 * @param aState Whether drawing into the titlebar should be activated.
1421 virtual void SetDrawsInTitlebar(bool aState) = 0;
1424 * Determine whether the widget shows a resize widget. If it does,
1425 * aResizerRect returns the resizer's rect.
1427 * Returns false on any platform that does not support it.
1429 * @param aResizerRect The resizer's rect in device pixels.
1430 * @return Whether a resize widget is shown.
1432 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1435 * Begin a window resizing drag, based on the event passed in.
1437 [[nodiscard]] virtual nsresult BeginResizeDrag(
1438 mozilla::WidgetGUIEvent* aEvent, int32_t aHorizontal,
1439 int32_t aVertical) = 0;
1441 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1442 // EnumSet class.
1443 enum Modifiers : uint32_t {
1444 NO_MODIFIERS = 0x00000000,
1445 CAPS_LOCK = 0x00000001, // when CapsLock is active
1446 NUM_LOCK = 0x00000002, // when NumLock is active
1447 SHIFT_L = 0x00000100,
1448 SHIFT_R = 0x00000200,
1449 CTRL_L = 0x00000400,
1450 CTRL_R = 0x00000800,
1451 ALT_L = 0x00001000, // includes Option
1452 ALT_R = 0x00002000,
1453 COMMAND_L = 0x00004000,
1454 COMMAND_R = 0x00008000,
1455 HELP = 0x00010000,
1456 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1457 // AltRight key behavior of keyboard
1458 // layouts which maps AltGr to AltRight
1459 // key.
1460 FUNCTION = 0x00100000,
1461 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1464 * Utility method intended for testing. Dispatches native key events
1465 * to this widget to simulate the press and release of a key.
1466 * @param aNativeKeyboardLayout a *platform-specific* constant.
1467 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1468 * On Windows, it is converted to a hex string and passed to
1469 * LoadKeyboardLayout, see
1470 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1471 * @param aNativeKeyCode a *platform-specific* keycode.
1472 * On Windows, this is the virtual key code.
1473 * @param aModifiers some combination of the above 'Modifiers' flags;
1474 * not all flags will apply to all platforms. Mac ignores the _R
1475 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1476 * FUNCTION.
1477 * @param aCharacters characters that the OS would decide to generate
1478 * from the event. On Windows, this is the charCode passed by
1479 * WM_CHAR.
1480 * @param aUnmodifiedCharacters characters that the OS would decide
1481 * to generate from the event if modifier keys (other than shift)
1482 * were assumed inactive. Needed on Mac, ignored on Windows.
1483 * @param aObserver the observer that will get notified once the events
1484 * have been dispatched.
1485 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1486 * layout is not supported and the event was not fired
1488 virtual nsresult SynthesizeNativeKeyEvent(
1489 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1490 uint32_t aModifierFlags, const nsAString& aCharacters,
1491 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1494 * Utility method intended for testing. Dispatches native mouse events
1495 * may even move the mouse cursor. On Mac the events are guaranteed to
1496 * be sent to the window containing this widget, but on Windows they'll go
1497 * to whatever's topmost on the screen at that position, so for
1498 * cross-platform testing ensure that your window is at the top of the
1499 * z-order.
1500 * @param aPoint screen location of the mouse, in device
1501 * pixels, with origin at the top left
1502 * @param aNativeMessage abstract native message.
1503 * @param aButton Mouse button defined by DOM UI Events.
1504 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1505 * FYI: On Windows, Android and Headless widget on all
1506 * platroms, this hasn't been handled yet.
1507 * @param aObserver the observer that will get notified once the events
1508 * have been dispatched.
1510 enum class NativeMouseMessage : uint32_t {
1511 ButtonDown, // button down
1512 ButtonUp, // button up
1513 Move, // mouse cursor move
1514 EnterWindow, // mouse cursor comes into a window
1515 LeaveWindow, // mouse cursor leaves from a window
1517 virtual nsresult SynthesizeNativeMouseEvent(
1518 LayoutDeviceIntPoint aPoint, NativeMouseMessage aNativeMessage,
1519 mozilla::MouseButton aButton, nsIWidget::Modifiers aModifierFlags,
1520 nsIObserver* aObserver) = 0;
1523 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1524 * message. aPoint is location in device pixels to which the mouse pointer
1525 * moves to.
1526 * @param aObserver the observer that will get notified once the events
1527 * have been dispatched.
1529 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1530 nsIObserver* aObserver) = 0;
1533 * Utility method intended for testing. Dispatching native mouse scroll
1534 * events may move the mouse cursor.
1536 * @param aPoint Mouse cursor position in screen coordinates.
1537 * In device pixels, the origin at the top left of
1538 * the primary display.
1539 * @param aNativeMessage Platform native message.
1540 * @param aDeltaX The delta value for X direction. If the native
1541 * message doesn't indicate X direction scrolling,
1542 * this may be ignored.
1543 * @param aDeltaY The delta value for Y direction. If the native
1544 * message doesn't indicate Y direction scrolling,
1545 * this may be ignored.
1546 * @param aDeltaZ The delta value for Z direction. If the native
1547 * message doesn't indicate Z direction scrolling,
1548 * this may be ignored.
1549 * @param aModifierFlags Must be values of Modifiers, or zero.
1550 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1551 * document.
1552 * @param aObserver The observer that will get notified once the
1553 * events have been dispatched.
1555 virtual nsresult SynthesizeNativeMouseScrollEvent(
1556 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1557 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1558 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1561 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1562 * touch states in nsIDOMWindowUtils.idl.
1564 enum TouchPointerState {
1565 // The pointer is in a hover state above the digitizer
1566 TOUCH_HOVER = (1 << 0),
1567 // The pointer is in contact with the digitizer
1568 TOUCH_CONTACT = (1 << 1),
1569 // The pointer has been removed from the digitizer detection area
1570 TOUCH_REMOVE = (1 << 2),
1571 // The pointer has been canceled. Will cancel any pending os level
1572 // gestures that would triggered as a result of completion of the
1573 // input sequence. This may not cancel moz platform related events
1574 // that might get tirggered by input already delivered.
1575 TOUCH_CANCEL = (1 << 3),
1577 // ALL_BITS used for validity checking during IPC serialization
1578 ALL_BITS = (1 << 4) - 1
1581 * TouchpadGesturePhase states for SynthesizeNativeTouchPadPinch and
1582 * SynthesizeNativeTouchpadPan. Match phase states in nsIDOMWindowUtils.idl.
1584 enum TouchpadGesturePhase {
1585 PHASE_BEGIN = 0,
1586 PHASE_UPDATE = 1,
1587 PHASE_END = 2
1590 * Create a new or update an existing touch pointer on the digitizer.
1591 * To trigger os level gestures, individual touch points should
1592 * transition through a complete set of touch states which should be
1593 * sent as individual messages.
1595 * @param aPointerId The touch point id to create or update.
1596 * @param aPointerState one or more of the touch states listed above
1597 * @param aPoint coords of this event
1598 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1599 * @param aOrientation 0 -> 359 degree value indicating the
1600 * orientation of the pointer. Use 90 for normal taps.
1601 * @param aObserver The observer that will get notified once the events
1602 * have been dispatched.
1604 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1605 TouchPointerState aPointerState,
1606 LayoutDeviceIntPoint aPoint,
1607 double aPointerPressure,
1608 uint32_t aPointerOrientation,
1609 nsIObserver* aObserver) = 0;
1611 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1613 virtual nsresult SynthesizeNativeTouchPadPinch(
1614 TouchpadGesturePhase aEventPhase, float aScale,
1615 LayoutDeviceIntPoint aPoint, int32_t aModifierFlags) = 0;
1618 * Helper for simulating a simple tap event with one touch point. When
1619 * aLongTap is true, simulates a native long tap with a duration equal to
1620 * ui.click_hold_context_menus.delay. This pref is compatible with the
1621 * apzc long tap duration. Defaults to 1.5 seconds.
1622 * @param aObserver The observer that will get notified once the events
1623 * have been dispatched.
1625 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1626 bool aLongTap,
1627 nsIObserver* aObserver);
1629 virtual nsresult SynthesizeNativePenInput(uint32_t aPointerId,
1630 TouchPointerState aPointerState,
1631 LayoutDeviceIntPoint aPoint,
1632 double aPressure,
1633 uint32_t aRotation, int32_t aTiltX,
1634 int32_t aTiltY, int32_t aButton,
1635 nsIObserver* aObserver) = 0;
1638 * Cancels all active simulated touch input points and pending long taps.
1639 * Native widgets should track existing points such that they can clear the
1640 * digitizer state when this call is made.
1641 * @param aObserver The observer that will get notified once the touch
1642 * sequence has been cleared.
1644 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1647 * Send a native event as if the user double tapped the touchpad with two
1648 * fingers.
1650 virtual nsresult SynthesizeNativeTouchpadDoubleTap(
1651 LayoutDeviceIntPoint aPoint, uint32_t aModifierFlags) = 0;
1654 * See nsIDOMWindowUtils.sendNativeTouchpadPan().
1656 virtual nsresult SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase,
1657 LayoutDeviceIntPoint aPoint,
1658 double aDeltaX, double aDeltaY,
1659 int32_t aModifierFlags) = 0;
1661 virtual void StartAsyncScrollbarDrag(
1662 const AsyncDragMetrics& aDragMetrics) = 0;
1665 * Notify APZ to start autoscrolling.
1666 * @param aAnchorLocation the location of the autoscroll anchor
1667 * @param aGuid identifies the scroll frame to be autoscrolled
1668 * @return true if APZ has been successfully notified
1670 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1671 const ScrollableLayerGuid& aGuid) = 0;
1674 * Notify APZ to stop autoscrolling.
1675 * @param aGuid identifies the scroll frame which is being autoscrolled.
1677 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid& aGuid) = 0;
1679 virtual LayersId GetRootLayerTreeId() = 0;
1681 // If this widget supports out-of-process compositing, it can override
1682 // this method to provide additional information to the compositor.
1683 virtual void GetCompositorWidgetInitData(
1684 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1687 * Setter/Getter of the system font setting for testing.
1689 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1690 return NS_ERROR_NOT_IMPLEMENTED;
1692 virtual nsresult GetSystemFont(nsCString& aFontName) {
1693 return NS_ERROR_NOT_IMPLEMENTED;
1696 // Get rectangle of the screen where the window is placed.
1697 // It's used to detect popup overflow under Wayland because
1698 // Screenmanager does not work under it.
1699 virtual nsRect GetPreferredPopupRect() {
1700 NS_WARNING("GetPreferredPopupRect implemented only for wayland");
1701 return nsRect(0, 0, 0, 0);
1703 virtual void FlushPreferredPopupRect() {
1704 NS_WARNING("FlushPreferredPopupRect implemented only for wayland");
1705 return;
1709 * If this widget uses native pointer lock instead of warp-to-center
1710 * (currently only GTK on Wayland), these methods provide access to that
1711 * functionality.
1713 virtual void SetNativePointerLockCenter(
1714 const LayoutDeviceIntPoint& aLockCenter) {}
1715 virtual void LockNativePointer() {}
1716 virtual void UnlockNativePointer() {}
1719 * Get safe area insets except to cutout.
1720 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1722 virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const {
1723 return mozilla::ScreenIntMargin();
1726 private:
1727 class LongTapInfo {
1728 public:
1729 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1730 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1731 : mPointerId(aPointerId),
1732 mPosition(aPoint),
1733 mDuration(aDuration),
1734 mObserver(aObserver),
1735 mStamp(mozilla::TimeStamp::Now()) {}
1737 int32_t mPointerId;
1738 LayoutDeviceIntPoint mPosition;
1739 mozilla::TimeDuration mDuration;
1740 nsCOMPtr<nsIObserver> mObserver;
1741 mozilla::TimeStamp mStamp;
1744 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1746 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1747 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1749 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1750 nsCOMPtr<nsITimer> mLongTapTimer;
1751 static int32_t sPointerIdCounter;
1753 public:
1755 * If key events have not been handled by content or XBL handlers, they can
1756 * be offered to the system (for custom application shortcuts set in system
1757 * preferences, for example).
1759 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1762 * Activates a native menu item at the position specified by the index
1763 * string. The index string is a string of positive integers separated
1764 * by the "|" (pipe) character. The last integer in the string represents
1765 * the item index in a submenu located using the integers preceding it.
1767 * Example: 1|0|4
1768 * In this string, the first integer represents the top-level submenu
1769 * in the native menu bar. Since the integer is 1, it is the second submeu
1770 * in the native menu bar. Within that, the first item (index 0) is a
1771 * submenu, and we want to activate the 5th item within that submenu.
1773 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1776 * This is used for native menu system testing.
1778 * Updates a native menu at the position specified by the index string.
1779 * The index string is a string of positive integers separated by the "|"
1780 * (pipe) character.
1782 * Example: 1|0|4
1783 * In this string, the first integer represents the top-level submenu
1784 * in the native menu bar. Since the integer is 1, it is the second submeu
1785 * in the native menu bar. Within that, the first item (index 0) is a
1786 * submenu, and we want to update submenu at index 4 within that submenu.
1788 * If this is called with an empty string it forces a full reload of the
1789 * menu system.
1791 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1794 * This is used for testing macOS service menu code.
1796 * @param aResult - the current text selection. Is empty if no selection.
1797 * @return nsresult - whether or not aResult was assigned the selected text.
1799 [[nodiscard]] virtual nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1800 return NS_ERROR_NOT_IMPLEMENTED;
1804 * Notify IME of the specified notification.
1806 * @return If the notification is mouse button event and it's consumed by
1807 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1809 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1812 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1813 * of the widget, in the event that we were not able to observe and respond to
1814 * the initial focus event. This is necessary for the early skeleton UI
1815 * window, which is displayed and receives its initial focus event before we
1816 * can actually respond to it.
1818 virtual void MaybeDispatchInitialFocusEvent() {}
1821 * Notifies the input context changes.
1823 virtual void SetInputContext(const InputContext& aContext,
1824 const InputContextAction& aAction) = 0;
1827 * Get current input context.
1829 virtual InputContext GetInputContext() = 0;
1832 * Get native IME context. This is different from GetNativeData() with
1833 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1834 * process.
1836 virtual NativeIMEContext GetNativeIMEContext() = 0;
1839 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1840 * native (OS-level) event for it. This method allows tests to simulate
1841 * keystrokes that trigger native key bindings (which require a native
1842 * event).
1844 [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
1845 mozilla::WidgetKeyboardEvent& aEvent) = 0;
1848 * Retrieve edit commands when the key combination of aEvent is used
1849 * in platform native applications.
1851 enum NativeKeyBindingsType : uint8_t {
1852 NativeKeyBindingsForSingleLineEditor,
1853 NativeKeyBindingsForMultiLineEditor,
1854 NativeKeyBindingsForRichTextEditor
1856 MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
1857 NativeKeyBindingsType aType, const mozilla::WidgetKeyboardEvent& aEvent,
1858 nsTArray<mozilla::CommandInt>& aCommands);
1861 * Retrieves a reference to notification requests of IME. Note that the
1862 * reference is valid while the nsIWidget instance is alive. So, if you
1863 * need to store the reference for a long time, you need to grab the widget
1864 * instance too.
1866 const IMENotificationRequests& IMENotificationRequestsRef();
1869 * Call this method when a dialog is opened which has a default button.
1870 * The button's rectangle should be supplied in aButtonRect.
1872 [[nodiscard]] virtual nsresult OnDefaultButtonLoaded(
1873 const LayoutDeviceIntRect& aButtonRect) = 0;
1876 * Return true if this process shouldn't use platform widgets, and
1877 * so should use PuppetWidgets instead. If this returns true, the
1878 * result of creating and using a platform widget is undefined,
1879 * and likely to end in crashes or other buggy behavior.
1881 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1883 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1885 static already_AddRefed<nsIWidget> CreateChildWindow();
1888 * Allocate and return a "puppet widget" that doesn't directly
1889 * correlate to a platform widget; platform events and data must
1890 * be fed to it. Currently used in content processes. NULL is
1891 * returned if puppet widgets aren't supported in this build
1892 * config, on this platform, or for this process type.
1894 * This function is called "Create" to match CreateInstance().
1895 * The returned widget must still be nsIWidget::Create()d.
1897 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1898 BrowserChild* aBrowserChild);
1900 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1903 * Reparent this widget's native widget.
1904 * @param aNewParent the native widget of aNewParent is the new native
1905 * parent widget
1907 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1910 * Return true if widget has it's own GL context
1912 virtual bool HasGLContext() { return false; }
1915 * Returns true to indicate that this widget paints an opaque background
1916 * that we want to be visible under the page, so layout should not force
1917 * a default background.
1919 virtual bool WidgetPaintsBackground() { return false; }
1921 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1924 * Get the natural bounds of this widget. This method is only
1925 * meaningful for widgets for which Gecko implements screen
1926 * rotation natively. When this is the case, GetBounds() returns
1927 * the widget bounds taking rotation into account, and
1928 * GetNaturalBounds() returns the bounds *not* taking rotation
1929 * into account.
1931 * No code outside of the composition pipeline should know or care
1932 * about this. If you're not an agent of the compositor, you
1933 * probably shouldn't call this method.
1935 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1938 * Set size constraints on the window size such that it is never less than
1939 * the specified minimum size and never larger than the specified maximum
1940 * size. The size constraints are sizes of the outer rectangle including
1941 * the window frame and title bar. Use 0 for an unconstrained minimum size
1942 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1943 * does not necessarily change the size of a window to conform to this size,
1944 * thus Resize should be called afterwards.
1946 * @param aConstraints: the size constraints in device pixels
1948 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1951 * Return the size constraints currently observed by the widget.
1953 * @return the constraints in device pixels
1955 virtual const SizeConstraints GetSizeConstraints() = 0;
1958 * Apply the current size constraints to the given size.
1960 * @param aWidth width to constrain
1961 * @param aHeight height to constrain
1963 virtual void ConstrainSize(int32_t* aWidth, int32_t* aHeight) = 0;
1966 * If this is owned by a BrowserChild, return that. Otherwise return
1967 * null.
1969 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
1972 * If this isn't directly compositing to its window surface,
1973 * return the compositor which is doing that on our behalf.
1975 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
1978 * Clear WebRender resources
1980 virtual void ClearCachedWebrenderResources() {}
1983 * If this widget has its own vsync source, return it, otherwise return
1984 * nullptr. An example of such local source would be Wayland frame callbacks.
1986 virtual RefPtr<mozilla::gfx::VsyncSource> GetVsyncSource() { return nullptr; }
1989 * Returns true if the widget requires synchronous repaints on resize,
1990 * false otherwise.
1992 virtual bool SynchronouslyRepaintOnResize() { return true; }
1995 * Some platforms (only cocoa right now) round widget coordinates to the
1996 * nearest even pixels (see bug 892994), this function allows us to
1997 * determine how widget coordinates will be rounded.
1999 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2001 virtual void UpdateZoomConstraints(
2002 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2003 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2006 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2007 * widget. Note that this never returns nullptr.
2009 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2012 * GetNativeTextEventDispatcherListener() returns a
2013 * TextEventDispatcherListener instance which is used when the widget
2014 * instance handles native IME and/or keyboard events.
2016 virtual TextEventDispatcherListener*
2017 GetNativeTextEventDispatcherListener() = 0;
2019 virtual void ZoomToRect(const uint32_t& aPresShellId,
2020 const ScrollableLayerGuid::ViewID& aViewId,
2021 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2024 * LookUpDictionary shows the dictionary for the word around current point.
2026 * @param aText the word to look up dictiorary.
2027 * @param aFontRangeArray text decoration of aText
2028 * @param aIsVertical true if the word is vertical layout
2029 * @param aPoint top-left point of aText
2031 virtual void LookUpDictionary(
2032 const nsAString& aText,
2033 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2034 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2036 virtual void RequestFxrOutput() {
2037 MOZ_ASSERT(false, "This function should only execute in Windows");
2040 #if defined(MOZ_WIDGET_ANDROID)
2042 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2043 * thread.
2045 * @param aMessage message being sent to Android UI thread.
2047 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2050 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2051 * thread
2053 * @param aScrollOffset page scroll offset value in screen pixels.
2054 * @param aZoom current page zoom.
2056 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2057 const CSSToScreenScale& aZoom) = 0;
2060 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2061 * for android robocop tests.
2063 * @param aMem shared memory containing the frame buffer pixels.
2064 * @param aSize size of the buffer in screen pixels.
2066 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2067 const ScreenIntSize& aSize,
2068 bool aNeedsYFlip) = 0;
2070 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2071 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2072 return 0;
2074 #endif
2076 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2079 * Like GetDefaultScale, but taking into account only the system settings
2080 * and ignoring Gecko preferences.
2082 virtual double GetDefaultScaleInternal() { return 1.0; }
2085 * Layout uses this to alert the widget to the client rect representing
2086 * the window maximize button. An empty rect indicates there is no
2087 * maximize button (for example, in fullscreen). This is only implemented
2088 * on Windows.
2090 virtual void SetWindowButtonRect(WindowButtonType aButtonType,
2091 const LayoutDeviceIntRect& aClientRect) {}
2093 protected:
2094 // keep the list of children. We also keep track of our siblings.
2095 // The ownership model is as follows: parent holds a strong ref to
2096 // the first element of the list, and each element holds a strong
2097 // ref to the next element in the list. The prevsibling and
2098 // lastchild pointers are weak, which is fine as long as they are
2099 // maintained properly.
2100 nsCOMPtr<nsIWidget> mFirstChild;
2101 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2102 nsCOMPtr<nsIWidget> mNextSibling;
2103 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2104 // When Destroy() is called, the sub class should set this true.
2105 bool mOnDestroyCalled;
2106 nsWindowType mWindowType;
2107 int32_t mZIndex;
2110 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2112 #endif // nsIWidget_h__