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/widget/IMEData.h"
31 #include "nsIObserver.h"
32 #include "nsISupports.h"
35 #include "nsIWidgetListener.h"
38 #include "nsStringFwd.h"
40 #include "nsTHashMap.h"
41 #include "nsWidgetInitData.h"
42 #include "nsXULAppAPI.h"
45 # include "VsyncSource.h"
48 // forward declarations
49 class nsIBidiKeyboard
;
50 class nsIRollupListener
;
56 class nsUint64HashKey
;
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;
77 class AsyncDragMetrics
;
79 class CompositorBridgeChild
;
82 class LayerManagerComposite
;
83 class PLayerTransactionChild
;
84 class WebRenderBridgeChild
;
90 class TextEventDispatcher
;
91 class TextEventDispatcherListener
;
92 class CompositorWidget
;
93 class CompositorWidgetInitData
;
96 class DisplayListBuilder
;
97 class IpcResourceUpdateQueue
;
98 enum class RenderRoot
: uint8_t;
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
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_PLUGIN_PORT 8
131 #define NS_NATIVE_SCREEN 9
132 // The toplevel GtkWidget containing this nsIWidget:
133 #define NS_NATIVE_SHELLWIDGET 10
134 // Has to match to NPNVnetscapeWindow, and shareable across processes
135 // HWND on Windows and XID on X11
136 #define NS_NATIVE_SHAREABLE_WINDOW 11
137 #define NS_NATIVE_OPENGL_CONTEXT 12
138 // See RegisterPluginWindowForRemoteUpdates
139 #define NS_NATIVE_PLUGIN_ID 13
140 // This is available only with GetNativeData() in parent process. Anybody
141 // shouldn't access this pointer as a valid pointer since the result may be
142 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
143 // an identifier of distinguishing a text composition is caused by which native
144 // IME context. Note that the result is only valid in the process. So,
145 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
146 #define NS_RAW_NATIVE_IME_CONTEXT 14
147 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
149 # define NS_NATIVE_PLUGIN_PORT_QD 100
150 # define NS_NATIVE_PLUGIN_PORT_CG 101
153 # define NS_NATIVE_TSF_THREAD_MGR 100
154 # define NS_NATIVE_TSF_CATEGORY_MGR 101
155 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
156 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
157 # define NS_NATIVE_CHILD_WINDOW 104
158 # define NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW 105
160 #if defined(MOZ_WIDGET_GTK)
161 // set/get nsPluginNativeWindowGtk, e10s specific
162 # define NS_NATIVE_PLUGIN_OBJECT_PTR 104
163 # define NS_NATIVE_EGL_WINDOW 106
165 #ifdef MOZ_WIDGET_ANDROID
166 # define NS_JAVA_SURFACE 100
167 # define NS_PRESENTATION_WINDOW 101
168 # define NS_PRESENTATION_SURFACE 102
171 #define MOZ_WIDGET_MAX_SIZE 16384
172 #define MOZ_WIDGET_INVALID_SCALE 0.0
174 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
175 #define NS_IWIDGET_IID \
177 0x06396bf6, 0x2dd8, 0x45e5, { \
178 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
186 enum nsTransparencyMode
{
187 eTransparencyOpaque
= 0, // Fully opaque
188 eTransparencyTransparent
, // Parts of the window may be transparent
189 eTransparencyGlass
, // Transparent parts of the window have Vista AeroGlass
191 eTransparencyBorderlessGlass
// As above, but without a border around the
192 // opaque areas when there would otherwise be
193 // one with eTransparencyGlass
194 // If you add to the end here, you must update the serialization code in
195 // WidgetMessageUtils.h
202 enum nsCursor
{ ///(normal cursor, usually rendered as an arrow)
204 ///(system is busy, usually rendered as a hourglass or watch)
206 ///(Selecting something, usually rendered as an IBeam)
208 ///(can hyper-link, usually rendered as a human hand)
210 ///(north/south/west/east edge sizing)
223 eCursor_copy
, // CSS3
225 eCursor_context_menu
,
236 eCursor_vertical_text
,
243 // This one is used for array sizing, and so better be the last
244 // one in this list...
247 // ...except for this one.
248 eCursorInvalid
= eCursorCount
+ 1
251 enum nsTopLevelWidgetZPlacement
{ // for PlaceBehind()
252 eZPlacementBottom
= 0, // bottom of the window stack
253 eZPlacementBelow
, // just below another widget
254 eZPlacementTop
// top of the window stack
258 * Before the OS goes to sleep, this topic is notified.
260 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
263 * After the OS wakes up, this topic is notified.
265 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
268 * Before the OS suspends the current process, this topic is notified. Some
269 * OS will kill processes that are suspended instead of resuming them.
270 * For that reason this topic may be useful to safely close down resources.
272 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
275 * After the current process resumes from being suspended, this topic is
278 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
281 * When an app(-shell) is activated by the OS, this topic is notified.
282 * Currently, this only happens on Mac OSX.
284 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
290 * Size constraints for setting the minimum and maximum size of a widget.
291 * Values are in device pixels.
293 struct SizeConstraints
{
295 : mMaxSize(MOZ_WIDGET_MAX_SIZE
, MOZ_WIDGET_MAX_SIZE
),
296 mScale(MOZ_WIDGET_INVALID_SCALE
) {}
298 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize
,
299 mozilla::LayoutDeviceIntSize aMaxSize
,
300 mozilla::DesktopToLayoutDeviceScale aScale
)
301 : mMinSize(aMinSize
), mMaxSize(aMaxSize
), mScale(aScale
) {
302 if (mMaxSize
.width
> MOZ_WIDGET_MAX_SIZE
) {
303 mMaxSize
.width
= MOZ_WIDGET_MAX_SIZE
;
305 if (mMaxSize
.height
> MOZ_WIDGET_MAX_SIZE
) {
306 mMaxSize
.height
= MOZ_WIDGET_MAX_SIZE
;
310 mozilla::LayoutDeviceIntSize mMinSize
;
311 mozilla::LayoutDeviceIntSize mMaxSize
;
314 * The scale used to convert from desktop to device dimensions.
315 * MOZ_WIDGET_INVALID_SCALE if the value is not known.
317 * Bug 1701109 is filed to revisit adding of 'mScale' and deal
318 * with multi-monitor scaling issues in more complete way across
319 * all widget implementations.
321 mozilla::DesktopToLayoutDeviceScale mScale
;
324 struct AutoObserverNotifier
{
325 AutoObserverNotifier(nsIObserver
* aObserver
, const char* aTopic
)
326 : mObserver(aObserver
), mTopic(aTopic
) {}
328 void SkipNotification() { mObserver
= nullptr; }
330 uint64_t SaveObserver() {
334 uint64_t observerId
= ++sObserverId
;
335 sSavedObservers
.InsertOrUpdate(observerId
, mObserver
);
340 ~AutoObserverNotifier() {
342 mObserver
->Observe(nullptr, mTopic
, nullptr);
346 static void NotifySavedObserver(const uint64_t& aObserverId
,
347 const char* aTopic
) {
348 nsCOMPtr
<nsIObserver
> observer
= sSavedObservers
.Get(aObserverId
);
350 MOZ_ASSERT(aObserverId
== 0,
351 "We should always find a saved observer for nonzero IDs");
355 sSavedObservers
.Remove(aObserverId
);
356 observer
->Observe(nullptr, aTopic
, nullptr);
360 nsCOMPtr
<nsIObserver
> mObserver
;
364 static uint64_t sObserverId
;
365 static nsTHashMap
<uint64_t, nsCOMPtr
<nsIObserver
>> sSavedObservers
;
368 } // namespace widget
369 } // namespace mozilla
372 * The base class for all the widgets. It provides the interface for
373 * all basic and necessary functionality.
375 class nsIWidget
: public nsISupports
{
377 typedef mozilla::dom::BrowserChild BrowserChild
;
380 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild
;
381 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics
;
382 typedef mozilla::layers::FrameMetrics FrameMetrics
;
383 typedef mozilla::layers::LayerManager LayerManager
;
384 typedef mozilla::layers::LayerManagerComposite LayerManagerComposite
;
385 typedef mozilla::layers::LayersBackend LayersBackend
;
386 typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild
;
387 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid
;
388 typedef mozilla::layers::ZoomConstraints ZoomConstraints
;
389 typedef mozilla::widget::IMEEnabled IMEEnabled
;
390 typedef mozilla::widget::IMEMessage IMEMessage
;
391 typedef mozilla::widget::IMENotification IMENotification
;
392 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests
;
393 typedef mozilla::widget::IMEState IMEState
;
394 typedef mozilla::widget::InputContext InputContext
;
395 typedef mozilla::widget::InputContextAction InputContextAction
;
396 typedef mozilla::widget::NativeIMEContext NativeIMEContext
;
397 typedef mozilla::widget::SizeConstraints SizeConstraints
;
398 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher
;
399 typedef mozilla::widget::TextEventDispatcherListener
400 TextEventDispatcherListener
;
401 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin
;
402 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint
;
403 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect
;
404 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion
;
405 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize
;
406 typedef mozilla::ScreenIntPoint ScreenIntPoint
;
407 typedef mozilla::ScreenIntMargin ScreenIntMargin
;
408 typedef mozilla::ScreenIntSize ScreenIntSize
;
409 typedef mozilla::ScreenPoint ScreenPoint
;
410 typedef mozilla::CSSToScreenScale CSSToScreenScale
;
411 typedef mozilla::DesktopIntRect DesktopIntRect
;
412 typedef mozilla::DesktopPoint DesktopPoint
;
413 typedef mozilla::DesktopRect DesktopRect
;
414 typedef mozilla::DesktopSize DesktopSize
;
415 typedef mozilla::CSSPoint CSSPoint
;
416 typedef mozilla::CSSRect CSSRect
;
418 // Used in UpdateThemeGeometries.
419 struct ThemeGeometry
{
420 // The ThemeGeometryType value for the themed widget, see
421 // nsITheme::ThemeGeometryTypeForWidget.
422 nsITheme::ThemeGeometryType mType
;
423 // The device-pixel rect within the window for the themed widget
424 LayoutDeviceIntRect mRect
;
426 ThemeGeometry(nsITheme::ThemeGeometryType aType
,
427 const LayoutDeviceIntRect
& aRect
)
428 : mType(aType
), mRect(aRect
) {}
431 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID
)
434 : mLastChild(nullptr),
435 mPrevSibling(nullptr),
436 mOnDestroyCalled(false),
437 mWindowType(eWindowType_child
),
441 ClearNativeTouchSequence(nullptr);
445 * Create and initialize a widget.
447 * All the arguments can be null in which case a top level window
448 * with size 0 is created. The event callback function has to be
449 * provided only if the caller wants to deal with the events this
450 * widget receives. The event callback is basically a preprocess
451 * hook called synchronously. The return value determines whether
452 * the event goes to the default window procedure or it is hidden
453 * to the os. The assumption is that if the event handler returns
454 * false the widget does not see the event. The widget should not
455 * automatically clear the window to the background color. The
456 * calling code must handle paint messages and clear the background
459 * In practice at least one of aParent and aNativeParent will be null. If
460 * both are null the widget isn't parented (e.g. context menus or
461 * independent top level windows).
463 * The dimensions given in aRect are specified in the parent's
464 * device coordinate system.
465 * This must not be called for parentless widgets such as top-level
466 * windows, which use the desktop pixel coordinate system; a separate
467 * method is provided for these.
469 * @param aParent parent nsIWidget
470 * @param aNativeParent native parent widget
471 * @param aRect the widget dimension
472 * @param aInitData data that is used for widget initialization
475 [[nodiscard
]] virtual nsresult
Create(
476 nsIWidget
* aParent
, nsNativeWidget aNativeParent
,
477 const LayoutDeviceIntRect
& aRect
,
478 nsWidgetInitData
* aInitData
= nullptr) = 0;
481 * As above, but with aRect specified in DesktopPixel units (for top-level
483 * Default implementation just converts aRect to device pixels and calls
484 * through to device-pixel Create, but platforms may override this if the
485 * mapping is not straightforward or the native platform needs to use the
486 * desktop pixel values directly.
488 [[nodiscard
]] virtual nsresult
Create(nsIWidget
* aParent
,
489 nsNativeWidget aNativeParent
,
490 const DesktopIntRect
& aRect
,
491 nsWidgetInitData
* aInitData
= nullptr) {
492 LayoutDeviceIntRect devPixRect
=
493 RoundedToInt(aRect
* GetDesktopToDeviceScale());
494 return Create(aParent
, aNativeParent
, devPixRect
, aInitData
);
498 * Allocate, initialize, and return a widget that is a child of
499 * |this|. The returned widget (if nonnull) has gone through the
500 * equivalent of CreateInstance(widgetCID) + Create(...).
502 * |CreateChild()| lets widget backends decide whether to parent
503 * the new child widget to this, nonnatively parent it, or both.
504 * This interface exists to support the PuppetWidget backend,
505 * which is entirely non-native. All other params are the same as
508 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
509 * |nsIWidget*| this, not its native widget (if it exists), when
510 * calling |Create()|. This is a timid hack around poorly
511 * understood code, and shouldn't be used in new code.
513 virtual already_AddRefed
<nsIWidget
> CreateChild(
514 const LayoutDeviceIntRect
& aRect
, nsWidgetInitData
* aInitData
= nullptr,
515 bool aForceUseIWidgetParent
= false) = 0;
518 * Attach to a top level widget.
520 * In cases where a top level chrome widget is being used as a content
521 * container, attach a secondary listener and update the device
522 * context. The primary widget listener will continue to be called for
523 * notifications relating to the top-level window, whereas other
524 * notifications such as painting and events will instead be called via
525 * the attached listener. SetAttachedWidgetListener should be used to
526 * assign the attached listener.
528 * aUseAttachedEvents if true, events are sent to the attached listener
529 * instead of the normal listener.
531 virtual void AttachViewToTopLevel(bool aUseAttachedEvents
) = 0;
534 * Accessor functions to get and set the attached listener. Used by
535 * nsView in connection with AttachViewToTopLevel above.
537 virtual void SetAttachedWidgetListener(nsIWidgetListener
* aListener
) = 0;
538 virtual nsIWidgetListener
* GetAttachedWidgetListener() = 0;
539 virtual void SetPreviouslyAttachedWidgetListener(
540 nsIWidgetListener
* aListener
) = 0;
541 virtual nsIWidgetListener
* GetPreviouslyAttachedWidgetListener() = 0;
544 * Accessor functions to get and set the listener which handles various
545 * actions for the widget.
548 virtual nsIWidgetListener
* GetWidgetListener() = 0;
549 virtual void SetWidgetListener(nsIWidgetListener
* alistener
) = 0;
553 * Close and destroy the internal native window.
554 * This method does not delete the widget.
557 virtual void Destroy() = 0;
560 * Destroyed() returns true if Destroy() has been called already.
563 bool Destroyed() const { return mOnDestroyCalled
; }
568 * Change the widget's parent. Null parents are allowed.
570 * @param aNewParent new parent
572 virtual void SetParent(nsIWidget
* aNewParent
) = 0;
575 * Return the parent Widget of this Widget or nullptr if this is a
578 * @return the parent widget or nullptr if it does not have a parent
581 virtual nsIWidget
* GetParent(void) = 0;
584 * Return the top level Widget of this Widget
586 * @return the top level widget
588 virtual nsIWidget
* GetTopLevelWidget() = 0;
591 * Return the top (non-sheet) parent of this Widget if it's a sheet,
592 * or nullptr if this isn't a sheet (or some other error occurred).
593 * Sheets are only supported on some platforms (currently only macOS).
595 * @return the top (non-sheet) parent widget or nullptr
598 virtual nsIWidget
* GetSheetWindowParent(void) = 0;
601 * Return the physical DPI of the screen containing the window ...
602 * the number of device pixels per inch.
604 virtual float GetDPI() = 0;
607 * Return the scaling factor between device pixels and the platform-
608 * dependent "desktop pixels" used to manage window positions on a
609 * potentially multi-screen, mixed-resolution desktop.
611 virtual mozilla::DesktopToLayoutDeviceScale
GetDesktopToDeviceScale() = 0;
614 * Return the scaling factor between device pixels and the platform-
615 * dependent "desktop pixels" by looking up the screen by the position
618 virtual mozilla::DesktopToLayoutDeviceScale
619 GetDesktopToDeviceScaleByScreen() = 0;
622 * Return the default scale factor for the window. This is the
623 * default number of device pixels per CSS pixel to use. This should
624 * depend on OS/platform settings such as the Mac's "UI scale factor"
625 * or Windows' "font DPI". This will take into account Gecko preferences
626 * overriding the system setting.
628 mozilla::CSSToLayoutDeviceScale
GetDefaultScale();
631 * Return the first child of this widget. Will return null if
632 * there are no children.
634 nsIWidget
* GetFirstChild() const { return mFirstChild
; }
637 * Return the last child of this widget. Will return null if
638 * there are no children.
640 nsIWidget
* GetLastChild() const { return mLastChild
; }
643 * Return the next sibling of this widget
645 nsIWidget
* GetNextSibling() const { return mNextSibling
; }
648 * Set the next sibling of this widget
650 void SetNextSibling(nsIWidget
* aSibling
) { mNextSibling
= aSibling
; }
653 * Return the previous sibling of this widget
655 nsIWidget
* GetPrevSibling() const { return mPrevSibling
; }
658 * Set the previous sibling of this widget
660 void SetPrevSibling(nsIWidget
* aSibling
) { mPrevSibling
= aSibling
; }
663 * Show or hide this widget
665 * @param aState true to show the Widget, false to hide it
668 virtual void Show(bool aState
) = 0;
671 * Whether or not a widget must be recreated after being hidden to show
674 virtual bool NeedsRecreateToReshow() { return false; }
677 * Make the window modal.
679 virtual void SetModal(bool aModal
) = 0;
682 * Make the non-modal window opened by modal window fake-modal, that will
683 * call SetFakeModal(false) on destroy on Cocoa.
685 virtual void SetFakeModal(bool aModal
) { SetModal(aModal
); }
688 * Are we app modal. Currently only implemented on Cocoa.
690 virtual bool IsRunningAppModal() { return false; }
693 * The maximum number of simultaneous touch contacts supported by the device.
694 * In the case of devices with multiple digitizers (e.g. multiple touch
695 * screens), the value will be the maximum of the set of maximum supported
696 * contacts by each individual digitizer.
698 virtual uint32_t GetMaxTouchPoints() const = 0;
701 * Returns whether the window is visible
704 virtual bool IsVisible() const = 0;
707 * Perform platform-dependent sanity check on a potential window position.
708 * This is guaranteed to work only for top-level windows.
710 * @param aAllowSlop: if true, allow the window to slop offscreen;
711 * the window should be partially visible. if false,
712 * force the entire window onscreen (or at least
713 * the upper-left corner, if it's too large).
714 * @param aX in: an x position expressed in screen coordinates.
715 * out: the x position constrained to fit on the screen(s).
716 * @param aY in: an y position expressed in screen coordinates.
717 * out: the y position constrained to fit on the screen(s).
720 virtual void ConstrainPosition(bool aAllowSlop
, int32_t* aX
, int32_t* aY
) = 0;
725 * For a top-level window widget, the "parent's coordinate system" is the
726 * "global" display pixel coordinate space, *not* device pixels (which
727 * may be inconsistent between multiple screens, at least in the Mac OS
728 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
729 * following Move and Resize widget APIs.
731 * The display-/device-pixel distinction becomes important for (at least)
732 * macOS with Hi-DPI (retina) displays, and Windows when the UI scale factor
733 * is set to other than 100%.
735 * The Move and Resize methods take floating-point parameters, rather than
736 * integer ones. This is important when manipulating top-level widgets,
737 * where the coordinate system may not be an integral multiple of the
738 * device-pixel space.
744 * Coordinates refer to the top-left of the widget. For toplevel windows
745 * with decorations, this is the top-left of the titlebar and frame .
747 * @param aX the new x position expressed in the parent's coordinate system
748 * @param aY the new y position expressed in the parent's coordinate system
751 virtual void Move(double aX
, double aY
) = 0;
754 * Reposition this widget so that the client area has the given offset.
756 * @param aOffset the new offset of the client area expressed as an
757 * offset from the origin of the client area of the parent
758 * widget (for root widgets and popup widgets it is in
759 * screen coordinates)
761 virtual void MoveClient(const DesktopPoint
& aOffset
) = 0;
764 * Resize this widget. Any size constraints set for the window by a
765 * previous call to SetSizeConstraints will be applied.
767 * @param aWidth the new width expressed in the parent's coordinate system
768 * @param aHeight the new height expressed in the parent's coordinate
770 * @param aRepaint whether the widget should be repainted
772 virtual void Resize(double aWidth
, double aHeight
, bool aRepaint
) = 0;
775 * Lock the aspect ratio of a Window
777 * @param aShouldLock bool
780 virtual void LockAspectRatio(bool aShouldLock
){};
783 * Move or resize this widget. Any size constraints set for the window by
784 * a previous call to SetSizeConstraints will be applied.
786 * @param aX the new x position expressed in the parent's coordinate
788 * @param aY the new y position expressed in the parent's coordinate
790 * @param aWidth the new width expressed in the parent's coordinate system
791 * @param aHeight the new height expressed in the parent's coordinate
793 * @param aRepaint whether the widget should be repainted if the size
797 virtual void Resize(double aX
, double aY
, double aWidth
, double aHeight
,
800 virtual mozilla::Maybe
<bool> IsResizingNativeWidget() {
801 return mozilla::Nothing();
805 * Resize the widget so that the inner client area has the given size.
807 * @param aSize the new size of the client area.
808 * @param aRepaint whether the widget should be repainted
810 virtual void ResizeClient(const DesktopSize
& aSize
, bool aRepaint
) = 0;
813 * Resize and reposition the widget so tht inner client area has the given
816 * @param aRect the new offset and size of the client area. The offset is
817 * expressed as an offset from the origin of the client area
818 * of the parent widget (for root widgets and popup widgets it
819 * is in screen coordinates).
820 * @param aRepaint whether the widget should be repainted
822 virtual void ResizeClient(const DesktopRect
& aRect
, bool aRepaint
) = 0;
825 * Sets the widget's z-index.
827 virtual void SetZIndex(int32_t aZIndex
) = 0;
830 * Gets the widget's z-index.
832 int32_t GetZIndex() { return mZIndex
; }
835 * Position this widget just behind the given widget. (Used to
836 * control z-order for top-level widgets. Get/SetZIndex by contrast
837 * control z-order for child widgets of other widgets.)
838 * @param aPlacement top, bottom, or below a widget
839 * (if top or bottom, param aWidget is ignored)
840 * @param aWidget widget to place this widget behind
841 * (only if aPlacement is eZPlacementBelow).
842 * null is equivalent to aPlacement of eZPlacementTop
843 * @param aActivate true to activate the widget after placing it
845 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement
,
846 nsIWidget
* aWidget
, bool aActivate
) = 0;
849 * Minimize, maximize or normalize the window size.
850 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
852 virtual void SetSizeMode(nsSizeMode aMode
) = 0;
854 virtual void GetWorkspaceID(nsAString
& workspaceID
) = 0;
856 virtual void MoveToWorkspace(const nsAString
& workspaceID
) = 0;
859 * Suppress animations that are applied to a window by OS.
861 virtual void SuppressAnimation(bool aSuppress
) {}
864 * Return size mode (minimized, maximized, normalized).
865 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
867 virtual nsSizeMode
SizeMode() = 0;
870 * Ask whether the window is tiled.
872 virtual bool IsTiled() const = 0;
875 * Ask wether the widget is fully occluded
877 virtual bool IsFullyOccluded() const = 0;
880 * Enable or disable this Widget
882 * @param aState true to enable the Widget, false to disable it.
884 virtual void Enable(bool aState
) = 0;
887 * Ask whether the widget is enabled
889 virtual bool IsEnabled() const = 0;
892 * Whether we should request activation of this widget's toplevel window.
900 * Request activation of this window or give focus to this widget.
902 virtual void SetFocus(Raise
, mozilla::dom::CallerType aCallerType
) = 0;
905 * Get this widget's outside dimensions relative to its parent widget. For
906 * popup widgets the returned rect is in screen coordinates and not
907 * relative to its parent widget.
909 * @return the x, y, width and height of this widget.
911 virtual LayoutDeviceIntRect
GetBounds() = 0;
914 * Get this widget's outside dimensions in device coordinates. This
915 * includes any title bar on the window.
917 * @return the x, y, width and height of this widget.
919 virtual LayoutDeviceIntRect
GetScreenBounds() = 0;
922 * Similar to GetScreenBounds except that this function will always
923 * get the size when the widget is in the nsSizeMode_Normal size mode
924 * even if the current size mode is not nsSizeMode_Normal.
925 * This method will fail if the size mode is not nsSizeMode_Normal and
926 * the platform doesn't have the ability.
927 * This method will always succeed if the current size mode is
930 * @param aRect On return it holds the x, y, width and height of
933 [[nodiscard
]] virtual nsresult
GetRestoredBounds(
934 LayoutDeviceIntRect
& aRect
) = 0;
937 * Get this widget's client area bounds, if the window has a 3D border
938 * appearance this returns the area inside the border. The position is the
939 * position of the client area relative to the client area of the parent
940 * widget (for root widgets and popup widgets it is in screen coordinates).
942 * @return the x, y, width and height of the client area of this widget.
944 virtual LayoutDeviceIntRect
GetClientBounds() = 0;
947 * Sets the non-client area dimensions of the window. Pass -1 to restore
948 * the system default frame size for that border. Pass zero to remove
949 * a border, or pass a specific value adjust a border. Units are in
950 * pixels. (DPI dependent)
953 * Windows: shrinking top non-client height will remove application
954 * icon and window title text. Glass desktops will refuse to set
955 * dimensions between zero and size < system default.
957 virtual nsresult
SetNonClientMargins(LayoutDeviceIntMargin
& aMargins
) = 0;
960 * Get the client offset from the window origin.
962 * @return the x and y of the offset.
964 virtual LayoutDeviceIntPoint
GetClientOffset() = 0;
967 * Equivalent to GetClientBounds but only returns the size.
969 virtual LayoutDeviceIntSize
GetClientSize() {
970 // Depending on the backend, overloading this method may be useful if
971 // requesting the client offset is expensive.
972 return GetClientBounds().Size();
976 * Set the background color for this widget
978 * @param aColor the new background color
982 virtual void SetBackgroundColor(const nscolor
& aColor
) {}
985 * If a cursor type is currently cached locally for this widget, clear the
986 * cached cursor to force an update on the next SetCursor call.
989 virtual void ClearCachedCursor() = 0;
992 * Sets the cursor cursor for this widget.
994 * @param aDefaultCursor the default cursor to be set
995 * @param aCursorImage a custom cursor, maybe null.
996 * @param aX the X coordinate of the hotspot for aCursorImage (from left).
997 * @param aY the Y coordinate of the hotspot for aCursorImage (from top).
999 virtual void SetCursor(nsCursor aDefaultCursor
, imgIContainer
* aCursorImage
,
1000 uint32_t aHotspotX
, uint32_t aHotspotY
) = 0;
1003 * Get the window type of this widget.
1005 nsWindowType
WindowType() { return mWindowType
; }
1008 * Determines if this widget is one of the three types of plugin widgets.
1011 return mWindowType
== eWindowType_plugin
||
1012 mWindowType
== eWindowType_plugin_ipc_chrome
||
1013 mWindowType
== eWindowType_plugin_ipc_content
;
1017 * Set the transparency mode of the top-level window containing this widget.
1018 * So, e.g., if you call this on the widget for an IFRAME, the top level
1019 * browser window containing the IFRAME actually gets set. Be careful.
1021 * This can fail if the platform doesn't support
1022 * transparency/glass. By default widgets are not
1023 * transparent. This will also fail if the toplevel window is not
1024 * a Mozilla window, e.g., if the widget is in an embedded
1027 * After transparency/glass has been enabled, the initial alpha channel
1028 * value for all pixels is 1, i.e., opaque.
1029 * If the window is resized then the alpha channel values for
1030 * all pixels are reset to 1.
1031 * Pixel RGB color values are already premultiplied with alpha channel values.
1033 virtual void SetTransparencyMode(nsTransparencyMode aMode
) = 0;
1036 * Get the transparency mode of the top-level window that contains this
1039 virtual nsTransparencyMode
GetTransparencyMode() = 0;
1042 * This represents a command to set the bounds and clip region of
1045 struct Configuration
{
1046 nsCOMPtr
<nsIWidget
> mChild
;
1047 uintptr_t mWindowID
; // e10s specific, the unique plugin port id
1048 bool mVisible
; // e10s specific, widget visibility
1049 LayoutDeviceIntRect mBounds
;
1050 CopyableTArray
<LayoutDeviceIntRect
> mClipRegion
;
1054 * Sets the clip region of each mChild (which must actually be a child
1055 * of this widget) to the union of the pixel rects given in
1056 * mClipRegion, all relative to the top-left of the child
1057 * widget. Clip regions are not implemented on all platforms and only
1058 * need to actually work for children that are plugins.
1060 * Also sets the bounds of each child to mBounds.
1062 * This will invalidate areas of the children that have changed, but
1063 * does not need to invalidate any part of this widget.
1065 * Children should be moved in the order given; the array is
1066 * sorted so to minimize unnecessary invalidation if children are
1067 * moved in that order.
1069 virtual nsresult
ConfigureChildren(
1070 const nsTArray
<Configuration
>& aConfigurations
) = 0;
1071 virtual nsresult
SetWindowClipRegion(
1072 const nsTArray
<LayoutDeviceIntRect
>& aRects
,
1073 bool aIntersectWithExisting
) = 0;
1076 * Appends to aRects the rectangles constituting this widget's clip
1077 * region. If this widget is not clipped, appends a single rectangle
1078 * (0, 0, bounds.width, bounds.height).
1080 virtual void GetWindowClipRegion(nsTArray
<LayoutDeviceIntRect
>* aRects
) = 0;
1083 * Register or unregister native plugin widgets which receive Configuration
1084 * data from the content process via the compositor.
1086 * Lookups are used by the main thread via the compositor to lookup widgets
1087 * based on a unique window id. On Windows and Linux this is the
1088 * NS_NATIVE_PLUGIN_PORT (hwnd/XID). This tracking maintains a reference to
1089 * widgets held. Consumers are responsible for removing widgets from this
1092 virtual void RegisterPluginWindowForRemoteUpdates() = 0;
1093 virtual void UnregisterPluginWindowForRemoteUpdates() = 0;
1094 static nsIWidget
* LookupRegisteredPluginWindow(uintptr_t aWindowID
);
1097 * Iterates across the list of registered plugin widgets and updates thier
1098 * visibility based on which plugins are included in the 'visible' list.
1100 * The compositor knows little about tabs, but it does know which plugin
1101 * widgets are currently included in the visible layer tree. It calls this
1102 * helper to hide widgets it knows nothing about.
1104 static void UpdateRegisteredPluginWindowVisibility(
1105 uintptr_t aOwnerWidget
, nsTArray
<uintptr_t>& aPluginIds
);
1109 * Iterates over the list of registered plugins and for any that are owned
1110 * by aOwnerWidget and visible it takes a snapshot.
1112 * @param aOwnerWidget only captures visible widgets owned by this
1114 static void CaptureRegisteredPlugins(uintptr_t aOwnerWidget
);
1117 * Take a scroll capture for this widget if possible.
1119 virtual void UpdateScrollCapture() = 0;
1122 * Creates an async ImageContainer to hold scroll capture images that can be
1123 * used if the plugin is hidden during scroll.
1124 * @return the async container ID of the created ImageContainer.
1126 virtual uint64_t CreateScrollCaptureContainer() = 0;
1130 * Set the shadow style of the window.
1132 * Ignored on child widgets and on non-Mac platforms.
1134 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle
) = 0;
1137 * Set the opacity of the window.
1138 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1140 * Ignored on child widgets and on non-Mac platforms.
1142 virtual void SetWindowOpacity(float aOpacity
) {}
1145 * Set the transform of the window. Values are in device pixels,
1146 * the origin is the top left corner of the window.
1148 * Ignored on child widgets and on non-Mac platforms.
1150 virtual void SetWindowTransform(const mozilla::gfx::Matrix
& aTransform
) {}
1153 * Set whether the window should ignore mouse events or not.
1155 * This is only used on popup windows.
1157 virtual void SetWindowMouseTransparent(bool aIsTransparent
) {}
1160 * On macOS, this method shows or hides the pill button in the titlebar
1161 * that's used to collapse the toolbar.
1163 * Ignored on child widgets and on non-Mac platforms.
1165 virtual void SetShowsToolbarButton(bool aShow
) = 0;
1168 * On macOS, this method determines whether we tell cocoa that the window
1169 * supports native full screen. If we do so, and another window is in
1170 * native full screen, this window will also appear in native full screen.
1172 * We generally only want to do this for primary application windows.
1174 * Ignored on child widgets and on non-Mac platforms.
1176 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen
) = 0;
1178 enum WindowAnimationType
{
1179 eGenericWindowAnimation
,
1180 eDocumentWindowAnimation
1184 * Sets the kind of top-level window animation this widget should have. On
1185 * macOS, this causes a particular kind of animation to be shown when the
1186 * window is first made visible.
1188 * Ignored on child widgets and on non-Mac platforms.
1190 virtual void SetWindowAnimationType(WindowAnimationType aType
) = 0;
1193 * Specifies whether the window title should be drawn even if the window
1194 * contents extend into the titlebar. Ignored on windows that don't draw
1195 * in the titlebar. Only implemented on macOS.
1197 virtual void SetDrawsTitle(bool aDrawTitle
) {}
1200 * These values are used to communicate the expected window apperance via
1201 * SetWindowAppearance (see function comment below for more info):
1202 * eSystem: Use the system default window appearance, which can be light or
1204 * eLight: Use the light window appearance, regardless of the current system
1205 * window appearance.
1206 * eDark: Use the dark window appearance, regardless of the current system
1207 * window appearance.
1209 enum WindowAppearance
{ eSystem
, eLight
, eDark
};
1212 * Allows overriding the window's light/dark appearance. This is used for
1213 * windows whose light/dark look can differ from the system-wide look, and
1214 * allows the window decorations to better match the window contents, for
1215 * example ensuring sufficient contrast for the window buttons. The window
1216 * appearance affects the look of the window frame, window buttons, titlebars
1217 * and vibrant sidebars, and various -moz-default-appearance types.
1219 * Ignored on non-Mac platforms.
1221 virtual void SetWindowAppearance(WindowAppearance aAppearance
) {}
1224 * Hide window chrome (borders, buttons) for this widget.
1227 virtual void HideWindowChrome(bool aShouldHide
) = 0;
1229 enum FullscreenTransitionStage
{
1230 eBeforeFullscreenToggle
,
1231 eAfterFullscreenToggle
1235 * Prepares for fullscreen transition and returns whether the widget
1236 * supports fullscreen transition. If this method returns false,
1237 * PerformFullscreenTransition() must never be called. Otherwise,
1238 * caller should call that method twice with "before" and "after"
1239 * stages respectively in order. In the latter case, this method may
1240 * return some data via aData pointer. Caller must pass that data to
1241 * PerformFullscreenTransition() if any, and caller is responsible
1242 * for releasing that data.
1244 virtual bool PrepareForFullscreenTransition(nsISupports
** aData
) = 0;
1247 * Performs fullscreen transition. This method returns immediately,
1248 * and will post aCallback to the main thread when the transition
1251 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage
,
1254 nsIRunnable
* aCallback
) = 0;
1257 * Perform any actions needed after the fullscreen transition has ended.
1259 virtual void CleanupFullscreenTransition() = 0;
1262 * Return the screen the widget is in, or null if we don't know.
1264 virtual already_AddRefed
<nsIScreen
> GetWidgetScreen() = 0;
1267 * Put the toplevel window into or out of fullscreen mode.
1268 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1269 * if possible. (If not, it behaves as if aTargetScreen is null.)
1270 * If !aFullScreen, aTargetScreen is ignored.
1271 * aTargetScreen support is currently only implemented on Windows.
1273 * @return NS_OK if the widget is setup properly for fullscreen and
1274 * FullscreenChanged callback has been or will be called. If other
1275 * value is returned, the caller should continue the change itself.
1277 virtual nsresult
MakeFullScreen(bool aFullScreen
,
1278 nsIScreen
* aTargetScreen
= nullptr) = 0;
1281 * Same as MakeFullScreen, except that, on systems which natively
1282 * support fullscreen transition, calling this method explicitly
1283 * requests that behavior.
1284 * It is currently only supported on macOS 10.7+.
1286 virtual nsresult
MakeFullScreenWithNativeTransition(
1287 bool aFullScreen
, nsIScreen
* aTargetScreen
= nullptr) {
1288 return MakeFullScreen(aFullScreen
, aTargetScreen
);
1292 * Invalidate a specified rect for a widget so that it will be repainted
1295 virtual void Invalidate(const LayoutDeviceIntRect
& aRect
) = 0;
1297 enum LayerManagerPersistence
{
1298 LAYER_MANAGER_CURRENT
= 0,
1299 LAYER_MANAGER_PERSISTENT
1303 * Return the widget's LayerManager. The layer tree for that
1304 * LayerManager is what gets rendered to the widget.
1306 inline LayerManager
* GetLayerManager() {
1307 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE
,
1308 LAYER_MANAGER_CURRENT
);
1311 inline LayerManager
* GetLayerManager(LayerManagerPersistence aPersistence
) {
1312 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE
,
1317 * Like GetLayerManager(), but prefers creating a layer manager of
1318 * type |aBackendHint| instead of what would normally be created.
1319 * LayersBackend::LAYERS_NONE means "no hint".
1321 virtual LayerManager
* GetLayerManager(
1322 PLayerTransactionChild
* aShadowManager
, LayersBackend aBackendHint
,
1323 LayerManagerPersistence aPersistence
= LAYER_MANAGER_CURRENT
) = 0;
1326 * Called before each layer manager transaction to allow any preparation
1327 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1329 * Always called on the main thread.
1331 virtual void PrepareWindowEffects() = 0;
1334 * Called on the main thread at the end of WebRender display list building.
1336 virtual void AddWindowOverlayWebRenderCommands(
1337 mozilla::layers::WebRenderBridgeChild
* aWrBridge
,
1338 mozilla::wr::DisplayListBuilder
& aBuilder
,
1339 mozilla::wr::IpcResourceUpdateQueue
& aResources
) {}
1342 * Called when Gecko knows which themed widgets exist in this window.
1343 * The passed array contains an entry for every themed widget of the right
1344 * type (currently only StyleAppearance::Toolbar) within the window, except
1345 * for themed widgets which are transformed or have effects applied to them
1346 * (e.g. CSS opacity or filters).
1347 * This could sometimes be called during display list construction
1348 * outside of painting.
1349 * If called during painting, it will be called before we actually
1352 virtual void UpdateThemeGeometries(
1353 const nsTArray
<ThemeGeometry
>& aThemeGeometries
) = 0;
1356 * Informs the widget about the region of the window that is opaque.
1358 * @param aOpaqueRegion the region of the window that is opaque.
1360 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion
& aOpaqueRegion
) {}
1363 * Informs the widget about the region of the window that is draggable.
1365 virtual void UpdateWindowDraggingRegion(
1366 const LayoutDeviceIntRegion
& aRegion
) {}
1369 * Tells the widget whether the given input block results in a swipe.
1370 * Should be called in response to a WidgetWheelEvent that has
1371 * mFlags.mCanTriggerSwipe set on it.
1373 virtual void ReportSwipeStarted(uint64_t aInputBlockId
, bool aStartSwipe
) {}
1380 virtual void AddChild(nsIWidget
* aChild
) = 0;
1381 virtual void RemoveChild(nsIWidget
* aChild
) = 0;
1382 virtual void* GetNativeData(uint32_t aDataType
) = 0;
1383 virtual void SetNativeData(uint32_t aDataType
, uintptr_t aVal
) = 0;
1384 virtual void FreeNativeData(void* data
, uint32_t aDataType
) = 0; //~~~
1389 * Set the widget's title.
1390 * Must be called after Create.
1392 * @param aTitle string displayed as the title of the widget
1394 virtual nsresult
SetTitle(const nsAString
& aTitle
) = 0;
1397 * Set the widget's icon.
1398 * Must be called after Create.
1400 * @param aIconSpec string specifying the icon to use; convention is to
1401 * pass a resource: URL from which a platform-dependent
1402 * resource file name will be constructed
1404 virtual void SetIcon(const nsAString
& aIconSpec
) = 0;
1407 * Return this widget's origin in screen coordinates.
1409 * @return screen coordinates stored in the x,y members
1411 virtual LayoutDeviceIntPoint
WidgetToScreenOffset() = 0;
1414 * The same as WidgetToScreenOffset(), except in the case of
1415 * PuppetWidget where this method omits the chrome offset.
1417 virtual LayoutDeviceIntPoint
TopLevelWidgetToScreenOffset() {
1418 return WidgetToScreenOffset();
1422 * For a PuppetWidget, returns the transform from the coordinate
1423 * space of the PuppetWidget to the coordinate space of the
1424 * top-level native widget.
1426 * Identity transform in other cases.
1428 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1429 WidgetToTopLevelWidgetTransform() {
1430 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1434 * Given the specified client size, return the corresponding window size,
1435 * which includes the area for the borders and titlebar. This method
1436 * should work even when the window is not yet visible.
1438 virtual LayoutDeviceIntSize
ClientToWindowSize(
1439 const LayoutDeviceIntSize
& aClientSize
) = 0;
1442 * Dispatches an event to the widget
1444 virtual nsresult
DispatchEvent(mozilla::WidgetGUIEvent
* event
,
1445 nsEventStatus
& aStatus
) = 0;
1448 * Dispatches an event to APZ only.
1449 * No-op in the child process.
1451 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent
* aEvent
) = 0;
1454 * Dispatches an event that must be handled by APZ first, when APZ is
1455 * enabled. If invoked in the child process, it is forwarded to the
1456 * parent process synchronously.
1458 virtual nsEventStatus
DispatchInputEvent(
1459 mozilla::WidgetInputEvent
* aEvent
) = 0;
1462 * Confirm an APZ-aware event target. This should be used when APZ will
1463 * not need a layers update to process the event.
1465 virtual void SetConfirmedTargetAPZC(
1466 uint64_t aInputBlockId
,
1467 const nsTArray
<ScrollableLayerGuid
>& aTargets
) const = 0;
1470 * Returns true if APZ is in use, false otherwise.
1472 virtual bool AsyncPanZoomEnabled() const = 0;
1475 * Enables the dropping of files to a widget.
1477 virtual void EnableDragDrop(bool aEnable
) = 0;
1478 virtual nsresult
AsyncEnableDragDrop(bool aEnable
) = 0;
1481 * Enables/Disables system mouse capture.
1482 * @param aCapture true enables mouse capture, false disables mouse capture
1485 virtual void CaptureMouse(bool aCapture
) = 0;
1488 * Classify the window for the window manager. Mostly for X11.
1490 virtual void SetWindowClass(const nsAString
& xulWinType
) = 0;
1493 * Enables/Disables system capture of any and all events that would cause a
1494 * popup to be rolled up. aListener should be set to a non-null value for
1495 * any popups that are not managed by the popup manager.
1496 * @param aDoCapture true enables capture, false disables capture
1499 virtual void CaptureRollupEvents(nsIRollupListener
* aListener
,
1500 bool aDoCapture
) = 0;
1503 * Bring this window to the user's attention. This is intended to be a more
1504 * gentle notification than popping the window to the top or putting up an
1505 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1506 * the Mac. The notification should be suppressed if the window is already
1507 * in the foreground and should be dismissed when the user brings this window
1508 * to the foreground.
1509 * @param aCycleCount Maximum number of times to animate the window per system
1510 * conventions. If set to -1, cycles indefinitely until
1511 * window is brought into the foreground.
1513 [[nodiscard
]] virtual nsresult
GetAttention(int32_t aCycleCount
) = 0;
1516 * Ask whether there user input events pending. All input events are
1517 * included, including those not targeted at this nsIwidget instance.
1519 virtual bool HasPendingInputEvent() = 0;
1522 * If set to true, the window will draw its contents into the titlebar
1523 * instead of below it.
1525 * Ignored on any platform that does not support it. Ignored by widgets that
1526 * do not represent windows.
1527 * May result in a resize event, so should only be called from places where
1528 * reflow and painting is allowed.
1530 * @param aState Whether drawing into the titlebar should be activated.
1532 virtual void SetDrawsInTitlebar(bool aState
) = 0;
1535 * Determine whether the widget shows a resize widget. If it does,
1536 * aResizerRect returns the resizer's rect.
1538 * Returns false on any platform that does not support it.
1540 * @param aResizerRect The resizer's rect in device pixels.
1541 * @return Whether a resize widget is shown.
1543 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect
* aResizerRect
) = 0;
1546 * Begin a window resizing drag, based on the event passed in.
1548 [[nodiscard
]] virtual nsresult
BeginResizeDrag(
1549 mozilla::WidgetGUIEvent
* aEvent
, int32_t aHorizontal
,
1550 int32_t aVertical
) = 0;
1552 // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or
1554 enum Modifiers
: uint32_t {
1555 NO_MODIFIERS
= 0x00000000,
1556 CAPS_LOCK
= 0x00000001, // when CapsLock is active
1557 NUM_LOCK
= 0x00000002, // when NumLock is active
1558 SHIFT_L
= 0x00000100,
1559 SHIFT_R
= 0x00000200,
1560 CTRL_L
= 0x00000400,
1561 CTRL_R
= 0x00000800,
1562 ALT_L
= 0x00001000, // includes Option
1564 COMMAND_L
= 0x00004000,
1565 COMMAND_R
= 0x00008000,
1567 ALTGRAPH
= 0x00020000, // AltGr key on Windows. This emulates
1568 // AltRight key behavior of keyboard
1569 // layouts which maps AltGr to AltRight
1571 FUNCTION
= 0x00100000,
1572 NUMERIC_KEY_PAD
= 0x01000000 // when the key is coming from the keypad
1575 * Utility method intended for testing. Dispatches native key events
1576 * to this widget to simulate the press and release of a key.
1577 * @param aNativeKeyboardLayout a *platform-specific* constant.
1578 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1579 * On Windows, it is converted to a hex string and passed to
1580 * LoadKeyboardLayout, see
1581 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1582 * @param aNativeKeyCode a *platform-specific* keycode.
1583 * On Windows, this is the virtual key code.
1584 * @param aModifiers some combination of the above 'Modifiers' flags;
1585 * not all flags will apply to all platforms. Mac ignores the _R
1586 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1588 * @param aCharacters characters that the OS would decide to generate
1589 * from the event. On Windows, this is the charCode passed by
1591 * @param aUnmodifiedCharacters characters that the OS would decide
1592 * to generate from the event if modifier keys (other than shift)
1593 * were assumed inactive. Needed on Mac, ignored on Windows.
1594 * @param aObserver the observer that will get notified once the events
1595 * have been dispatched.
1596 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1597 * layout is not supported and the event was not fired
1599 virtual nsresult
SynthesizeNativeKeyEvent(
1600 int32_t aNativeKeyboardLayout
, int32_t aNativeKeyCode
,
1601 uint32_t aModifierFlags
, const nsAString
& aCharacters
,
1602 const nsAString
& aUnmodifiedCharacters
, nsIObserver
* aObserver
) = 0;
1605 * Utility method intended for testing. Dispatches native mouse events
1606 * may even move the mouse cursor. On Mac the events are guaranteed to
1607 * be sent to the window containing this widget, but on Windows they'll go
1608 * to whatever's topmost on the screen at that position, so for
1609 * cross-platform testing ensure that your window is at the top of the
1611 * @param aPoint screen location of the mouse, in device
1612 * pixels, with origin at the top left
1613 * @param aNativeMessage abstract native message.
1614 * @param aButton Mouse button defined by DOM UI Events.
1615 * @param aModifierFlags Some values of nsIWidget::Modifiers.
1616 * FYI: On Windows, Android and Headless widget on all
1617 * platroms, this hasn't been handled yet.
1618 * @param aObserver the observer that will get notified once the events
1619 * have been dispatched.
1621 enum class NativeMouseMessage
: uint32_t {
1622 ButtonDown
, // button down
1623 ButtonUp
, // button up
1624 Move
, // mouse cursor move
1625 EnterWindow
, // mouse cursor comes into a window
1626 LeaveWindow
, // mouse cursor leaves from a window
1628 virtual nsresult
SynthesizeNativeMouseEvent(
1629 LayoutDeviceIntPoint aPoint
, NativeMouseMessage aNativeMessage
,
1630 mozilla::MouseButton aButton
, nsIWidget::Modifiers aModifierFlags
,
1631 nsIObserver
* aObserver
) = 0;
1634 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1635 * message. aPoint is location in device pixels to which the mouse pointer
1637 * @param aObserver the observer that will get notified once the events
1638 * have been dispatched.
1640 virtual nsresult
SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint
,
1641 nsIObserver
* aObserver
) = 0;
1644 * Utility method intended for testing. Dispatching native mouse scroll
1645 * events may move the mouse cursor.
1647 * @param aPoint Mouse cursor position in screen coordinates.
1648 * In device pixels, the origin at the top left of
1649 * the primary display.
1650 * @param aNativeMessage Platform native message.
1651 * @param aDeltaX The delta value for X direction. If the native
1652 * message doesn't indicate X direction scrolling,
1653 * this may be ignored.
1654 * @param aDeltaY The delta value for Y direction. If the native
1655 * message doesn't indicate Y direction scrolling,
1656 * this may be ignored.
1657 * @param aDeltaZ The delta value for Z direction. If the native
1658 * message doesn't indicate Z direction scrolling,
1659 * this may be ignored.
1660 * @param aModifierFlags Must be values of Modifiers, or zero.
1661 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1663 * @param aObserver The observer that will get notified once the
1664 * events have been dispatched.
1666 virtual nsresult
SynthesizeNativeMouseScrollEvent(
1667 LayoutDeviceIntPoint aPoint
, uint32_t aNativeMessage
, double aDeltaX
,
1668 double aDeltaY
, double aDeltaZ
, uint32_t aModifierFlags
,
1669 uint32_t aAdditionalFlags
, nsIObserver
* aObserver
) = 0;
1672 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1673 * touch states in nsIDOMWindowUtils.idl.
1675 enum TouchPointerState
{
1676 // The pointer is in a hover state above the digitizer
1677 TOUCH_HOVER
= (1 << 0),
1678 // The pointer is in contact with the digitizer
1679 TOUCH_CONTACT
= (1 << 1),
1680 // The pointer has been removed from the digitizer detection area
1681 TOUCH_REMOVE
= (1 << 2),
1682 // The pointer has been canceled. Will cancel any pending os level
1683 // gestures that would triggered as a result of completion of the
1684 // input sequence. This may not cancel moz platform related events
1685 // that might get tirggered by input already delivered.
1686 TOUCH_CANCEL
= (1 << 3),
1688 // ALL_BITS used for validity checking during IPC serialization
1689 ALL_BITS
= (1 << 4) - 1
1692 * TouchpadPinchPhase states for SynthesizeNativeTouchPadPinch. Match
1693 * Phase states in nsIDOMWindowUtils.idl.
1695 enum TouchpadPinchPhase
{ PHASE_BEGIN
= 0, PHASE_UPDATE
= 1, PHASE_END
= 2 };
1697 * Create a new or update an existing touch pointer on the digitizer.
1698 * To trigger os level gestures, individual touch points should
1699 * transition through a complete set of touch states which should be
1700 * sent as individual messages.
1702 * @param aPointerId The touch point id to create or update.
1703 * @param aPointerState one or more of the touch states listed above
1704 * @param aPoint coords of this event
1705 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1706 * @param aOrientation 0 -> 359 degree value indicating the
1707 * orientation of the pointer. Use 90 for normal taps.
1708 * @param aObserver The observer that will get notified once the events
1709 * have been dispatched.
1711 virtual nsresult
SynthesizeNativeTouchPoint(uint32_t aPointerId
,
1712 TouchPointerState aPointerState
,
1713 LayoutDeviceIntPoint aPoint
,
1714 double aPointerPressure
,
1715 uint32_t aPointerOrientation
,
1716 nsIObserver
* aObserver
) = 0;
1718 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1720 virtual nsresult
SynthesizeNativeTouchPadPinch(TouchpadPinchPhase aEventPhase
,
1722 LayoutDeviceIntPoint aPoint
,
1723 int32_t aModifierFlags
) = 0;
1726 * Helper for simulating a simple tap event with one touch point. When
1727 * aLongTap is true, simulates a native long tap with a duration equal to
1728 * ui.click_hold_context_menus.delay. This pref is compatible with the
1729 * apzc long tap duration. Defaults to 1.5 seconds.
1730 * @param aObserver The observer that will get notified once the events
1731 * have been dispatched.
1733 virtual nsresult
SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint
,
1735 nsIObserver
* aObserver
);
1737 virtual nsresult
SynthesizeNativePenInput(
1738 uint32_t aPointerId
, TouchPointerState aPointerState
,
1739 LayoutDeviceIntPoint aPoint
, double aPressure
, uint32_t aRotation
,
1740 int32_t aTiltX
, int32_t aTiltY
, nsIObserver
* aObserver
) = 0;
1743 * Cancels all active simulated touch input points and pending long taps.
1744 * Native widgets should track existing points such that they can clear the
1745 * digitizer state when this call is made.
1746 * @param aObserver The observer that will get notified once the touch
1747 * sequence has been cleared.
1749 virtual nsresult
ClearNativeTouchSequence(nsIObserver
* aObserver
);
1752 * Send a native event as if the user double tapped the touchpad with two
1755 virtual nsresult
SynthesizeNativeTouchpadDoubleTap(
1756 LayoutDeviceIntPoint aPoint
, uint32_t aModifierFlags
) = 0;
1758 virtual void StartAsyncScrollbarDrag(
1759 const AsyncDragMetrics
& aDragMetrics
) = 0;
1762 * Notify APZ to start autoscrolling.
1763 * @param aAnchorLocation the location of the autoscroll anchor
1764 * @param aGuid identifies the scroll frame to be autoscrolled
1765 * @return true if APZ has been successfully notified
1767 virtual bool StartAsyncAutoscroll(const ScreenPoint
& aAnchorLocation
,
1768 const ScrollableLayerGuid
& aGuid
) = 0;
1771 * Notify APZ to stop autoscrolling.
1772 * @param aGuid identifies the scroll frame which is being autoscrolled.
1774 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid
& aGuid
) = 0;
1776 // If this widget supports out-of-process compositing, it can override
1777 // this method to provide additional information to the compositor.
1778 virtual void GetCompositorWidgetInitData(
1779 mozilla::widget::CompositorWidgetInitData
* aInitData
) {}
1782 * Setter/Getter of the system font setting for testing.
1784 virtual nsresult
SetSystemFont(const nsCString
& aFontName
) {
1785 return NS_ERROR_NOT_IMPLEMENTED
;
1787 virtual nsresult
GetSystemFont(nsCString
& aFontName
) {
1788 return NS_ERROR_NOT_IMPLEMENTED
;
1791 // Get rectangle of the screen where the window is placed.
1792 // It's used to detect popup overflow under Wayland because
1793 // Screenmanager does not work under it.
1795 virtual nsresult
GetScreenRect(LayoutDeviceIntRect
* aRect
) {
1796 return NS_ERROR_NOT_IMPLEMENTED
;
1798 virtual nsRect
GetPreferredPopupRect() {
1799 NS_WARNING("GetPreferredPopupRect implemented only for wayland");
1800 return nsRect(0, 0, 0, 0);
1802 virtual void FlushPreferredPopupRect() {
1803 NS_WARNING("FlushPreferredPopupRect implemented only for wayland");
1810 * Get safe area insets except to cutout.
1811 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1813 virtual mozilla::ScreenIntMargin
GetSafeAreaInsets() const {
1814 return mozilla::ScreenIntMargin();
1820 LongTapInfo(int32_t aPointerId
, LayoutDeviceIntPoint
& aPoint
,
1821 mozilla::TimeDuration aDuration
, nsIObserver
* aObserver
)
1822 : mPointerId(aPointerId
),
1824 mDuration(aDuration
),
1825 mObserver(aObserver
),
1826 mStamp(mozilla::TimeStamp::Now()) {}
1829 LayoutDeviceIntPoint mPosition
;
1830 mozilla::TimeDuration mDuration
;
1831 nsCOMPtr
<nsIObserver
> mObserver
;
1832 mozilla::TimeStamp mStamp
;
1835 static void OnLongTapTimerCallback(nsITimer
* aTimer
, void* aClosure
);
1837 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboardContentProcess();
1838 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboardInner();
1840 mozilla::UniquePtr
<LongTapInfo
> mLongTapTouchPoint
;
1841 nsCOMPtr
<nsITimer
> mLongTapTimer
;
1842 static int32_t sPointerIdCounter
;
1846 * If key events have not been handled by content or XBL handlers, they can
1847 * be offered to the system (for custom application shortcuts set in system
1848 * preferences, for example).
1850 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent
* aEvent
);
1853 * Activates a native menu item at the position specified by the index
1854 * string. The index string is a string of positive integers separated
1855 * by the "|" (pipe) character. The last integer in the string represents
1856 * the item index in a submenu located using the integers preceding it.
1859 * In this string, the first integer represents the top-level submenu
1860 * in the native menu bar. Since the integer is 1, it is the second submeu
1861 * in the native menu bar. Within that, the first item (index 0) is a
1862 * submenu, and we want to activate the 5th item within that submenu.
1864 virtual nsresult
ActivateNativeMenuItemAt(const nsAString
& indexString
) = 0;
1867 * This is used for native menu system testing.
1869 * Updates a native menu at the position specified by the index string.
1870 * The index string is a string of positive integers separated by the "|"
1874 * In this string, the first integer represents the top-level submenu
1875 * in the native menu bar. Since the integer is 1, it is the second submeu
1876 * in the native menu bar. Within that, the first item (index 0) is a
1877 * submenu, and we want to update submenu at index 4 within that submenu.
1879 * If this is called with an empty string it forces a full reload of the
1882 virtual nsresult
ForceUpdateNativeMenuAt(const nsAString
& indexString
) = 0;
1885 * This is used for testing macOS service menu code.
1887 * @param aResult - the current text selection. Is empty if no selection.
1888 * @return nsresult - whether or not aResult was assigned the selected text.
1890 [[nodiscard
]] virtual nsresult
GetSelectionAsPlaintext(nsAString
& aResult
) {
1891 return NS_ERROR_NOT_IMPLEMENTED
;
1895 * Notify IME of the specified notification.
1897 * @return If the notification is mouse button event and it's consumed by
1898 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1900 virtual nsresult
NotifyIME(const IMENotification
& aIMENotification
) = 0;
1903 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1904 * of the widget, in the event that we were not able to observe and respond to
1905 * the initial focus event. This is necessary for the early skeleton UI
1906 * window, which is displayed and receives its initial focus event before we
1907 * can actually respond to it.
1909 virtual void MaybeDispatchInitialFocusEvent() {}
1912 * Notifies the input context changes.
1914 virtual void SetInputContext(const InputContext
& aContext
,
1915 const InputContextAction
& aAction
) = 0;
1918 * Get current input context.
1920 virtual InputContext
GetInputContext() = 0;
1923 * Get native IME context. This is different from GetNativeData() with
1924 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1927 virtual NativeIMEContext
GetNativeIMEContext() = 0;
1930 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1931 * native (OS-level) event for it. This method allows tests to simulate
1932 * keystrokes that trigger native key bindings (which require a native
1935 [[nodiscard
]] virtual nsresult
AttachNativeKeyEvent(
1936 mozilla::WidgetKeyboardEvent
& aEvent
) = 0;
1939 * Retrieve edit commands when the key combination of aEvent is used
1940 * in platform native applications.
1942 enum NativeKeyBindingsType
: uint8_t {
1943 NativeKeyBindingsForSingleLineEditor
,
1944 NativeKeyBindingsForMultiLineEditor
,
1945 NativeKeyBindingsForRichTextEditor
1947 MOZ_CAN_RUN_SCRIPT
virtual bool GetEditCommands(
1948 NativeKeyBindingsType aType
, const mozilla::WidgetKeyboardEvent
& aEvent
,
1949 nsTArray
<mozilla::CommandInt
>& aCommands
);
1952 * Retrieves a reference to notification requests of IME. Note that the
1953 * reference is valid while the nsIWidget instance is alive. So, if you
1954 * need to store the reference for a long time, you need to grab the widget
1957 const IMENotificationRequests
& IMENotificationRequestsRef();
1960 * Call this method when a dialog is opened which has a default button.
1961 * The button's rectangle should be supplied in aButtonRect.
1963 [[nodiscard
]] virtual nsresult
OnDefaultButtonLoaded(
1964 const LayoutDeviceIntRect
& aButtonRect
) = 0;
1967 * Return true if this process shouldn't use platform widgets, and
1968 * so should use PuppetWidgets instead. If this returns true, the
1969 * result of creating and using a platform widget is undefined,
1970 * and likely to end in crashes or other buggy behavior.
1972 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1974 static already_AddRefed
<nsIWidget
> CreateTopLevelWindow();
1976 static already_AddRefed
<nsIWidget
> CreateChildWindow();
1979 * Allocate and return a "puppet widget" that doesn't directly
1980 * correlate to a platform widget; platform events and data must
1981 * be fed to it. Currently used in content processes. NULL is
1982 * returned if puppet widgets aren't supported in this build
1983 * config, on this platform, or for this process type.
1985 * This function is called "Create" to match CreateInstance().
1986 * The returned widget must still be nsIWidget::Create()d.
1988 static already_AddRefed
<nsIWidget
> CreatePuppetWidget(
1989 BrowserChild
* aBrowserChild
);
1991 static already_AddRefed
<nsIWidget
> CreateHeadlessWidget();
1994 * Reparent this widget's native widget.
1995 * @param aNewParent the native widget of aNewParent is the new native
1998 virtual void ReparentNativeWidget(nsIWidget
* aNewParent
) = 0;
2001 * Return true if widget has it's own GL context
2003 virtual bool HasGLContext() { return false; }
2006 * Returns true to indicate that this widget paints an opaque background
2007 * that we want to be visible under the page, so layout should not force
2008 * a default background.
2010 virtual bool WidgetPaintsBackground() { return false; }
2012 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
2015 * Get the natural bounds of this widget. This method is only
2016 * meaningful for widgets for which Gecko implements screen
2017 * rotation natively. When this is the case, GetBounds() returns
2018 * the widget bounds taking rotation into account, and
2019 * GetNaturalBounds() returns the bounds *not* taking rotation
2022 * No code outside of the composition pipeline should know or care
2023 * about this. If you're not an agent of the compositor, you
2024 * probably shouldn't call this method.
2026 virtual LayoutDeviceIntRect
GetNaturalBounds() { return GetBounds(); }
2029 * Set size constraints on the window size such that it is never less than
2030 * the specified minimum size and never larger than the specified maximum
2031 * size. The size constraints are sizes of the outer rectangle including
2032 * the window frame and title bar. Use 0 for an unconstrained minimum size
2033 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
2034 * does not necessarily change the size of a window to conform to this size,
2035 * thus Resize should be called afterwards.
2037 * @param aConstraints: the size constraints in device pixels
2039 virtual void SetSizeConstraints(const SizeConstraints
& aConstraints
) = 0;
2042 * Return the size constraints currently observed by the widget.
2044 * @return the constraints in device pixels
2046 virtual const SizeConstraints
GetSizeConstraints() = 0;
2049 * If this is owned by a BrowserChild, return that. Otherwise return
2052 virtual BrowserChild
* GetOwningBrowserChild() { return nullptr; }
2055 * If this isn't directly compositing to its window surface,
2056 * return the compositor which is doing that on our behalf.
2058 virtual CompositorBridgeChild
* GetRemoteRenderer() { return nullptr; }
2061 * Clear WebRender resources
2063 virtual void ClearCachedWebrenderResources() {}
2066 * If this widget has its own vsync source, return it, otherwise return
2067 * nullptr. An example of such local source would be Wayland frame callbacks.
2069 virtual RefPtr
<mozilla::gfx::VsyncSource
> GetVsyncSource() { return nullptr; }
2072 * Returns true if the widget requires synchronous repaints on resize,
2075 virtual bool SynchronouslyRepaintOnResize() { return true; }
2078 * Some platforms (only cocoa right now) round widget coordinates to the
2079 * nearest even pixels (see bug 892994), this function allows us to
2080 * determine how widget coordinates will be rounded.
2082 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2084 virtual void UpdateZoomConstraints(
2085 const uint32_t& aPresShellId
, const ScrollableLayerGuid::ViewID
& aViewId
,
2086 const mozilla::Maybe
<ZoomConstraints
>& aConstraints
){};
2089 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2090 * widget. Note that this never returns nullptr.
2092 virtual TextEventDispatcher
* GetTextEventDispatcher() = 0;
2095 * GetNativeTextEventDispatcherListener() returns a
2096 * TextEventDispatcherListener instance which is used when the widget
2097 * instance handles native IME and/or keyboard events.
2099 virtual TextEventDispatcherListener
*
2100 GetNativeTextEventDispatcherListener() = 0;
2102 virtual void ZoomToRect(const uint32_t& aPresShellId
,
2103 const ScrollableLayerGuid::ViewID
& aViewId
,
2104 const CSSRect
& aRect
, const uint32_t& aFlags
) = 0;
2107 * LookUpDictionary shows the dictionary for the word around current point.
2109 * @param aText the word to look up dictiorary.
2110 * @param aFontRangeArray text decoration of aText
2111 * @param aIsVertical true if the word is vertical layout
2112 * @param aPoint top-left point of aText
2114 virtual void LookUpDictionary(
2115 const nsAString
& aText
,
2116 const nsTArray
<mozilla::FontRange
>& aFontRangeArray
,
2117 const bool aIsVertical
, const LayoutDeviceIntPoint
& aPoint
) {}
2119 virtual void RequestFxrOutput() {
2120 MOZ_ASSERT(false, "This function should only execute in Windows");
2123 #if defined(MOZ_WIDGET_ANDROID)
2125 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2128 * @param aMessage message being sent to Android UI thread.
2130 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage
) = 0;
2133 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2136 * @param aScrollOffset page scroll offset value in screen pixels.
2137 * @param aZoom current page zoom.
2139 virtual void UpdateRootFrameMetrics(const ScreenPoint
& aScrollOffset
,
2140 const CSSToScreenScale
& aZoom
) = 0;
2143 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2144 * for android robocop tests.
2146 * @param aMem shared memory containing the frame buffer pixels.
2147 * @param aSize size of the buffer in screen pixels.
2149 virtual void RecvScreenPixels(mozilla::ipc::Shmem
&& aMem
,
2150 const ScreenIntSize
& aSize
,
2151 bool aNeedsYFlip
) = 0;
2153 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight
) {}
2154 virtual mozilla::ScreenIntCoord
GetDynamicToolbarMaxHeight() const {
2159 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboard();
2162 * Like GetDefaultScale, but taking into account only the system settings
2163 * and ignoring Gecko preferences.
2165 virtual double GetDefaultScaleInternal() { return 1.0; }
2168 // keep the list of children. We also keep track of our siblings.
2169 // The ownership model is as follows: parent holds a strong ref to
2170 // the first element of the list, and each element holds a strong
2171 // ref to the next element in the list. The prevsibling and
2172 // lastchild pointers are weak, which is fine as long as they are
2173 // maintained properly.
2174 nsCOMPtr
<nsIWidget
> mFirstChild
;
2175 nsIWidget
* MOZ_NON_OWNING_REF mLastChild
;
2176 nsCOMPtr
<nsIWidget
> mNextSibling
;
2177 nsIWidget
* MOZ_NON_OWNING_REF mPrevSibling
;
2178 // When Destroy() is called, the sub class should set this true.
2179 bool mOnDestroyCalled
;
2180 nsWindowType mWindowType
;
2184 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget
, NS_IWIDGET_IID
)
2186 #endif // nsIWidget_h__