Bug 1692971 [wpt PR 27638] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / widget / nsIWidget.h
bloba3b5756b2bdafdd4a4b0486647a8b06c96302d47
1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIWidget_h__
7 #define nsIWidget_h__
9 #include <cmath>
10 #include <cstdint>
11 #include "ErrorList.h"
12 #include "Units.h"
13 #include "mozilla/AlreadyAddRefed.h"
14 #include "mozilla/Assertions.h"
15 #include "mozilla/Attributes.h"
16 #include "mozilla/EventForwards.h"
17 #include "mozilla/Maybe.h"
18 #include "mozilla/RefPtr.h"
19 #include "mozilla/TimeStamp.h"
20 #include "mozilla/UniquePtr.h"
21 #include "mozilla/dom/BindingDeclarations.h"
22 #include "mozilla/gfx/Matrix.h"
23 #include "mozilla/gfx/Rect.h"
24 #include "mozilla/layers/LayersTypes.h"
25 #include "mozilla/layers/ScrollableLayerGuid.h"
26 #include "mozilla/layers/ZoomConstraints.h"
27 #include "mozilla/widget/IMEData.h"
28 #include "nsCOMPtr.h"
29 #include "nsColor.h"
30 #include "nsDataHashtable.h"
31 #include "nsDebug.h"
32 #include "nsID.h"
33 #include "nsIObserver.h"
34 #include "nsISupports.h"
35 #include "nsITheme.h"
36 #include "nsITimer.h"
37 #include "nsIWidgetListener.h"
38 #include "nsRect.h"
39 #include "nsSize.h"
40 #include "nsStringFwd.h"
41 #include "nsTArray.h"
42 #include "nsWidgetInitData.h"
43 #include "nsXULAppAPI.h"
45 #ifdef MOZ_IS_GCC
46 # include "VsyncSource.h"
47 #endif
49 // forward declarations
50 class nsIBidiKeyboard;
51 class nsIRollupListener;
52 class imgIContainer;
53 class nsIContent;
54 class ViewWrapper;
55 class nsIScreen;
56 class nsIRunnable;
57 class nsUint64HashKey;
59 namespace mozilla {
60 class NativeEventData;
61 class WidgetGUIEvent;
62 class WidgetInputEvent;
63 class WidgetKeyboardEvent;
64 struct FontRange;
66 enum class StyleWindowShadow : uint8_t;
68 #if defined(MOZ_WIDGET_ANDROID)
69 namespace ipc {
70 class Shmem;
72 #endif // defined(MOZ_WIDGET_ANDROID)
73 namespace dom {
74 class BrowserChild;
75 } // namespace dom
76 namespace plugins {
77 class PluginWidgetChild;
78 } // namespace plugins
79 namespace layers {
80 class AsyncDragMetrics;
81 class Compositor;
82 class CompositorBridgeChild;
83 struct FrameMetrics;
84 class LayerManager;
85 class LayerManagerComposite;
86 class PLayerTransactionChild;
87 class WebRenderBridgeChild;
88 } // namespace layers
89 namespace gfx {
90 class VsyncSource;
91 } // namespace gfx
92 namespace widget {
93 class TextEventDispatcher;
94 class TextEventDispatcherListener;
95 class CompositorWidget;
96 class CompositorWidgetInitData;
97 } // namespace widget
98 namespace wr {
99 class DisplayListBuilder;
100 class IpcResourceUpdateQueue;
101 enum class RenderRoot : uint8_t;
102 } // namespace wr
103 } // namespace mozilla
106 * Callback function that processes events.
108 * The argument is actually a subtype (subclass) of WidgetEvent which carries
109 * platform specific information about the event. Platform specific code
110 * knows how to deal with it.
112 * The return value determines whether or not the default action should take
113 * place.
115 typedef nsEventStatus (*EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
117 // Hide the native window system's real window type so as to avoid
118 // including native window system types and APIs. This is necessary
119 // to ensure cross-platform code.
120 typedef void* nsNativeWidget;
123 * Flags for the GetNativeData and SetNativeData functions
125 #define NS_NATIVE_WINDOW 0
126 #define NS_NATIVE_GRAPHIC 1
127 #define NS_NATIVE_TMP_WINDOW 2
128 #define NS_NATIVE_WIDGET 3
129 #define NS_NATIVE_DISPLAY 4
130 #define NS_NATIVE_REGION 5
131 #define NS_NATIVE_OFFSETX 6
132 #define NS_NATIVE_OFFSETY 7
133 #define NS_NATIVE_PLUGIN_PORT 8
134 #define NS_NATIVE_SCREEN 9
135 // The toplevel GtkWidget containing this nsIWidget:
136 #define NS_NATIVE_SHELLWIDGET 10
137 // Has to match to NPNVnetscapeWindow, and shareable across processes
138 // HWND on Windows and XID on X11
139 #define NS_NATIVE_SHAREABLE_WINDOW 11
140 #define NS_NATIVE_OPENGL_CONTEXT 12
141 // See RegisterPluginWindowForRemoteUpdates
142 #define NS_NATIVE_PLUGIN_ID 13
143 // This is available only with GetNativeData() in parent process. Anybody
144 // shouldn't access this pointer as a valid pointer since the result may be
145 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
146 // an identifier of distinguishing a text composition is caused by which native
147 // IME context. Note that the result is only valid in the process. So,
148 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
149 #define NS_RAW_NATIVE_IME_CONTEXT 14
150 #define NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID 15
151 #ifdef XP_MACOSX
152 # define NS_NATIVE_PLUGIN_PORT_QD 100
153 # define NS_NATIVE_PLUGIN_PORT_CG 101
154 #endif
155 #ifdef XP_WIN
156 # define NS_NATIVE_TSF_THREAD_MGR 100
157 # define NS_NATIVE_TSF_CATEGORY_MGR 101
158 # define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
159 # define NS_NATIVE_ICOREWINDOW 103 // winrt specific
160 # define NS_NATIVE_CHILD_WINDOW 104
161 # define NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW 105
162 #endif
163 #if defined(MOZ_WIDGET_GTK)
164 // set/get nsPluginNativeWindowGtk, e10s specific
165 # define NS_NATIVE_PLUGIN_OBJECT_PTR 104
166 # define NS_NATIVE_EGL_WINDOW 106
167 #endif
168 #ifdef MOZ_WIDGET_ANDROID
169 # define NS_JAVA_SURFACE 100
170 # define NS_PRESENTATION_WINDOW 101
171 # define NS_PRESENTATION_SURFACE 102
172 #endif
174 #define MOZ_WIDGET_MAX_SIZE 16384
176 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
177 #define NS_IWIDGET_IID \
179 0x06396bf6, 0x2dd8, 0x45e5, { \
180 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
185 * Transparency modes
188 enum nsTransparencyMode {
189 eTransparencyOpaque = 0, // Fully opaque
190 eTransparencyTransparent, // Parts of the window may be transparent
191 eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass
192 // effect applied
193 eTransparencyBorderlessGlass // As above, but without a border around the
194 // opaque areas when there would otherwise be
195 // one with eTransparencyGlass
196 // If you add to the end here, you must update the serialization code in
197 // WidgetMessageUtils.h
201 * Cursor types.
204 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
205 eCursor_standard,
206 ///(system is busy, usually rendered as a hourglass or watch)
207 eCursor_wait,
208 ///(Selecting something, usually rendered as an IBeam)
209 eCursor_select,
210 ///(can hyper-link, usually rendered as a human hand)
211 eCursor_hyperlink,
212 ///(north/south/west/east edge sizing)
213 eCursor_n_resize,
214 eCursor_s_resize,
215 eCursor_w_resize,
216 eCursor_e_resize,
217 ///(corner sizing)
218 eCursor_nw_resize,
219 eCursor_se_resize,
220 eCursor_ne_resize,
221 eCursor_sw_resize,
222 eCursor_crosshair,
223 eCursor_move,
224 eCursor_help,
225 eCursor_copy, // CSS3
226 eCursor_alias,
227 eCursor_context_menu,
228 eCursor_cell,
229 eCursor_grab,
230 eCursor_grabbing,
231 eCursor_spinning,
232 eCursor_zoom_in,
233 eCursor_zoom_out,
234 eCursor_not_allowed,
235 eCursor_col_resize,
236 eCursor_row_resize,
237 eCursor_no_drop,
238 eCursor_vertical_text,
239 eCursor_all_scroll,
240 eCursor_nesw_resize,
241 eCursor_nwse_resize,
242 eCursor_ns_resize,
243 eCursor_ew_resize,
244 eCursor_none,
245 // This one is used for array sizing, and so better be the last
246 // one in this list...
247 eCursorCount,
249 // ...except for this one.
250 eCursorInvalid = eCursorCount + 1
253 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
254 eZPlacementBottom = 0, // bottom of the window stack
255 eZPlacementBelow, // just below another widget
256 eZPlacementTop // top of the window stack
260 * Before the OS goes to sleep, this topic is notified.
262 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
265 * After the OS wakes up, this topic is notified.
267 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
270 * Before the OS suspends the current process, this topic is notified. Some
271 * OS will kill processes that are suspended instead of resuming them.
272 * For that reason this topic may be useful to safely close down resources.
274 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
277 * After the current process resumes from being suspended, this topic is
278 * notified.
280 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
283 * When an app(-shell) is activated by the OS, this topic is notified.
284 * Currently, this only happens on Mac OSX.
286 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
288 namespace mozilla {
289 namespace widget {
292 * Size constraints for setting the minimum and maximum size of a widget.
293 * Values are in device pixels.
295 struct SizeConstraints {
296 SizeConstraints() : mMaxSize(MOZ_WIDGET_MAX_SIZE, MOZ_WIDGET_MAX_SIZE) {}
298 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
299 mozilla::LayoutDeviceIntSize aMaxSize)
300 : mMinSize(aMinSize), mMaxSize(aMaxSize) {
301 if (mMaxSize.width > MOZ_WIDGET_MAX_SIZE) {
302 mMaxSize.width = MOZ_WIDGET_MAX_SIZE;
304 if (mMaxSize.height > MOZ_WIDGET_MAX_SIZE) {
305 mMaxSize.height = MOZ_WIDGET_MAX_SIZE;
309 mozilla::LayoutDeviceIntSize mMinSize;
310 mozilla::LayoutDeviceIntSize mMaxSize;
313 struct AutoObserverNotifier {
314 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
315 : mObserver(aObserver), mTopic(aTopic) {}
317 void SkipNotification() { mObserver = nullptr; }
319 uint64_t SaveObserver() {
320 if (!mObserver) {
321 return 0;
323 uint64_t observerId = ++sObserverId;
324 sSavedObservers.Put(observerId, mObserver);
325 SkipNotification();
326 return observerId;
329 ~AutoObserverNotifier() {
330 if (mObserver) {
331 mObserver->Observe(nullptr, mTopic, nullptr);
335 static void NotifySavedObserver(const uint64_t& aObserverId,
336 const char* aTopic) {
337 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
338 if (!observer) {
339 MOZ_ASSERT(aObserverId == 0,
340 "We should always find a saved observer for nonzero IDs");
341 return;
344 sSavedObservers.Remove(aObserverId);
345 observer->Observe(nullptr, aTopic, nullptr);
348 private:
349 nsCOMPtr<nsIObserver> mObserver;
350 const char* mTopic;
352 private:
353 static uint64_t sObserverId;
354 static nsDataHashtable<nsUint64HashKey, nsCOMPtr<nsIObserver>>
355 sSavedObservers;
358 } // namespace widget
359 } // namespace mozilla
362 * The base class for all the widgets. It provides the interface for
363 * all basic and necessary functionality.
365 class nsIWidget : public nsISupports {
366 protected:
367 typedef mozilla::dom::BrowserChild BrowserChild;
369 public:
370 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
371 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
372 typedef mozilla::layers::FrameMetrics FrameMetrics;
373 typedef mozilla::layers::LayerManager LayerManager;
374 typedef mozilla::layers::LayerManagerComposite LayerManagerComposite;
375 typedef mozilla::layers::LayersBackend LayersBackend;
376 typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild;
377 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
378 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
379 typedef mozilla::widget::IMEEnabled IMEEnabled;
380 typedef mozilla::widget::IMEMessage IMEMessage;
381 typedef mozilla::widget::IMENotification IMENotification;
382 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
383 typedef mozilla::widget::IMEState IMEState;
384 typedef mozilla::widget::InputContext InputContext;
385 typedef mozilla::widget::InputContextAction InputContextAction;
386 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
387 typedef mozilla::widget::SizeConstraints SizeConstraints;
388 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
389 typedef mozilla::widget::TextEventDispatcherListener
390 TextEventDispatcherListener;
391 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
392 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
393 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
394 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
395 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
396 typedef mozilla::ScreenIntPoint ScreenIntPoint;
397 typedef mozilla::ScreenIntMargin ScreenIntMargin;
398 typedef mozilla::ScreenIntSize ScreenIntSize;
399 typedef mozilla::ScreenPoint ScreenPoint;
400 typedef mozilla::CSSToScreenScale CSSToScreenScale;
401 typedef mozilla::DesktopIntRect DesktopIntRect;
402 typedef mozilla::DesktopPoint DesktopPoint;
403 typedef mozilla::DesktopRect DesktopRect;
404 typedef mozilla::DesktopSize DesktopSize;
405 typedef mozilla::CSSPoint CSSPoint;
406 typedef mozilla::CSSRect CSSRect;
408 // Used in UpdateThemeGeometries.
409 struct ThemeGeometry {
410 // The ThemeGeometryType value for the themed widget, see
411 // nsITheme::ThemeGeometryTypeForWidget.
412 nsITheme::ThemeGeometryType mType;
413 // The device-pixel rect within the window for the themed widget
414 LayoutDeviceIntRect mRect;
416 ThemeGeometry(nsITheme::ThemeGeometryType aType,
417 const LayoutDeviceIntRect& aRect)
418 : mType(aType), mRect(aRect) {}
421 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
423 nsIWidget()
424 : mLastChild(nullptr),
425 mPrevSibling(nullptr),
426 mOnDestroyCalled(false),
427 mWindowType(eWindowType_child),
428 mZIndex(0)
431 ClearNativeTouchSequence(nullptr);
435 * Create and initialize a widget.
437 * All the arguments can be null in which case a top level window
438 * with size 0 is created. The event callback function has to be
439 * provided only if the caller wants to deal with the events this
440 * widget receives. The event callback is basically a preprocess
441 * hook called synchronously. The return value determines whether
442 * the event goes to the default window procedure or it is hidden
443 * to the os. The assumption is that if the event handler returns
444 * false the widget does not see the event. The widget should not
445 * automatically clear the window to the background color. The
446 * calling code must handle paint messages and clear the background
447 * itself.
449 * In practice at least one of aParent and aNativeParent will be null. If
450 * both are null the widget isn't parented (e.g. context menus or
451 * independent top level windows).
453 * The dimensions given in aRect are specified in the parent's
454 * device coordinate system.
455 * This must not be called for parentless widgets such as top-level
456 * windows, which use the desktop pixel coordinate system; a separate
457 * method is provided for these.
459 * @param aParent parent nsIWidget
460 * @param aNativeParent native parent widget
461 * @param aRect the widget dimension
462 * @param aInitData data that is used for widget initialization
465 [[nodiscard]] virtual nsresult Create(
466 nsIWidget* aParent, nsNativeWidget aNativeParent,
467 const LayoutDeviceIntRect& aRect,
468 nsWidgetInitData* aInitData = nullptr) = 0;
471 * As above, but with aRect specified in DesktopPixel units (for top-level
472 * widgets).
473 * Default implementation just converts aRect to device pixels and calls
474 * through to device-pixel Create, but platforms may override this if the
475 * mapping is not straightforward or the native platform needs to use the
476 * desktop pixel values directly.
478 [[nodiscard]] virtual nsresult Create(nsIWidget* aParent,
479 nsNativeWidget aNativeParent,
480 const DesktopIntRect& aRect,
481 nsWidgetInitData* aInitData = nullptr) {
482 LayoutDeviceIntRect devPixRect =
483 RoundedToInt(aRect * GetDesktopToDeviceScale());
484 return Create(aParent, aNativeParent, devPixRect, aInitData);
488 * Allocate, initialize, and return a widget that is a child of
489 * |this|. The returned widget (if nonnull) has gone through the
490 * equivalent of CreateInstance(widgetCID) + Create(...).
492 * |CreateChild()| lets widget backends decide whether to parent
493 * the new child widget to this, nonnatively parent it, or both.
494 * This interface exists to support the PuppetWidget backend,
495 * which is entirely non-native. All other params are the same as
496 * for |Create()|.
498 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
499 * |nsIWidget*| this, not its native widget (if it exists), when
500 * calling |Create()|. This is a timid hack around poorly
501 * understood code, and shouldn't be used in new code.
503 virtual already_AddRefed<nsIWidget> CreateChild(
504 const LayoutDeviceIntRect& aRect, nsWidgetInitData* aInitData = nullptr,
505 bool aForceUseIWidgetParent = false) = 0;
508 * Attach to a top level widget.
510 * In cases where a top level chrome widget is being used as a content
511 * container, attach a secondary listener and update the device
512 * context. The primary widget listener will continue to be called for
513 * notifications relating to the top-level window, whereas other
514 * notifications such as painting and events will instead be called via
515 * the attached listener. SetAttachedWidgetListener should be used to
516 * assign the attached listener.
518 * aUseAttachedEvents if true, events are sent to the attached listener
519 * instead of the normal listener.
521 virtual void AttachViewToTopLevel(bool aUseAttachedEvents) = 0;
524 * Accessor functions to get and set the attached listener. Used by
525 * nsView in connection with AttachViewToTopLevel above.
527 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
528 virtual nsIWidgetListener* GetAttachedWidgetListener() = 0;
529 virtual void SetPreviouslyAttachedWidgetListener(
530 nsIWidgetListener* aListener) = 0;
531 virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() = 0;
534 * Accessor functions to get and set the listener which handles various
535 * actions for the widget.
537 //@{
538 virtual nsIWidgetListener* GetWidgetListener() = 0;
539 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
540 //@}
543 * Close and destroy the internal native window.
544 * This method does not delete the widget.
547 virtual void Destroy() = 0;
550 * Destroyed() returns true if Destroy() has been called already.
551 * Otherwise, false.
553 bool Destroyed() const { return mOnDestroyCalled; }
556 * Reparent a widget
558 * Change the widget's parent. Null parents are allowed.
560 * @param aNewParent new parent
562 virtual void SetParent(nsIWidget* aNewParent) = 0;
565 * Return the parent Widget of this Widget or nullptr if this is a
566 * top level window
568 * @return the parent widget or nullptr if it does not have a parent
571 virtual nsIWidget* GetParent(void) = 0;
574 * Return the top level Widget of this Widget
576 * @return the top level widget
578 virtual nsIWidget* GetTopLevelWidget() = 0;
581 * Return the top (non-sheet) parent of this Widget if it's a sheet,
582 * or nullptr if this isn't a sheet (or some other error occurred).
583 * Sheets are only supported on some platforms (currently only OS X).
585 * @return the top (non-sheet) parent widget or nullptr
588 virtual nsIWidget* GetSheetWindowParent(void) = 0;
591 * Return the physical DPI of the screen containing the window ...
592 * the number of device pixels per inch.
594 virtual float GetDPI() = 0;
597 * Return the scaling factor between device pixels and the platform-
598 * dependent "desktop pixels" used to manage window positions on a
599 * potentially multi-screen, mixed-resolution desktop.
601 virtual mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() = 0;
604 * Return the scaling factor between device pixels and the platform-
605 * dependent "desktop pixels" by looking up the screen by the position
606 * of the widget.
608 virtual mozilla::DesktopToLayoutDeviceScale
609 GetDesktopToDeviceScaleByScreen() = 0;
612 * Return the default scale factor for the window. This is the
613 * default number of device pixels per CSS pixel to use. This should
614 * depend on OS/platform settings such as the Mac's "UI scale factor"
615 * or Windows' "font DPI". This will take into account Gecko preferences
616 * overriding the system setting.
618 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
621 * Return the first child of this widget. Will return null if
622 * there are no children.
624 nsIWidget* GetFirstChild() const { return mFirstChild; }
627 * Return the last child of this widget. Will return null if
628 * there are no children.
630 nsIWidget* GetLastChild() const { return mLastChild; }
633 * Return the next sibling of this widget
635 nsIWidget* GetNextSibling() const { return mNextSibling; }
638 * Set the next sibling of this widget
640 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
643 * Return the previous sibling of this widget
645 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
648 * Set the previous sibling of this widget
650 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
653 * Show or hide this widget
655 * @param aState true to show the Widget, false to hide it
658 virtual void Show(bool aState) = 0;
661 * Whether or not a widget must be recreated after being hidden to show
662 * again properly.
664 virtual bool NeedsRecreateToReshow() { return false; }
667 * Make the window modal.
669 virtual void SetModal(bool aModal) = 0;
672 * Make the non-modal window opened by modal window fake-modal, that will
673 * call SetFakeModal(false) on destroy on Cocoa.
675 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
678 * Are we app modal. Currently only implemented on Cocoa.
680 virtual bool IsRunningAppModal() { return false; }
683 * The maximum number of simultaneous touch contacts supported by the device.
684 * In the case of devices with multiple digitizers (e.g. multiple touch
685 * screens), the value will be the maximum of the set of maximum supported
686 * contacts by each individual digitizer.
688 virtual uint32_t GetMaxTouchPoints() const = 0;
691 * Returns whether the window is visible
694 virtual bool IsVisible() const = 0;
697 * Perform platform-dependent sanity check on a potential window position.
698 * This is guaranteed to work only for top-level windows.
700 * @param aAllowSlop: if true, allow the window to slop offscreen;
701 * the window should be partially visible. if false,
702 * force the entire window onscreen (or at least
703 * the upper-left corner, if it's too large).
704 * @param aX in: an x position expressed in screen coordinates.
705 * out: the x position constrained to fit on the screen(s).
706 * @param aY in: an y position expressed in screen coordinates.
707 * out: the y position constrained to fit on the screen(s).
710 virtual void ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) = 0;
713 * NOTE:
715 * For a top-level window widget, the "parent's coordinate system" is the
716 * "global" display pixel coordinate space, *not* device pixels (which
717 * may be inconsistent between multiple screens, at least in the Mac OS
718 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
719 * following Move and Resize widget APIs.
721 * The display-/device-pixel distinction becomes important for (at least)
722 * Mac OS X with Hi-DPI (retina) displays, and Windows when the UI scale
723 * factor is set to other than 100%.
725 * The Move and Resize methods take floating-point parameters, rather than
726 * integer ones. This is important when manipulating top-level widgets,
727 * where the coordinate system may not be an integral multiple of the
728 * device-pixel space.
732 * Move this widget.
734 * Coordinates refer to the top-left of the widget. For toplevel windows
735 * with decorations, this is the top-left of the titlebar and frame .
737 * @param aX the new x position expressed in the parent's coordinate system
738 * @param aY the new y position expressed in the parent's coordinate system
741 virtual void Move(double aX, double aY) = 0;
744 * Reposition this widget so that the client area has the given offset.
746 * @param aOffset the new offset of the client area expressed as an
747 * offset from the origin of the client area of the parent
748 * widget (for root widgets and popup widgets it is in
749 * screen coordinates)
751 virtual void MoveClient(const DesktopPoint& aOffset) = 0;
754 * Resize this widget. Any size constraints set for the window by a
755 * previous call to SetSizeConstraints will be applied.
757 * @param aWidth the new width expressed in the parent's coordinate system
758 * @param aHeight the new height expressed in the parent's coordinate
759 * system
760 * @param aRepaint whether the widget should be repainted
762 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
765 * Lock the aspect ratio of a Window
767 * @param aShouldLock bool
770 virtual void LockAspectRatio(bool aShouldLock){};
773 * Move or resize this widget. Any size constraints set for the window by
774 * a previous call to SetSizeConstraints will be applied.
776 * @param aX the new x position expressed in the parent's coordinate
777 * system
778 * @param aY the new y position expressed in the parent's coordinate
779 * system
780 * @param aWidth the new width expressed in the parent's coordinate system
781 * @param aHeight the new height expressed in the parent's coordinate
782 * system
783 * @param aRepaint whether the widget should be repainted if the size
784 * changes
787 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
788 bool aRepaint) = 0;
790 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
791 return mozilla::Nothing();
795 * Resize the widget so that the inner client area has the given size.
797 * @param aSize the new size of the client area.
798 * @param aRepaint whether the widget should be repainted
800 virtual void ResizeClient(const DesktopSize& aSize, bool aRepaint) = 0;
803 * Resize and reposition the widget so tht inner client area has the given
804 * offset and size.
806 * @param aRect the new offset and size of the client area. The offset is
807 * expressed as an offset from the origin of the client area
808 * of the parent widget (for root widgets and popup widgets it
809 * is in screen coordinates).
810 * @param aRepaint whether the widget should be repainted
812 virtual void ResizeClient(const DesktopRect& aRect, bool aRepaint) = 0;
815 * Sets the widget's z-index.
817 virtual void SetZIndex(int32_t aZIndex) = 0;
820 * Gets the widget's z-index.
822 int32_t GetZIndex() { return mZIndex; }
825 * Position this widget just behind the given widget. (Used to
826 * control z-order for top-level widgets. Get/SetZIndex by contrast
827 * control z-order for child widgets of other widgets.)
828 * @param aPlacement top, bottom, or below a widget
829 * (if top or bottom, param aWidget is ignored)
830 * @param aWidget widget to place this widget behind
831 * (only if aPlacement is eZPlacementBelow).
832 * null is equivalent to aPlacement of eZPlacementTop
833 * @param aActivate true to activate the widget after placing it
835 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
836 nsIWidget* aWidget, bool aActivate) = 0;
839 * Minimize, maximize or normalize the window size.
840 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
842 virtual void SetSizeMode(nsSizeMode aMode) = 0;
844 virtual void GetWorkspaceID(nsAString& workspaceID) = 0;
846 virtual void MoveToWorkspace(const nsAString& workspaceID) = 0;
849 * Suppress animations that are applied to a window by OS.
851 virtual void SuppressAnimation(bool aSuppress) {}
854 * Return size mode (minimized, maximized, normalized).
855 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
857 virtual nsSizeMode SizeMode() = 0;
860 * Ask whether the window is tiled.
862 virtual bool IsTiled() const = 0;
865 * Ask wether the widget is fully occluded
867 virtual bool IsFullyOccluded() const = 0;
870 * Enable or disable this Widget
872 * @param aState true to enable the Widget, false to disable it.
874 virtual void Enable(bool aState) = 0;
877 * Ask whether the widget is enabled
879 virtual bool IsEnabled() const = 0;
882 * Whether we should request activation of this widget's toplevel window.
884 enum class Raise {
886 Yes,
890 * Request activation of this window or give focus to this widget.
892 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
895 * Get this widget's outside dimensions relative to its parent widget. For
896 * popup widgets the returned rect is in screen coordinates and not
897 * relative to its parent widget.
899 * @return the x, y, width and height of this widget.
901 virtual LayoutDeviceIntRect GetBounds() = 0;
904 * Get this widget's outside dimensions in device coordinates. This
905 * includes any title bar on the window.
907 * @return the x, y, width and height of this widget.
909 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
912 * Similar to GetScreenBounds except that this function will always
913 * get the size when the widget is in the nsSizeMode_Normal size mode
914 * even if the current size mode is not nsSizeMode_Normal.
915 * This method will fail if the size mode is not nsSizeMode_Normal and
916 * the platform doesn't have the ability.
917 * This method will always succeed if the current size mode is
918 * nsSizeMode_Normal.
920 * @param aRect On return it holds the x, y, width and height of
921 * this widget.
923 [[nodiscard]] virtual nsresult GetRestoredBounds(
924 LayoutDeviceIntRect& aRect) = 0;
927 * Get this widget's client area bounds, if the window has a 3D border
928 * appearance this returns the area inside the border. The position is the
929 * position of the client area relative to the client area of the parent
930 * widget (for root widgets and popup widgets it is in screen coordinates).
932 * @return the x, y, width and height of the client area of this widget.
934 virtual LayoutDeviceIntRect GetClientBounds() = 0;
937 * Sets the non-client area dimensions of the window. Pass -1 to restore
938 * the system default frame size for that border. Pass zero to remove
939 * a border, or pass a specific value adjust a border. Units are in
940 * pixels. (DPI dependent)
942 * Platform notes:
943 * Windows: shrinking top non-client height will remove application
944 * icon and window title text. Glass desktops will refuse to set
945 * dimensions between zero and size < system default.
947 virtual nsresult SetNonClientMargins(LayoutDeviceIntMargin& aMargins) = 0;
950 * Get the client offset from the window origin.
952 * @return the x and y of the offset.
954 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
957 * Equivalent to GetClientBounds but only returns the size.
959 virtual LayoutDeviceIntSize GetClientSize() {
960 // Depending on the backend, overloading this method may be useful if
961 // requesting the client offset is expensive.
962 return GetClientBounds().Size();
966 * Set the background color for this widget
968 * @param aColor the new background color
972 virtual void SetBackgroundColor(const nscolor& aColor) {}
975 * If a cursor type is currently cached locally for this widget, clear the
976 * cached cursor to force an update on the next SetCursor call.
979 virtual void ClearCachedCursor() = 0;
982 * Sets the cursor cursor for this widget.
984 * @param aDefaultCursor the default cursor to be set
985 * @param aCursorImage a custom cursor, maybe null.
986 * @param aX the X coordinate of the hotspot for aCursorImage (from left).
987 * @param aY the Y coordinate of the hotspot for aCursorImage (from top).
989 virtual void SetCursor(nsCursor aDefaultCursor, imgIContainer* aCursorImage,
990 uint32_t aHotspotX, uint32_t aHotspotY) = 0;
993 * Get the window type of this widget.
995 nsWindowType WindowType() { return mWindowType; }
998 * Determines if this widget is one of the three types of plugin widgets.
1000 bool IsPlugin() {
1001 return mWindowType == eWindowType_plugin ||
1002 mWindowType == eWindowType_plugin_ipc_chrome ||
1003 mWindowType == eWindowType_plugin_ipc_content;
1007 * Set the transparency mode of the top-level window containing this widget.
1008 * So, e.g., if you call this on the widget for an IFRAME, the top level
1009 * browser window containing the IFRAME actually gets set. Be careful.
1011 * This can fail if the platform doesn't support
1012 * transparency/glass. By default widgets are not
1013 * transparent. This will also fail if the toplevel window is not
1014 * a Mozilla window, e.g., if the widget is in an embedded
1015 * context.
1017 * After transparency/glass has been enabled, the initial alpha channel
1018 * value for all pixels is 1, i.e., opaque.
1019 * If the window is resized then the alpha channel values for
1020 * all pixels are reset to 1.
1021 * Pixel RGB color values are already premultiplied with alpha channel values.
1023 virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
1026 * Get the transparency mode of the top-level window that contains this
1027 * widget.
1029 virtual nsTransparencyMode GetTransparencyMode() = 0;
1032 * This represents a command to set the bounds and clip region of
1033 * a child widget.
1035 struct Configuration {
1036 nsCOMPtr<nsIWidget> mChild;
1037 uintptr_t mWindowID; // e10s specific, the unique plugin port id
1038 bool mVisible; // e10s specific, widget visibility
1039 LayoutDeviceIntRect mBounds;
1040 CopyableTArray<LayoutDeviceIntRect> mClipRegion;
1044 * Sets the clip region of each mChild (which must actually be a child
1045 * of this widget) to the union of the pixel rects given in
1046 * mClipRegion, all relative to the top-left of the child
1047 * widget. Clip regions are not implemented on all platforms and only
1048 * need to actually work for children that are plugins.
1050 * Also sets the bounds of each child to mBounds.
1052 * This will invalidate areas of the children that have changed, but
1053 * does not need to invalidate any part of this widget.
1055 * Children should be moved in the order given; the array is
1056 * sorted so to minimize unnecessary invalidation if children are
1057 * moved in that order.
1059 virtual nsresult ConfigureChildren(
1060 const nsTArray<Configuration>& aConfigurations) = 0;
1061 virtual nsresult SetWindowClipRegion(
1062 const nsTArray<LayoutDeviceIntRect>& aRects,
1063 bool aIntersectWithExisting) = 0;
1066 * Appends to aRects the rectangles constituting this widget's clip
1067 * region. If this widget is not clipped, appends a single rectangle
1068 * (0, 0, bounds.width, bounds.height).
1070 virtual void GetWindowClipRegion(nsTArray<LayoutDeviceIntRect>* aRects) = 0;
1073 * Register or unregister native plugin widgets which receive Configuration
1074 * data from the content process via the compositor.
1076 * Lookups are used by the main thread via the compositor to lookup widgets
1077 * based on a unique window id. On Windows and Linux this is the
1078 * NS_NATIVE_PLUGIN_PORT (hwnd/XID). This tracking maintains a reference to
1079 * widgets held. Consumers are responsible for removing widgets from this
1080 * list.
1082 virtual void RegisterPluginWindowForRemoteUpdates() = 0;
1083 virtual void UnregisterPluginWindowForRemoteUpdates() = 0;
1084 static nsIWidget* LookupRegisteredPluginWindow(uintptr_t aWindowID);
1087 * Iterates across the list of registered plugin widgets and updates thier
1088 * visibility based on which plugins are included in the 'visible' list.
1090 * The compositor knows little about tabs, but it does know which plugin
1091 * widgets are currently included in the visible layer tree. It calls this
1092 * helper to hide widgets it knows nothing about.
1094 static void UpdateRegisteredPluginWindowVisibility(
1095 uintptr_t aOwnerWidget, nsTArray<uintptr_t>& aPluginIds);
1097 #if defined(XP_WIN)
1099 * Iterates over the list of registered plugins and for any that are owned
1100 * by aOwnerWidget and visible it takes a snapshot.
1102 * @param aOwnerWidget only captures visible widgets owned by this
1104 static void CaptureRegisteredPlugins(uintptr_t aOwnerWidget);
1107 * Take a scroll capture for this widget if possible.
1109 virtual void UpdateScrollCapture() = 0;
1112 * Creates an async ImageContainer to hold scroll capture images that can be
1113 * used if the plugin is hidden during scroll.
1114 * @return the async container ID of the created ImageContainer.
1116 virtual uint64_t CreateScrollCaptureContainer() = 0;
1117 #endif
1120 * Set the shadow style of the window.
1122 * Ignored on child widgets and on non-Mac platforms.
1124 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) = 0;
1127 * Set the opacity of the window.
1128 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1130 * Ignored on child widgets and on non-Mac platforms.
1132 virtual void SetWindowOpacity(float aOpacity) {}
1135 * Set the transform of the window. Values are in device pixels,
1136 * the origin is the top left corner of the window.
1138 * Ignored on child widgets and on non-Mac platforms.
1140 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1143 * Set whether the window should ignore mouse events or not.
1145 * This is only used on popup windows.
1147 virtual void SetWindowMouseTransparent(bool aIsTransparent) {}
1150 * On Mac OS X, this method shows or hides the pill button in the titlebar
1151 * that's used to collapse the toolbar.
1153 * Ignored on child widgets and on non-Mac platforms.
1155 virtual void SetShowsToolbarButton(bool aShow) = 0;
1158 * On macOS, this method determines whether we tell cocoa that the window
1159 * supports native full screen. If we do so, and another window is in
1160 * native full screen, this window will also appear in native full screen.
1162 * We generally only want to do this for primary application windows.
1164 * Ignored on child widgets and on non-Mac platforms.
1166 virtual void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen) = 0;
1168 enum WindowAnimationType {
1169 eGenericWindowAnimation,
1170 eDocumentWindowAnimation
1174 * Sets the kind of top-level window animation this widget should have. On
1175 * Mac OS X, this causes a particular kind of animation to be shown when the
1176 * window is first made visible.
1178 * Ignored on child widgets and on non-Mac platforms.
1180 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1183 * Specifies whether the window title should be drawn even if the window
1184 * contents extend into the titlebar. Ignored on windows that don't draw
1185 * in the titlebar. Only implemented on OS X.
1187 virtual void SetDrawsTitle(bool aDrawTitle) {}
1190 * Hide window chrome (borders, buttons) for this widget.
1193 virtual void HideWindowChrome(bool aShouldHide) = 0;
1195 enum FullscreenTransitionStage {
1196 eBeforeFullscreenToggle,
1197 eAfterFullscreenToggle
1201 * Prepares for fullscreen transition and returns whether the widget
1202 * supports fullscreen transition. If this method returns false,
1203 * PerformFullscreenTransition() must never be called. Otherwise,
1204 * caller should call that method twice with "before" and "after"
1205 * stages respectively in order. In the latter case, this method may
1206 * return some data via aData pointer. Caller must pass that data to
1207 * PerformFullscreenTransition() if any, and caller is responsible
1208 * for releasing that data.
1210 virtual bool PrepareForFullscreenTransition(nsISupports** aData) = 0;
1213 * Performs fullscreen transition. This method returns immediately,
1214 * and will post aCallback to the main thread when the transition
1215 * finishes.
1217 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
1218 uint16_t aDuration,
1219 nsISupports* aData,
1220 nsIRunnable* aCallback) = 0;
1223 * Perform any actions needed after the fullscreen transition has ended.
1225 virtual void CleanupFullscreenTransition() = 0;
1228 * Return the screen the widget is in, or null if we don't know.
1230 virtual already_AddRefed<nsIScreen> GetWidgetScreen() = 0;
1233 * Put the toplevel window into or out of fullscreen mode.
1234 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1235 * if possible. (If not, it behaves as if aTargetScreen is null.)
1236 * If !aFullScreen, aTargetScreen is ignored.
1237 * aTargetScreen support is currently only implemented on Windows.
1239 * @return NS_OK if the widget is setup properly for fullscreen and
1240 * FullscreenChanged callback has been or will be called. If other
1241 * value is returned, the caller should continue the change itself.
1243 virtual nsresult MakeFullScreen(bool aFullScreen,
1244 nsIScreen* aTargetScreen = nullptr) = 0;
1247 * Same as MakeFullScreen, except that, on systems which natively
1248 * support fullscreen transition, calling this method explicitly
1249 * requests that behavior.
1250 * It is currently only supported on OS X 10.7+.
1252 virtual nsresult MakeFullScreenWithNativeTransition(
1253 bool aFullScreen, nsIScreen* aTargetScreen = nullptr) {
1254 return MakeFullScreen(aFullScreen, aTargetScreen);
1258 * Invalidate a specified rect for a widget so that it will be repainted
1259 * later.
1261 virtual void Invalidate(const LayoutDeviceIntRect& aRect) = 0;
1263 enum LayerManagerPersistence {
1264 LAYER_MANAGER_CURRENT = 0,
1265 LAYER_MANAGER_PERSISTENT
1269 * Return the widget's LayerManager. The layer tree for that
1270 * LayerManager is what gets rendered to the widget.
1272 inline LayerManager* GetLayerManager() {
1273 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE,
1274 LAYER_MANAGER_CURRENT);
1277 inline LayerManager* GetLayerManager(LayerManagerPersistence aPersistence) {
1278 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE,
1279 aPersistence);
1283 * Like GetLayerManager(), but prefers creating a layer manager of
1284 * type |aBackendHint| instead of what would normally be created.
1285 * LayersBackend::LAYERS_NONE means "no hint".
1287 virtual LayerManager* GetLayerManager(
1288 PLayerTransactionChild* aShadowManager, LayersBackend aBackendHint,
1289 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) = 0;
1292 * Called before each layer manager transaction to allow any preparation
1293 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1295 * Always called on the main thread.
1297 virtual void PrepareWindowEffects() = 0;
1300 * Called on the main thread at the end of WebRender display list building.
1302 virtual void AddWindowOverlayWebRenderCommands(
1303 mozilla::layers::WebRenderBridgeChild* aWrBridge,
1304 mozilla::wr::DisplayListBuilder& aBuilder,
1305 mozilla::wr::IpcResourceUpdateQueue& aResources) {}
1308 * Called when Gecko knows which themed widgets exist in this window.
1309 * The passed array contains an entry for every themed widget of the right
1310 * type (currently only StyleAppearance::Toolbar) within the window, except
1311 * for themed widgets which are transformed or have effects applied to them
1312 * (e.g. CSS opacity or filters).
1313 * This could sometimes be called during display list construction
1314 * outside of painting.
1315 * If called during painting, it will be called before we actually
1316 * paint anything.
1318 virtual void UpdateThemeGeometries(
1319 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1322 * Informs the widget about the region of the window that is opaque.
1324 * @param aOpaqueRegion the region of the window that is opaque.
1326 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1329 * Informs the widget about the region of the window that is draggable.
1331 virtual void UpdateWindowDraggingRegion(
1332 const LayoutDeviceIntRegion& aRegion) {}
1335 * Tells the widget whether the given input block results in a swipe.
1336 * Should be called in response to a WidgetWheelEvent that has
1337 * mFlags.mCanTriggerSwipe set on it.
1339 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1342 * Internal methods
1345 //@{
1346 virtual void AddChild(nsIWidget* aChild) = 0;
1347 virtual void RemoveChild(nsIWidget* aChild) = 0;
1348 virtual void* GetNativeData(uint32_t aDataType) = 0;
1349 virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal) = 0;
1350 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1352 //@}
1355 * Set the widget's title.
1356 * Must be called after Create.
1358 * @param aTitle string displayed as the title of the widget
1360 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1363 * Set the widget's icon.
1364 * Must be called after Create.
1366 * @param aIconSpec string specifying the icon to use; convention is to
1367 * pass a resource: URL from which a platform-dependent
1368 * resource file name will be constructed
1370 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1373 * Return this widget's origin in screen coordinates.
1375 * @return screen coordinates stored in the x,y members
1377 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1380 * The same as WidgetToScreenOffset(), except in the case of
1381 * PuppetWidget where this method omits the chrome offset.
1383 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1384 return WidgetToScreenOffset();
1388 * For a PuppetWidget, returns the transform from the coordinate
1389 * space of the PuppetWidget to the coordinate space of the
1390 * top-level native widget.
1392 * Identity transform in other cases.
1394 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1395 WidgetToTopLevelWidgetTransform() {
1396 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1400 * Given the specified client size, return the corresponding window size,
1401 * which includes the area for the borders and titlebar. This method
1402 * should work even when the window is not yet visible.
1404 virtual LayoutDeviceIntSize ClientToWindowSize(
1405 const LayoutDeviceIntSize& aClientSize) = 0;
1408 * Dispatches an event to the widget
1410 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1411 nsEventStatus& aStatus) = 0;
1414 * Dispatches an event to APZ only.
1415 * No-op in the child process.
1417 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1420 * Dispatches an event that must be handled by APZ first, when APZ is
1421 * enabled. If invoked in the child process, it is forwarded to the
1422 * parent process synchronously.
1424 virtual nsEventStatus DispatchInputEvent(
1425 mozilla::WidgetInputEvent* aEvent) = 0;
1428 * Confirm an APZ-aware event target. This should be used when APZ will
1429 * not need a layers update to process the event.
1431 virtual void SetConfirmedTargetAPZC(
1432 uint64_t aInputBlockId,
1433 const nsTArray<ScrollableLayerGuid>& aTargets) const = 0;
1436 * Returns true if APZ is in use, false otherwise.
1438 virtual bool AsyncPanZoomEnabled() const = 0;
1441 * Enables the dropping of files to a widget.
1443 virtual void EnableDragDrop(bool aEnable) = 0;
1444 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1447 * Enables/Disables system mouse capture.
1448 * @param aCapture true enables mouse capture, false disables mouse capture
1451 virtual void CaptureMouse(bool aCapture) = 0;
1454 * Classify the window for the window manager. Mostly for X11.
1456 virtual void SetWindowClass(const nsAString& xulWinType) = 0;
1459 * Enables/Disables system capture of any and all events that would cause a
1460 * popup to be rolled up. aListener should be set to a non-null value for
1461 * any popups that are not managed by the popup manager.
1462 * @param aDoCapture true enables capture, false disables capture
1465 virtual void CaptureRollupEvents(nsIRollupListener* aListener,
1466 bool aDoCapture) = 0;
1469 * Bring this window to the user's attention. This is intended to be a more
1470 * gentle notification than popping the window to the top or putting up an
1471 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1472 * the Mac. The notification should be suppressed if the window is already
1473 * in the foreground and should be dismissed when the user brings this window
1474 * to the foreground.
1475 * @param aCycleCount Maximum number of times to animate the window per system
1476 * conventions. If set to -1, cycles indefinitely until
1477 * window is brought into the foreground.
1479 [[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) = 0;
1482 * Ask whether there user input events pending. All input events are
1483 * included, including those not targeted at this nsIwidget instance.
1485 virtual bool HasPendingInputEvent() = 0;
1488 * If set to true, the window will draw its contents into the titlebar
1489 * instead of below it.
1491 * Ignored on any platform that does not support it. Ignored by widgets that
1492 * do not represent windows.
1493 * May result in a resize event, so should only be called from places where
1494 * reflow and painting is allowed.
1496 * @param aState Whether drawing into the titlebar should be activated.
1498 virtual void SetDrawsInTitlebar(bool aState) = 0;
1501 * Determine whether the widget shows a resize widget. If it does,
1502 * aResizerRect returns the resizer's rect.
1504 * Returns false on any platform that does not support it.
1506 * @param aResizerRect The resizer's rect in device pixels.
1507 * @return Whether a resize widget is shown.
1509 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1512 * Begin a window resizing drag, based on the event passed in.
1514 [[nodiscard]] virtual nsresult BeginResizeDrag(
1515 mozilla::WidgetGUIEvent* aEvent, int32_t aHorizontal,
1516 int32_t aVertical) = 0;
1518 enum Modifiers {
1519 CAPS_LOCK = 0x00000001, // when CapsLock is active
1520 NUM_LOCK = 0x00000002, // when NumLock is active
1521 SHIFT_L = 0x00000100,
1522 SHIFT_R = 0x00000200,
1523 CTRL_L = 0x00000400,
1524 CTRL_R = 0x00000800,
1525 ALT_L = 0x00001000, // includes Option
1526 ALT_R = 0x00002000,
1527 COMMAND_L = 0x00004000,
1528 COMMAND_R = 0x00008000,
1529 HELP = 0x00010000,
1530 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1531 // AltRight key behavior of keyboard
1532 // layouts which maps AltGr to AltRight
1533 // key.
1534 FUNCTION = 0x00100000,
1535 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1538 * Utility method intended for testing. Dispatches native key events
1539 * to this widget to simulate the press and release of a key.
1540 * @param aNativeKeyboardLayout a *platform-specific* constant.
1541 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1542 * On Windows, it is converted to a hex string and passed to
1543 * LoadKeyboardLayout, see
1544 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1545 * @param aNativeKeyCode a *platform-specific* keycode.
1546 * On Windows, this is the virtual key code.
1547 * @param aModifiers some combination of the above 'Modifiers' flags;
1548 * not all flags will apply to all platforms. Mac ignores the _R
1549 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1550 * FUNCTION.
1551 * @param aCharacters characters that the OS would decide to generate
1552 * from the event. On Windows, this is the charCode passed by
1553 * WM_CHAR.
1554 * @param aUnmodifiedCharacters characters that the OS would decide
1555 * to generate from the event if modifier keys (other than shift)
1556 * were assumed inactive. Needed on Mac, ignored on Windows.
1557 * @param aObserver the observer that will get notified once the events
1558 * have been dispatched.
1559 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1560 * layout is not supported and the event was not fired
1562 virtual nsresult SynthesizeNativeKeyEvent(
1563 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1564 uint32_t aModifierFlags, const nsAString& aCharacters,
1565 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1568 * Utility method intended for testing. Dispatches native mouse events
1569 * may even move the mouse cursor. On Mac the events are guaranteed to
1570 * be sent to the window containing this widget, but on Windows they'll go
1571 * to whatever's topmost on the screen at that position, so for
1572 * cross-platform testing ensure that your window is at the top of the
1573 * z-order.
1574 * @param aPoint screen location of the mouse, in device
1575 * pixels, with origin at the top left
1576 * @param aNativeMessage *platform-specific* event type (e.g. on Mac,
1577 * NSEventTypeMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN
1578 * etc)
1579 * @param aModifierFlags *platform-specific* modifier flags (ignored
1580 * on Windows)
1581 * @param aObserver the observer that will get notified once the events
1582 * have been dispatched.
1584 virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
1585 uint32_t aNativeMessage,
1586 uint32_t aModifierFlags,
1587 nsIObserver* aObserver) = 0;
1590 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1591 * message. aPoint is location in device pixels to which the mouse pointer
1592 * moves to.
1593 * @param aObserver the observer that will get notified once the events
1594 * have been dispatched.
1596 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1597 nsIObserver* aObserver) = 0;
1600 * Utility method intended for testing. Dispatching native mouse scroll
1601 * events may move the mouse cursor.
1603 * @param aPoint Mouse cursor position in screen coordinates.
1604 * In device pixels, the origin at the top left of
1605 * the primary display.
1606 * @param aNativeMessage Platform native message.
1607 * @param aDeltaX The delta value for X direction. If the native
1608 * message doesn't indicate X direction scrolling,
1609 * this may be ignored.
1610 * @param aDeltaY The delta value for Y direction. If the native
1611 * message doesn't indicate Y direction scrolling,
1612 * this may be ignored.
1613 * @param aDeltaZ The delta value for Z direction. If the native
1614 * message doesn't indicate Z direction scrolling,
1615 * this may be ignored.
1616 * @param aModifierFlags Must be values of Modifiers, or zero.
1617 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1618 * document.
1619 * @param aObserver The observer that will get notified once the
1620 * events have been dispatched.
1622 virtual nsresult SynthesizeNativeMouseScrollEvent(
1623 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1624 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1625 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1628 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1629 * touch states in nsIDOMWindowUtils.idl.
1631 enum TouchPointerState {
1632 // The pointer is in a hover state above the digitizer
1633 TOUCH_HOVER = (1 << 0),
1634 // The pointer is in contact with the digitizer
1635 TOUCH_CONTACT = (1 << 1),
1636 // The pointer has been removed from the digitizer detection area
1637 TOUCH_REMOVE = (1 << 2),
1638 // The pointer has been canceled. Will cancel any pending os level
1639 // gestures that would triggered as a result of completion of the
1640 // input sequence. This may not cancel moz platform related events
1641 // that might get tirggered by input already delivered.
1642 TOUCH_CANCEL = (1 << 3),
1644 // ALL_BITS used for validity checking during IPC serialization
1645 ALL_BITS = (1 << 4) - 1
1648 * TouchpadPinchPhase states for SynthesizeNativeTouchPadPinch. Match
1649 * Phase states in nsIDOMWindowUtils.idl.
1651 enum TouchpadPinchPhase { PHASE_BEGIN = 0, PHASE_UPDATE = 1, PHASE_END = 2 };
1653 * Create a new or update an existing touch pointer on the digitizer.
1654 * To trigger os level gestures, individual touch points should
1655 * transition through a complete set of touch states which should be
1656 * sent as individual messages.
1658 * @param aPointerId The touch point id to create or update.
1659 * @param aPointerState one or more of the touch states listed above
1660 * @param aPoint coords of this event
1661 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1662 * @param aOrientation 0 -> 359 degree value indicating the
1663 * orientation of the pointer. Use 90 for normal taps.
1664 * @param aObserver The observer that will get notified once the events
1665 * have been dispatched.
1667 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1668 TouchPointerState aPointerState,
1669 LayoutDeviceIntPoint aPoint,
1670 double aPointerPressure,
1671 uint32_t aPointerOrientation,
1672 nsIObserver* aObserver) = 0;
1674 * See nsIDOMWindowUtils.sendNativeTouchpadPinch().
1676 virtual nsresult SynthesizeNativeTouchPadPinch(TouchpadPinchPhase aEventPhase,
1677 float aScale,
1678 LayoutDeviceIntPoint aPoint,
1679 int32_t aModifierFlags) = 0;
1682 * Helper for simulating a simple tap event with one touch point. When
1683 * aLongTap is true, simulates a native long tap with a duration equal to
1684 * ui.click_hold_context_menus.delay. This pref is compatible with the
1685 * apzc long tap duration. Defaults to 1.5 seconds.
1686 * @param aObserver The observer that will get notified once the events
1687 * have been dispatched.
1689 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1690 bool aLongTap,
1691 nsIObserver* aObserver);
1694 * Cancels all active simulated touch input points and pending long taps.
1695 * Native widgets should track existing points such that they can clear the
1696 * digitizer state when this call is made.
1697 * @param aObserver The observer that will get notified once the touch
1698 * sequence has been cleared.
1700 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1702 virtual void StartAsyncScrollbarDrag(
1703 const AsyncDragMetrics& aDragMetrics) = 0;
1706 * Notify APZ to start autoscrolling.
1707 * @param aAnchorLocation the location of the autoscroll anchor
1708 * @param aGuid identifies the scroll frame to be autoscrolled
1709 * @return true if APZ has been successfully notified
1711 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1712 const ScrollableLayerGuid& aGuid) = 0;
1715 * Notify APZ to stop autoscrolling.
1716 * @param aGuid identifies the scroll frame which is being autoscrolled.
1718 virtual void StopAsyncAutoscroll(const ScrollableLayerGuid& aGuid) = 0;
1720 // If this widget supports out-of-process compositing, it can override
1721 // this method to provide additional information to the compositor.
1722 virtual void GetCompositorWidgetInitData(
1723 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1726 * Setter/Getter of the system font setting for testing.
1728 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1729 return NS_ERROR_NOT_IMPLEMENTED;
1731 virtual nsresult GetSystemFont(nsCString& aFontName) {
1732 return NS_ERROR_NOT_IMPLEMENTED;
1735 // Get rectangle of the screen where the window is placed.
1736 // It's used to detect popup overflow under Wayland because
1737 // Screenmanager does not work under it.
1738 #ifdef MOZ_WAYLAND
1739 virtual nsresult GetScreenRect(LayoutDeviceIntRect* aRect) {
1740 return NS_ERROR_NOT_IMPLEMENTED;
1742 virtual nsRect GetPreferredPopupRect() {
1743 NS_WARNING("GetPreferredPopupRect implemented only for wayland");
1744 return nsRect(0, 0, 0, 0);
1746 virtual void FlushPreferredPopupRect() {
1747 NS_WARNING("FlushPreferredPopupRect implemented only for wayland");
1748 return;
1751 #endif
1754 * Get safe area insets except to cutout.
1755 * See https://drafts.csswg.org/css-env-1/#safe-area-insets.
1757 virtual mozilla::ScreenIntMargin GetSafeAreaInsets() const {
1758 return mozilla::ScreenIntMargin();
1761 private:
1762 class LongTapInfo {
1763 public:
1764 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1765 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1766 : mPointerId(aPointerId),
1767 mPosition(aPoint),
1768 mDuration(aDuration),
1769 mObserver(aObserver),
1770 mStamp(mozilla::TimeStamp::Now()) {}
1772 int32_t mPointerId;
1773 LayoutDeviceIntPoint mPosition;
1774 mozilla::TimeDuration mDuration;
1775 nsCOMPtr<nsIObserver> mObserver;
1776 mozilla::TimeStamp mStamp;
1779 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1781 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1782 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1784 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1785 nsCOMPtr<nsITimer> mLongTapTimer;
1786 static int32_t sPointerIdCounter;
1788 public:
1790 * If key events have not been handled by content or XBL handlers, they can
1791 * be offered to the system (for custom application shortcuts set in system
1792 * preferences, for example).
1794 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1797 * Activates a native menu item at the position specified by the index
1798 * string. The index string is a string of positive integers separated
1799 * by the "|" (pipe) character. The last integer in the string represents
1800 * the item index in a submenu located using the integers preceding it.
1802 * Example: 1|0|4
1803 * In this string, the first integer represents the top-level submenu
1804 * in the native menu bar. Since the integer is 1, it is the second submeu
1805 * in the native menu bar. Within that, the first item (index 0) is a
1806 * submenu, and we want to activate the 5th item within that submenu.
1808 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1811 * This is used for native menu system testing.
1813 * Updates a native menu at the position specified by the index string.
1814 * The index string is a string of positive integers separated by the "|"
1815 * (pipe) character.
1817 * Example: 1|0|4
1818 * In this string, the first integer represents the top-level submenu
1819 * in the native menu bar. Since the integer is 1, it is the second submeu
1820 * in the native menu bar. Within that, the first item (index 0) is a
1821 * submenu, and we want to update submenu at index 4 within that submenu.
1823 * If this is called with an empty string it forces a full reload of the
1824 * menu system.
1826 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1829 * This is used for testing macOS service menu code.
1831 * @param aResult - the current text selection. Is empty if no selection.
1832 * @return nsresult - whether or not aResult was assigned the selected text.
1834 [[nodiscard]] virtual nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1835 return NS_ERROR_NOT_IMPLEMENTED;
1839 * Notify IME of the specified notification.
1841 * @return If the notification is mouse button event and it's consumed by
1842 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1844 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1847 * MaybeDispatchInitialFocusEvent will dispatch a focus event after creation
1848 * of the widget, in the event that we were not able to observe and respond to
1849 * the initial focus event. This is necessary for the early skeleton UI
1850 * window, which is displayed and receives its initial focus event before we
1851 * can actually respond to it.
1853 virtual void MaybeDispatchInitialFocusEvent() {}
1856 * Notifies the input context changes.
1858 virtual void SetInputContext(const InputContext& aContext,
1859 const InputContextAction& aAction) = 0;
1862 * Get current input context.
1864 virtual InputContext GetInputContext() = 0;
1867 * Get native IME context. This is different from GetNativeData() with
1868 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1869 * process.
1871 virtual NativeIMEContext GetNativeIMEContext() = 0;
1874 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1875 * native (OS-level) event for it. This method allows tests to simulate
1876 * keystrokes that trigger native key bindings (which require a native
1877 * event).
1879 [[nodiscard]] virtual nsresult AttachNativeKeyEvent(
1880 mozilla::WidgetKeyboardEvent& aEvent) = 0;
1883 * Retrieve edit commands when the key combination of aEvent is used
1884 * in platform native applications.
1886 enum NativeKeyBindingsType : uint8_t {
1887 NativeKeyBindingsForSingleLineEditor,
1888 NativeKeyBindingsForMultiLineEditor,
1889 NativeKeyBindingsForRichTextEditor
1891 MOZ_CAN_RUN_SCRIPT virtual bool GetEditCommands(
1892 NativeKeyBindingsType aType, const mozilla::WidgetKeyboardEvent& aEvent,
1893 nsTArray<mozilla::CommandInt>& aCommands);
1896 * Retrieves a reference to notification requests of IME. Note that the
1897 * reference is valid while the nsIWidget instance is alive. So, if you
1898 * need to store the reference for a long time, you need to grab the widget
1899 * instance too.
1901 const IMENotificationRequests& IMENotificationRequestsRef();
1904 * Call this method when a dialog is opened which has a default button.
1905 * The button's rectangle should be supplied in aButtonRect.
1907 [[nodiscard]] virtual nsresult OnDefaultButtonLoaded(
1908 const LayoutDeviceIntRect& aButtonRect) = 0;
1911 * Return true if this process shouldn't use platform widgets, and
1912 * so should use PuppetWidgets instead. If this returns true, the
1913 * result of creating and using a platform widget is undefined,
1914 * and likely to end in crashes or other buggy behavior.
1916 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1918 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1920 static already_AddRefed<nsIWidget> CreateChildWindow();
1923 * Allocate and return a "puppet widget" that doesn't directly
1924 * correlate to a platform widget; platform events and data must
1925 * be fed to it. Currently used in content processes. NULL is
1926 * returned if puppet widgets aren't supported in this build
1927 * config, on this platform, or for this process type.
1929 * This function is called "Create" to match CreateInstance().
1930 * The returned widget must still be nsIWidget::Create()d.
1932 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1933 BrowserChild* aBrowserChild);
1935 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1938 * Allocate and return a "plugin proxy widget", a subclass of PuppetWidget
1939 * used in wrapping a PPluginWidget connection for remote widgets. Note
1940 * this call creates the base object, it does not create the widget. Use
1941 * nsIWidget's Create to do this.
1943 static already_AddRefed<nsIWidget> CreatePluginProxyWidget(
1944 BrowserChild* aBrowserChild, mozilla::plugins::PluginWidgetChild* aActor);
1947 * Reparent this widget's native widget.
1948 * @param aNewParent the native widget of aNewParent is the new native
1949 * parent widget
1951 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1954 * Return true if widget has it's own GL context
1956 virtual bool HasGLContext() { return false; }
1959 * Returns true to indicate that this widget paints an opaque background
1960 * that we want to be visible under the page, so layout should not force
1961 * a default background.
1963 virtual bool WidgetPaintsBackground() { return false; }
1965 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1968 * Get the natural bounds of this widget. This method is only
1969 * meaningful for widgets for which Gecko implements screen
1970 * rotation natively. When this is the case, GetBounds() returns
1971 * the widget bounds taking rotation into account, and
1972 * GetNaturalBounds() returns the bounds *not* taking rotation
1973 * into account.
1975 * No code outside of the composition pipeline should know or care
1976 * about this. If you're not an agent of the compositor, you
1977 * probably shouldn't call this method.
1979 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1982 * Set size constraints on the window size such that it is never less than
1983 * the specified minimum size and never larger than the specified maximum
1984 * size. The size constraints are sizes of the outer rectangle including
1985 * the window frame and title bar. Use 0 for an unconstrained minimum size
1986 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1987 * does not necessarily change the size of a window to conform to this size,
1988 * thus Resize should be called afterwards.
1990 * @param aConstraints: the size constraints in device pixels
1992 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1995 * Return the size constraints currently observed by the widget.
1997 * @return the constraints in device pixels
1999 virtual const SizeConstraints GetSizeConstraints() = 0;
2002 * If this is owned by a BrowserChild, return that. Otherwise return
2003 * null.
2005 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
2008 * If this isn't directly compositing to its window surface,
2009 * return the compositor which is doing that on our behalf.
2011 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
2014 * Clear WebRender resources
2016 virtual void ClearCachedWebrenderResources() {}
2019 * If this widget has its own vsync source, return it, otherwise return
2020 * nullptr. An example of such local source would be Wayland frame callbacks.
2022 virtual RefPtr<mozilla::gfx::VsyncSource> GetVsyncSource() { return nullptr; }
2025 * Returns true if the widget requires synchronous repaints on resize,
2026 * false otherwise.
2028 virtual bool SynchronouslyRepaintOnResize() { return true; }
2031 * Some platforms (only cocoa right now) round widget coordinates to the
2032 * nearest even pixels (see bug 892994), this function allows us to
2033 * determine how widget coordinates will be rounded.
2035 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2037 virtual void UpdateZoomConstraints(
2038 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2039 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2042 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2043 * widget. Note that this never returns nullptr.
2045 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2048 * GetNativeTextEventDispatcherListener() returns a
2049 * TextEventDispatcherListener instance which is used when the widget
2050 * instance handles native IME and/or keyboard events.
2052 virtual TextEventDispatcherListener*
2053 GetNativeTextEventDispatcherListener() = 0;
2055 virtual void ZoomToRect(const uint32_t& aPresShellId,
2056 const ScrollableLayerGuid::ViewID& aViewId,
2057 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2060 * LookUpDictionary shows the dictionary for the word around current point.
2062 * @param aText the word to look up dictiorary.
2063 * @param aFontRangeArray text decoration of aText
2064 * @param aIsVertical true if the word is vertical layout
2065 * @param aPoint top-left point of aText
2067 virtual void LookUpDictionary(
2068 const nsAString& aText,
2069 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2070 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2072 virtual void RequestFxrOutput() {
2073 MOZ_ASSERT(false, "This function should only execute in Windows");
2076 #if defined(MOZ_WIDGET_ANDROID)
2078 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2079 * thread.
2081 * @param aMessage message being sent to Android UI thread.
2083 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2086 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2087 * thread
2089 * @param aScrollOffset page scroll offset value in screen pixels.
2090 * @param aZoom current page zoom.
2092 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2093 const CSSToScreenScale& aZoom) = 0;
2096 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2097 * for android robocop tests.
2099 * @param aMem shared memory containing the frame buffer pixels.
2100 * @param aSize size of the buffer in screen pixels.
2102 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2103 const ScreenIntSize& aSize,
2104 bool aNeedsYFlip) = 0;
2106 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2107 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2108 return 0;
2110 #endif
2112 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2115 * Like GetDefaultScale, but taking into account only the system settings
2116 * and ignoring Gecko preferences.
2118 virtual double GetDefaultScaleInternal() { return 1.0; }
2120 protected:
2121 // keep the list of children. We also keep track of our siblings.
2122 // The ownership model is as follows: parent holds a strong ref to
2123 // the first element of the list, and each element holds a strong
2124 // ref to the next element in the list. The prevsibling and
2125 // lastchild pointers are weak, which is fine as long as they are
2126 // maintained properly.
2127 nsCOMPtr<nsIWidget> mFirstChild;
2128 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2129 nsCOMPtr<nsIWidget> mNextSibling;
2130 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2131 // When Destroy() is called, the sub class should set this true.
2132 bool mOnDestroyCalled;
2133 nsWindowType mWindowType;
2134 int32_t mZIndex;
2137 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2139 #endif // nsIWidget_h__