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/. */
9 #include "mozilla/UniquePtr.h"
10 #include "nsISupports.h"
16 #include "nsWidgetInitData.h"
20 #include "nsRegionFwd.h"
21 #include "nsXULAppAPI.h"
22 #include "mozilla/Maybe.h"
23 #include "mozilla/EventForwards.h"
24 #include "mozilla/layers/ScrollableLayerGuid.h"
25 #include "mozilla/layers/ZoomConstraints.h"
26 #include "mozilla/RefPtr.h"
27 #include "mozilla/TimeStamp.h"
28 #include "mozilla/gfx/Point.h"
29 #include "mozilla/widget/IMEData.h"
30 #include "VsyncSource.h"
31 #include "nsDataHashtable.h"
32 #include "nsIObserver.h"
33 #include "nsIWidgetListener.h"
35 #include "mozilla/dom/BindingDeclarations.h"
37 // forward declarations
38 class nsIBidiKeyboard
;
39 class nsIRollupListener
;
45 class nsIKeyEventInPluginCallback
;
49 enum class StyleWindowShadow
: uint8_t;
51 #if defined(MOZ_WIDGET_ANDROID)
55 #endif // defined(MOZ_WIDGET_ANDROID)
60 class PluginWidgetChild
;
61 } // namespace plugins
63 class AsyncDragMetrics
;
65 class CompositorBridgeChild
;
68 class LayerManagerComposite
;
69 class PLayerTransactionChild
;
70 class WebRenderBridgeChild
;
77 class TextEventDispatcher
;
78 class TextEventDispatcherListener
;
79 class CompositorWidget
;
80 class CompositorWidgetInitData
;
83 class DisplayListBuilder
;
84 class IpcResourceUpdateQueue
;
85 enum class RenderRoot
: uint8_t;
87 } // namespace mozilla
90 * Callback function that processes events.
92 * The argument is actually a subtype (subclass) of WidgetEvent which carries
93 * platform specific information about the event. Platform specific code
94 * knows how to deal with it.
96 * The return value determines whether or not the default action should take
99 typedef nsEventStatus (*EVENT_CALLBACK
)(mozilla::WidgetGUIEvent
* aEvent
);
101 // Hide the native window system's real window type so as to avoid
102 // including native window system types and APIs. This is necessary
103 // to ensure cross-platform code.
104 typedef void* nsNativeWidget
;
107 * Flags for the GetNativeData and SetNativeData functions
109 #define NS_NATIVE_WINDOW 0
110 #define NS_NATIVE_GRAPHIC 1
111 #define NS_NATIVE_TMP_WINDOW 2
112 #define NS_NATIVE_WIDGET 3
113 #define NS_NATIVE_DISPLAY 4
114 #define NS_NATIVE_REGION 5
115 #define NS_NATIVE_OFFSETX 6
116 #define NS_NATIVE_OFFSETY 7
117 #define NS_NATIVE_PLUGIN_PORT 8
118 #define NS_NATIVE_SCREEN 9
119 // The toplevel GtkWidget containing this nsIWidget:
120 #define NS_NATIVE_SHELLWIDGET 10
121 // Has to match to NPNVnetscapeWindow, and shareable across processes
122 // HWND on Windows and XID on X11
123 #define NS_NATIVE_SHAREABLE_WINDOW 11
124 #define NS_NATIVE_OPENGL_CONTEXT 12
125 // See RegisterPluginWindowForRemoteUpdates
126 #define NS_NATIVE_PLUGIN_ID 13
127 // This is available only with GetNativeData() in parent process. Anybody
128 // shouldn't access this pointer as a valid pointer since the result may be
129 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
130 // an identifier of distinguishing a text composition is caused by which native
131 // IME context. Note that the result is only valid in the process. So,
132 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
133 #define NS_RAW_NATIVE_IME_CONTEXT 14
134 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
136 # define NS_NATIVE_PLUGIN_PORT_QD 100
137 # define NS_NATIVE_PLUGIN_PORT_CG 101
140 # define NS_NATIVE_TSF_THREAD_MGR 100
141 # define NS_NATIVE_TSF_CATEGORY_MGR 101
142 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
143 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
144 # define NS_NATIVE_CHILD_WINDOW 104
145 # define NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW 105
147 #if defined(MOZ_WIDGET_GTK)
148 // set/get nsPluginNativeWindowGtk, e10s specific
149 # define NS_NATIVE_PLUGIN_OBJECT_PTR 104
150 # define NS_NATIVE_EGL_WINDOW 106
152 #ifdef MOZ_WIDGET_ANDROID
153 # define NS_JAVA_SURFACE 100
154 # define NS_PRESENTATION_WINDOW 101
155 # define NS_PRESENTATION_SURFACE 102
158 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
159 #define NS_IWIDGET_IID \
161 0x06396bf6, 0x2dd8, 0x45e5, { \
162 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
170 enum nsTransparencyMode
{
171 eTransparencyOpaque
= 0, // Fully opaque
172 eTransparencyTransparent
, // Parts of the window may be transparent
173 eTransparencyGlass
, // Transparent parts of the window have Vista AeroGlass
175 eTransparencyBorderlessGlass
// As above, but without a border around the
176 // opaque areas when there would otherwise be
177 // one with eTransparencyGlass
178 // If you add to the end here, you must update the serialization code in
179 // WidgetMessageUtils.h
186 enum nsCursor
{ ///(normal cursor, usually rendered as an arrow)
188 ///(system is busy, usually rendered as a hourglass or watch)
190 ///(Selecting something, usually rendered as an IBeam)
192 ///(can hyper-link, usually rendered as a human hand)
194 ///(north/south/west/east edge sizing)
207 eCursor_copy
, // CSS3
209 eCursor_context_menu
,
220 eCursor_vertical_text
,
227 // This one is used for array sizing, and so better be the last
228 // one in this list...
231 // ...except for this one.
232 eCursorInvalid
= eCursorCount
+ 1
235 enum nsTopLevelWidgetZPlacement
{ // for PlaceBehind()
236 eZPlacementBottom
= 0, // bottom of the window stack
237 eZPlacementBelow
, // just below another widget
238 eZPlacementTop
// top of the window stack
242 * Before the OS goes to sleep, this topic is notified.
244 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
247 * After the OS wakes up, this topic is notified.
249 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
252 * Before the OS suspends the current process, this topic is notified. Some
253 * OS will kill processes that are suspended instead of resuming them.
254 * For that reason this topic may be useful to safely close down resources.
256 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
259 * After the current process resumes from being suspended, this topic is
262 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
265 * When an app(-shell) is activated by the OS, this topic is notified.
266 * Currently, this only happens on Mac OSX.
268 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
274 * Size constraints for setting the minimum and maximum size of a widget.
275 * Values are in device pixels.
277 struct SizeConstraints
{
278 SizeConstraints() : mMaxSize(NS_MAXSIZE
, NS_MAXSIZE
) {}
280 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize
,
281 mozilla::LayoutDeviceIntSize aMaxSize
)
282 : mMinSize(aMinSize
), mMaxSize(aMaxSize
) {}
284 mozilla::LayoutDeviceIntSize mMinSize
;
285 mozilla::LayoutDeviceIntSize mMaxSize
;
288 struct AutoObserverNotifier
{
289 AutoObserverNotifier(nsIObserver
* aObserver
, const char* aTopic
)
290 : mObserver(aObserver
), mTopic(aTopic
) {}
292 void SkipNotification() { mObserver
= nullptr; }
294 uint64_t SaveObserver() {
298 uint64_t observerId
= ++sObserverId
;
299 sSavedObservers
.Put(observerId
, mObserver
);
304 ~AutoObserverNotifier() {
306 mObserver
->Observe(nullptr, mTopic
, nullptr);
310 static void NotifySavedObserver(const uint64_t& aObserverId
,
311 const char* aTopic
) {
312 nsCOMPtr
<nsIObserver
> observer
= sSavedObservers
.Get(aObserverId
);
314 MOZ_ASSERT(aObserverId
== 0,
315 "We should always find a saved observer for nonzero IDs");
319 sSavedObservers
.Remove(aObserverId
);
320 observer
->Observe(nullptr, aTopic
, nullptr);
324 nsCOMPtr
<nsIObserver
> mObserver
;
328 static uint64_t sObserverId
;
329 static nsDataHashtable
<nsUint64HashKey
, nsCOMPtr
<nsIObserver
>>
333 } // namespace widget
334 } // namespace mozilla
337 * The base class for all the widgets. It provides the interface for
338 * all basic and necessary functionality.
340 class nsIWidget
: public nsISupports
{
342 typedef mozilla::dom::BrowserChild BrowserChild
;
345 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild
;
346 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics
;
347 typedef mozilla::layers::FrameMetrics FrameMetrics
;
348 typedef mozilla::layers::LayerManager LayerManager
;
349 typedef mozilla::layers::LayerManagerComposite LayerManagerComposite
;
350 typedef mozilla::layers::LayersBackend LayersBackend
;
351 typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild
;
352 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid
;
353 typedef mozilla::layers::ZoomConstraints ZoomConstraints
;
354 typedef mozilla::widget::IMEMessage IMEMessage
;
355 typedef mozilla::widget::IMENotification IMENotification
;
356 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests
;
357 typedef mozilla::widget::IMEState IMEState
;
358 typedef mozilla::widget::InputContext InputContext
;
359 typedef mozilla::widget::InputContextAction InputContextAction
;
360 typedef mozilla::widget::NativeIMEContext NativeIMEContext
;
361 typedef mozilla::widget::SizeConstraints SizeConstraints
;
362 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher
;
363 typedef mozilla::widget::TextEventDispatcherListener
364 TextEventDispatcherListener
;
365 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin
;
366 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint
;
367 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect
;
368 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion
;
369 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize
;
370 typedef mozilla::ScreenIntPoint ScreenIntPoint
;
371 typedef mozilla::ScreenIntMargin ScreenIntMargin
;
372 typedef mozilla::ScreenIntSize ScreenIntSize
;
373 typedef mozilla::ScreenPoint ScreenPoint
;
374 typedef mozilla::CSSToScreenScale CSSToScreenScale
;
375 typedef mozilla::DesktopIntRect DesktopIntRect
;
376 typedef mozilla::DesktopPoint DesktopPoint
;
377 typedef mozilla::DesktopRect DesktopRect
;
378 typedef mozilla::DesktopSize DesktopSize
;
379 typedef mozilla::CSSPoint CSSPoint
;
380 typedef mozilla::CSSRect CSSRect
;
382 // Used in UpdateThemeGeometries.
383 struct ThemeGeometry
{
384 // The ThemeGeometryType value for the themed widget, see
385 // nsITheme::ThemeGeometryTypeForWidget.
386 nsITheme::ThemeGeometryType mType
;
387 // The device-pixel rect within the window for the themed widget
388 LayoutDeviceIntRect mRect
;
390 ThemeGeometry(nsITheme::ThemeGeometryType aType
,
391 const LayoutDeviceIntRect
& aRect
)
392 : mType(aType
), mRect(aRect
) {}
395 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID
)
398 : mLastChild(nullptr),
399 mPrevSibling(nullptr),
400 mOnDestroyCalled(false),
401 mWindowType(eWindowType_child
),
405 ClearNativeTouchSequence(nullptr);
409 * Create and initialize a widget.
411 * All the arguments can be null in which case a top level window
412 * with size 0 is created. The event callback function has to be
413 * provided only if the caller wants to deal with the events this
414 * widget receives. The event callback is basically a preprocess
415 * hook called synchronously. The return value determines whether
416 * the event goes to the default window procedure or it is hidden
417 * to the os. The assumption is that if the event handler returns
418 * false the widget does not see the event. The widget should not
419 * automatically clear the window to the background color. The
420 * calling code must handle paint messages and clear the background
423 * In practice at least one of aParent and aNativeParent will be null. If
424 * both are null the widget isn't parented (e.g. context menus or
425 * independent top level windows).
427 * The dimensions given in aRect are specified in the parent's
428 * device coordinate system.
429 * This must not be called for parentless widgets such as top-level
430 * windows, which use the desktop pixel coordinate system; a separate
431 * method is provided for these.
433 * @param aParent parent nsIWidget
434 * @param aNativeParent native parent widget
435 * @param aRect the widget dimension
436 * @param aInitData data that is used for widget initialization
439 [[nodiscard
]] virtual nsresult
Create(
440 nsIWidget
* aParent
, nsNativeWidget aNativeParent
,
441 const LayoutDeviceIntRect
& aRect
,
442 nsWidgetInitData
* aInitData
= nullptr) = 0;
445 * As above, but with aRect specified in DesktopPixel units (for top-level
447 * Default implementation just converts aRect to device pixels and calls
448 * through to device-pixel Create, but platforms may override this if the
449 * mapping is not straightforward or the native platform needs to use the
450 * desktop pixel values directly.
452 [[nodiscard
]] virtual nsresult
Create(nsIWidget
* aParent
,
453 nsNativeWidget aNativeParent
,
454 const DesktopIntRect
& aRect
,
455 nsWidgetInitData
* aInitData
= nullptr) {
456 LayoutDeviceIntRect devPixRect
=
457 RoundedToInt(aRect
* GetDesktopToDeviceScale());
458 return Create(aParent
, aNativeParent
, devPixRect
, aInitData
);
462 * Allocate, initialize, and return a widget that is a child of
463 * |this|. The returned widget (if nonnull) has gone through the
464 * equivalent of CreateInstance(widgetCID) + Create(...).
466 * |CreateChild()| lets widget backends decide whether to parent
467 * the new child widget to this, nonnatively parent it, or both.
468 * This interface exists to support the PuppetWidget backend,
469 * which is entirely non-native. All other params are the same as
472 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
473 * |nsIWidget*| this, not its native widget (if it exists), when
474 * calling |Create()|. This is a timid hack around poorly
475 * understood code, and shouldn't be used in new code.
477 virtual already_AddRefed
<nsIWidget
> CreateChild(
478 const LayoutDeviceIntRect
& aRect
, nsWidgetInitData
* aInitData
= nullptr,
479 bool aForceUseIWidgetParent
= false) = 0;
482 * Attach to a top level widget.
484 * In cases where a top level chrome widget is being used as a content
485 * container, attach a secondary listener and update the device
486 * context. The primary widget listener will continue to be called for
487 * notifications relating to the top-level window, whereas other
488 * notifications such as painting and events will instead be called via
489 * the attached listener. SetAttachedWidgetListener should be used to
490 * assign the attached listener.
492 * aUseAttachedEvents if true, events are sent to the attached listener
493 * instead of the normal listener.
495 virtual void AttachViewToTopLevel(bool aUseAttachedEvents
) = 0;
498 * Accessor functions to get and set the attached listener. Used by
499 * nsView in connection with AttachViewToTopLevel above.
501 virtual void SetAttachedWidgetListener(nsIWidgetListener
* aListener
) = 0;
502 virtual nsIWidgetListener
* GetAttachedWidgetListener() = 0;
503 virtual void SetPreviouslyAttachedWidgetListener(
504 nsIWidgetListener
* aListener
) = 0;
505 virtual nsIWidgetListener
* GetPreviouslyAttachedWidgetListener() = 0;
508 * Accessor functions to get and set the listener which handles various
509 * actions for the widget.
512 virtual nsIWidgetListener
* GetWidgetListener() = 0;
513 virtual void SetWidgetListener(nsIWidgetListener
* alistener
) = 0;
517 * Close and destroy the internal native window.
518 * This method does not delete the widget.
521 virtual void Destroy() = 0;
524 * Destroyed() returns true if Destroy() has been called already.
527 bool Destroyed() const { return mOnDestroyCalled
; }
532 * Change the widget's parent. Null parents are allowed.
534 * @param aNewParent new parent
536 virtual void SetParent(nsIWidget
* aNewParent
) = 0;
539 * Return the parent Widget of this Widget or nullptr if this is a
542 * @return the parent widget or nullptr if it does not have a parent
545 virtual nsIWidget
* GetParent(void) = 0;
548 * Return the top level Widget of this Widget
550 * @return the top level widget
552 virtual nsIWidget
* GetTopLevelWidget() = 0;
555 * Return the top (non-sheet) parent of this Widget if it's a sheet,
556 * or nullptr if this isn't a sheet (or some other error occurred).
557 * Sheets are only supported on some platforms (currently only OS X).
559 * @return the top (non-sheet) parent widget or nullptr
562 virtual nsIWidget
* GetSheetWindowParent(void) = 0;
565 * Return the physical DPI of the screen containing the window ...
566 * the number of device pixels per inch.
568 virtual float GetDPI() = 0;
571 * Return the scaling factor between device pixels and the platform-
572 * dependent "desktop pixels" used to manage window positions on a
573 * potentially multi-screen, mixed-resolution desktop.
575 virtual mozilla::DesktopToLayoutDeviceScale
GetDesktopToDeviceScale() = 0;
578 * Return the scaling factor between device pixels and the platform-
579 * dependent "desktop pixels" by looking up the screen by the position
582 virtual mozilla::DesktopToLayoutDeviceScale
583 GetDesktopToDeviceScaleByScreen() = 0;
586 * Return the default scale factor for the window. This is the
587 * default number of device pixels per CSS pixel to use. This should
588 * depend on OS/platform settings such as the Mac's "UI scale factor"
589 * or Windows' "font DPI". This will take into account Gecko preferences
590 * overriding the system setting.
592 mozilla::CSSToLayoutDeviceScale
GetDefaultScale();
595 * Return the first child of this widget. Will return null if
596 * there are no children.
598 nsIWidget
* GetFirstChild() const { return mFirstChild
; }
601 * Return the last child of this widget. Will return null if
602 * there are no children.
604 nsIWidget
* GetLastChild() const { return mLastChild
; }
607 * Return the next sibling of this widget
609 nsIWidget
* GetNextSibling() const { return mNextSibling
; }
612 * Set the next sibling of this widget
614 void SetNextSibling(nsIWidget
* aSibling
) { mNextSibling
= aSibling
; }
617 * Return the previous sibling of this widget
619 nsIWidget
* GetPrevSibling() const { return mPrevSibling
; }
622 * Set the previous sibling of this widget
624 void SetPrevSibling(nsIWidget
* aSibling
) { mPrevSibling
= aSibling
; }
627 * Show or hide this widget
629 * @param aState true to show the Widget, false to hide it
632 virtual void Show(bool aState
) = 0;
635 * Whether or not a widget must be recreated after being hidden to show
638 virtual bool NeedsRecreateToReshow() { return false; }
641 * Make the window modal.
643 virtual void SetModal(bool aModal
) = 0;
646 * Make the non-modal window opened by modal window fake-modal, that will
647 * call SetFakeModal(false) on destroy on Cocoa.
649 virtual void SetFakeModal(bool aModal
) { SetModal(aModal
); }
652 * Are we app modal. Currently only implemented on Cocoa.
654 virtual bool IsRunningAppModal() { return false; }
657 * The maximum number of simultaneous touch contacts supported by the device.
658 * In the case of devices with multiple digitizers (e.g. multiple touch
659 * screens), the value will be the maximum of the set of maximum supported
660 * contacts by each individual digitizer.
662 virtual uint32_t GetMaxTouchPoints() const = 0;
665 * Returns whether the window is visible
668 virtual bool IsVisible() const = 0;
671 * Perform platform-dependent sanity check on a potential window position.
672 * This is guaranteed to work only for top-level windows.
674 * @param aAllowSlop: if true, allow the window to slop offscreen;
675 * the window should be partially visible. if false,
676 * force the entire window onscreen (or at least
677 * the upper-left corner, if it's too large).
678 * @param aX in: an x position expressed in screen coordinates.
679 * out: the x position constrained to fit on the screen(s).
680 * @param aY in: an y position expressed in screen coordinates.
681 * out: the y position constrained to fit on the screen(s).
684 virtual void ConstrainPosition(bool aAllowSlop
, int32_t* aX
, int32_t* aY
) = 0;
689 * For a top-level window widget, the "parent's coordinate system" is the
690 * "global" display pixel coordinate space, *not* device pixels (which
691 * may be inconsistent between multiple screens, at least in the Mac OS
692 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
693 * following Move and Resize widget APIs.
695 * The display-/device-pixel distinction becomes important for (at least)
696 * Mac OS X with Hi-DPI (retina) displays, and Windows when the UI scale
697 * factor is set to other than 100%.
699 * The Move and Resize methods take floating-point parameters, rather than
700 * integer ones. This is important when manipulating top-level widgets,
701 * where the coordinate system may not be an integral multiple of the
702 * device-pixel space.
708 * Coordinates refer to the top-left of the widget. For toplevel windows
709 * with decorations, this is the top-left of the titlebar and frame .
711 * @param aX the new x position expressed in the parent's coordinate system
712 * @param aY the new y position expressed in the parent's coordinate system
715 virtual void Move(double aX
, double aY
) = 0;
718 * Reposition this widget so that the client area has the given offset.
720 * @param aOffset the new offset of the client area expressed as an
721 * offset from the origin of the client area of the parent
722 * widget (for root widgets and popup widgets it is in
723 * screen coordinates)
725 virtual void MoveClient(const DesktopPoint
& aOffset
) = 0;
728 * Resize this widget. Any size constraints set for the window by a
729 * previous call to SetSizeConstraints will be applied.
731 * @param aWidth the new width expressed in the parent's coordinate system
732 * @param aHeight the new height expressed in the parent's coordinate
734 * @param aRepaint whether the widget should be repainted
736 virtual void Resize(double aWidth
, double aHeight
, bool aRepaint
) = 0;
739 * Lock the aspect ratio of a Window
741 * @param aShouldLock bool
744 virtual void LockAspectRatio(bool aShouldLock
){};
747 * Move or resize this widget. Any size constraints set for the window by
748 * a previous call to SetSizeConstraints will be applied.
750 * @param aX the new x position expressed in the parent's coordinate
752 * @param aY the new y position expressed in the parent's coordinate
754 * @param aWidth the new width expressed in the parent's coordinate system
755 * @param aHeight the new height expressed in the parent's coordinate
757 * @param aRepaint whether the widget should be repainted if the size
761 virtual void Resize(double aX
, double aY
, double aWidth
, double aHeight
,
764 virtual mozilla::Maybe
<bool> IsResizingNativeWidget() {
765 return mozilla::Nothing();
769 * Resize the widget so that the inner client area has the given size.
771 * @param aSize the new size of the client area.
772 * @param aRepaint whether the widget should be repainted
774 virtual void ResizeClient(const DesktopSize
& aSize
, bool aRepaint
) = 0;
777 * Resize and reposition the widget so tht inner client area has the given
780 * @param aRect the new offset and size of the client area. The offset is
781 * expressed as an offset from the origin of the client area
782 * of the parent widget (for root widgets and popup widgets it
783 * is in screen coordinates).
784 * @param aRepaint whether the widget should be repainted
786 virtual void ResizeClient(const DesktopRect
& aRect
, bool aRepaint
) = 0;
789 * Sets the widget's z-index.
791 virtual void SetZIndex(int32_t aZIndex
) = 0;
794 * Gets the widget's z-index.
796 int32_t GetZIndex() { return mZIndex
; }
799 * Position this widget just behind the given widget. (Used to
800 * control z-order for top-level widgets. Get/SetZIndex by contrast
801 * control z-order for child widgets of other widgets.)
802 * @param aPlacement top, bottom, or below a widget
803 * (if top or bottom, param aWidget is ignored)
804 * @param aWidget widget to place this widget behind
805 * (only if aPlacement is eZPlacementBelow).
806 * null is equivalent to aPlacement of eZPlacementTop
807 * @param aActivate true to activate the widget after placing it
809 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement
,
810 nsIWidget
* aWidget
, bool aActivate
) = 0;
813 * Minimize, maximize or normalize the window size.
814 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
816 virtual void SetSizeMode(nsSizeMode aMode
) = 0;
818 virtual void GetWorkspaceID(nsAString
& workspaceID
) = 0;
820 virtual void MoveToWorkspace(const nsAString
& workspaceID
) = 0;
823 * Suppress animations that are applied to a window by OS.
825 virtual void SuppressAnimation(bool aSuppress
) {}
828 * Return size mode (minimized, maximized, normalized).
829 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
831 virtual nsSizeMode
SizeMode() = 0;
834 * Ask whether the window is tiled.
836 virtual bool IsTiled() const = 0;
839 * Ask wether the widget is fully occluded
841 virtual bool IsFullyOccluded() const = 0;
844 * Enable or disable this Widget
846 * @param aState true to enable the Widget, false to disable it.
848 virtual void Enable(bool aState
) = 0;
851 * Ask whether the widget is enabled
853 virtual bool IsEnabled() const = 0;
856 * Whether we should request activation of this widget's toplevel window.
864 * Request activation of this window or give focus to this widget.
866 virtual void SetFocus(Raise
, mozilla::dom::CallerType aCallerType
) = 0;
869 * Get this widget's outside dimensions relative to its parent widget. For
870 * popup widgets the returned rect is in screen coordinates and not
871 * relative to its parent widget.
873 * @return the x, y, width and height of this widget.
875 virtual LayoutDeviceIntRect
GetBounds() = 0;
878 * Get this widget's outside dimensions in device coordinates. This
879 * includes any title bar on the window.
881 * @return the x, y, width and height of this widget.
883 virtual LayoutDeviceIntRect
GetScreenBounds() = 0;
886 * Similar to GetScreenBounds except that this function will always
887 * get the size when the widget is in the nsSizeMode_Normal size mode
888 * even if the current size mode is not nsSizeMode_Normal.
889 * This method will fail if the size mode is not nsSizeMode_Normal and
890 * the platform doesn't have the ability.
891 * This method will always succeed if the current size mode is
894 * @param aRect On return it holds the x, y, width and height of
897 [[nodiscard
]] virtual nsresult
GetRestoredBounds(
898 LayoutDeviceIntRect
& aRect
) = 0;
901 * Get this widget's client area bounds, if the window has a 3D border
902 * appearance this returns the area inside the border. The position is the
903 * position of the client area relative to the client area of the parent
904 * widget (for root widgets and popup widgets it is in screen coordinates).
906 * @return the x, y, width and height of the client area of this widget.
908 virtual LayoutDeviceIntRect
GetClientBounds() = 0;
911 * Sets the non-client area dimensions of the window. Pass -1 to restore
912 * the system default frame size for that border. Pass zero to remove
913 * a border, or pass a specific value adjust a border. Units are in
914 * pixels. (DPI dependent)
917 * Windows: shrinking top non-client height will remove application
918 * icon and window title text. Glass desktops will refuse to set
919 * dimensions between zero and size < system default.
921 virtual nsresult
SetNonClientMargins(LayoutDeviceIntMargin
& aMargins
) = 0;
924 * Get the client offset from the window origin.
926 * @return the x and y of the offset.
928 virtual LayoutDeviceIntPoint
GetClientOffset() = 0;
931 * Equivalent to GetClientBounds but only returns the size.
933 virtual LayoutDeviceIntSize
GetClientSize() {
934 // Depending on the backend, overloading this method may be useful if
935 // requesting the client offset is expensive.
936 return GetClientBounds().Size();
940 * Set the background color for this widget
942 * @param aColor the new background color
946 virtual void SetBackgroundColor(const nscolor
& aColor
) {}
949 * If a cursor type is currently cached locally for this widget, clear the
950 * cached cursor to force an update on the next SetCursor call.
953 virtual void ClearCachedCursor() = 0;
956 * Sets the cursor cursor for this widget.
958 * @param aDefaultCursor the default cursor to be set
959 * @param aCursorImage a custom cursor, maybe null.
960 * @param aX the X coordinate of the hotspot for aCursorImage (from left).
961 * @param aY the Y coordinate of the hotspot for aCursorImage (from top).
963 virtual void SetCursor(nsCursor aDefaultCursor
, imgIContainer
* aCursorImage
,
964 uint32_t aHotspotX
, uint32_t aHotspotY
) = 0;
967 * Get the window type of this widget.
969 nsWindowType
WindowType() { return mWindowType
; }
972 * Determines if this widget is one of the three types of plugin widgets.
975 return mWindowType
== eWindowType_plugin
||
976 mWindowType
== eWindowType_plugin_ipc_chrome
||
977 mWindowType
== eWindowType_plugin_ipc_content
;
981 * Set the transparency mode of the top-level window containing this widget.
982 * So, e.g., if you call this on the widget for an IFRAME, the top level
983 * browser window containing the IFRAME actually gets set. Be careful.
985 * This can fail if the platform doesn't support
986 * transparency/glass. By default widgets are not
987 * transparent. This will also fail if the toplevel window is not
988 * a Mozilla window, e.g., if the widget is in an embedded
991 * After transparency/glass has been enabled, the initial alpha channel
992 * value for all pixels is 1, i.e., opaque.
993 * If the window is resized then the alpha channel values for
994 * all pixels are reset to 1.
995 * Pixel RGB color values are already premultiplied with alpha channel values.
997 virtual void SetTransparencyMode(nsTransparencyMode aMode
) = 0;
1000 * Get the transparency mode of the top-level window that contains this
1003 virtual nsTransparencyMode
GetTransparencyMode() = 0;
1006 * This represents a command to set the bounds and clip region of
1009 struct Configuration
{
1010 nsCOMPtr
<nsIWidget
> mChild
;
1011 uintptr_t mWindowID
; // e10s specific, the unique plugin port id
1012 bool mVisible
; // e10s specific, widget visibility
1013 LayoutDeviceIntRect mBounds
;
1014 CopyableTArray
<LayoutDeviceIntRect
> mClipRegion
;
1018 * Sets the clip region of each mChild (which must actually be a child
1019 * of this widget) to the union of the pixel rects given in
1020 * mClipRegion, all relative to the top-left of the child
1021 * widget. Clip regions are not implemented on all platforms and only
1022 * need to actually work for children that are plugins.
1024 * Also sets the bounds of each child to mBounds.
1026 * This will invalidate areas of the children that have changed, but
1027 * does not need to invalidate any part of this widget.
1029 * Children should be moved in the order given; the array is
1030 * sorted so to minimize unnecessary invalidation if children are
1031 * moved in that order.
1033 virtual nsresult
ConfigureChildren(
1034 const nsTArray
<Configuration
>& aConfigurations
) = 0;
1035 virtual nsresult
SetWindowClipRegion(
1036 const nsTArray
<LayoutDeviceIntRect
>& aRects
,
1037 bool aIntersectWithExisting
) = 0;
1040 * Appends to aRects the rectangles constituting this widget's clip
1041 * region. If this widget is not clipped, appends a single rectangle
1042 * (0, 0, bounds.width, bounds.height).
1044 virtual void GetWindowClipRegion(nsTArray
<LayoutDeviceIntRect
>* aRects
) = 0;
1047 * Register or unregister native plugin widgets which receive Configuration
1048 * data from the content process via the compositor.
1050 * Lookups are used by the main thread via the compositor to lookup widgets
1051 * based on a unique window id. On Windows and Linux this is the
1052 * NS_NATIVE_PLUGIN_PORT (hwnd/XID). This tracking maintains a reference to
1053 * widgets held. Consumers are responsible for removing widgets from this
1056 virtual void RegisterPluginWindowForRemoteUpdates() = 0;
1057 virtual void UnregisterPluginWindowForRemoteUpdates() = 0;
1058 static nsIWidget
* LookupRegisteredPluginWindow(uintptr_t aWindowID
);
1061 * Iterates across the list of registered plugin widgets and updates thier
1062 * visibility based on which plugins are included in the 'visible' list.
1064 * The compositor knows little about tabs, but it does know which plugin
1065 * widgets are currently included in the visible layer tree. It calls this
1066 * helper to hide widgets it knows nothing about.
1068 static void UpdateRegisteredPluginWindowVisibility(
1069 uintptr_t aOwnerWidget
, nsTArray
<uintptr_t>& aPluginIds
);
1073 * Iterates over the list of registered plugins and for any that are owned
1074 * by aOwnerWidget and visible it takes a snapshot.
1076 * @param aOwnerWidget only captures visible widgets owned by this
1078 static void CaptureRegisteredPlugins(uintptr_t aOwnerWidget
);
1081 * Take a scroll capture for this widget if possible.
1083 virtual void UpdateScrollCapture() = 0;
1086 * Creates an async ImageContainer to hold scroll capture images that can be
1087 * used if the plugin is hidden during scroll.
1088 * @return the async container ID of the created ImageContainer.
1090 virtual uint64_t CreateScrollCaptureContainer() = 0;
1094 * Set the shadow style of the window.
1096 * Ignored on child widgets and on non-Mac platforms.
1098 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle
) = 0;
1101 * Set the opacity of the window.
1102 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1104 * Ignored on child widgets and on non-Mac platforms.
1106 virtual void SetWindowOpacity(float aOpacity
) {}
1109 * Set the transform of the window. Values are in device pixels,
1110 * the origin is the top left corner of the window.
1112 * Ignored on child widgets and on non-Mac platforms.
1114 virtual void SetWindowTransform(const mozilla::gfx::Matrix
& aTransform
) {}
1117 * Set whether the window should ignore mouse events or not.
1119 * This is only used on popup windows.
1121 virtual void SetWindowMouseTransparent(bool aIsTransparent
) {}
1124 * On Mac OS X, this method shows or hides the pill button in the titlebar
1125 * that's used to collapse the toolbar.
1127 * Ignored on child widgets and on non-Mac platforms.
1129 virtual void SetShowsToolbarButton(bool aShow
) = 0;
1132 * On macOS, this method determines whether we tell cocoa that the window
1133 * supports native full screen. If we do so, and another window is in
1134 * native full screen, this window will also appear in native full screen.
1136 * We generally only want to do this for primary application windows.
1138 * Ignored on child widgets and on non-Mac platforms.
1140 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen
) = 0;
1142 enum WindowAnimationType
{
1143 eGenericWindowAnimation
,
1144 eDocumentWindowAnimation
1148 * Sets the kind of top-level window animation this widget should have. On
1149 * Mac OS X, this causes a particular kind of animation to be shown when the
1150 * window is first made visible.
1152 * Ignored on child widgets and on non-Mac platforms.
1154 virtual void SetWindowAnimationType(WindowAnimationType aType
) = 0;
1157 * Specifies whether the window title should be drawn even if the window
1158 * contents extend into the titlebar. Ignored on windows that don't draw
1159 * in the titlebar. Only implemented on OS X.
1161 virtual void SetDrawsTitle(bool aDrawTitle
) {}
1164 * Indicates whether the widget should attempt to make titlebar controls
1165 * easier to see on dark titlebar backgrounds.
1167 virtual void SetUseBrightTitlebarForeground(bool aBrightForeground
) {}
1170 * Hide window chrome (borders, buttons) for this widget.
1173 virtual void HideWindowChrome(bool aShouldHide
) = 0;
1175 enum FullscreenTransitionStage
{
1176 eBeforeFullscreenToggle
,
1177 eAfterFullscreenToggle
1181 * Prepares for fullscreen transition and returns whether the widget
1182 * supports fullscreen transition. If this method returns false,
1183 * PerformFullscreenTransition() must never be called. Otherwise,
1184 * caller should call that method twice with "before" and "after"
1185 * stages respectively in order. In the latter case, this method may
1186 * return some data via aData pointer. Caller must pass that data to
1187 * PerformFullscreenTransition() if any, and caller is responsible
1188 * for releasing that data.
1190 virtual bool PrepareForFullscreenTransition(nsISupports
** aData
) = 0;
1193 * Performs fullscreen transition. This method returns immediately,
1194 * and will post aCallback to the main thread when the transition
1197 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage
,
1200 nsIRunnable
* aCallback
) = 0;
1203 * Perform any actions needed after the fullscreen transition has ended.
1205 virtual void CleanupFullscreenTransition() = 0;
1208 * Return the screen the widget is in, or null if we don't know.
1210 virtual already_AddRefed
<nsIScreen
> GetWidgetScreen() = 0;
1213 * Put the toplevel window into or out of fullscreen mode.
1214 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1215 * if possible. (If not, it behaves as if aTargetScreen is null.)
1216 * If !aFullScreen, aTargetScreen is ignored.
1217 * aTargetScreen support is currently only implemented on Windows.
1219 * @return NS_OK if the widget is setup properly for fullscreen and
1220 * FullscreenChanged callback has been or will be called. If other
1221 * value is returned, the caller should continue the change itself.
1223 virtual nsresult
MakeFullScreen(bool aFullScreen
,
1224 nsIScreen
* aTargetScreen
= nullptr) = 0;
1227 * Same as MakeFullScreen, except that, on systems which natively
1228 * support fullscreen transition, calling this method explicitly
1229 * requests that behavior.
1230 * It is currently only supported on OS X 10.7+.
1232 virtual nsresult
MakeFullScreenWithNativeTransition(
1233 bool aFullScreen
, nsIScreen
* aTargetScreen
= nullptr) {
1234 return MakeFullScreen(aFullScreen
, aTargetScreen
);
1238 * Invalidate a specified rect for a widget so that it will be repainted
1241 virtual void Invalidate(const LayoutDeviceIntRect
& aRect
) = 0;
1243 enum LayerManagerPersistence
{
1244 LAYER_MANAGER_CURRENT
= 0,
1245 LAYER_MANAGER_PERSISTENT
1249 * Return the widget's LayerManager. The layer tree for that
1250 * LayerManager is what gets rendered to the widget.
1252 inline LayerManager
* GetLayerManager() {
1253 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE
,
1254 LAYER_MANAGER_CURRENT
);
1257 inline LayerManager
* GetLayerManager(LayerManagerPersistence aPersistence
) {
1258 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE
,
1263 * Like GetLayerManager(), but prefers creating a layer manager of
1264 * type |aBackendHint| instead of what would normally be created.
1265 * LayersBackend::LAYERS_NONE means "no hint".
1267 virtual LayerManager
* GetLayerManager(
1268 PLayerTransactionChild
* aShadowManager
, LayersBackend aBackendHint
,
1269 LayerManagerPersistence aPersistence
= LAYER_MANAGER_CURRENT
) = 0;
1272 * Called before each layer manager transaction to allow any preparation
1273 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1275 * Always called on the main thread.
1277 virtual void PrepareWindowEffects() = 0;
1280 * Called on the main thread at the end of WebRender display list building.
1282 virtual void AddWindowOverlayWebRenderCommands(
1283 mozilla::layers::WebRenderBridgeChild
* aWrBridge
,
1284 mozilla::wr::DisplayListBuilder
& aBuilder
,
1285 mozilla::wr::IpcResourceUpdateQueue
& aResources
) {}
1288 * Called when Gecko knows which themed widgets exist in this window.
1289 * The passed array contains an entry for every themed widget of the right
1290 * type (currently only StyleAppearance::Toolbar) within the window, except
1291 * for themed widgets which are transformed or have effects applied to them
1292 * (e.g. CSS opacity or filters).
1293 * This could sometimes be called during display list construction
1294 * outside of painting.
1295 * If called during painting, it will be called before we actually
1298 virtual void UpdateThemeGeometries(
1299 const nsTArray
<ThemeGeometry
>& aThemeGeometries
) = 0;
1302 * Informs the widget about the region of the window that is opaque.
1304 * @param aOpaqueRegion the region of the window that is opaque.
1306 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion
& aOpaqueRegion
) {}
1309 * Informs the widget about the region of the window that is draggable.
1311 virtual void UpdateWindowDraggingRegion(
1312 const LayoutDeviceIntRegion
& aRegion
) {}
1315 * Tells the widget whether the given input block results in a swipe.
1316 * Should be called in response to a WidgetWheelEvent that has
1317 * mFlags.mCanTriggerSwipe set on it.
1319 virtual void ReportSwipeStarted(uint64_t aInputBlockId
, bool aStartSwipe
) {}
1326 virtual void AddChild(nsIWidget
* aChild
) = 0;
1327 virtual void RemoveChild(nsIWidget
* aChild
) = 0;
1328 virtual void* GetNativeData(uint32_t aDataType
) = 0;
1329 virtual void SetNativeData(uint32_t aDataType
, uintptr_t aVal
) = 0;
1330 virtual void FreeNativeData(void* data
, uint32_t aDataType
) = 0; //~~~
1335 * Set the widget's title.
1336 * Must be called after Create.
1338 * @param aTitle string displayed as the title of the widget
1340 virtual nsresult
SetTitle(const nsAString
& aTitle
) = 0;
1343 * Set the widget's icon.
1344 * Must be called after Create.
1346 * @param aIconSpec string specifying the icon to use; convention is to
1347 * pass a resource: URL from which a platform-dependent
1348 * resource file name will be constructed
1350 virtual void SetIcon(const nsAString
& aIconSpec
) = 0;
1353 * Return this widget's origin in screen coordinates.
1355 * @return screen coordinates stored in the x,y members
1357 virtual LayoutDeviceIntPoint
WidgetToScreenOffset() = 0;
1360 * The same as WidgetToScreenOffset(), except in the case of
1361 * PuppetWidget where this method omits the chrome offset.
1363 virtual LayoutDeviceIntPoint
TopLevelWidgetToScreenOffset() {
1364 return WidgetToScreenOffset();
1368 * For a PuppetWidget, returns the transform from the coordinate
1369 * space of the PuppetWidget to the coordinate space of the
1370 * top-level native widget.
1372 * Identity transform in other cases.
1374 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1375 WidgetToTopLevelWidgetTransform() {
1376 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1380 * Given the specified client size, return the corresponding window size,
1381 * which includes the area for the borders and titlebar. This method
1382 * should work even when the window is not yet visible.
1384 virtual LayoutDeviceIntSize
ClientToWindowSize(
1385 const LayoutDeviceIntSize
& aClientSize
) = 0;
1388 * Dispatches an event to the widget
1390 virtual nsresult
DispatchEvent(mozilla::WidgetGUIEvent
* event
,
1391 nsEventStatus
& aStatus
) = 0;
1394 * Dispatches an event to APZ only.
1395 * No-op in the child process.
1397 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent
* aEvent
) = 0;
1400 * Dispatches an event that must be handled by APZ first, when APZ is
1401 * enabled. If invoked in the child process, it is forwarded to the
1402 * parent process synchronously.
1404 virtual nsEventStatus
DispatchInputEvent(
1405 mozilla::WidgetInputEvent
* aEvent
) = 0;
1408 * Confirm an APZ-aware event target. This should be used when APZ will
1409 * not need a layers update to process the event.
1411 virtual void SetConfirmedTargetAPZC(
1412 uint64_t aInputBlockId
,
1413 const nsTArray
<ScrollableLayerGuid
>& aTargets
) const = 0;
1416 * Returns true if APZ is in use, false otherwise.
1418 virtual bool AsyncPanZoomEnabled() const = 0;
1421 * Enables the dropping of files to a widget.
1423 virtual void EnableDragDrop(bool aEnable
) = 0;
1424 virtual nsresult
AsyncEnableDragDrop(bool aEnable
) = 0;
1427 * Enables/Disables system mouse capture.
1428 * @param aCapture true enables mouse capture, false disables mouse capture
1431 virtual void CaptureMouse(bool aCapture
) = 0;
1434 * Classify the window for the window manager. Mostly for X11.
1436 virtual void SetWindowClass(const nsAString
& xulWinType
) = 0;
1439 * Enables/Disables system capture of any and all events that would cause a
1440 * popup to be rolled up. aListener should be set to a non-null value for
1441 * any popups that are not managed by the popup manager.
1442 * @param aDoCapture true enables capture, false disables capture
1445 virtual void CaptureRollupEvents(nsIRollupListener
* aListener
,
1446 bool aDoCapture
) = 0;
1449 * Bring this window to the user's attention. This is intended to be a more
1450 * gentle notification than popping the window to the top or putting up an
1451 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1452 * the Mac. The notification should be suppressed if the window is already
1453 * in the foreground and should be dismissed when the user brings this window
1454 * to the foreground.
1455 * @param aCycleCount Maximum number of times to animate the window per system
1456 * conventions. If set to -1, cycles indefinitely until
1457 * window is brought into the foreground.
1459 [[nodiscard
]] virtual nsresult
GetAttention(int32_t aCycleCount
) = 0;
1462 * Ask whether there user input events pending. All input events are
1463 * included, including those not targeted at this nsIwidget instance.
1465 virtual bool HasPendingInputEvent() = 0;
1468 * If set to true, the window will draw its contents into the titlebar
1469 * instead of below it.
1471 * Ignored on any platform that does not support it. Ignored by widgets that
1472 * do not represent windows.
1473 * May result in a resize event, so should only be called from places where
1474 * reflow and painting is allowed.
1476 * @param aState Whether drawing into the titlebar should be activated.
1478 virtual void SetDrawsInTitlebar(bool aState
) = 0;
1481 * Determine whether the widget shows a resize widget. If it does,
1482 * aResizerRect returns the resizer's rect.
1484 * Returns false on any platform that does not support it.
1486 * @param aResizerRect The resizer's rect in device pixels.
1487 * @return Whether a resize widget is shown.
1489 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect
* aResizerRect
) = 0;
1492 * Begin a window resizing drag, based on the event passed in.
1494 [[nodiscard
]] virtual nsresult
BeginResizeDrag(
1495 mozilla::WidgetGUIEvent
* aEvent
, int32_t aHorizontal
,
1496 int32_t aVertical
) = 0;
1499 CAPS_LOCK
= 0x00000001, // when CapsLock is active
1500 NUM_LOCK
= 0x00000002, // when NumLock is active
1501 SHIFT_L
= 0x00000100,
1502 SHIFT_R
= 0x00000200,
1503 CTRL_L
= 0x00000400,
1504 CTRL_R
= 0x00000800,
1505 ALT_L
= 0x00001000, // includes Option
1507 COMMAND_L
= 0x00004000,
1508 COMMAND_R
= 0x00008000,
1510 ALTGRAPH
= 0x00020000, // AltGr key on Windows. This emulates
1511 // AltRight key behavior of keyboard
1512 // layouts which maps AltGr to AltRight
1514 FUNCTION
= 0x00100000,
1515 NUMERIC_KEY_PAD
= 0x01000000 // when the key is coming from the keypad
1518 * Utility method intended for testing. Dispatches native key events
1519 * to this widget to simulate the press and release of a key.
1520 * @param aNativeKeyboardLayout a *platform-specific* constant.
1521 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1522 * On Windows, it is converted to a hex string and passed to
1523 * LoadKeyboardLayout, see
1524 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1525 * @param aNativeKeyCode a *platform-specific* keycode.
1526 * On Windows, this is the virtual key code.
1527 * @param aModifiers some combination of the above 'Modifiers' flags;
1528 * not all flags will apply to all platforms. Mac ignores the _R
1529 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1531 * @param aCharacters characters that the OS would decide to generate
1532 * from the event. On Windows, this is the charCode passed by
1534 * @param aUnmodifiedCharacters characters that the OS would decide
1535 * to generate from the event if modifier keys (other than shift)
1536 * were assumed inactive. Needed on Mac, ignored on Windows.
1537 * @param aObserver the observer that will get notified once the events
1538 * have been dispatched.
1539 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1540 * layout is not supported and the event was not fired
1542 virtual nsresult
SynthesizeNativeKeyEvent(
1543 int32_t aNativeKeyboardLayout
, int32_t aNativeKeyCode
,
1544 uint32_t aModifierFlags
, const nsAString
& aCharacters
,
1545 const nsAString
& aUnmodifiedCharacters
, nsIObserver
* aObserver
) = 0;
1548 * Utility method intended for testing. Dispatches native mouse events
1549 * may even move the mouse cursor. On Mac the events are guaranteed to
1550 * be sent to the window containing this widget, but on Windows they'll go
1551 * to whatever's topmost on the screen at that position, so for
1552 * cross-platform testing ensure that your window is at the top of the
1554 * @param aPoint screen location of the mouse, in device
1555 * pixels, with origin at the top left
1556 * @param aNativeMessage *platform-specific* event type (e.g. on Mac,
1557 * NSMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN etc)
1558 * @param aModifierFlags *platform-specific* modifier flags (ignored
1560 * @param aObserver the observer that will get notified once the events
1561 * have been dispatched.
1563 virtual nsresult
SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint
,
1564 uint32_t aNativeMessage
,
1565 uint32_t aModifierFlags
,
1566 nsIObserver
* aObserver
) = 0;
1569 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1570 * message. aPoint is location in device pixels to which the mouse pointer
1572 * @param aObserver the observer that will get notified once the events
1573 * have been dispatched.
1575 virtual nsresult
SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint
,
1576 nsIObserver
* aObserver
) = 0;
1579 * Utility method intended for testing. Dispatching native mouse scroll
1580 * events may move the mouse cursor.
1582 * @param aPoint Mouse cursor position in screen coordinates.
1583 * In device pixels, the origin at the top left of
1584 * the primary display.
1585 * @param aNativeMessage Platform native message.
1586 * @param aDeltaX The delta value for X direction. If the native
1587 * message doesn't indicate X direction scrolling,
1588 * this may be ignored.
1589 * @param aDeltaY The delta value for Y direction. If the native
1590 * message doesn't indicate Y direction scrolling,
1591 * this may be ignored.
1592 * @param aDeltaZ The delta value for Z direction. If the native
1593 * message doesn't indicate Z direction scrolling,
1594 * this may be ignored.
1595 * @param aModifierFlags Must be values of Modifiers, or zero.
1596 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1598 * @param aObserver The observer that will get notified once the
1599 * events have been dispatched.
1601 virtual nsresult
SynthesizeNativeMouseScrollEvent(
1602 LayoutDeviceIntPoint aPoint
, uint32_t aNativeMessage
, double aDeltaX
,
1603 double aDeltaY
, double aDeltaZ
, uint32_t aModifierFlags
,
1604 uint32_t aAdditionalFlags
, nsIObserver
* aObserver
) = 0;
1607 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1608 * touch states in nsIDOMWindowUtils.idl.
1610 enum TouchPointerState
{
1611 // The pointer is in a hover state above the digitizer
1612 TOUCH_HOVER
= (1 << 0),
1613 // The pointer is in contact with the digitizer
1614 TOUCH_CONTACT
= (1 << 1),
1615 // The pointer has been removed from the digitizer detection area
1616 TOUCH_REMOVE
= (1 << 2),
1617 // The pointer has been canceled. Will cancel any pending os level
1618 // gestures that would triggered as a result of completion of the
1619 // input sequence. This may not cancel moz platform related events
1620 // that might get tirggered by input already delivered.
1621 TOUCH_CANCEL
= (1 << 3),
1623 // ALL_BITS used for validity checking during IPC serialization
1624 ALL_BITS
= (1 << 4) - 1
1628 * Create a new or update an existing touch pointer on the digitizer.
1629 * To trigger os level gestures, individual touch points should
1630 * transition through a complete set of touch states which should be
1631 * sent as individual messages.
1633 * @param aPointerId The touch point id to create or update.
1634 * @param aPointerState one or more of the touch states listed above
1635 * @param aPoint coords of this event
1636 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1637 * @param aOrientation 0 -> 359 degree value indicating the
1638 * orientation of the pointer. Use 90 for normal taps.
1639 * @param aObserver The observer that will get notified once the events
1640 * have been dispatched.
1642 virtual nsresult
SynthesizeNativeTouchPoint(uint32_t aPointerId
,
1643 TouchPointerState aPointerState
,
1644 LayoutDeviceIntPoint aPoint
,
1645 double aPointerPressure
,
1646 uint32_t aPointerOrientation
,
1647 nsIObserver
* aObserver
) = 0;
1650 * Helper for simulating a simple tap event with one touch point. When
1651 * aLongTap is true, simulates a native long tap with a duration equal to
1652 * ui.click_hold_context_menus.delay. This pref is compatible with the
1653 * apzc long tap duration. Defaults to 1.5 seconds.
1654 * @param aObserver The observer that will get notified once the events
1655 * have been dispatched.
1657 virtual nsresult
SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint
,
1659 nsIObserver
* aObserver
);
1662 * Cancels all active simulated touch input points and pending long taps.
1663 * Native widgets should track existing points such that they can clear the
1664 * digitizer state when this call is made.
1665 * @param aObserver The observer that will get notified once the touch
1666 * sequence has been cleared.
1668 virtual nsresult
ClearNativeTouchSequence(nsIObserver
* aObserver
);
1670 virtual void StartAsyncScrollbarDrag(
1671 const AsyncDragMetrics
& aDragMetrics
) = 0;
1674 * Notify APZ to start autoscrolling.
1675 * @param aAnchorLocation the location of the autoscroll anchor
1676 * @param aGuid identifies the scroll frame to be autoscrolled
1677 * @return true if APZ has been successfully notified
1679 virtual bool StartAsyncAutoscroll(const ScreenPoint
& aAnchorLocation
,
1680 const ScrollableLayerGuid
& aGuid
) = 0;
1683 * Notify APZ to stop autoscrolling.
1684 * @param aGuid identifies the scroll frame which is being autoscrolled.
1686 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid
& aGuid
) = 0;
1688 // If this widget supports out-of-process compositing, it can override
1689 // this method to provide additional information to the compositor.
1690 virtual void GetCompositorWidgetInitData(
1691 mozilla::widget::CompositorWidgetInitData
* aInitData
) {}
1694 * Setter/Getter of the system font setting for testing.
1696 virtual nsresult
SetSystemFont(const nsCString
& aFontName
) {
1697 return NS_ERROR_NOT_IMPLEMENTED
;
1699 virtual nsresult
GetSystemFont(nsCString
& aFontName
) {
1700 return NS_ERROR_NOT_IMPLEMENTED
;
1703 // Get rectangle of the screen where the window is placed.
1704 // It's used to detect popup overflow under Wayland because
1705 // Screenmanager does not work under it.
1707 virtual nsresult
GetScreenRect(LayoutDeviceIntRect
* aRect
) {
1708 return NS_ERROR_NOT_IMPLEMENTED
;
1710 virtual nsRect
GetPreferredPopupRect() {
1711 NS_WARNING("GetPreferredPopupRect implemented only for wayland");
1712 return nsRect(0, 0, 0, 0);
1714 virtual void FlushPreferredPopupRect() {
1715 NS_WARNING("FlushPreferredPopupRect implemented only for wayland");
1722 * Get safe area insets except to cutout.
1723 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1725 virtual mozilla::ScreenIntMargin
GetSafeAreaInsets() const {
1726 return mozilla::ScreenIntMargin();
1732 LongTapInfo(int32_t aPointerId
, LayoutDeviceIntPoint
& aPoint
,
1733 mozilla::TimeDuration aDuration
, nsIObserver
* aObserver
)
1734 : mPointerId(aPointerId
),
1736 mDuration(aDuration
),
1737 mObserver(aObserver
),
1738 mStamp(mozilla::TimeStamp::Now()) {}
1741 LayoutDeviceIntPoint mPosition
;
1742 mozilla::TimeDuration mDuration
;
1743 nsCOMPtr
<nsIObserver
> mObserver
;
1744 mozilla::TimeStamp mStamp
;
1747 static void OnLongTapTimerCallback(nsITimer
* aTimer
, void* aClosure
);
1749 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboardContentProcess();
1750 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboardInner();
1752 mozilla::UniquePtr
<LongTapInfo
> mLongTapTouchPoint
;
1753 nsCOMPtr
<nsITimer
> mLongTapTimer
;
1754 static int32_t sPointerIdCounter
;
1758 * If key events have not been handled by content or XBL handlers, they can
1759 * be offered to the system (for custom application shortcuts set in system
1760 * preferences, for example).
1762 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent
* aEvent
);
1765 * Activates a native menu item at the position specified by the index
1766 * string. The index string is a string of positive integers separated
1767 * by the "|" (pipe) character. The last integer in the string represents
1768 * the item index in a submenu located using the integers preceding it.
1771 * In this string, the first integer represents the top-level submenu
1772 * in the native menu bar. Since the integer is 1, it is the second submeu
1773 * in the native menu bar. Within that, the first item (index 0) is a
1774 * submenu, and we want to activate the 5th item within that submenu.
1776 virtual nsresult
ActivateNativeMenuItemAt(const nsAString
& indexString
) = 0;
1779 * This is used for native menu system testing.
1781 * Updates a native menu at the position specified by the index string.
1782 * The index string is a string of positive integers separated by the "|"
1786 * In this string, the first integer represents the top-level submenu
1787 * in the native menu bar. Since the integer is 1, it is the second submeu
1788 * in the native menu bar. Within that, the first item (index 0) is a
1789 * submenu, and we want to update submenu at index 4 within that submenu.
1791 * If this is called with an empty string it forces a full reload of the
1794 virtual nsresult
ForceUpdateNativeMenuAt(const nsAString
& indexString
) = 0;
1797 * This is used for testing macOS service menu code.
1799 * @param aResult - the current text selection. Is empty if no selection.
1800 * @return nsresult - whether or not aResult was assigned the selected text.
1802 [[nodiscard
]] virtual nsresult
GetSelectionAsPlaintext(nsAString
& aResult
) {
1803 return NS_ERROR_NOT_IMPLEMENTED
;
1807 * Notify IME of the specified notification.
1809 * @return If the notification is mouse button event and it's consumed by
1810 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1812 virtual nsresult
NotifyIME(const IMENotification
& aIMENotification
) = 0;
1815 * Start plugin IME. If this results in a string getting committed, the
1816 * result is in aCommitted (otherwise aCommitted is empty).
1818 * aKeyboardEvent The event with which plugin IME is to be started
1819 * panelX and panelY Location in screen coordinates of the IME input panel
1820 * (should be just under the plugin)
1821 * aCommitted The string committed during IME -- otherwise empty
1823 [[nodiscard
]] virtual nsresult
StartPluginIME(
1824 const mozilla::WidgetKeyboardEvent
& aKeyboardEvent
, int32_t aPanelX
,
1825 int32_t aPanelY
, nsString
& aCommitted
) = 0;
1828 * Tells the widget whether or not a plugin (inside the widget) has the
1829 * keyboard focus. Should be sent when the keyboard focus changes too or
1832 * aFocused Whether or not a plugin is focused
1834 virtual void SetPluginFocused(bool& aFocused
) = 0;
1837 * Tell the plugin has focus. It is unnecessary to use IPC
1839 bool PluginHasFocus() {
1840 return GetInputContext().mIMEState
.mEnabled
== IMEState::PLUGIN
;
1844 * Set IME candidate window position by windowless plugin.
1846 virtual void SetCandidateWindowForPlugin(
1847 const mozilla::widget::CandidateWindowPosition
& aPosition
) = 0;
1850 * Handle default action when PluginEvent isn't handled
1852 virtual void DefaultProcOfPluginEvent(
1853 const mozilla::WidgetPluginEvent
& aEvent
) = 0;
1856 * Enable or Disable IME by windowless plugin.
1858 virtual void EnableIMEForPlugin(bool aEnable
) {}
1861 * Notifies the input context changes.
1863 virtual void SetInputContext(const InputContext
& aContext
,
1864 const InputContextAction
& aAction
) = 0;
1867 * Get current input context.
1869 virtual InputContext
GetInputContext() = 0;
1872 * Get native IME context. This is different from GetNativeData() with
1873 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1876 virtual NativeIMEContext
GetNativeIMEContext() = 0;
1879 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1880 * native (OS-level) event for it. This method allows tests to simulate
1881 * keystrokes that trigger native key bindings (which require a native
1884 [[nodiscard
]] virtual nsresult
AttachNativeKeyEvent(
1885 mozilla::WidgetKeyboardEvent
& aEvent
) = 0;
1888 * Retrieve edit commands when the key combination of aEvent is used
1889 * in platform native applications.
1891 enum NativeKeyBindingsType
: uint8_t {
1892 NativeKeyBindingsForSingleLineEditor
,
1893 NativeKeyBindingsForMultiLineEditor
,
1894 NativeKeyBindingsForRichTextEditor
1896 virtual bool GetEditCommands(NativeKeyBindingsType aType
,
1897 const mozilla::WidgetKeyboardEvent
& aEvent
,
1898 nsTArray
<mozilla::CommandInt
>& aCommands
);
1901 * Retrieves a reference to notification requests of IME. Note that the
1902 * reference is valid while the nsIWidget instance is alive. So, if you
1903 * need to store the reference for a long time, you need to grab the widget
1906 const IMENotificationRequests
& IMENotificationRequestsRef();
1909 * Call this method when a dialog is opened which has a default button.
1910 * The button's rectangle should be supplied in aButtonRect.
1912 [[nodiscard
]] virtual nsresult
OnDefaultButtonLoaded(
1913 const LayoutDeviceIntRect
& aButtonRect
) = 0;
1916 * Return true if this process shouldn't use platform widgets, and
1917 * so should use PuppetWidgets instead. If this returns true, the
1918 * result of creating and using a platform widget is undefined,
1919 * and likely to end in crashes or other buggy behavior.
1921 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1923 static already_AddRefed
<nsIWidget
> CreateTopLevelWindow();
1925 static already_AddRefed
<nsIWidget
> CreateChildWindow();
1928 * Allocate and return a "puppet widget" that doesn't directly
1929 * correlate to a platform widget; platform events and data must
1930 * be fed to it. Currently used in content processes. NULL is
1931 * returned if puppet widgets aren't supported in this build
1932 * config, on this platform, or for this process type.
1934 * This function is called "Create" to match CreateInstance().
1935 * The returned widget must still be nsIWidget::Create()d.
1937 static already_AddRefed
<nsIWidget
> CreatePuppetWidget(
1938 BrowserChild
* aBrowserChild
);
1940 static already_AddRefed
<nsIWidget
> CreateHeadlessWidget();
1943 * Allocate and return a "plugin proxy widget", a subclass of PuppetWidget
1944 * used in wrapping a PPluginWidget connection for remote widgets. Note
1945 * this call creates the base object, it does not create the widget. Use
1946 * nsIWidget's Create to do this.
1948 static already_AddRefed
<nsIWidget
> CreatePluginProxyWidget(
1949 BrowserChild
* aBrowserChild
, mozilla::plugins::PluginWidgetChild
* aActor
);
1952 * Reparent this widget's native widget.
1953 * @param aNewParent the native widget of aNewParent is the new native
1956 virtual void ReparentNativeWidget(nsIWidget
* aNewParent
) = 0;
1959 * Return true if widget has it's own GL context
1961 virtual bool HasGLContext() { return false; }
1964 * Returns true to indicate that this widget paints an opaque background
1965 * that we want to be visible under the page, so layout should not force
1966 * a default background.
1968 virtual bool WidgetPaintsBackground() { return false; }
1970 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1973 * Get the natural bounds of this widget. This method is only
1974 * meaningful for widgets for which Gecko implements screen
1975 * rotation natively. When this is the case, GetBounds() returns
1976 * the widget bounds taking rotation into account, and
1977 * GetNaturalBounds() returns the bounds *not* taking rotation
1980 * No code outside of the composition pipeline should know or care
1981 * about this. If you're not an agent of the compositor, you
1982 * probably shouldn't call this method.
1984 virtual LayoutDeviceIntRect
GetNaturalBounds() { return GetBounds(); }
1987 * Set size constraints on the window size such that it is never less than
1988 * the specified minimum size and never larger than the specified maximum
1989 * size. The size constraints are sizes of the outer rectangle including
1990 * the window frame and title bar. Use 0 for an unconstrained minimum size
1991 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1992 * does not necessarily change the size of a window to conform to this size,
1993 * thus Resize should be called afterwards.
1995 * @param aConstraints: the size constraints in device pixels
1997 virtual void SetSizeConstraints(const SizeConstraints
& aConstraints
) = 0;
2000 * Return the size constraints currently observed by the widget.
2002 * @return the constraints in device pixels
2004 virtual const SizeConstraints
GetSizeConstraints() = 0;
2007 * If this is owned by a BrowserChild, return that. Otherwise return
2010 virtual BrowserChild
* GetOwningBrowserChild() { return nullptr; }
2013 * If this isn't directly compositing to its window surface,
2014 * return the compositor which is doing that on our behalf.
2016 virtual CompositorBridgeChild
* GetRemoteRenderer() { return nullptr; }
2019 * Clear WebRender resources
2021 virtual void ClearCachedWebrenderResources() {}
2024 * If this widget has its own vsync source, return it, otherwise return
2025 * nullptr. An example of such local source would be Wayland frame callbacks.
2027 virtual RefPtr
<mozilla::gfx::VsyncSource
> GetVsyncSource() { return nullptr; }
2030 * Returns true if the widget requires synchronous repaints on resize,
2033 virtual bool SynchronouslyRepaintOnResize() { return true; }
2036 * Some platforms (only cocoa right now) round widget coordinates to the
2037 * nearest even pixels (see bug 892994), this function allows us to
2038 * determine how widget coordinates will be rounded.
2040 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2042 virtual void UpdateZoomConstraints(
2043 const uint32_t& aPresShellId
, const ScrollableLayerGuid::ViewID
& aViewId
,
2044 const mozilla::Maybe
<ZoomConstraints
>& aConstraints
){};
2047 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2048 * widget. Note that this never returns nullptr.
2050 virtual TextEventDispatcher
* GetTextEventDispatcher() = 0;
2053 * GetNativeTextEventDispatcherListener() returns a
2054 * TextEventDispatcherListener instance which is used when the widget
2055 * instance handles native IME and/or keyboard events.
2057 virtual TextEventDispatcherListener
*
2058 GetNativeTextEventDispatcherListener() = 0;
2060 virtual void ZoomToRect(const uint32_t& aPresShellId
,
2061 const ScrollableLayerGuid::ViewID
& aViewId
,
2062 const CSSRect
& aRect
, const uint32_t& aFlags
) = 0;
2065 * OnWindowedPluginKeyEvent() is called when native key event is
2066 * received in the focused plugin process directly in PluginInstanceChild.
2068 * @param aKeyEventData The native key event data. The actual type
2069 * copied into NativeEventData depends on the
2070 * caller. Please check PluginInstanceChild.
2071 * @param aCallback Callback interface. When this returns
2072 * NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY,
2073 * the event handler has to call this callback.
2074 * Otherwise, the caller should do that instead.
2075 * @return NS_ERROR_* if this fails to handle the event.
2076 * NS_SUCCESS_EVENT_CONSUMED if the key event is
2078 * NS_OK if the key event isn't consumed.
2079 * NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY if the
2080 * key event will be handled asynchronously.
2082 virtual nsresult
OnWindowedPluginKeyEvent(
2083 const mozilla::NativeEventData
& aKeyEventData
,
2084 nsIKeyEventInPluginCallback
* aCallback
);
2087 * LookUpDictionary shows the dictionary for the word around current point.
2089 * @param aText the word to look up dictiorary.
2090 * @param aFontRangeArray text decoration of aText
2091 * @param aIsVertical true if the word is vertical layout
2092 * @param aPoint top-left point of aText
2094 virtual void LookUpDictionary(
2095 const nsAString
& aText
,
2096 const nsTArray
<mozilla::FontRange
>& aFontRangeArray
,
2097 const bool aIsVertical
, const LayoutDeviceIntPoint
& aPoint
) {}
2099 virtual void RequestFxrOutput() {
2100 MOZ_ASSERT(false, "This function should only execute in Windows");
2103 #if defined(MOZ_WIDGET_ANDROID)
2105 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2108 * @param aMessage message being sent to Android UI thread.
2110 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage
) = 0;
2113 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2116 * @param aScrollOffset page scroll offset value in screen pixels.
2117 * @param aZoom current page zoom.
2119 virtual void UpdateRootFrameMetrics(const ScreenPoint
& aScrollOffset
,
2120 const CSSToScreenScale
& aZoom
) = 0;
2123 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2124 * for android robocop tests.
2126 * @param aMem shared memory containing the frame buffer pixels.
2127 * @param aSize size of the buffer in screen pixels.
2129 virtual void RecvScreenPixels(mozilla::ipc::Shmem
&& aMem
,
2130 const ScreenIntSize
& aSize
,
2131 bool aNeedsYFlip
) = 0;
2133 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight
) {}
2134 virtual mozilla::ScreenIntCoord
GetDynamicToolbarMaxHeight() const {
2139 static already_AddRefed
<nsIBidiKeyboard
> CreateBidiKeyboard();
2142 * Like GetDefaultScale, but taking into account only the system settings
2143 * and ignoring Gecko preferences.
2145 virtual double GetDefaultScaleInternal() { return 1.0; }
2148 // keep the list of children. We also keep track of our siblings.
2149 // The ownership model is as follows: parent holds a strong ref to
2150 // the first element of the list, and each element holds a strong
2151 // ref to the next element in the list. The prevsibling and
2152 // lastchild pointers are weak, which is fine as long as they are
2153 // maintained properly.
2154 nsCOMPtr
<nsIWidget
> mFirstChild
;
2155 nsIWidget
* MOZ_NON_OWNING_REF mLastChild
;
2156 nsCOMPtr
<nsIWidget
> mNextSibling
;
2157 nsIWidget
* MOZ_NON_OWNING_REF mPrevSibling
;
2158 // When Destroy() is called, the sub class should set this true.
2159 bool mOnDestroyCalled
;
2160 nsWindowType mWindowType
;
2164 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget
, NS_IWIDGET_IID
)
2166 #endif // nsIWidget_h__