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/. */
11 #include "ErrorList.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"
32 #include "nsIObserver.h"
33 #include "nsISupports.h"
36 #include "nsIWidgetListener.h"
39 #include "nsStringFwd.h"
41 #include "nsTHashMap.h"
42 #include "nsWidgetInitData.h"
43 #include "nsXULAppAPI.h"
46 # include "VsyncSource.h"
49 // forward declarations
50 class nsIBidiKeyboard
;
51 class nsIRollupListener
;
59 class NativeEventData
;
61 class WidgetInputEvent
;
62 class WidgetKeyboardEvent
;
65 enum class StyleWindowShadow
: uint8_t;
67 #if defined(MOZ_WIDGET_ANDROID)
71 #endif // defined(MOZ_WIDGET_ANDROID)
74 enum class CallerType
: uint32_t;
78 class AsyncDragMetrics
;
80 class CompositorBridgeChild
;
83 class WebRenderBridgeChild
;
89 class TextEventDispatcher
;
90 class TextEventDispatcherListener
;
91 class CompositorWidget
;
92 class CompositorWidgetInitData
;
95 class DisplayListBuilder
;
96 class IpcResourceUpdateQueue
;
97 enum class RenderRoot
: uint8_t;
99 } // namespace mozilla
102 * Callback function that processes events.
104 * The argument is actually a subtype (subclass) of WidgetEvent which carries
105 * platform specific information about the event. Platform specific code
106 * knows how to deal with it.
108 * The return value determines whether or not the default action should take
111 typedef nsEventStatus (*EVENT_CALLBACK
)(mozilla::WidgetGUIEvent
* aEvent
);
113 // Hide the native window system's real window type so as to avoid
114 // including native window system types and APIs. This is necessary
115 // to ensure cross-platform code.
116 typedef void* nsNativeWidget
;
119 * Flags for the GetNativeData and SetNativeData functions
121 #define NS_NATIVE_WINDOW 0
122 #define NS_NATIVE_GRAPHIC 1
123 #define NS_NATIVE_TMP_WINDOW 2
124 #define NS_NATIVE_WIDGET 3
125 #define NS_NATIVE_DISPLAY 4
126 #define NS_NATIVE_REGION 5
127 #define NS_NATIVE_OFFSETX 6
128 #define NS_NATIVE_OFFSETY 7
129 #define NS_NATIVE_PLUGIN_PORT 8
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 // See RegisterPluginWindowForRemoteUpdates
135 #define NS_NATIVE_PLUGIN_ID 13
136 // This is available only with GetNativeData() in parent process. Anybody
137 // shouldn't access this pointer as a valid pointer since the result may be
138 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
139 // an identifier of distinguishing a text composition is caused by which native
140 // IME context. Note that the result is only valid in the process. So,
141 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
142 #define NS_RAW_NATIVE_IME_CONTEXT 14
143 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
145 # define NS_NATIVE_PLUGIN_PORT_QD 100
146 # define NS_NATIVE_PLUGIN_PORT_CG 101
149 # define NS_NATIVE_TSF_THREAD_MGR 100
150 # define NS_NATIVE_TSF_CATEGORY_MGR 101
151 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
152 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
154 #if defined(MOZ_WIDGET_GTK)
155 // set/get nsPluginNativeWindowGtk, e10s specific
156 # define NS_NATIVE_PLUGIN_OBJECT_PTR 104
157 # define NS_NATIVE_EGL_WINDOW 106
159 #ifdef MOZ_WIDGET_ANDROID
160 # define NS_JAVA_SURFACE 100
161 # define NS_PRESENTATION_WINDOW 101
162 # define NS_PRESENTATION_SURFACE 102
165 #define MOZ_WIDGET_MAX_SIZE 16384
166 #define MOZ_WIDGET_INVALID_SCALE 0.0
168 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
169 #define NS_IWIDGET_IID \
171 0x06396bf6, 0x2dd8, 0x45e5, { \
172 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
180 enum nsTransparencyMode
{
181 eTransparencyOpaque
= 0, // Fully opaque
182 eTransparencyTransparent
, // Parts of the window may be transparent
183 eTransparencyGlass
, // Transparent parts of the window have Vista AeroGlass
185 eTransparencyBorderlessGlass
// As above, but without a border around the
186 // opaque areas when there would otherwise be
187 // one with eTransparencyGlass
188 // If you add to the end here, you must update the serialization code in
189 // WidgetMessageUtils.h
196 enum nsCursor
{ ///(normal cursor, usually rendered as an arrow)
198 ///(system is busy, usually rendered as a hourglass or watch)
200 ///(Selecting something, usually rendered as an IBeam)
202 ///(can hyper-link, usually rendered as a human hand)
204 ///(north/south/west/east edge sizing)
217 eCursor_copy
, // CSS3
219 eCursor_context_menu
,
230 eCursor_vertical_text
,
237 // This one is used for array sizing, and so better be the last
238 // one in this list...
241 // ...except for this one.
242 eCursorInvalid
= eCursorCount
+ 1
245 enum nsTopLevelWidgetZPlacement
{ // for PlaceBehind()
246 eZPlacementBottom
= 0, // bottom of the window stack
247 eZPlacementBelow
, // just below another widget
248 eZPlacementTop
// top of the window stack
252 * Before the OS goes to sleep, this topic is notified.
254 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
257 * After the OS wakes up, this topic is notified.
259 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
262 * Before the OS suspends the current process, this topic is notified. Some
263 * OS will kill processes that are suspended instead of resuming them.
264 * For that reason this topic may be useful to safely close down resources.
266 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
269 * After the current process resumes from being suspended, this topic is
272 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
275 * When an app(-shell) is activated by the OS, this topic is notified.
276 * Currently, this only happens on Mac OSX.
278 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
284 * Size constraints for setting the minimum and maximum size of a widget.
285 * Values are in device pixels.
287 struct SizeConstraints
{
289 : mMaxSize(MOZ_WIDGET_MAX_SIZE
, MOZ_WIDGET_MAX_SIZE
),
290 mScale(MOZ_WIDGET_INVALID_SCALE
) {}
292 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize
,
293 mozilla::LayoutDeviceIntSize aMaxSize
,
294 mozilla::DesktopToLayoutDeviceScale aScale
)
295 : mMinSize(aMinSize
), mMaxSize(aMaxSize
), mScale(aScale
) {
296 if (mMaxSize
.width
> MOZ_WIDGET_MAX_SIZE
) {
297 mMaxSize
.width
= MOZ_WIDGET_MAX_SIZE
;
299 if (mMaxSize
.height
> MOZ_WIDGET_MAX_SIZE
) {
300 mMaxSize
.height
= MOZ_WIDGET_MAX_SIZE
;
304 mozilla::LayoutDeviceIntSize mMinSize
;
305 mozilla::LayoutDeviceIntSize mMaxSize
;
308 * The scale used to convert from desktop to device dimensions.
309 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
311 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
312 * with multi-monitor scaling issues in more complete way across
313 * all widget implementations.
315 mozilla::DesktopToLayoutDeviceScale mScale
;
318 struct AutoObserverNotifier
{
319 AutoObserverNotifier(nsIObserver
* aObserver
, const char* aTopic
)
320 : mObserver(aObserver
), mTopic(aTopic
) {}
322 void SkipNotification() { mObserver
= nullptr; }
324 uint64_t SaveObserver() {
328 uint64_t observerId
= ++sObserverId
;
329 sSavedObservers
.InsertOrUpdate(observerId
, mObserver
);
334 ~AutoObserverNotifier() {
336 mObserver
->Observe(nullptr, mTopic
, nullptr);
340 static void NotifySavedObserver(const uint64_t& aObserverId
,
341 const char* aTopic
) {
342 nsCOMPtr
<nsIObserver
> observer
= sSavedObservers
.Get(aObserverId
);
344 MOZ_ASSERT(aObserverId
== 0,
345 "We should always find a saved observer for nonzero IDs");
349 sSavedObservers
.Remove(aObserverId
);
350 observer
->Observe(nullptr, aTopic
, nullptr);
354 nsCOMPtr
<nsIObserver
> mObserver
;
358 static uint64_t sObserverId
;
359 static nsTHashMap
<uint64_t, nsCOMPtr
<nsIObserver
>> sSavedObservers
;
362 } // namespace widget
363 } // namespace mozilla
366 * The base class for all the widgets. It provides the interface for
367 * all basic and necessary functionality.
369 class nsIWidget
: public nsISupports
{
371 typedef mozilla::dom::BrowserChild BrowserChild
;
374 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild
;
375 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics
;
376 typedef mozilla::layers::FrameMetrics FrameMetrics
;
377 typedef mozilla::layers::LayerManager LayerManager
;
378 typedef mozilla::WindowRenderer WindowRenderer
;
379 typedef mozilla::layers::LayersBackend LayersBackend
;
380 typedef mozilla::layers::LayersId LayersId
;
381 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid
;
382 typedef mozilla::layers::ZoomConstraints ZoomConstraints
;
383 typedef mozilla::widget::IMEEnabled IMEEnabled
;
384 typedef mozilla::widget::IMEMessage IMEMessage
;
385 typedef mozilla::widget::IMENotification IMENotification
;
386 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests
;
387 typedef mozilla::widget::IMEState IMEState
;
388 typedef mozilla::widget::InputContext InputContext
;
389 typedef mozilla::widget::InputContextAction InputContextAction
;
390 typedef mozilla::widget::NativeIMEContext NativeIMEContext
;
391 typedef mozilla::widget::SizeConstraints SizeConstraints
;
392 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher
;
393 typedef mozilla::widget::TextEventDispatcherListener
394 TextEventDispatcherListener
;
395 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin
;
396 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint
;
397 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect
;
398 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion
;
399 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize
;
400 typedef mozilla::ScreenIntPoint ScreenIntPoint
;
401 typedef mozilla::ScreenIntMargin ScreenIntMargin
;
402 typedef mozilla::ScreenIntSize ScreenIntSize
;
403 typedef mozilla::ScreenPoint ScreenPoint
;
404 typedef mozilla::CSSToScreenScale CSSToScreenScale
;
405 typedef mozilla::DesktopIntRect DesktopIntRect
;
406 typedef mozilla::DesktopPoint DesktopPoint
;
407 typedef mozilla::DesktopRect DesktopRect
;
408 typedef mozilla::DesktopSize DesktopSize
;
409 typedef mozilla::CSSPoint CSSPoint
;
410 typedef mozilla::CSSRect CSSRect
;
412 // Used in UpdateThemeGeometries.
413 struct ThemeGeometry
{
414 // The ThemeGeometryType value for the themed widget, see
415 // nsITheme::ThemeGeometryTypeForWidget.
416 nsITheme::ThemeGeometryType mType
;
417 // The device-pixel rect within the window for the themed widget
418 LayoutDeviceIntRect mRect
;
420 ThemeGeometry(nsITheme::ThemeGeometryType aType
,
421 const LayoutDeviceIntRect
& aRect
)
422 : mType(aType
), mRect(aRect
) {}
425 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID
)
428 : mLastChild(nullptr),
429 mPrevSibling(nullptr),
430 mOnDestroyCalled(false),
431 mWindowType(eWindowType_child
),
435 ClearNativeTouchSequence(nullptr);
439 * Create and initialize a widget.
441 * All the arguments can be null in which case a top level window
442 * with size 0 is created. The event callback function has to be
443 * provided only if the caller wants to deal with the events this
444 * widget receives. The event callback is basically a preprocess
445 * hook called synchronously. The return value determines whether
446 * the event goes to the default window procedure or it is hidden
447 * to the os. The assumption is that if the event handler returns
448 * false the widget does not see the event. The widget should not
449 * automatically clear the window to the background color. The
450 * calling code must handle paint messages and clear the background
453 * In practice at least one of aParent and aNativeParent will be null. If
454 * both are null the widget isn't parented (e.g. context menus or
455 * independent top level windows).
457 * The dimensions given in aRect are specified in the parent's
458 * device coordinate system.
459 * This must not be called for parentless widgets such as top-level
460 * windows, which use the desktop pixel coordinate system; a separate
461 * method is provided for these.
463 * @param aParent parent nsIWidget
464 * @param aNativeParent native parent widget
465 * @param aRect the widget dimension
466 * @param aInitData data that is used for widget initialization
469 [[nodiscard
]] virtual nsresult
Create(
470 nsIWidget
* aParent
, nsNativeWidget aNativeParent
,
471 const LayoutDeviceIntRect
& aRect
,
472 nsWidgetInitData
* aInitData
= nullptr) = 0;
475 * As above, but with aRect specified in DesktopPixel units (for top-level
477 * Default implementation just converts aRect to device pixels and calls
478 * through to device-pixel Create, but platforms may override this if the
479 * mapping is not straightforward or the native platform needs to use the
480 * desktop pixel values directly.
482 [[nodiscard
]] virtual nsresult
Create(nsIWidget
* aParent
,
483 nsNativeWidget aNativeParent
,
484 const DesktopIntRect
& aRect
,
485 nsWidgetInitData
* aInitData
= nullptr) {
486 LayoutDeviceIntRect devPixRect
=
487 RoundedToInt(aRect
* GetDesktopToDeviceScale());
488 return Create(aParent
, aNativeParent
, devPixRect
, aInitData
);
492 * Allocate, initialize, and return a widget that is a child of
493 * |this|. The returned widget (if nonnull) has gone through the
494 * equivalent of CreateInstance(widgetCID) + Create(...).
496 * |CreateChild()| lets widget backends decide whether to parent
497 * the new child widget to this, nonnatively parent it, or both.
498 * This interface exists to support the PuppetWidget backend,
499 * which is entirely non-native. All other params are the same as
502 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
503 * |nsIWidget*| this, not its native widget (if it exists), when
504 * calling |Create()|. This is a timid hack around poorly
505 * understood code, and shouldn't be used in new code.
507 virtual already_AddRefed
<nsIWidget
> CreateChild(
508 const LayoutDeviceIntRect
& aRect
, nsWidgetInitData
* aInitData
= nullptr,
509 bool aForceUseIWidgetParent
= false) = 0;
512 * Attach to a top level widget.
514 * In cases where a top level chrome widget is being used as a content
515 * container, attach a secondary listener and update the device
516 * context. The primary widget listener will continue to be called for
517 * notifications relating to the top-level window, whereas other
518 * notifications such as painting and events will instead be called via
519 * the attached listener. SetAttachedWidgetListener should be used to
520 * assign the attached listener.
522 * aUseAttachedEvents if true, events are sent to the attached listener
523 * instead of the normal listener.
525 virtual void AttachViewToTopLevel(bool aUseAttachedEvents
) = 0;
528 * Accessor functions to get and set the attached listener. Used by
529 * nsView in connection with AttachViewToTopLevel above.
531 virtual void SetAttachedWidgetListener(nsIWidgetListener
* aListener
) = 0;
532 virtual nsIWidgetListener
* GetAttachedWidgetListener() = 0;
533 virtual void SetPreviouslyAttachedWidgetListener(
534 nsIWidgetListener
* aListener
) = 0;
535 virtual nsIWidgetListener
* GetPreviouslyAttachedWidgetListener() = 0;
538 * Accessor functions to get and set the listener which handles various
539 * actions for the widget.
542 virtual nsIWidgetListener
* GetWidgetListener() = 0;
543 virtual void SetWidgetListener(nsIWidgetListener
* alistener
) = 0;
547 * Close and destroy the internal native window.
548 * This method does not delete the widget.
551 virtual void Destroy() = 0;
554 * Destroyed() returns true if Destroy() has been called already.
557 bool Destroyed() const { return mOnDestroyCalled
; }
562 * Change the widget's parent. Null parents are allowed.
564 * @param aNewParent new parent
566 virtual void SetParent(nsIWidget
* aNewParent
) = 0;
569 * Return the parent Widget of this Widget or nullptr if this is a
572 * @return the parent widget or nullptr if it does not have a parent
575 virtual nsIWidget
* GetParent(void) = 0;
578 * Return the top level Widget of this Widget
580 * @return the top level widget
582 virtual nsIWidget
* GetTopLevelWidget() = 0;
585 * Return the top (non-sheet) parent of this Widget if it's a sheet,
586 * or nullptr if this isn't a sheet (or some other error occurred).
587 * Sheets are only supported on some platforms (currently only macOS).
589 * @return the top (non-sheet) parent widget or nullptr
592 virtual nsIWidget
* GetSheetWindowParent(void) = 0;
595 * Return the physical DPI of the screen containing the window ...
596 * the number of device pixels per inch.
598 virtual float GetDPI() = 0;
601 * Return the scaling factor between device pixels and the platform-
602 * dependent "desktop pixels" used to manage window positions on a
603 * potentially multi-screen, mixed-resolution desktop.
605 virtual mozilla::DesktopToLayoutDeviceScale
GetDesktopToDeviceScale() = 0;
608 * Return the scaling factor between device pixels and the platform-
609 * dependent "desktop pixels" by looking up the screen by the position
612 virtual mozilla::DesktopToLayoutDeviceScale
613 GetDesktopToDeviceScaleByScreen() = 0;
616 * Return the default scale factor for the window. This is the
617 * default number of device pixels per CSS pixel to use. This should
618 * depend on OS/platform settings such as the Mac's "UI scale factor"
619 * or Windows' "font DPI". This will take into account Gecko preferences
620 * overriding the system setting.
622 mozilla::CSSToLayoutDeviceScale
GetDefaultScale();
625 * Return the first child of this widget. Will return null if
626 * there are no children.
628 nsIWidget
* GetFirstChild() const { return mFirstChild
; }
631 * Return the last child of this widget. Will return null if
632 * there are no children.
634 nsIWidget
* GetLastChild() const { return mLastChild
; }
637 * Return the next sibling of this widget
639 nsIWidget
* GetNextSibling() const { return mNextSibling
; }
642 * Set the next sibling of this widget
644 void SetNextSibling(nsIWidget
* aSibling
) { mNextSibling
= aSibling
; }
647 * Return the previous sibling of this widget
649 nsIWidget
* GetPrevSibling() const { return mPrevSibling
; }
652 * Set the previous sibling of this widget
654 void SetPrevSibling(nsIWidget
* aSibling
) { mPrevSibling
= aSibling
; }
657 * Show or hide this widget
659 * @param aState true to show the Widget, false to hide it
662 virtual void Show(bool aState
) = 0;
665 * Whether or not a widget must be recreated after being hidden to show
668 virtual bool NeedsRecreateToReshow() { return false; }
671 * Make the window modal.
673 virtual void SetModal(bool aModal
) = 0;
676 * Make the non-modal window opened by modal window fake-modal, that will
677 * call SetFakeModal(false) on destroy on Cocoa.
679 virtual void SetFakeModal(bool aModal
) { SetModal(aModal
); }
682 * Are we app modal. Currently only implemented on Cocoa.
684 virtual bool IsRunningAppModal() { return false; }
687 * The maximum number of simultaneous touch contacts supported by the device.
688 * In the case of devices with multiple digitizers (e.g. multiple touch
689 * screens), the value will be the maximum of the set of maximum supported
690 * contacts by each individual digitizer.
692 virtual uint32_t GetMaxTouchPoints() const = 0;
695 * Returns whether the window is visible
698 virtual bool IsVisible() const = 0;
701 * Perform platform-dependent sanity check on a potential window position.
702 * This is guaranteed to work only for top-level windows.
704 * @param aAllowSlop: if true, allow the window to slop offscreen;
705 * the window should be partially visible. if false,
706 * force the entire window onscreen (or at least
707 * the upper-left corner, if it's too large).
708 * @param aX in: an x position expressed in screen coordinates.
709 * out: the x position constrained to fit on the screen(s).
710 * @param aY in: an y position expressed in screen coordinates.
711 * out: the y position constrained to fit on the screen(s).
714 virtual void ConstrainPosition(bool aAllowSlop
, int32_t* aX
, int32_t* aY
) = 0;
719 * For a top-level window widget, the "parent's coordinate system" is the
720 * "global" display pixel coordinate space, *not* device pixels (which
721 * may be inconsistent between multiple screens, at least in the Mac OS
722 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
723 * following Move and Resize widget APIs.
725 * The display-/device-pixel distinction becomes important for (at least)
726 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
727 * is set to other than 100%.
729 * The Move and Resize methods take floating-point parameters, rather than
730 * integer ones. This is important when manipulating top-level widgets,
731 * where the coordinate system may not be an integral multiple of the
732 * device-pixel space.
738 * Coordinates refer to the top-left of the widget. For toplevel windows
739 * with decorations, this is the top-left of the titlebar and frame .
741 * @param aX the new x position expressed in the parent's coordinate system
742 * @param aY the new y position expressed in the parent's coordinate system
745 virtual void Move(double aX
, double aY
) = 0;
748 * Reposition this widget so that the client area has the given offset.
750 * @param aOffset the new offset of the client area expressed as an
751 * offset from the origin of the client area of the parent
752 * widget (for root widgets and popup widgets it is in
753 * screen coordinates)
755 virtual void MoveClient(const DesktopPoint
& aOffset
) = 0;
758 * Resize this widget. Any size constraints set for the window by a
759 * previous call to SetSizeConstraints will be applied.
761 * @param aWidth the new width expressed in the parent's coordinate system
762 * @param aHeight the new height expressed in the parent's coordinate
764 * @param aRepaint whether the widget should be repainted
766 virtual void Resize(double aWidth
, double aHeight
, bool aRepaint
) = 0;
769 * Lock the aspect ratio of a Window
771 * @param aShouldLock bool
774 virtual void LockAspectRatio(bool aShouldLock
){};
777 * Move or resize this widget. Any size constraints set for the window by
778 * a previous call to SetSizeConstraints will be applied.
780 * @param aX the new x position expressed in the parent's coordinate
782 * @param aY the new y position expressed in the parent's coordinate
784 * @param aWidth the new width expressed in the parent's coordinate system
785 * @param aHeight the new height expressed in the parent's coordinate
787 * @param aRepaint whether the widget should be repainted if the size
791 virtual void Resize(double aX
, double aY
, double aWidth
, double aHeight
,
794 virtual mozilla::Maybe
<bool> IsResizingNativeWidget() {
795 return mozilla::Nothing();
799 * Resize the widget so that the inner client area has the given size.
801 * @param aSize the new size of the client area.
802 * @param aRepaint whether the widget should be repainted
804 virtual void ResizeClient(const DesktopSize
& aSize
, bool aRepaint
) = 0;
807 * Resize and reposition the widget so tht inner client area has the given
810 * @param aRect the new offset and size of the client area. The offset is
811 * expressed as an offset from the origin of the client area
812 * of the parent widget (for root widgets and popup widgets it
813 * is in screen coordinates).
814 * @param aRepaint whether the widget should be repainted
816 virtual void ResizeClient(const DesktopRect
& aRect
, bool aRepaint
) = 0;
819 * Sets the widget's z-index.
821 virtual void SetZIndex(int32_t aZIndex
) = 0;
824 * Gets the widget's z-index.
826 int32_t GetZIndex() { return mZIndex
; }
829 * Position this widget just behind the given widget. (Used to
830 * control z-order for top-level widgets. Get/SetZIndex by contrast
831 * control z-order for child widgets of other widgets.)
832 * @param aPlacement top, bottom, or below a widget
833 * (if top or bottom, param aWidget is ignored)
834 * @param aWidget widget to place this widget behind
835 * (only if aPlacement is eZPlacementBelow).
836 * null is equivalent to aPlacement of eZPlacementTop
837 * @param aActivate true to activate the widget after placing it
839 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement
,
840 nsIWidget
* aWidget
, bool aActivate
) = 0;
843 * Minimize, maximize or normalize the window size.
844 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
846 virtual void SetSizeMode(nsSizeMode aMode
) = 0;
848 virtual void GetWorkspaceID(nsAString
& workspaceID
) = 0;
850 virtual void MoveToWorkspace(const nsAString
& workspaceID
) = 0;
853 * Suppress animations that are applied to a window by OS.
855 virtual void SuppressAnimation(bool aSuppress
) {}
858 * Return size mode (minimized, maximized, normalized).
859 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
861 virtual nsSizeMode
SizeMode() = 0;
864 * Ask whether the window is tiled.
866 virtual bool IsTiled() const = 0;
869 * Ask wether the widget is fully occluded
871 virtual bool IsFullyOccluded() const = 0;
874 * Enable or disable this Widget
876 * @param aState true to enable the Widget, false to disable it.
878 virtual void Enable(bool aState
) = 0;
881 * Ask whether the widget is enabled
883 virtual bool IsEnabled() const = 0;
886 * Whether we should request activation of this widget's toplevel window.
894 * Request activation of this window or give focus to this widget.
896 virtual void SetFocus(Raise
, mozilla::dom::CallerType aCallerType
) = 0;
899 * Get this widget's outside dimensions relative to its parent widget. For
900 * popup widgets the returned rect is in screen coordinates and not
901 * relative to its parent widget.
903 * @return the x, y, width and height of this widget.
905 virtual LayoutDeviceIntRect
GetBounds() = 0;
908 * Get this widget's outside dimensions in device coordinates. This
909 * includes any title bar on the window.
911 * @return the x, y, width and height of this widget.
913 virtual LayoutDeviceIntRect
GetScreenBounds() = 0;
916 * Similar to GetScreenBounds except that this function will always
917 * get the size when the widget is in the nsSizeMode_Normal size mode
918 * even if the current size mode is not nsSizeMode_Normal.
919 * This method will fail if the size mode is not nsSizeMode_Normal and
920 * the platform doesn't have the ability.
921 * This method will always succeed if the current size mode is
924 * @param aRect On return it holds the x, y, width and height of
927 [[nodiscard
]] virtual nsresult
GetRestoredBounds(
928 LayoutDeviceIntRect
& aRect
) = 0;
931 * Get this widget's client area bounds, if the window has a 3D border
932 * appearance this returns the area inside the border. The position is the
933 * position of the client area relative to the client area of the parent
934 * widget (for root widgets and popup widgets it is in screen coordinates).
936 * @return the x, y, width and height of the client area of this widget.
938 virtual LayoutDeviceIntRect
GetClientBounds() = 0;
941 * Sets the non-client area dimensions of the window. Pass -1 to restore
942 * the system default frame size for that border. Pass zero to remove
943 * a border, or pass a specific value adjust a border. Units are in
944 * pixels. (DPI dependent)
947 * Windows: shrinking top non-client height will remove application
948 * icon and window title text. Glass desktops will refuse to set
949 * dimensions between zero and size < system default.
951 virtual nsresult
SetNonClientMargins(LayoutDeviceIntMargin
& aMargins
) = 0;
954 * Get the client offset from the window origin.
956 * @return the x and y of the offset.
958 virtual LayoutDeviceIntPoint
GetClientOffset() = 0;
961 * Equivalent to GetClientBounds but only returns the size.
963 virtual LayoutDeviceIntSize
GetClientSize() {
964 // Depending on the backend, overloading this method may be useful if
965 // requesting the client offset is expensive.
966 return GetClientBounds().Size();
970 * Set the background color for this widget
972 * @param aColor the new background color
976 virtual void SetBackgroundColor(const nscolor
& aColor
) {}
979 * If a cursor type is currently cached locally for this widget, clear the
980 * cached cursor to force an update on the next SetCursor call.
983 virtual void ClearCachedCursor() = 0;
986 // The system cursor chosen by the page. This is used if there's no custom
987 // cursor, or if we fail to use the custom cursor in some way (if the image
988 // fails to load, for example).
989 nsCursor mDefaultCursor
= eCursor_standard
;
990 // May be null, to represent no custom cursor image.
991 nsCOMPtr
<imgIContainer
> mContainer
;
992 uint32_t mHotspotX
= 0;
993 uint32_t mHotspotY
= 0;
994 mozilla::ImageResolution mResolution
;
996 bool IsCustom() const { return !!mContainer
; }
998 bool operator==(const Cursor
& aOther
) const {
999 return mDefaultCursor
== aOther
.mDefaultCursor
&&
1000 mContainer
.get() == aOther
.mContainer
.get() &&
1001 mHotspotX
== aOther
.mHotspotX
&& mHotspotY
== aOther
.mHotspotY
&&
1002 mResolution
== aOther
.mResolution
;
1005 bool operator!=(const Cursor
& aOther
) const { return !(*this == aOther
); }
1009 * Sets the cursor for this widget.
1011 virtual void SetCursor(const Cursor
&) = 0;
1013 static nsIntSize
CustomCursorSize(const Cursor
&);
1016 * Get the window type of this widget.
1018 nsWindowType
WindowType() { return mWindowType
; }
1021 * Determines if this widget is one of the three types of plugin widgets.
1024 return mWindowType
== eWindowType_plugin
||
1025 mWindowType
== eWindowType_plugin_ipc_chrome
||
1026 mWindowType
== eWindowType_plugin_ipc_content
;
1030 * Set the transparency mode of the top-level window containing this widget.
1031 * So, e.g., if you call this on the widget for an IFRAME, the top level
1032 * browser window containing the IFRAME actually gets set. Be careful.
1034 * This can fail if the platform doesn't support
1035 * transparency/glass. By default widgets are not
1036 * transparent. This will also fail if the toplevel window is not
1037 * a Mozilla window, e.g., if the widget is in an embedded
1040 * After transparency/glass has been enabled, the initial alpha channel
1041 * value for all pixels is 1, i.e., opaque.
1042 * If the window is resized then the alpha channel values for
1043 * all pixels are reset to 1.
1044 * Pixel RGB color values are already premultiplied with alpha channel values.
1046 virtual void SetTransparencyMode(nsTransparencyMode aMode
) = 0;
1049 * Get the transparency mode of the top-level window that contains this
1052 virtual nsTransparencyMode
GetTransparencyMode() = 0;
1055 * This represents a command to set the bounds and clip region of
1058 struct Configuration
{
1059 nsCOMPtr
<nsIWidget
> mChild
;
1060 uintptr_t mWindowID
; // e10s specific, the unique plugin port id
1061 bool mVisible
; // e10s specific, widget visibility
1062 LayoutDeviceIntRect mBounds
;
1063 CopyableTArray
<LayoutDeviceIntRect
> mClipRegion
;
1067 * Sets the clip region of each mChild (which must actually be a child
1068 * of this widget) to the union of the pixel rects given in
1069 * mClipRegion, all relative to the top-left of the child
1070 * widget. Clip regions are not implemented on all platforms and only
1071 * need to actually work for children that are plugins.
1073 * Also sets the bounds of each child to mBounds.
1075 * This will invalidate areas of the children that have changed, but
1076 * does not need to invalidate any part of this widget.
1078 * Children should be moved in the order given; the array is
1079 * sorted so to minimize unnecessary invalidation if children are
1080 * moved in that order.
1082 virtual nsresult
ConfigureChildren(
1083 const nsTArray
<Configuration
>& aConfigurations
) = 0;
1084 virtual nsresult
SetWindowClipRegion(
1085 const nsTArray
<LayoutDeviceIntRect
>& aRects
,
1086 bool aIntersectWithExisting
) = 0;
1089 * Appends to aRects the rectangles constituting this widget's clip
1090 * region. If this widget is not clipped, appends a single rectangle
1091 * (0, 0, bounds.width, bounds.height).
1093 virtual void GetWindowClipRegion(nsTArray
<LayoutDeviceIntRect
>* aRects
) = 0;
1096 * Register or unregister native plugin widgets which receive Configuration
1097 * data from the content process via the compositor.
1099 * Lookups are used by the main thread via the compositor to lookup widgets
1100 * based on a unique window id. On Windows and Linux this is the
1101 * NS_NATIVE_PLUGIN_PORT (hwnd/XID). This tracking maintains a reference to
1102 * widgets held. Consumers are responsible for removing widgets from this
1105 virtual void RegisterPluginWindowForRemoteUpdates() = 0;
1106 virtual void UnregisterPluginWindowForRemoteUpdates() = 0;
1107 static nsIWidget
* LookupRegisteredPluginWindow(uintptr_t aWindowID
);
1110 * Iterates across the list of registered plugin widgets and updates thier
1111 * visibility based on which plugins are included in the 'visible' list.
1113 * The compositor knows little about tabs, but it does know which plugin
1114 * widgets are currently included in the visible layer tree. It calls this
1115 * helper to hide widgets it knows nothing about.
1117 static void UpdateRegisteredPluginWindowVisibility(
1118 uintptr_t aOwnerWidget
, nsTArray
<uintptr_t>& aPluginIds
);
1122 * Iterates over the list of registered plugins and for any that are owned
1123 * by aOwnerWidget and visible it takes a snapshot.
1125 * @param aOwnerWidget only captures visible widgets owned by this
1127 static void CaptureRegisteredPlugins(uintptr_t aOwnerWidget
);
1130 * Take a scroll capture for this widget if possible.
1132 virtual void UpdateScrollCapture() = 0;
1135 * Creates an async ImageContainer to hold scroll capture images that can be
1136 * used if the plugin is hidden during scroll.
1137 * @return the async container ID of the created ImageContainer.
1139 virtual uint64_t CreateScrollCaptureContainer() = 0;
1143 * Set the shadow style of the window.
1145 * Ignored on child widgets and on non-Mac platforms.
1147 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle
) = 0;
1150 * Set the opacity of the window.
1151 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1153 * Ignored on child widgets and on non-Mac platforms.
1155 virtual void SetWindowOpacity(float aOpacity
) {}
1158 * Set the transform of the window. Values are in device pixels,
1159 * the origin is the top left corner of the window.
1161 * Ignored on child widgets and on non-Mac platforms.
1163 virtual void SetWindowTransform(const mozilla::gfx::Matrix
& aTransform
) {}
1166 * Set whether the window should ignore mouse events or not.
1168 * This is only used on popup windows.
1170 virtual void SetWindowMouseTransparent(bool aIsTransparent
) {}
1173 * On macOS, this method shows or hides the pill button in the titlebar
1174 * that's used to collapse the toolbar.
1176 * Ignored on child widgets and on non-Mac platforms.
1178 virtual void SetShowsToolbarButton(bool aShow
) = 0;
1181 * On macOS, this method determines whether we tell cocoa that the window
1182 * supports native full screen. If we do so, and another window is in
1183 * native full screen, this window will also appear in native full screen.
1185 * We generally only want to do this for primary application windows.
1187 * Ignored on child widgets and on non-Mac platforms.
1189 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen
) = 0;
1191 enum WindowAnimationType
{
1192 eGenericWindowAnimation
,
1193 eDocumentWindowAnimation
1197 * Sets the kind of top-level window animation this widget should have. On
1198 * macOS, this causes a particular kind of animation to be shown when the
1199 * window is first made visible.
1201 * Ignored on child widgets and on non-Mac platforms.
1203 virtual void SetWindowAnimationType(WindowAnimationType aType
) = 0;
1206 * Specifies whether the window title should be drawn even if the window
1207 * contents extend into the titlebar. Ignored on windows that don't draw
1208 * in the titlebar. Only implemented on macOS.
1210 virtual void SetDrawsTitle(bool aDrawTitle
) {}
1213 * Hide window chrome (borders, buttons) for this widget.
1216 virtual void HideWindowChrome(bool aShouldHide
) = 0;
1218 enum FullscreenTransitionStage
{
1219 eBeforeFullscreenToggle
,
1220 eAfterFullscreenToggle
1224 * Prepares for fullscreen transition and returns whether the widget
1225 * supports fullscreen transition. If this method returns false,
1226 * PerformFullscreenTransition() must never be called. Otherwise,
1227 * caller should call that method twice with "before" and "after"
1228 * stages respectively in order. In the latter case, this method may
1229 * return some data via aData pointer. Caller must pass that data to
1230 * PerformFullscreenTransition() if any, and caller is responsible
1231 * for releasing that data.
1233 virtual bool PrepareForFullscreenTransition(nsISupports
** aData
) = 0;
1236 * Performs fullscreen transition. This method returns immediately,
1237 * and will post aCallback to the main thread when the transition
1240 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage
,
1243 nsIRunnable
* aCallback
) = 0;
1246 * Perform any actions needed after the fullscreen transition has ended.
1248 virtual void CleanupFullscreenTransition() = 0;
1251 * Return the screen the widget is in, or null if we don't know.
1253 virtual already_AddRefed
<nsIScreen
> GetWidgetScreen() = 0;
1256 * Put the toplevel window into or out of fullscreen mode.
1257 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1258 * if possible. (If not, it behaves as if aTargetScreen is null.)
1259 * If !aFullScreen, aTargetScreen is ignored.
1260 * aTargetScreen support is currently only implemented on Windows.
1262 * @return NS_OK if the widget is setup properly for fullscreen and
1263 * FullscreenChanged callback has been or will be called. If other
1264 * value is returned, the caller should continue the change itself.
1266 virtual nsresult
MakeFullScreen(bool aFullScreen
,
1267 nsIScreen
* aTargetScreen
= nullptr) = 0;
1270 * Same as MakeFullScreen, except that, on systems which natively
1271 * support fullscreen transition, calling this method explicitly
1272 * requests that behavior.
1273 * It is currently only supported on macOS 10.7+.
1275 virtual nsresult
MakeFullScreenWithNativeTransition(
1276 bool aFullScreen
, nsIScreen
* aTargetScreen
= nullptr) {
1277 return MakeFullScreen(aFullScreen
, aTargetScreen
);
1281 * Invalidate a specified rect for a widget so that it will be repainted
1284 virtual void Invalidate(const LayoutDeviceIntRect
& aRect
) = 0;
1286 enum LayerManagerPersistence
{
1287 LAYER_MANAGER_CURRENT
= 0,
1288 LAYER_MANAGER_PERSISTENT
1292 * Return the widget's LayerManager. The layer tree for that
1293 * LayerManager is what gets rendered to the widget.
1295 virtual WindowRenderer
* GetWindowRenderer() = 0;
1298 * Called before each layer manager transaction to allow any preparation
1299 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1301 * Always called on the main thread.
1303 virtual void PrepareWindowEffects() = 0;
1306 * Called on the main thread at the end of WebRender display list building.
1308 virtual void AddWindowOverlayWebRenderCommands(
1309 mozilla::layers::WebRenderBridgeChild
* aWrBridge
,
1310 mozilla::wr::DisplayListBuilder
& aBuilder
,
1311 mozilla::wr::IpcResourceUpdateQueue
& aResources
) {}
1314 * Called when Gecko knows which themed widgets exist in this window.
1315 * The passed array contains an entry for every themed widget of the right
1316 * type (currently only StyleAppearance::Toolbar) within the window, except
1317 * for themed widgets which are transformed or have effects applied to them
1318 * (e.g. CSS opacity or filters).
1319 * This could sometimes be called during display list construction
1320 * outside of painting.
1321 * If called during painting, it will be called before we actually
1324 virtual void UpdateThemeGeometries(
1325 const nsTArray
<ThemeGeometry
>& aThemeGeometries
) = 0;
1328 * Informs the widget about the region of the window that is opaque.
1330 * @param aOpaqueRegion the region of the window that is opaque.
1332 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion
& aOpaqueRegion
) {}
1335 * Informs the widget about the region of the window that is draggable.
1337 virtual void UpdateWindowDraggingRegion(
1338 const LayoutDeviceIntRegion
& aRegion
) {}
1341 * Tells the widget whether the given input block results in a swipe.
1342 * Should be called in response to a WidgetWheelEvent that has
1343 * mFlags.mCanTriggerSwipe set on it.
1345 virtual void ReportSwipeStarted(uint64_t aInputBlockId
, bool aStartSwipe
) {}
1352 virtual void AddChild(nsIWidget
* aChild
) = 0;
1353 virtual void RemoveChild(nsIWidget
* aChild
) = 0;
1354 virtual void* GetNativeData(uint32_t aDataType
) = 0;
1355 virtual void SetNativeData(uint32_t aDataType
, uintptr_t aVal
) = 0;
1356 virtual void FreeNativeData(void* data
, uint32_t aDataType
) = 0; //~~~
1361 * Set the widget's title.
1362 * Must be called after Create.
1364 * @param aTitle string displayed as the title of the widget
1366 virtual nsresult
SetTitle(const nsAString
& aTitle
) = 0;
1369 * Set the widget's icon.
1370 * Must be called after Create.
1372 * @param aIconSpec string specifying the icon to use; convention is to
1373 * pass a resource: URL from which a platform-dependent
1374 * resource file name will be constructed
1376 virtual void SetIcon(const nsAString
& aIconSpec
) = 0;
1379 * Return this widget's origin in screen coordinates.
1381 * @return screen coordinates stored in the x,y members
1383 virtual LayoutDeviceIntPoint
WidgetToScreenOffset() = 0;
1386 * The same as WidgetToScreenOffset(), except in the case of
1387 * PuppetWidget where this method omits the chrome offset.
1389 virtual LayoutDeviceIntPoint
TopLevelWidgetToScreenOffset() {
1390 return WidgetToScreenOffset();
1394 * For a PuppetWidget, returns the transform from the coordinate
1395 * space of the PuppetWidget to the coordinate space of the
1396 * top-level native widget.
1398 * Identity transform in other cases.
1400 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1401 WidgetToTopLevelWidgetTransform() {
1402 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1406 * Given the specified client size, return the corresponding window size,
1407 * which includes the area for the borders and titlebar. This method
1408 * should work even when the window is not yet visible.
1410 virtual LayoutDeviceIntSize
ClientToWindowSize(
1411 const LayoutDeviceIntSize
& aClientSize
) = 0;
1414 * Dispatches an event to the widget
1416 virtual nsresult
DispatchEvent(mozilla::WidgetGUIEvent
* event
,
1417 nsEventStatus
& aStatus
) = 0;
1420 * Dispatches an event to APZ only.
1421 * No-op in the child process.
1423 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent
* aEvent
) = 0;
1425 // A structure that groups the statuses from APZ dispatch and content
1427 struct ContentAndAPZEventStatus
{
1428 // Either of these may not be set if the event was not dispatched
1429 // to APZ or to content.
1430 nsEventStatus mApzStatus
= nsEventStatus_eIgnore
;
1431 nsEventStatus mContentStatus
= nsEventStatus_eIgnore
;
1435 * Dispatches an event that must be handled by APZ first, when APZ is
1436 * enabled. If invoked in the child process, it is forwarded to the
1437 * parent process synchronously.
1439 virtual ContentAndAPZEventStatus
DispatchInputEvent(
1440 mozilla::WidgetInputEvent
* aEvent
) = 0;
1443 * Confirm an APZ-aware event target. This should be used when APZ will
1444 * not need a layers update to process the event.
1446 virtual void SetConfirmedTargetAPZC(
1447 uint64_t aInputBlockId
,
1448 const nsTArray
<ScrollableLayerGuid
>& aTargets
) const = 0;
1451 * Returns true if APZ is in use, false otherwise.
1453 virtual bool AsyncPanZoomEnabled() const = 0;
1456 * Enables the dropping of files to a widget.
1458 virtual void EnableDragDrop(bool aEnable
) = 0;
1459 virtual nsresult
AsyncEnableDragDrop(bool aEnable
) = 0;
1462 * Enables/Disables system mouse capture.
1463 * @param aCapture true enables mouse capture, false disables mouse capture
1466 virtual void CaptureMouse(bool aCapture
) = 0;
1469 * Classify the window for the window manager. Mostly for X11.
1471 virtual void SetWindowClass(const nsAString
& xulWinType
) = 0;
1474 * Enables/Disables system capture of any and all events that would cause a
1475 * popup to be rolled up. aListener should be set to a non-null value for
1476 * any popups that are not managed by the popup manager.
1477 * @param aDoCapture true enables capture, false disables capture
1480 virtual void CaptureRollupEvents(nsIRollupListener
* aListener
,
1481 bool aDoCapture
) = 0;
1484 * Bring this window to the user's attention. This is intended to be a more
1485 * gentle notification than popping the window to the top or putting up an
1486 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1487 * the Mac. The notification should be suppressed if the window is already
1488 * in the foreground and should be dismissed when the user brings this window
1489 * to the foreground.
1490 * @param aCycleCount Maximum number of times to animate the window per system
1491 * conventions. If set to -1, cycles indefinitely until
1492 * window is brought into the foreground.
1494 [[nodiscard
]] virtual nsresult
GetAttention(int32_t aCycleCount
) = 0;
1497 * Ask whether there user input events pending. All input events are
1498 * included, including those not targeted at this nsIwidget instance.
1500 virtual bool HasPendingInputEvent() = 0;
1503 * If set to true, the window will draw its contents into the titlebar
1504 * instead of below it.
1506 * Ignored on any platform that does not support it. Ignored by widgets that
1507 * do not represent windows.
1508 * May result in a resize event, so should only be called from places where
1509 * reflow and painting is allowed.
1511 * @param aState Whether drawing into the titlebar should be activated.
1513 virtual void SetDrawsInTitlebar(bool aState
) = 0;
1516 * Determine whether the widget shows a resize widget. If it does,
1517 * aResizerRect returns the resizer's rect.
1519 * Returns false on any platform that does not support it.
1521 * @param aResizerRect The resizer's rect in device pixels.
1522 * @return Whether a resize widget is shown.
1524 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect
* aResizerRect
) = 0;
1527 * Begin a window resizing drag, based on the event passed in.
1529 [[nodiscard
]] virtual nsresult
BeginResizeDrag(
1530 mozilla::WidgetGUIEvent
* aEvent
, int32_t aHorizontal
,
1531 int32_t aVertical
) = 0;
1533 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1535 enum Modifiers
: uint32_t {
1536 NO_MODIFIERS
= 0x00000000,
1537 CAPS_LOCK
= 0x00000001, // when CapsLock is active
1538 NUM_LOCK
= 0x00000002, // when NumLock is active
1539 SHIFT_L
= 0x00000100,
1540 SHIFT_R
= 0x00000200,
1541 CTRL_L
= 0x00000400,
1542 CTRL_R
= 0x00000800,
1543 ALT_L
= 0x00001000, // includes Option
1545 COMMAND_L
= 0x00004000,
1546 COMMAND_R
= 0x00008000,
1548 ALTGRAPH
= 0x00020000, // AltGr key on Windows. This emulates
1549 // AltRight key behavior of keyboard
1550 // layouts which maps AltGr to AltRight
1552 FUNCTION
= 0x00100000,
1553 NUMERIC_KEY_PAD
= 0x01000000 // when the key is coming from the keypad
1556 * Utility method intended for testing. Dispatches native key events
1557 * to this widget to simulate the press and release of a key.
1558 * @param aNativeKeyboardLayout a *platform-specific* constant.
1559 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1560 * On Windows, it is converted to a hex string and passed to
1561 * LoadKeyboardLayout, see
1562 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1563 * @param aNativeKeyCode a *platform-specific* keycode.
1564 * On Windows, this is the virtual key code.
1565 * @param aModifiers some combination of the above 'Modifiers' flags;
1566 * not all flags will apply to all platforms. Mac ignores the _R
1567 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1569 * @param aCharacters characters that the OS would decide to generate
1570 * from the event. On Windows, this is the charCode passed by
1572 * @param aUnmodifiedCharacters characters that the OS would decide
1573 * to generate from the event if modifier keys (other than shift)
1574 * were assumed inactive. Needed on Mac, ignored on Windows.
1575 * @param aObserver the observer that will get notified once the events
1576 * have been dispatched.
1577 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1578 * layout is not supported and the event was not fired
1580 virtual nsresult
SynthesizeNativeKeyEvent(
1581 int32_t aNativeKeyboardLayout
, int32_t aNativeKeyCode
,
1582 uint32_t aModifierFlags
, const nsAString
& aCharacters
,
1583 const nsAString
& aUnmodifiedCharacters
, nsIObserver
* aObserver
) = 0;
1586 * Utility method intended for testing. Dispatches native mouse events
1587 * may even move the mouse cursor. On Mac the events are guaranteed to
1588 * be sent to the window containing this widget, but on Windows they'll go
1589 * to whatever's topmost on the screen at that position, so for
1590 * cross-platform testing ensure that your window is at the top of the
1592 * @param aPoint screen location of the mouse, in device
1593 * pixels, with origin at the top left
1594 * @param aNativeMessage abstract native message.
1595 * @param aButton Mouse button defined by DOM UI Events.
1596 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1597 * FYI: On Windows, Android and Headless widget on all
1598 * platroms, this hasn't been handled yet.
1599 * @param aObserver the observer that will get notified once the events
1600 * have been dispatched.
1602 enum class NativeMouseMessage
: uint32_t {
1603 ButtonDown
, // button down
1604 ButtonUp
, // button up
1605 Move
, // mouse cursor move
1606 EnterWindow
, // mouse cursor comes into a window
1607 LeaveWindow
, // mouse cursor leaves from a window
1609 virtual nsresult
SynthesizeNativeMouseEvent(
1610 LayoutDeviceIntPoint aPoint
, NativeMouseMessage aNativeMessage
,
1611 mozilla::MouseButton aButton
, nsIWidget::Modifiers aModifierFlags
,
1612 nsIObserver
* aObserver
) = 0;
1615 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1616 * message. aPoint is location in device pixels to which the mouse pointer
1618 * @param aObserver the observer that will get notified once the events
1619 * have been dispatched.
1621 virtual nsresult
SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint
,
1622 nsIObserver
* aObserver
) = 0;
1625 * Utility method intended for testing. Dispatching native mouse scroll
1626 * events may move the mouse cursor.
1628 * @param aPoint Mouse cursor position in screen coordinates.
1629 * In device pixels, the origin at the top left of
1630 * the primary display.
1631 * @param aNativeMessage Platform native message.
1632 * @param aDeltaX The delta value for X direction. If the native
1633 * message doesn't indicate X direction scrolling,
1634 * this may be ignored.
1635 * @param aDeltaY The delta value for Y direction. If the native
1636 * message doesn't indicate Y direction scrolling,
1637 * this may be ignored.
1638 * @param aDeltaZ The delta value for Z direction. If the native
1639 * message doesn't indicate Z direction scrolling,
1640 * this may be ignored.
1641 * @param aModifierFlags Must be values of Modifiers, or zero.
1642 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1644 * @param aObserver The observer that will get notified once the
1645 * events have been dispatched.
1647 virtual nsresult
SynthesizeNativeMouseScrollEvent(
1648 LayoutDeviceIntPoint aPoint
, uint32_t aNativeMessage
, double aDeltaX
,
1649 double aDeltaY
, double aDeltaZ
, uint32_t aModifierFlags
,
1650 uint32_t aAdditionalFlags
, nsIObserver
* aObserver
) = 0;
1653 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1654 * touch states in nsIDOMWindowUtils.idl.
1656 enum TouchPointerState
{
1657 // The pointer is in a hover state above the digitizer
1658 TOUCH_HOVER
= (1 << 0),
1659 // The pointer is in contact with the digitizer
1660 TOUCH_CONTACT
= (1 << 1),
1661 // The pointer has been removed from the digitizer detection area
1662 TOUCH_REMOVE
= (1 << 2),
1663 // The pointer has been canceled. Will cancel any pending os level
1664 // gestures that would triggered as a result of completion of the
1665 // input sequence. This may not cancel moz platform related events
1666 // that might get tirggered by input already delivered.
1667 TOUCH_CANCEL
= (1 << 3),
1669 // ALL_BITS used for validity checking during IPC serialization
1670 ALL_BITS
= (1 << 4) - 1
1673 * TouchpadGesturePhase states for SynthesizeNativeTouchPadPinch and
1674 * SynthesizeNativeTouchpadPan. Match phase states in nsIDOMWindowUtils.idl.
1676 enum TouchpadGesturePhase
{
1682 * Create a new or update an existing touch pointer on the digitizer.
1683 * To trigger os level gestures, individual touch points should
1684 * transition through a complete set of touch states which should be
1685 * sent as individual messages.
1687 * @param aPointerId The touch point id to create or update.
1688 * @param aPointerState one or more of the touch states listed above
1689 * @param aPoint coords of this event
1690 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1691 * @param aOrientation 0 -> 359 degree value indicating the
1692 * orientation of the pointer. Use 90 for normal taps.
1693 * @param aObserver The observer that will get notified once the events
1694 * have been dispatched.
1696 virtual nsresult
SynthesizeNativeTouchPoint(uint32_t aPointerId
,
1697 TouchPointerState aPointerState
,
1698 LayoutDeviceIntPoint aPoint
,
1699 double aPointerPressure
,
1700 uint32_t aPointerOrientation
,
1701 nsIObserver
* aObserver
) = 0;
1703 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1705 virtual nsresult
SynthesizeNativeTouchPadPinch(
1706 TouchpadGesturePhase aEventPhase
, float aScale
,
1707 LayoutDeviceIntPoint aPoint
, int32_t aModifierFlags
) = 0;
1710 * Helper for simulating a simple tap event with one touch point. When
1711 * aLongTap is true, simulates a native long tap with a duration equal to
1712 * ui.click_hold_context_menus.delay. This pref is compatible with the
1713 * apzc long tap duration. Defaults to 1.5 seconds.
1714 * @param aObserver The observer that will get notified once the events
1715 * have been dispatched.
1717 virtual nsresult
SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint
,
1719 nsIObserver
* aObserver
);
1721 virtual nsresult
SynthesizeNativePenInput(uint32_t aPointerId
,
1722 TouchPointerState aPointerState
,
1723 LayoutDeviceIntPoint aPoint
,
1725 uint32_t aRotation
, int32_t aTiltX
,
1726 int32_t aTiltY
, int32_t aButton
,
1727 nsIObserver
* aObserver
) = 0;
1730 * Cancels all active simulated touch input points and pending long taps.
1731 * Native widgets should track existing points such that they can clear the
1732 * digitizer state when this call is made.
1733 * @param aObserver The observer that will get notified once the touch
1734 * sequence has been cleared.
1736 virtual nsresult
ClearNativeTouchSequence(nsIObserver
* aObserver
);
1739 * Send a native event as if the user double tapped the touchpad with two
1742 virtual nsresult
SynthesizeNativeTouchpadDoubleTap(
1743 LayoutDeviceIntPoint aPoint
, uint32_t aModifierFlags
) = 0;
1746 * See nsIDOMWindowUtils.sendNativeTouchpadPan().
1748 virtual nsresult
SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase
,
1749 LayoutDeviceIntPoint aPoint
,
1750 double aDeltaX
, double aDeltaY
,
1751 int32_t aModifierFlags
) = 0;
1753 virtual void StartAsyncScrollbarDrag(
1754 const AsyncDragMetrics
& aDragMetrics
) = 0;
1757 * Notify APZ to start autoscrolling.
1758 * @param aAnchorLocation the location of the autoscroll anchor
1759 * @param aGuid identifies the scroll frame to be autoscrolled
1760 * @return true if APZ has been successfully notified
1762 virtual bool StartAsyncAutoscroll(const ScreenPoint
& aAnchorLocation
,
1763 const ScrollableLayerGuid
& aGuid
) = 0;
1766 * Notify APZ to stop autoscrolling.
1767 * @param aGuid identifies the scroll frame which is being autoscrolled.
1769 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid
& aGuid
) = 0;
1771 virtual LayersId
GetRootLayerTreeId() = 0;
1773 // If this widget supports out-of-process compositing, it can override
1774 // this method to provide additional information to the compositor.
1775 virtual void GetCompositorWidgetInitData(
1776 mozilla::widget::CompositorWidgetInitData
* aInitData
) {}
1779 * Setter/Getter of the system font setting for testing.
1781 virtual nsresult
SetSystemFont(const nsCString
& aFontName
) {
1782 return NS_ERROR_NOT_IMPLEMENTED
;
1784 virtual nsresult
GetSystemFont(nsCString
& aFontName
) {
1785 return NS_ERROR_NOT_IMPLEMENTED
;
1788 // Get rectangle of the screen where the window is placed.
1789 // It's used to detect popup overflow under Wayland because
1790 // Screenmanager does not work under it.
1791 virtual nsRect
GetPreferredPopupRect() {
1792 NS_WARNING("GetPreferredPopupRect implemented only for wayland");
1793 return nsRect(0, 0, 0, 0);
1795 virtual void FlushPreferredPopupRect() {
1796 NS_WARNING("FlushPreferredPopupRect implemented only for wayland");
1801 * If this widget uses native pointer lock instead of warp-to-center
1802 * (currently only GTK on Wayland), these methods provide access to that
1805 virtual void SetNativePointerLockCenter(
1806 const LayoutDeviceIntPoint
& aLockCenter
) {}
1807 virtual void LockNativePointer() {}
1808 virtual void UnlockNativePointer() {}
1811 * Get safe area insets except to cutout.
1812 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1814 virtual mozilla::ScreenIntMargin
GetSafeAreaInsets() const {
1815 return mozilla::ScreenIntMargin();
1821 LongTapInfo(int32_t aPointerId
, LayoutDeviceIntPoint
& aPoint
,
1822 mozilla::TimeDuration aDuration
, nsIObserver
* aObserver
)
1823 : mPointerId(aPointerId
),
1825 mDuration(aDuration
),
1826 mObserver(aObserver
),
1827 mStamp(mozilla::TimeStamp::Now()) {}
1830 LayoutDeviceIntPoint mPosition
;
1831 mozilla::TimeDuration mDuration
;
1832 nsCOMPtr
<nsIObserver
> mObserver
;
1833 mozilla::TimeStamp mStamp
;
1836 static void OnLongTapTimerCallback(nsITimer
* aTimer
, void* aClosure
);
1838 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboardContentProcess();
1839 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboardInner();
1841 mozilla::UniquePtr
<LongTapInfo
> mLongTapTouchPoint
;
1842 nsCOMPtr
<nsITimer
> mLongTapTimer
;
1843 static int32_t sPointerIdCounter
;
1847 * If key events have not been handled by content or XBL handlers, they can
1848 * be offered to the system (for custom application shortcuts set in system
1849 * preferences, for example).
1851 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent
* aEvent
);
1854 * Activates a native menu item at the position specified by the index
1855 * string. The index string is a string of positive integers separated
1856 * by the "|" (pipe) character. The last integer in the string represents
1857 * the item index in a submenu located using the integers preceding it.
1860 * In this string, the first integer represents the top-level submenu
1861 * in the native menu bar. Since the integer is 1, it is the second submeu
1862 * in the native menu bar. Within that, the first item (index 0) is a
1863 * submenu, and we want to activate the 5th item within that submenu.
1865 virtual nsresult
ActivateNativeMenuItemAt(const nsAString
& indexString
) = 0;
1868 * This is used for native menu system testing.
1870 * Updates a native menu at the position specified by the index string.
1871 * The index string is a string of positive integers separated by the "|"
1875 * In this string, the first integer represents the top-level submenu
1876 * in the native menu bar. Since the integer is 1, it is the second submeu
1877 * in the native menu bar. Within that, the first item (index 0) is a
1878 * submenu, and we want to update submenu at index 4 within that submenu.
1880 * If this is called with an empty string it forces a full reload of the
1883 virtual nsresult
ForceUpdateNativeMenuAt(const nsAString
& indexString
) = 0;
1886 * This is used for testing macOS service menu code.
1888 * @param aResult - the current text selection. Is empty if no selection.
1889 * @return nsresult - whether or not aResult was assigned the selected text.
1891 [[nodiscard
]] virtual nsresult
GetSelectionAsPlaintext(nsAString
& aResult
) {
1892 return NS_ERROR_NOT_IMPLEMENTED
;
1896 * Notify IME of the specified notification.
1898 * @return If the notification is mouse button event and it's consumed by
1899 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1901 virtual nsresult
NotifyIME(const IMENotification
& aIMENotification
) = 0;
1904 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1905 * of the widget, in the event that we were not able to observe and respond to
1906 * the initial focus event. This is necessary for the early skeleton UI
1907 * window, which is displayed and receives its initial focus event before we
1908 * can actually respond to it.
1910 virtual void MaybeDispatchInitialFocusEvent() {}
1913 * Notifies the input context changes.
1915 virtual void SetInputContext(const InputContext
& aContext
,
1916 const InputContextAction
& aAction
) = 0;
1919 * Get current input context.
1921 virtual InputContext
GetInputContext() = 0;
1924 * Get native IME context. This is different from GetNativeData() with
1925 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1928 virtual NativeIMEContext
GetNativeIMEContext() = 0;
1931 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1932 * native (OS-level) event for it. This method allows tests to simulate
1933 * keystrokes that trigger native key bindings (which require a native
1936 [[nodiscard
]] virtual nsresult
AttachNativeKeyEvent(
1937 mozilla::WidgetKeyboardEvent
& aEvent
) = 0;
1940 * Retrieve edit commands when the key combination of aEvent is used
1941 * in platform native applications.
1943 enum NativeKeyBindingsType
: uint8_t {
1944 NativeKeyBindingsForSingleLineEditor
,
1945 NativeKeyBindingsForMultiLineEditor
,
1946 NativeKeyBindingsForRichTextEditor
1948 MOZ_CAN_RUN_SCRIPT
virtual bool GetEditCommands(
1949 NativeKeyBindingsType aType
, const mozilla::WidgetKeyboardEvent
& aEvent
,
1950 nsTArray
<mozilla::CommandInt
>& aCommands
);
1953 * Retrieves a reference to notification requests of IME. Note that the
1954 * reference is valid while the nsIWidget instance is alive. So, if you
1955 * need to store the reference for a long time, you need to grab the widget
1958 const IMENotificationRequests
& IMENotificationRequestsRef();
1961 * Call this method when a dialog is opened which has a default button.
1962 * The button's rectangle should be supplied in aButtonRect.
1964 [[nodiscard
]] virtual nsresult
OnDefaultButtonLoaded(
1965 const LayoutDeviceIntRect
& aButtonRect
) = 0;
1968 * Return true if this process shouldn't use platform widgets, and
1969 * so should use PuppetWidgets instead. If this returns true, the
1970 * result of creating and using a platform widget is undefined,
1971 * and likely to end in crashes or other buggy behavior.
1973 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1975 static already_AddRefed
<nsIWidget
> CreateTopLevelWindow();
1977 static already_AddRefed
<nsIWidget
> CreateChildWindow();
1980 * Allocate and return a "puppet widget" that doesn't directly
1981 * correlate to a platform widget; platform events and data must
1982 * be fed to it. Currently used in content processes. NULL is
1983 * returned if puppet widgets aren't supported in this build
1984 * config, on this platform, or for this process type.
1986 * This function is called "Create" to match CreateInstance().
1987 * The returned widget must still be nsIWidget::Create()d.
1989 static already_AddRefed
<nsIWidget
> CreatePuppetWidget(
1990 BrowserChild
* aBrowserChild
);
1992 static already_AddRefed
<nsIWidget
> CreateHeadlessWidget();
1995 * Reparent this widget's native widget.
1996 * @param aNewParent the native widget of aNewParent is the new native
1999 virtual void ReparentNativeWidget(nsIWidget
* aNewParent
) = 0;
2002 * Return true if widget has it's own GL context
2004 virtual bool HasGLContext() { return false; }
2007 * Returns true to indicate that this widget paints an opaque background
2008 * that we want to be visible under the page, so layout should not force
2009 * a default background.
2011 virtual bool WidgetPaintsBackground() { return false; }
2013 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
2016 * Get the natural bounds of this widget. This method is only
2017 * meaningful for widgets for which Gecko implements screen
2018 * rotation natively. When this is the case, GetBounds() returns
2019 * the widget bounds taking rotation into account, and
2020 * GetNaturalBounds() returns the bounds *not* taking rotation
2023 * No code outside of the composition pipeline should know or care
2024 * about this. If you're not an agent of the compositor, you
2025 * probably shouldn't call this method.
2027 virtual LayoutDeviceIntRect
GetNaturalBounds() { return GetBounds(); }
2030 * Set size constraints on the window size such that it is never less than
2031 * the specified minimum size and never larger than the specified maximum
2032 * size. The size constraints are sizes of the outer rectangle including
2033 * the window frame and title bar. Use 0 for an unconstrained minimum size
2034 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
2035 * does not necessarily change the size of a window to conform to this size,
2036 * thus Resize should be called afterwards.
2038 * @param aConstraints: the size constraints in device pixels
2040 virtual void SetSizeConstraints(const SizeConstraints
& aConstraints
) = 0;
2043 * Return the size constraints currently observed by the widget.
2045 * @return the constraints in device pixels
2047 virtual const SizeConstraints
GetSizeConstraints() = 0;
2050 * Apply the current size constraints to the given size.
2052 * @param aWidth width to constrain
2053 * @param aHeight height to constrain
2055 virtual void ConstrainSize(int32_t* aWidth
, int32_t* aHeight
) = 0;
2058 * If this is owned by a BrowserChild, return that. Otherwise return
2061 virtual BrowserChild
* GetOwningBrowserChild() { return nullptr; }
2064 * If this isn't directly compositing to its window surface,
2065 * return the compositor which is doing that on our behalf.
2067 virtual CompositorBridgeChild
* GetRemoteRenderer() { return nullptr; }
2070 * Clear WebRender resources
2072 virtual void ClearCachedWebrenderResources() {}
2075 * If this widget has its own vsync source, return it, otherwise return
2076 * nullptr. An example of such local source would be Wayland frame callbacks.
2078 virtual RefPtr
<mozilla::gfx::VsyncSource
> GetVsyncSource() { return nullptr; }
2081 * Returns true if the widget requires synchronous repaints on resize,
2084 virtual bool SynchronouslyRepaintOnResize() { return true; }
2087 * Some platforms (only cocoa right now) round widget coordinates to the
2088 * nearest even pixels (see bug 892994), this function allows us to
2089 * determine how widget coordinates will be rounded.
2091 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2093 virtual void UpdateZoomConstraints(
2094 const uint32_t& aPresShellId
, const ScrollableLayerGuid::ViewID
& aViewId
,
2095 const mozilla::Maybe
<ZoomConstraints
>& aConstraints
){};
2098 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2099 * widget. Note that this never returns nullptr.
2101 virtual TextEventDispatcher
* GetTextEventDispatcher() = 0;
2104 * GetNativeTextEventDispatcherListener() returns a
2105 * TextEventDispatcherListener instance which is used when the widget
2106 * instance handles native IME and/or keyboard events.
2108 virtual TextEventDispatcherListener
*
2109 GetNativeTextEventDispatcherListener() = 0;
2111 virtual void ZoomToRect(const uint32_t& aPresShellId
,
2112 const ScrollableLayerGuid::ViewID
& aViewId
,
2113 const CSSRect
& aRect
, const uint32_t& aFlags
) = 0;
2116 * LookUpDictionary shows the dictionary for the word around current point.
2118 * @param aText the word to look up dictiorary.
2119 * @param aFontRangeArray text decoration of aText
2120 * @param aIsVertical true if the word is vertical layout
2121 * @param aPoint top-left point of aText
2123 virtual void LookUpDictionary(
2124 const nsAString
& aText
,
2125 const nsTArray
<mozilla::FontRange
>& aFontRangeArray
,
2126 const bool aIsVertical
, const LayoutDeviceIntPoint
& aPoint
) {}
2128 virtual void RequestFxrOutput() {
2129 MOZ_ASSERT(false, "This function should only execute in Windows");
2132 #if defined(MOZ_WIDGET_ANDROID)
2134 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2137 * @param aMessage message being sent to Android UI thread.
2139 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage
) = 0;
2142 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2145 * @param aScrollOffset page scroll offset value in screen pixels.
2146 * @param aZoom current page zoom.
2148 virtual void UpdateRootFrameMetrics(const ScreenPoint
& aScrollOffset
,
2149 const CSSToScreenScale
& aZoom
) = 0;
2152 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2153 * for android robocop tests.
2155 * @param aMem shared memory containing the frame buffer pixels.
2156 * @param aSize size of the buffer in screen pixels.
2158 virtual void RecvScreenPixels(mozilla::ipc::Shmem
&& aMem
,
2159 const ScreenIntSize
& aSize
,
2160 bool aNeedsYFlip
) = 0;
2162 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight
) {}
2163 virtual mozilla::ScreenIntCoord
GetDynamicToolbarMaxHeight() const {
2168 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboard();
2171 * Like GetDefaultScale, but taking into account only the system settings
2172 * and ignoring Gecko preferences.
2174 virtual double GetDefaultScaleInternal() { return 1.0; }
2177 * Layout uses this to alert the widget to the client rect representing
2178 * the window maximize button. An empty rect indicates there is no
2179 * maximize button (for example, in fullscreen). This is only implemented
2182 virtual void SetMaximizeButtonRect(const LayoutDeviceIntRect
& aClientRect
) {}
2185 // keep the list of children. We also keep track of our siblings.
2186 // The ownership model is as follows: parent holds a strong ref to
2187 // the first element of the list, and each element holds a strong
2188 // ref to the next element in the list. The prevsibling and
2189 // lastchild pointers are weak, which is fine as long as they are
2190 // maintained properly.
2191 nsCOMPtr
<nsIWidget
> mFirstChild
;
2192 nsIWidget
* MOZ_NON_OWNING_REF mLastChild
;
2193 nsCOMPtr
<nsIWidget
> mNextSibling
;
2194 nsIWidget
* MOZ_NON_OWNING_REF mPrevSibling
;
2195 // When Destroy() is called, the sub class should set this true.
2196 bool mOnDestroyCalled
;
2197 nsWindowType mWindowType
;
2201 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget
, NS_IWIDGET_IID
)
2203 #endif // nsIWidget_h__