Bug 1610796 [wpt PR 21339] - Remove instances of 'whitelist' from trusted-types/...
[gecko.git] / widget / nsIWidget.h
blob03e6b574241bbdcf5aae350e040e4ac877758493
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 "mozilla/UniquePtr.h"
10 #include "nsISupports.h"
11 #include "nsColor.h"
12 #include "nsRect.h"
13 #include "nsString.h"
15 #include "nsCOMPtr.h"
16 #include "nsWidgetInitData.h"
17 #include "nsTArray.h"
18 #include "nsITheme.h"
19 #include "nsITimer.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"
34 #include "Units.h"
35 #include "mozilla/dom/BindingDeclarations.h"
37 // forward declarations
38 class nsIBidiKeyboard;
39 class nsIRollupListener;
40 class imgIContainer;
41 class nsIContent;
42 class ViewWrapper;
43 class nsIScreen;
44 class nsIRunnable;
45 class nsIKeyEventInPluginCallback;
47 namespace mozilla {
49 enum class StyleWindowShadow : uint8_t;
51 #if defined(MOZ_WIDGET_ANDROID)
52 namespace ipc {
53 class Shmem;
55 #endif // defined(MOZ_WIDGET_ANDROID)
56 namespace dom {
57 class BrowserChild;
58 } // namespace dom
59 namespace plugins {
60 class PluginWidgetChild;
61 } // namespace plugins
62 namespace layers {
63 class AsyncDragMetrics;
64 class Compositor;
65 class CompositorBridgeChild;
66 struct FrameMetrics;
67 class LayerManager;
68 class LayerManagerComposite;
69 class PLayerTransactionChild;
70 struct SLGuidAndRenderRoot;
71 class WebRenderBridgeChild;
72 } // namespace layers
73 namespace gfx {
74 class DrawTarget;
75 class SourceSurface;
76 } // namespace gfx
77 namespace widget {
78 class TextEventDispatcher;
79 class TextEventDispatcherListener;
80 class CompositorWidget;
81 class CompositorWidgetInitData;
82 } // namespace widget
83 namespace wr {
84 class DisplayListBuilder;
85 class IpcResourceUpdateQueue;
86 enum class RenderRoot : uint8_t;
87 } // namespace wr
88 } // namespace mozilla
90 /**
91 * Callback function that processes events.
93 * The argument is actually a subtype (subclass) of WidgetEvent which carries
94 * platform specific information about the event. Platform specific code
95 * knows how to deal with it.
97 * The return value determines whether or not the default action should take
98 * place.
100 typedef nsEventStatus (*EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
102 // Hide the native window system's real window type so as to avoid
103 // including native window system types and APIs. This is necessary
104 // to ensure cross-platform code.
105 typedef void* nsNativeWidget;
108 * Flags for the GetNativeData and SetNativeData functions
110 #define NS_NATIVE_WINDOW 0
111 #define NS_NATIVE_GRAPHIC 1
112 #define NS_NATIVE_TMP_WINDOW 2
113 #define NS_NATIVE_WIDGET 3
114 #define NS_NATIVE_DISPLAY 4
115 #define NS_NATIVE_REGION 5
116 #define NS_NATIVE_OFFSETX 6
117 #define NS_NATIVE_OFFSETY 7
118 #define NS_NATIVE_PLUGIN_PORT 8
119 #define NS_NATIVE_SCREEN 9
120 // The toplevel GtkWidget containing this nsIWidget:
121 #define NS_NATIVE_SHELLWIDGET 10
122 // Has to match to NPNVnetscapeWindow, and shareable across processes
123 // HWND on Windows and XID on X11
124 #define NS_NATIVE_SHAREABLE_WINDOW 11
125 #define NS_NATIVE_OPENGL_CONTEXT 12
126 // See RegisterPluginWindowForRemoteUpdates
127 #define NS_NATIVE_PLUGIN_ID 13
128 // This is available only with GetNativeData() in parent process. Anybody
129 // shouldn't access this pointer as a valid pointer since the result may be
130 // special value like NS_ONLY_ONE_NATIVE_IME_CONTEXT. So, the result is just
131 // an identifier of distinguishing a text composition is caused by which native
132 // IME context. Note that the result is only valid in the process. So,
133 // XP code should use nsIWidget::GetNativeIMEContext() instead of using this.
134 #define NS_RAW_NATIVE_IME_CONTEXT 14
135 #ifdef XP_MACOSX
136 # define NS_NATIVE_PLUGIN_PORT_QD 100
137 # define NS_NATIVE_PLUGIN_PORT_CG 101
138 #endif
139 #ifdef XP_WIN
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
146 #endif
147 #if defined(MOZ_WIDGET_GTK)
148 // set/get nsPluginNativeWindowGtk, e10s specific
149 # define NS_NATIVE_PLUGIN_OBJECT_PTR 104
150 # ifdef MOZ_X11
151 # define NS_NATIVE_COMPOSITOR_DISPLAY 105
152 # endif // MOZ_X11
153 # define NS_NATIVE_EGL_WINDOW 106
154 #endif
155 #ifdef MOZ_WIDGET_ANDROID
156 # define NS_JAVA_SURFACE 100
157 # define NS_PRESENTATION_WINDOW 101
158 # define NS_PRESENTATION_SURFACE 102
159 #endif
161 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
162 #define NS_IWIDGET_IID \
164 0x06396bf6, 0x2dd8, 0x45e5, { \
165 0xac, 0x45, 0x75, 0x26, 0x53, 0xb1, 0xc9, 0x80 \
170 * Transparency modes
173 enum nsTransparencyMode {
174 eTransparencyOpaque = 0, // Fully opaque
175 eTransparencyTransparent, // Parts of the window may be transparent
176 eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass
177 // effect applied
178 eTransparencyBorderlessGlass // As above, but without a border around the
179 // opaque areas when there would otherwise be
180 // one with eTransparencyGlass
181 // If you add to the end here, you must update the serialization code in
182 // WidgetMessageUtils.h
186 * Cursor types.
189 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
190 eCursor_standard,
191 ///(system is busy, usually rendered as a hourglass or watch)
192 eCursor_wait,
193 ///(Selecting something, usually rendered as an IBeam)
194 eCursor_select,
195 ///(can hyper-link, usually rendered as a human hand)
196 eCursor_hyperlink,
197 ///(north/south/west/east edge sizing)
198 eCursor_n_resize,
199 eCursor_s_resize,
200 eCursor_w_resize,
201 eCursor_e_resize,
202 ///(corner sizing)
203 eCursor_nw_resize,
204 eCursor_se_resize,
205 eCursor_ne_resize,
206 eCursor_sw_resize,
207 eCursor_crosshair,
208 eCursor_move,
209 eCursor_help,
210 eCursor_copy, // CSS3
211 eCursor_alias,
212 eCursor_context_menu,
213 eCursor_cell,
214 eCursor_grab,
215 eCursor_grabbing,
216 eCursor_spinning,
217 eCursor_zoom_in,
218 eCursor_zoom_out,
219 eCursor_not_allowed,
220 eCursor_col_resize,
221 eCursor_row_resize,
222 eCursor_no_drop,
223 eCursor_vertical_text,
224 eCursor_all_scroll,
225 eCursor_nesw_resize,
226 eCursor_nwse_resize,
227 eCursor_ns_resize,
228 eCursor_ew_resize,
229 eCursor_none,
230 // This one is used for array sizing, and so better be the last
231 // one in this list...
232 eCursorCount,
234 // ...except for this one.
235 eCursorInvalid = eCursorCount + 1
238 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
239 eZPlacementBottom = 0, // bottom of the window stack
240 eZPlacementBelow, // just below another widget
241 eZPlacementTop // top of the window stack
245 * Before the OS goes to sleep, this topic is notified.
247 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
250 * After the OS wakes up, this topic is notified.
252 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
255 * Before the OS suspends the current process, this topic is notified. Some
256 * OS will kill processes that are suspended instead of resuming them.
257 * For that reason this topic may be useful to safely close down resources.
259 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
262 * After the current process resumes from being suspended, this topic is
263 * notified.
265 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
268 * When an app(-shell) is activated by the OS, this topic is notified.
269 * Currently, this only happens on Mac OSX.
271 #define NS_WIDGET_MAC_APP_ACTIVATE_OBSERVER_TOPIC "mac_app_activate"
273 namespace mozilla {
274 namespace widget {
277 * Size constraints for setting the minimum and maximum size of a widget.
278 * Values are in device pixels.
280 struct SizeConstraints {
281 SizeConstraints() : mMaxSize(NS_MAXSIZE, NS_MAXSIZE) {}
283 SizeConstraints(mozilla::LayoutDeviceIntSize aMinSize,
284 mozilla::LayoutDeviceIntSize aMaxSize)
285 : mMinSize(aMinSize), mMaxSize(aMaxSize) {}
287 mozilla::LayoutDeviceIntSize mMinSize;
288 mozilla::LayoutDeviceIntSize mMaxSize;
291 struct AutoObserverNotifier {
292 AutoObserverNotifier(nsIObserver* aObserver, const char* aTopic)
293 : mObserver(aObserver), mTopic(aTopic) {}
295 void SkipNotification() { mObserver = nullptr; }
297 uint64_t SaveObserver() {
298 if (!mObserver) {
299 return 0;
301 uint64_t observerId = ++sObserverId;
302 sSavedObservers.Put(observerId, mObserver);
303 SkipNotification();
304 return observerId;
307 ~AutoObserverNotifier() {
308 if (mObserver) {
309 mObserver->Observe(nullptr, mTopic, nullptr);
313 static void NotifySavedObserver(const uint64_t& aObserverId,
314 const char* aTopic) {
315 nsCOMPtr<nsIObserver> observer = sSavedObservers.Get(aObserverId);
316 if (!observer) {
317 MOZ_ASSERT(aObserverId == 0,
318 "We should always find a saved observer for nonzero IDs");
319 return;
322 sSavedObservers.Remove(aObserverId);
323 observer->Observe(nullptr, aTopic, nullptr);
326 private:
327 nsCOMPtr<nsIObserver> mObserver;
328 const char* mTopic;
330 private:
331 static uint64_t sObserverId;
332 static nsDataHashtable<nsUint64HashKey, nsCOMPtr<nsIObserver>>
333 sSavedObservers;
336 } // namespace widget
337 } // namespace mozilla
340 * The base class for all the widgets. It provides the interface for
341 * all basic and necessary functionality.
343 class nsIWidget : public nsISupports {
344 protected:
345 typedef mozilla::dom::BrowserChild BrowserChild;
347 public:
348 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
349 typedef mozilla::layers::AsyncDragMetrics AsyncDragMetrics;
350 typedef mozilla::layers::FrameMetrics FrameMetrics;
351 typedef mozilla::layers::LayerManager LayerManager;
352 typedef mozilla::layers::LayerManagerComposite LayerManagerComposite;
353 typedef mozilla::layers::LayersBackend LayersBackend;
354 typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild;
355 typedef mozilla::layers::SLGuidAndRenderRoot SLGuidAndRenderRoot;
356 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
357 typedef mozilla::layers::ZoomConstraints ZoomConstraints;
358 typedef mozilla::widget::IMEMessage IMEMessage;
359 typedef mozilla::widget::IMENotification IMENotification;
360 typedef mozilla::widget::IMENotificationRequests IMENotificationRequests;
361 typedef mozilla::widget::IMEState IMEState;
362 typedef mozilla::widget::InputContext InputContext;
363 typedef mozilla::widget::InputContextAction InputContextAction;
364 typedef mozilla::widget::NativeIMEContext NativeIMEContext;
365 typedef mozilla::widget::SizeConstraints SizeConstraints;
366 typedef mozilla::widget::TextEventDispatcher TextEventDispatcher;
367 typedef mozilla::widget::TextEventDispatcherListener
368 TextEventDispatcherListener;
369 typedef mozilla::LayoutDeviceIntMargin LayoutDeviceIntMargin;
370 typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
371 typedef mozilla::LayoutDeviceIntRect LayoutDeviceIntRect;
372 typedef mozilla::LayoutDeviceIntRegion LayoutDeviceIntRegion;
373 typedef mozilla::LayoutDeviceIntSize LayoutDeviceIntSize;
374 typedef mozilla::ScreenIntPoint ScreenIntPoint;
375 typedef mozilla::ScreenIntSize ScreenIntSize;
376 typedef mozilla::ScreenPoint ScreenPoint;
377 typedef mozilla::CSSToScreenScale CSSToScreenScale;
378 typedef mozilla::DesktopIntRect DesktopIntRect;
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)
397 nsIWidget()
398 : mLastChild(nullptr),
399 mPrevSibling(nullptr),
400 mOnDestroyCalled(false),
401 mWindowType(eWindowType_child),
402 mZIndex(0)
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
421 * itself.
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 virtual MOZ_MUST_USE nsresult
440 Create(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
446 * widgets).
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 virtual MOZ_MUST_USE 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
470 * for |Create()|.
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.
511 //@{
512 virtual nsIWidgetListener* GetWidgetListener() = 0;
513 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
514 //@}
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.
525 * Otherwise, false.
527 bool Destroyed() const { return mOnDestroyCalled; }
530 * Reparent a widget
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
540 * top level window
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
580 * of the widget.
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 Gecko override of the system default scale, if any;
596 * returns <= 0.0 if the system scale should be used as-is.
597 * nsIWidget::GetDefaultScale() [above] takes this into account.
598 * It is exposed here so that code that wants to check for a
599 * default-scale override without having a widget on hand can
600 * easily access the same value.
601 * Note that any scale override is a browser-wide value, whereas
602 * the default GetDefaultScale value (when no override is present)
603 * may vary between widgets (or screens).
605 static double DefaultScaleOverride();
608 * Return the first child of this widget. Will return null if
609 * there are no children.
611 nsIWidget* GetFirstChild() const { return mFirstChild; }
614 * Return the last child of this widget. Will return null if
615 * there are no children.
617 nsIWidget* GetLastChild() const { return mLastChild; }
620 * Return the next sibling of this widget
622 nsIWidget* GetNextSibling() const { return mNextSibling; }
625 * Set the next sibling of this widget
627 void SetNextSibling(nsIWidget* aSibling) { mNextSibling = aSibling; }
630 * Return the previous sibling of this widget
632 nsIWidget* GetPrevSibling() const { return mPrevSibling; }
635 * Set the previous sibling of this widget
637 void SetPrevSibling(nsIWidget* aSibling) { mPrevSibling = aSibling; }
640 * Show or hide this widget
642 * @param aState true to show the Widget, false to hide it
645 virtual void Show(bool aState) = 0;
648 * Make the window modal.
650 virtual void SetModal(bool aModal) = 0;
653 * Make the non-modal window opened by modal window fake-modal, that will
654 * call SetFakeModal(false) on destroy on Cocoa.
656 virtual void SetFakeModal(bool aModal) { SetModal(aModal); }
659 * Are we app modal. Currently only implemented on Cocoa.
661 virtual bool IsRunningAppModal() { return false; }
664 * The maximum number of simultaneous touch contacts supported by the device.
665 * In the case of devices with multiple digitizers (e.g. multiple touch
666 * screens), the value will be the maximum of the set of maximum supported
667 * contacts by each individual digitizer.
669 virtual uint32_t GetMaxTouchPoints() const = 0;
672 * Returns whether the window is visible
675 virtual bool IsVisible() const = 0;
678 * Perform platform-dependent sanity check on a potential window position.
679 * This is guaranteed to work only for top-level windows.
681 * @param aAllowSlop: if true, allow the window to slop offscreen;
682 * the window should be partially visible. if false,
683 * force the entire window onscreen (or at least
684 * the upper-left corner, if it's too large).
685 * @param aX in: an x position expressed in screen coordinates.
686 * out: the x position constrained to fit on the screen(s).
687 * @param aY in: an y position expressed in screen coordinates.
688 * out: the y position constrained to fit on the screen(s).
691 virtual void ConstrainPosition(bool aAllowSlop, int32_t* aX, int32_t* aY) = 0;
694 * NOTE:
696 * For a top-level window widget, the "parent's coordinate system" is the
697 * "global" display pixel coordinate space, *not* device pixels (which
698 * may be inconsistent between multiple screens, at least in the Mac OS
699 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
700 * following Move and Resize widget APIs.
702 * The display-/device-pixel distinction becomes important for (at least)
703 * Mac OS X with Hi-DPI (retina) displays, and Windows when the UI scale
704 * factor is set to other than 100%.
706 * The Move and Resize methods take floating-point parameters, rather than
707 * integer ones. This is important when manipulating top-level widgets,
708 * where the coordinate system may not be an integral multiple of the
709 * device-pixel space.
713 * Move this widget.
715 * Coordinates refer to the top-left of the widget. For toplevel windows
716 * with decorations, this is the top-left of the titlebar and frame .
718 * @param aX the new x position expressed in the parent's coordinate system
719 * @param aY the new y position expressed in the parent's coordinate system
722 virtual void Move(double aX, double aY) = 0;
725 * Reposition this widget so that the client area has the given offset.
727 * @param aX the new x offset of the client area expressed as an
728 * offset from the origin of the client area of the parent
729 * widget (for root widgets and popup widgets it is in
730 * screen coordinates)
731 * @param aY the new y offset of the client area expressed as an
732 * offset from the origin of the client area of the parent
733 * widget (for root widgets and popup widgets it is in
734 * screen coordinates)
736 virtual void MoveClient(double aX, double aY) = 0;
739 * Resize this widget. Any size constraints set for the window by a
740 * previous call to SetSizeConstraints will be applied.
742 * @param aWidth the new width expressed in the parent's coordinate system
743 * @param aHeight the new height expressed in the parent's coordinate
744 * system
745 * @param aRepaint whether the widget should be repainted
747 virtual void Resize(double aWidth, double aHeight, bool aRepaint) = 0;
750 * Lock the aspect ratio of a Window
752 * @param aShouldLock bool
755 virtual void LockAspectRatio(bool aShouldLock){};
758 * Move or resize this widget. Any size constraints set for the window by
759 * a previous call to SetSizeConstraints will be applied.
761 * @param aX the new x position expressed in the parent's coordinate
762 * system
763 * @param aY the new y position expressed in the parent's coordinate
764 * system
765 * @param aWidth the new width expressed in the parent's coordinate system
766 * @param aHeight the new height expressed in the parent's coordinate
767 * system
768 * @param aRepaint whether the widget should be repainted if the size
769 * changes
772 virtual void Resize(double aX, double aY, double aWidth, double aHeight,
773 bool aRepaint) = 0;
775 virtual mozilla::Maybe<bool> IsResizingNativeWidget() {
776 return mozilla::Nothing();
780 * Resize the widget so that the inner client area has the given size.
782 * @param aWidth the new width of the client area.
783 * @param aHeight the new height of the client area.
784 * @param aRepaint whether the widget should be repainted
786 virtual void ResizeClient(double aWidth, double aHeight, bool aRepaint) = 0;
789 * Resize and reposition the widget so tht inner client area has the given
790 * offset and size.
792 * @param aX the new x offset of the client area expressed as an
793 * offset from the origin of the client area of the parent
794 * widget (for root widgets and popup widgets it is in
795 * screen coordinates)
796 * @param aY the new y offset of the client area expressed as an
797 * offset from the origin of the client area of the parent
798 * widget (for root widgets and popup widgets it is in
799 * screen coordinates)
800 * @param aWidth the new width of the client area.
801 * @param aHeight the new height of the client area.
802 * @param aRepaint whether the widget should be repainted
804 virtual void ResizeClient(double aX, double aY, double aWidth, double aHeight,
805 bool aRepaint) = 0;
808 * Sets the widget's z-index.
810 virtual void SetZIndex(int32_t aZIndex) = 0;
813 * Gets the widget's z-index.
815 int32_t GetZIndex() { return mZIndex; }
818 * Position this widget just behind the given widget. (Used to
819 * control z-order for top-level widgets. Get/SetZIndex by contrast
820 * control z-order for child widgets of other widgets.)
821 * @param aPlacement top, bottom, or below a widget
822 * (if top or bottom, param aWidget is ignored)
823 * @param aWidget widget to place this widget behind
824 * (only if aPlacement is eZPlacementBelow).
825 * null is equivalent to aPlacement of eZPlacementTop
826 * @param aActivate true to activate the widget after placing it
828 virtual void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
829 nsIWidget* aWidget, bool aActivate) = 0;
832 * Minimize, maximize or normalize the window size.
833 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
835 virtual void SetSizeMode(nsSizeMode aMode) = 0;
838 * Suppress animations that are applied to a window by OS.
840 virtual void SuppressAnimation(bool aSuppress) {}
843 * Return size mode (minimized, maximized, normalized).
844 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
846 virtual nsSizeMode SizeMode() = 0;
849 * Ask whether the window is tiled.
851 virtual bool IsTiled() const = 0;
854 * Ask wether the widget is fully occluded
856 virtual bool IsFullyOccluded() const = 0;
859 * Enable or disable this Widget
861 * @param aState true to enable the Widget, false to disable it.
863 virtual void Enable(bool aState) = 0;
866 * Ask whether the widget is enabled
868 virtual bool IsEnabled() const = 0;
871 * Whether we should request activation of this widget's toplevel window.
873 enum class Raise {
875 Yes,
879 * Request activation of this window or give focus to this widget.
881 virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) = 0;
884 * Get this widget's outside dimensions relative to its parent widget. For
885 * popup widgets the returned rect is in screen coordinates and not
886 * relative to its parent widget.
888 * @return the x, y, width and height of this widget.
890 virtual LayoutDeviceIntRect GetBounds() = 0;
893 * Get this widget's outside dimensions in device coordinates. This
894 * includes any title bar on the window.
896 * @return the x, y, width and height of this widget.
898 virtual LayoutDeviceIntRect GetScreenBounds() = 0;
901 * Similar to GetScreenBounds except that this function will always
902 * get the size when the widget is in the nsSizeMode_Normal size mode
903 * even if the current size mode is not nsSizeMode_Normal.
904 * This method will fail if the size mode is not nsSizeMode_Normal and
905 * the platform doesn't have the ability.
906 * This method will always succeed if the current size mode is
907 * nsSizeMode_Normal.
909 * @param aRect On return it holds the x, y, width and height of
910 * this widget.
912 virtual MOZ_MUST_USE nsresult
913 GetRestoredBounds(LayoutDeviceIntRect& aRect) = 0;
916 * Get this widget's client area bounds, if the window has a 3D border
917 * appearance this returns the area inside the border. The position is the
918 * position of the client area relative to the client area of the parent
919 * widget (for root widgets and popup widgets it is in screen coordinates).
921 * @return the x, y, width and height of the client area of this widget.
923 virtual LayoutDeviceIntRect GetClientBounds() = 0;
926 * Sets the non-client area dimensions of the window. Pass -1 to restore
927 * the system default frame size for that border. Pass zero to remove
928 * a border, or pass a specific value adjust a border. Units are in
929 * pixels. (DPI dependent)
931 * Platform notes:
932 * Windows: shrinking top non-client height will remove application
933 * icon and window title text. Glass desktops will refuse to set
934 * dimensions between zero and size < system default.
936 virtual nsresult SetNonClientMargins(LayoutDeviceIntMargin& aMargins) = 0;
939 * Get the client offset from the window origin.
941 * @return the x and y of the offset.
943 virtual LayoutDeviceIntPoint GetClientOffset() = 0;
946 * Equivalent to GetClientBounds but only returns the size.
948 virtual LayoutDeviceIntSize GetClientSize() {
949 // Depending on the backend, overloading this method may be useful if
950 // requesting the client offset is expensive.
951 return GetClientBounds().Size();
955 * Get the size of the bounds of this widget that will be visible when
956 * rendered.
958 * @return the width and height of the composition size of this widget.
960 virtual LayoutDeviceIntSize GetCompositionSize() {
961 return GetBounds().Size();
965 * Set the background color for this widget
967 * @param aColor the new background color
971 virtual void SetBackgroundColor(const nscolor& aColor) {}
974 * If a cursor type is currently cached locally for this widget, clear the
975 * cached cursor to force an update on the next SetCursor call.
978 virtual void ClearCachedCursor() = 0;
981 * Sets the cursor cursor for this widget.
983 * @param aDefaultCursor the default cursor to be set
984 * @param aCursorImage a custom cursor, maybe null.
985 * @param aX the X coordinate of the hotspot for aCursorImage (from left).
986 * @param aY the Y coordinate of the hotspot for aCursorImage (from top).
988 virtual void SetCursor(nsCursor aDefaultCursor, imgIContainer* aCursorImage,
989 uint32_t aHotspotX, uint32_t aHotspotY) = 0;
992 * Get the window type of this widget.
994 nsWindowType WindowType() { return mWindowType; }
997 * Determines if this widget is one of the three types of plugin widgets.
999 bool IsPlugin() {
1000 return mWindowType == eWindowType_plugin ||
1001 mWindowType == eWindowType_plugin_ipc_chrome ||
1002 mWindowType == eWindowType_plugin_ipc_content;
1006 * Set the transparency mode of the top-level window containing this widget.
1007 * So, e.g., if you call this on the widget for an IFRAME, the top level
1008 * browser window containing the IFRAME actually gets set. Be careful.
1010 * This can fail if the platform doesn't support
1011 * transparency/glass. By default widgets are not
1012 * transparent. This will also fail if the toplevel window is not
1013 * a Mozilla window, e.g., if the widget is in an embedded
1014 * context.
1016 * After transparency/glass has been enabled, the initial alpha channel
1017 * value for all pixels is 1, i.e., opaque.
1018 * If the window is resized then the alpha channel values for
1019 * all pixels are reset to 1.
1020 * Pixel RGB color values are already premultiplied with alpha channel values.
1022 virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
1025 * Get the transparency mode of the top-level window that contains this
1026 * widget.
1028 virtual nsTransparencyMode GetTransparencyMode() = 0;
1031 * This represents a command to set the bounds and clip region of
1032 * a child widget.
1034 struct Configuration {
1035 nsCOMPtr<nsIWidget> mChild;
1036 uintptr_t mWindowID; // e10s specific, the unique plugin port id
1037 bool mVisible; // e10s specific, widget visibility
1038 LayoutDeviceIntRect mBounds;
1039 nsTArray<LayoutDeviceIntRect> mClipRegion;
1043 * Sets the clip region of each mChild (which must actually be a child
1044 * of this widget) to the union of the pixel rects given in
1045 * mClipRegion, all relative to the top-left of the child
1046 * widget. Clip regions are not implemented on all platforms and only
1047 * need to actually work for children that are plugins.
1049 * Also sets the bounds of each child to mBounds.
1051 * This will invalidate areas of the children that have changed, but
1052 * does not need to invalidate any part of this widget.
1054 * Children should be moved in the order given; the array is
1055 * sorted so to minimize unnecessary invalidation if children are
1056 * moved in that order.
1058 virtual nsresult ConfigureChildren(
1059 const nsTArray<Configuration>& aConfigurations) = 0;
1060 virtual nsresult SetWindowClipRegion(
1061 const nsTArray<LayoutDeviceIntRect>& aRects,
1062 bool aIntersectWithExisting) = 0;
1065 * Appends to aRects the rectangles constituting this widget's clip
1066 * region. If this widget is not clipped, appends a single rectangle
1067 * (0, 0, bounds.width, bounds.height).
1069 virtual void GetWindowClipRegion(nsTArray<LayoutDeviceIntRect>* aRects) = 0;
1072 * Register or unregister native plugin widgets which receive Configuration
1073 * data from the content process via the compositor.
1075 * Lookups are used by the main thread via the compositor to lookup widgets
1076 * based on a unique window id. On Windows and Linux this is the
1077 * NS_NATIVE_PLUGIN_PORT (hwnd/XID). This tracking maintains a reference to
1078 * widgets held. Consumers are responsible for removing widgets from this
1079 * list.
1081 virtual void RegisterPluginWindowForRemoteUpdates() = 0;
1082 virtual void UnregisterPluginWindowForRemoteUpdates() = 0;
1083 static nsIWidget* LookupRegisteredPluginWindow(uintptr_t aWindowID);
1086 * Iterates across the list of registered plugin widgets and updates thier
1087 * visibility based on which plugins are included in the 'visible' list.
1089 * The compositor knows little about tabs, but it does know which plugin
1090 * widgets are currently included in the visible layer tree. It calls this
1091 * helper to hide widgets it knows nothing about.
1093 static void UpdateRegisteredPluginWindowVisibility(
1094 uintptr_t aOwnerWidget, nsTArray<uintptr_t>& aPluginIds);
1096 #if defined(XP_WIN)
1098 * Iterates over the list of registered plugins and for any that are owned
1099 * by aOwnerWidget and visible it takes a snapshot.
1101 * @param aOwnerWidget only captures visible widgets owned by this
1103 static void CaptureRegisteredPlugins(uintptr_t aOwnerWidget);
1106 * Take a scroll capture for this widget if possible.
1108 virtual void UpdateScrollCapture() = 0;
1111 * Creates an async ImageContainer to hold scroll capture images that can be
1112 * used if the plugin is hidden during scroll.
1113 * @return the async container ID of the created ImageContainer.
1115 virtual uint64_t CreateScrollCaptureContainer() = 0;
1116 #endif
1119 * Set the shadow style of the window.
1121 * Ignored on child widgets and on non-Mac platforms.
1123 virtual void SetWindowShadowStyle(mozilla::StyleWindowShadow aStyle) = 0;
1126 * Set the opacity of the window.
1127 * Values need to be between 0.0f (invisible) and 1.0f (fully opaque).
1129 * Ignored on child widgets and on non-Mac platforms.
1131 virtual void SetWindowOpacity(float aOpacity) {}
1134 * Set the transform of the window. Values are in device pixels,
1135 * the origin is the top left corner of the window.
1137 * Ignored on child widgets and on non-Mac platforms.
1139 virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) {}
1142 * Set whether the window should ignore mouse events or not.
1144 * This is only used on popup windows.
1146 virtual void SetWindowMouseTransparent(bool aIsTransparent) {}
1149 * On Mac OS X, this method shows or hides the pill button in the titlebar
1150 * that's used to collapse the toolbar.
1152 * Ignored on child widgets and on non-Mac platforms.
1154 virtual void SetShowsToolbarButton(bool aShow) = 0;
1157 * On Mac OS X Lion, this method shows or hides the full screen button in
1158 * the titlebar that handles native full screen mode.
1160 * Ignored on child widgets, non-Mac platforms, & pre-Lion Mac.
1162 virtual void SetShowsFullScreenButton(bool aShow) = 0;
1164 enum WindowAnimationType {
1165 eGenericWindowAnimation,
1166 eDocumentWindowAnimation
1170 * Sets the kind of top-level window animation this widget should have. On
1171 * Mac OS X, this causes a particular kind of animation to be shown when the
1172 * window is first made visible.
1174 * Ignored on child widgets and on non-Mac platforms.
1176 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1179 * Specifies whether the window title should be drawn even if the window
1180 * contents extend into the titlebar. Ignored on windows that don't draw
1181 * in the titlebar. Only implemented on OS X.
1183 virtual void SetDrawsTitle(bool aDrawTitle) {}
1186 * Indicates whether the widget should attempt to make titlebar controls
1187 * easier to see on dark titlebar backgrounds.
1189 virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) {}
1192 * Hide window chrome (borders, buttons) for this widget.
1195 virtual void HideWindowChrome(bool aShouldHide) = 0;
1197 enum FullscreenTransitionStage {
1198 eBeforeFullscreenToggle,
1199 eAfterFullscreenToggle
1203 * Prepares for fullscreen transition and returns whether the widget
1204 * supports fullscreen transition. If this method returns false,
1205 * PerformFullscreenTransition() must never be called. Otherwise,
1206 * caller should call that method twice with "before" and "after"
1207 * stages respectively in order. In the latter case, this method may
1208 * return some data via aData pointer. Caller must pass that data to
1209 * PerformFullscreenTransition() if any, and caller is responsible
1210 * for releasing that data.
1212 virtual bool PrepareForFullscreenTransition(nsISupports** aData) = 0;
1215 * Performs fullscreen transition. This method returns immediately,
1216 * and will post aCallback to the main thread when the transition
1217 * finishes.
1219 virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
1220 uint16_t aDuration,
1221 nsISupports* aData,
1222 nsIRunnable* aCallback) = 0;
1225 * Perform any actions needed after the fullscreen transition has ended.
1227 virtual void CleanupFullscreenTransition() = 0;
1230 * Return the screen the widget is in, or null if we don't know.
1232 virtual already_AddRefed<nsIScreen> GetWidgetScreen() = 0;
1235 * Put the toplevel window into or out of fullscreen mode.
1236 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1237 * if possible. (If not, it behaves as if aTargetScreen is null.)
1238 * If !aFullScreen, aTargetScreen is ignored.
1239 * aTargetScreen support is currently only implemented on Windows.
1241 * @return NS_OK if the widget is setup properly for fullscreen and
1242 * FullscreenChanged callback has been or will be called. If other
1243 * value is returned, the caller should continue the change itself.
1245 virtual nsresult MakeFullScreen(bool aFullScreen,
1246 nsIScreen* aTargetScreen = nullptr) = 0;
1249 * Same as MakeFullScreen, except that, on systems which natively
1250 * support fullscreen transition, calling this method explicitly
1251 * requests that behavior.
1252 * It is currently only supported on OS X 10.7+.
1254 virtual nsresult MakeFullScreenWithNativeTransition(
1255 bool aFullScreen, nsIScreen* aTargetScreen = nullptr) {
1256 return MakeFullScreen(aFullScreen, aTargetScreen);
1260 * Invalidate a specified rect for a widget so that it will be repainted
1261 * later.
1263 virtual void Invalidate(const LayoutDeviceIntRect& aRect) = 0;
1265 enum LayerManagerPersistence {
1266 LAYER_MANAGER_CURRENT = 0,
1267 LAYER_MANAGER_PERSISTENT
1271 * Return the widget's LayerManager. The layer tree for that
1272 * LayerManager is what gets rendered to the widget.
1274 inline LayerManager* GetLayerManager() {
1275 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE,
1276 LAYER_MANAGER_CURRENT);
1279 inline LayerManager* GetLayerManager(LayerManagerPersistence aPersistence) {
1280 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE,
1281 aPersistence);
1285 * Like GetLayerManager(), but prefers creating a layer manager of
1286 * type |aBackendHint| instead of what would normally be created.
1287 * LayersBackend::LAYERS_NONE means "no hint".
1289 virtual LayerManager* GetLayerManager(
1290 PLayerTransactionChild* aShadowManager, LayersBackend aBackendHint,
1291 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) = 0;
1294 * Called before each layer manager transaction to allow any preparation
1295 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1297 * Always called on the main thread.
1299 virtual void PrepareWindowEffects() = 0;
1302 * Called on the main thread at the end of WebRender display list building.
1304 virtual void AddWindowOverlayWebRenderCommands(
1305 mozilla::layers::WebRenderBridgeChild* aWrBridge,
1306 mozilla::wr::DisplayListBuilder& aBuilder,
1307 mozilla::wr::IpcResourceUpdateQueue& aResources) {}
1310 * Called when Gecko knows which themed widgets exist in this window.
1311 * The passed array contains an entry for every themed widget of the right
1312 * type (currently only StyleAppearance::Toolbar) within the window, except
1313 * for themed widgets which are transformed or have effects applied to them
1314 * (e.g. CSS opacity or filters).
1315 * This could sometimes be called during display list construction
1316 * outside of painting.
1317 * If called during painting, it will be called before we actually
1318 * paint anything.
1320 virtual void UpdateThemeGeometries(
1321 const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1324 * Informs the widget about the region of the window that is opaque.
1326 * @param aOpaqueRegion the region of the window that is opaque.
1328 virtual void UpdateOpaqueRegion(const LayoutDeviceIntRegion& aOpaqueRegion) {}
1331 * Informs the widget about the region of the window that is draggable.
1333 virtual void UpdateWindowDraggingRegion(
1334 const LayoutDeviceIntRegion& aRegion) {}
1337 * Tells the widget whether the given input block results in a swipe.
1338 * Should be called in response to a WidgetWheelEvent that has
1339 * mFlags.mCanTriggerSwipe set on it.
1341 virtual void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) {}
1344 * Internal methods
1347 //@{
1348 virtual void AddChild(nsIWidget* aChild) = 0;
1349 virtual void RemoveChild(nsIWidget* aChild) = 0;
1350 virtual void* GetNativeData(uint32_t aDataType) = 0;
1351 virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal) = 0;
1352 virtual void FreeNativeData(void* data, uint32_t aDataType) = 0; //~~~
1354 //@}
1357 * Set the widget's title.
1358 * Must be called after Create.
1360 * @param aTitle string displayed as the title of the widget
1362 virtual nsresult SetTitle(const nsAString& aTitle) = 0;
1365 * Set the widget's icon.
1366 * Must be called after Create.
1368 * @param aIconSpec string specifying the icon to use; convention is to
1369 * pass a resource: URL from which a platform-dependent
1370 * resource file name will be constructed
1372 virtual void SetIcon(const nsAString& aIconSpec) = 0;
1375 * Return this widget's origin in screen coordinates.
1377 * @return screen coordinates stored in the x,y members
1379 virtual LayoutDeviceIntPoint WidgetToScreenOffset() = 0;
1382 * The same as WidgetToScreenOffset(), except in the case of
1383 * PuppetWidget where this method omits the chrome offset.
1385 virtual LayoutDeviceIntPoint TopLevelWidgetToScreenOffset() {
1386 return WidgetToScreenOffset();
1390 * For a PuppetWidget, returns the transform from the coordinate
1391 * space of the PuppetWidget to the coordinate space of the
1392 * top-level native widget.
1394 * Identity transform in other cases.
1396 virtual mozilla::LayoutDeviceToLayoutDeviceMatrix4x4
1397 WidgetToTopLevelWidgetTransform() {
1398 return mozilla::LayoutDeviceToLayoutDeviceMatrix4x4();
1402 * Given the specified client size, return the corresponding window size,
1403 * which includes the area for the borders and titlebar. This method
1404 * should work even when the window is not yet visible.
1406 virtual LayoutDeviceIntSize ClientToWindowSize(
1407 const LayoutDeviceIntSize& aClientSize) = 0;
1410 * Dispatches an event to the widget
1412 virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
1413 nsEventStatus& aStatus) = 0;
1416 * Dispatches an event to APZ only.
1417 * No-op in the child process.
1419 virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
1422 * Dispatches an event that must be handled by APZ first, when APZ is
1423 * enabled. If invoked in the child process, it is forwarded to the
1424 * parent process synchronously.
1426 virtual nsEventStatus DispatchInputEvent(
1427 mozilla::WidgetInputEvent* aEvent) = 0;
1430 * Confirm an APZ-aware event target. This should be used when APZ will
1431 * not need a layers update to process the event.
1433 virtual void SetConfirmedTargetAPZC(
1434 uint64_t aInputBlockId,
1435 const nsTArray<SLGuidAndRenderRoot>& aTargets) const = 0;
1438 * Returns true if APZ is in use, false otherwise.
1440 virtual bool AsyncPanZoomEnabled() const = 0;
1443 * Enables the dropping of files to a widget.
1445 virtual void EnableDragDrop(bool aEnable) = 0;
1446 virtual nsresult AsyncEnableDragDrop(bool aEnable) = 0;
1449 * Enables/Disables system mouse capture.
1450 * @param aCapture true enables mouse capture, false disables mouse capture
1453 virtual void CaptureMouse(bool aCapture) = 0;
1456 * Classify the window for the window manager. Mostly for X11.
1458 virtual void SetWindowClass(const nsAString& xulWinType) = 0;
1461 * Enables/Disables system capture of any and all events that would cause a
1462 * popup to be rolled up. aListener should be set to a non-null value for
1463 * any popups that are not managed by the popup manager.
1464 * @param aDoCapture true enables capture, false disables capture
1467 virtual void CaptureRollupEvents(nsIRollupListener* aListener,
1468 bool aDoCapture) = 0;
1471 * Bring this window to the user's attention. This is intended to be a more
1472 * gentle notification than popping the window to the top or putting up an
1473 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1474 * the Mac. The notification should be suppressed if the window is already
1475 * in the foreground and should be dismissed when the user brings this window
1476 * to the foreground.
1477 * @param aCycleCount Maximum number of times to animate the window per system
1478 * conventions. If set to -1, cycles indefinitely until
1479 * window is brought into the foreground.
1481 virtual MOZ_MUST_USE nsresult GetAttention(int32_t aCycleCount) = 0;
1484 * Ask whether there user input events pending. All input events are
1485 * included, including those not targeted at this nsIwidget instance.
1487 virtual bool HasPendingInputEvent() = 0;
1490 * If set to true, the window will draw its contents into the titlebar
1491 * instead of below it.
1493 * Ignored on any platform that does not support it. Ignored by widgets that
1494 * do not represent windows.
1495 * May result in a resize event, so should only be called from places where
1496 * reflow and painting is allowed.
1498 * @param aState Whether drawing into the titlebar should be activated.
1500 virtual void SetDrawsInTitlebar(bool aState) = 0;
1503 * Determine whether the widget shows a resize widget. If it does,
1504 * aResizerRect returns the resizer's rect.
1506 * Returns false on any platform that does not support it.
1508 * @param aResizerRect The resizer's rect in device pixels.
1509 * @return Whether a resize widget is shown.
1511 virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0;
1514 * Begin a window resizing drag, based on the event passed in.
1516 virtual MOZ_MUST_USE nsresult BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
1517 int32_t aHorizontal,
1518 int32_t aVertical) = 0;
1520 enum Modifiers {
1521 CAPS_LOCK = 0x00000001, // when CapsLock is active
1522 NUM_LOCK = 0x00000002, // when NumLock is active
1523 SHIFT_L = 0x00000100,
1524 SHIFT_R = 0x00000200,
1525 CTRL_L = 0x00000400,
1526 CTRL_R = 0x00000800,
1527 ALT_L = 0x00001000, // includes Option
1528 ALT_R = 0x00002000,
1529 COMMAND_L = 0x00004000,
1530 COMMAND_R = 0x00008000,
1531 HELP = 0x00010000,
1532 ALTGRAPH = 0x00020000, // AltGr key on Windows. This emulates
1533 // AltRight key behavior of keyboard
1534 // layouts which maps AltGr to AltRight
1535 // key.
1536 FUNCTION = 0x00100000,
1537 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1540 * Utility method intended for testing. Dispatches native key events
1541 * to this widget to simulate the press and release of a key.
1542 * @param aNativeKeyboardLayout a *platform-specific* constant.
1543 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1544 * On Windows, it is converted to a hex string and passed to
1545 * LoadKeyboardLayout, see
1546 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1547 * @param aNativeKeyCode a *platform-specific* keycode.
1548 * On Windows, this is the virtual key code.
1549 * @param aModifiers some combination of the above 'Modifiers' flags;
1550 * not all flags will apply to all platforms. Mac ignores the _R
1551 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1552 * FUNCTION.
1553 * @param aCharacters characters that the OS would decide to generate
1554 * from the event. On Windows, this is the charCode passed by
1555 * WM_CHAR.
1556 * @param aUnmodifiedCharacters characters that the OS would decide
1557 * to generate from the event if modifier keys (other than shift)
1558 * were assumed inactive. Needed on Mac, ignored on Windows.
1559 * @param aObserver the observer that will get notified once the events
1560 * have been dispatched.
1561 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1562 * layout is not supported and the event was not fired
1564 virtual nsresult SynthesizeNativeKeyEvent(
1565 int32_t aNativeKeyboardLayout, int32_t aNativeKeyCode,
1566 uint32_t aModifierFlags, const nsAString& aCharacters,
1567 const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) = 0;
1570 * Utility method intended for testing. Dispatches native mouse events
1571 * may even move the mouse cursor. On Mac the events are guaranteed to
1572 * be sent to the window containing this widget, but on Windows they'll go
1573 * to whatever's topmost on the screen at that position, so for
1574 * cross-platform testing ensure that your window is at the top of the
1575 * z-order.
1576 * @param aPoint screen location of the mouse, in device
1577 * pixels, with origin at the top left
1578 * @param aNativeMessage *platform-specific* event type (e.g. on Mac,
1579 * NSMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN etc)
1580 * @param aModifierFlags *platform-specific* modifier flags (ignored
1581 * on Windows)
1582 * @param aObserver the observer that will get notified once the events
1583 * have been dispatched.
1585 virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
1586 uint32_t aNativeMessage,
1587 uint32_t aModifierFlags,
1588 nsIObserver* aObserver) = 0;
1591 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native
1592 * message. aPoint is location in device pixels to which the mouse pointer
1593 * moves to.
1594 * @param aObserver the observer that will get notified once the events
1595 * have been dispatched.
1597 virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
1598 nsIObserver* aObserver) = 0;
1601 * Utility method intended for testing. Dispatching native mouse scroll
1602 * events may move the mouse cursor.
1604 * @param aPoint Mouse cursor position in screen coordinates.
1605 * In device pixels, the origin at the top left of
1606 * the primary display.
1607 * @param aNativeMessage Platform native message.
1608 * @param aDeltaX The delta value for X direction. If the native
1609 * message doesn't indicate X direction scrolling,
1610 * this may be ignored.
1611 * @param aDeltaY The delta value for Y direction. If the native
1612 * message doesn't indicate Y direction scrolling,
1613 * this may be ignored.
1614 * @param aDeltaZ The delta value for Z direction. If the native
1615 * message doesn't indicate Z direction scrolling,
1616 * this may be ignored.
1617 * @param aModifierFlags Must be values of Modifiers, or zero.
1618 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1619 * document.
1620 * @param aObserver The observer that will get notified once the
1621 * events have been dispatched.
1623 virtual nsresult SynthesizeNativeMouseScrollEvent(
1624 LayoutDeviceIntPoint aPoint, uint32_t aNativeMessage, double aDeltaX,
1625 double aDeltaY, double aDeltaZ, uint32_t aModifierFlags,
1626 uint32_t aAdditionalFlags, nsIObserver* aObserver) = 0;
1629 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1630 * touch states in nsIDOMWindowUtils.idl.
1632 enum TouchPointerState {
1633 // The pointer is in a hover state above the digitizer
1634 TOUCH_HOVER = (1 << 0),
1635 // The pointer is in contact with the digitizer
1636 TOUCH_CONTACT = (1 << 1),
1637 // The pointer has been removed from the digitizer detection area
1638 TOUCH_REMOVE = (1 << 2),
1639 // The pointer has been canceled. Will cancel any pending os level
1640 // gestures that would triggered as a result of completion of the
1641 // input sequence. This may not cancel moz platform related events
1642 // that might get tirggered by input already delivered.
1643 TOUCH_CANCEL = (1 << 3),
1645 // ALL_BITS used for validity checking during IPC serialization
1646 ALL_BITS = (1 << 4) - 1
1650 * Create a new or update an existing touch pointer on the digitizer.
1651 * To trigger os level gestures, individual touch points should
1652 * transition through a complete set of touch states which should be
1653 * sent as individual messages.
1655 * @param aPointerId The touch point id to create or update.
1656 * @param aPointerState one or more of the touch states listed above
1657 * @param aPoint coords of this event
1658 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1659 * @param aOrientation 0 -> 359 degree value indicating the
1660 * orientation of the pointer. Use 90 for normal taps.
1661 * @param aObserver The observer that will get notified once the events
1662 * have been dispatched.
1664 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1665 TouchPointerState aPointerState,
1666 LayoutDeviceIntPoint aPoint,
1667 double aPointerPressure,
1668 uint32_t aPointerOrientation,
1669 nsIObserver* aObserver) = 0;
1672 * Helper for simulating a simple tap event with one touch point. When
1673 * aLongTap is true, simulates a native long tap with a duration equal to
1674 * ui.click_hold_context_menus.delay. This pref is compatible with the
1675 * apzc long tap duration. Defaults to 1.5 seconds.
1676 * @param aObserver The observer that will get notified once the events
1677 * have been dispatched.
1679 virtual nsresult SynthesizeNativeTouchTap(LayoutDeviceIntPoint aPoint,
1680 bool aLongTap,
1681 nsIObserver* aObserver);
1684 * Cancels all active simulated touch input points and pending long taps.
1685 * Native widgets should track existing points such that they can clear the
1686 * digitizer state when this call is made.
1687 * @param aObserver The observer that will get notified once the touch
1688 * sequence has been cleared.
1690 virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver);
1692 virtual void StartAsyncScrollbarDrag(
1693 const AsyncDragMetrics& aDragMetrics) = 0;
1696 * Notify APZ to start autoscrolling.
1697 * @param aAnchorLocation the location of the autoscroll anchor
1698 * @param aGuid identifies the scroll frame to be autoscrolled
1699 * @return true if APZ has been successfully notified
1701 virtual bool StartAsyncAutoscroll(const ScreenPoint& aAnchorLocation,
1702 const SLGuidAndRenderRoot& aGuid) = 0;
1705 * Notify APZ to stop autoscrolling.
1706 * @param aGuid identifies the scroll frame which is being autoscrolled.
1708 virtual void StopAsyncAutoscroll(const SLGuidAndRenderRoot& aGuid) = 0;
1710 // If this widget supports out-of-process compositing, it can override
1711 // this method to provide additional information to the compositor.
1712 virtual void GetCompositorWidgetInitData(
1713 mozilla::widget::CompositorWidgetInitData* aInitData) {}
1716 * Setter/Getter of the system font setting for testing.
1718 virtual nsresult SetSystemFont(const nsCString& aFontName) {
1719 return NS_ERROR_NOT_IMPLEMENTED;
1721 virtual nsresult GetSystemFont(nsCString& aFontName) {
1722 return NS_ERROR_NOT_IMPLEMENTED;
1725 virtual nsresult SetPrefersReducedMotionOverrideForTest(bool aValue) {
1726 return NS_ERROR_NOT_IMPLEMENTED;
1728 virtual nsresult ResetPrefersReducedMotionOverrideForTest() {
1729 return NS_ERROR_NOT_IMPLEMENTED;
1732 // Get rectangle of the screen where the window is placed.
1733 // It's used to detect popup overflow under Wayland because
1734 // Screenmanager does not work under it.
1735 #ifdef MOZ_WAYLAND
1736 virtual nsresult GetScreenRect(LayoutDeviceIntRect* aRect) {
1737 return NS_ERROR_NOT_IMPLEMENTED;
1739 #endif
1741 private:
1742 class LongTapInfo {
1743 public:
1744 LongTapInfo(int32_t aPointerId, LayoutDeviceIntPoint& aPoint,
1745 mozilla::TimeDuration aDuration, nsIObserver* aObserver)
1746 : mPointerId(aPointerId),
1747 mPosition(aPoint),
1748 mDuration(aDuration),
1749 mObserver(aObserver),
1750 mStamp(mozilla::TimeStamp::Now()) {}
1752 int32_t mPointerId;
1753 LayoutDeviceIntPoint mPosition;
1754 mozilla::TimeDuration mDuration;
1755 nsCOMPtr<nsIObserver> mObserver;
1756 mozilla::TimeStamp mStamp;
1759 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1761 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
1762 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();
1764 mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
1765 nsCOMPtr<nsITimer> mLongTapTimer;
1766 static int32_t sPointerIdCounter;
1768 public:
1770 * If key events have not been handled by content or XBL handlers, they can
1771 * be offered to the system (for custom application shortcuts set in system
1772 * preferences, for example).
1774 virtual void PostHandleKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
1777 * Activates a native menu item at the position specified by the index
1778 * string. The index string is a string of positive integers separated
1779 * by the "|" (pipe) character. The last integer in the string represents
1780 * the item index in a submenu located using the integers preceding it.
1782 * Example: 1|0|4
1783 * In this string, the first integer represents the top-level submenu
1784 * in the native menu bar. Since the integer is 1, it is the second submeu
1785 * in the native menu bar. Within that, the first item (index 0) is a
1786 * submenu, and we want to activate the 5th item within that submenu.
1788 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1791 * This is used for native menu system testing.
1793 * Updates a native menu at the position specified by the index string.
1794 * The index string is a string of positive integers separated by the "|"
1795 * (pipe) character.
1797 * Example: 1|0|4
1798 * In this string, the first integer represents the top-level submenu
1799 * in the native menu bar. Since the integer is 1, it is the second submeu
1800 * in the native menu bar. Within that, the first item (index 0) is a
1801 * submenu, and we want to update submenu at index 4 within that submenu.
1803 * If this is called with an empty string it forces a full reload of the
1804 * menu system.
1806 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1809 * This is used for testing macOS service menu code.
1811 * @param aResult - the current text selection. Is empty if no selection.
1812 * @return nsresult - whether or not aResult was assigned the selected text.
1814 virtual MOZ_MUST_USE nsresult GetSelectionAsPlaintext(nsAString& aResult) {
1815 return NS_ERROR_NOT_IMPLEMENTED;
1819 * Notify IME of the specified notification.
1821 * @return If the notification is mouse button event and it's consumed by
1822 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1824 virtual nsresult NotifyIME(const IMENotification& aIMENotification) = 0;
1827 * Start plugin IME. If this results in a string getting committed, the
1828 * result is in aCommitted (otherwise aCommitted is empty).
1830 * aKeyboardEvent The event with which plugin IME is to be started
1831 * panelX and panelY Location in screen coordinates of the IME input panel
1832 * (should be just under the plugin)
1833 * aCommitted The string committed during IME -- otherwise empty
1835 virtual MOZ_MUST_USE nsresult
1836 StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
1837 int32_t aPanelX, int32_t aPanelY, nsString& aCommitted) = 0;
1840 * Tells the widget whether or not a plugin (inside the widget) has the
1841 * keyboard focus. Should be sent when the keyboard focus changes too or
1842 * from a plugin.
1844 * aFocused Whether or not a plugin is focused
1846 virtual void SetPluginFocused(bool& aFocused) = 0;
1849 * Tell the plugin has focus. It is unnecessary to use IPC
1851 bool PluginHasFocus() {
1852 return GetInputContext().mIMEState.mEnabled == IMEState::PLUGIN;
1856 * Set IME candidate window position by windowless plugin.
1858 virtual void SetCandidateWindowForPlugin(
1859 const mozilla::widget::CandidateWindowPosition& aPosition) = 0;
1862 * Handle default action when PluginEvent isn't handled
1864 virtual void DefaultProcOfPluginEvent(
1865 const mozilla::WidgetPluginEvent& aEvent) = 0;
1868 * Enable or Disable IME by windowless plugin.
1870 virtual void EnableIMEForPlugin(bool aEnable) {}
1873 * Notifies the input context changes.
1875 virtual void SetInputContext(const InputContext& aContext,
1876 const InputContextAction& aAction) = 0;
1879 * Get current input context.
1881 virtual InputContext GetInputContext() = 0;
1884 * Get native IME context. This is different from GetNativeData() with
1885 * NS_RAW_NATIVE_IME_CONTEXT, the result is unique even if in a remote
1886 * process.
1888 virtual NativeIMEContext GetNativeIMEContext() = 0;
1891 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1892 * native (OS-level) event for it. This method allows tests to simulate
1893 * keystrokes that trigger native key bindings (which require a native
1894 * event).
1896 virtual MOZ_MUST_USE nsresult
1897 AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) = 0;
1900 * Retrieve edit commands when the key combination of aEvent is used
1901 * in platform native applications.
1903 enum NativeKeyBindingsType : uint8_t {
1904 NativeKeyBindingsForSingleLineEditor,
1905 NativeKeyBindingsForMultiLineEditor,
1906 NativeKeyBindingsForRichTextEditor
1908 virtual bool GetEditCommands(NativeKeyBindingsType aType,
1909 const mozilla::WidgetKeyboardEvent& aEvent,
1910 nsTArray<mozilla::CommandInt>& aCommands);
1913 * Retrieves a reference to notification requests of IME. Note that the
1914 * reference is valid while the nsIWidget instance is alive. So, if you
1915 * need to store the reference for a long time, you need to grab the widget
1916 * instance too.
1918 const IMENotificationRequests& IMENotificationRequestsRef();
1921 * Call this method when a dialog is opened which has a default button.
1922 * The button's rectangle should be supplied in aButtonRect.
1924 virtual MOZ_MUST_USE nsresult
1925 OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect) = 0;
1928 * Return true if this process shouldn't use platform widgets, and
1929 * so should use PuppetWidgets instead. If this returns true, the
1930 * result of creating and using a platform widget is undefined,
1931 * and likely to end in crashes or other buggy behavior.
1933 static bool UsePuppetWidgets() { return XRE_IsContentProcess(); }
1935 static already_AddRefed<nsIWidget> CreateTopLevelWindow();
1937 static already_AddRefed<nsIWidget> CreateChildWindow();
1940 * Allocate and return a "puppet widget" that doesn't directly
1941 * correlate to a platform widget; platform events and data must
1942 * be fed to it. Currently used in content processes. NULL is
1943 * returned if puppet widgets aren't supported in this build
1944 * config, on this platform, or for this process type.
1946 * This function is called "Create" to match CreateInstance().
1947 * The returned widget must still be nsIWidget::Create()d.
1949 static already_AddRefed<nsIWidget> CreatePuppetWidget(
1950 BrowserChild* aBrowserChild);
1952 static already_AddRefed<nsIWidget> CreateHeadlessWidget();
1955 * Allocate and return a "plugin proxy widget", a subclass of PuppetWidget
1956 * used in wrapping a PPluginWidget connection for remote widgets. Note
1957 * this call creates the base object, it does not create the widget. Use
1958 * nsIWidget's Create to do this.
1960 static already_AddRefed<nsIWidget> CreatePluginProxyWidget(
1961 BrowserChild* aBrowserChild, mozilla::plugins::PluginWidgetChild* aActor);
1964 * Reparent this widget's native widget.
1965 * @param aNewParent the native widget of aNewParent is the new native
1966 * parent widget
1968 virtual void ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1971 * Return true if widget has it's own GL context
1973 virtual bool HasGLContext() { return false; }
1976 * Returns true to indicate that this widget paints an opaque background
1977 * that we want to be visible under the page, so layout should not force
1978 * a default background.
1980 virtual bool WidgetPaintsBackground() { return false; }
1982 virtual bool NeedsPaint() { return IsVisible() && !GetBounds().IsEmpty(); }
1985 * Get the natural bounds of this widget. This method is only
1986 * meaningful for widgets for which Gecko implements screen
1987 * rotation natively. When this is the case, GetBounds() returns
1988 * the widget bounds taking rotation into account, and
1989 * GetNaturalBounds() returns the bounds *not* taking rotation
1990 * into account.
1992 * No code outside of the composition pipeline should know or care
1993 * about this. If you're not an agent of the compositor, you
1994 * probably shouldn't call this method.
1996 virtual LayoutDeviceIntRect GetNaturalBounds() { return GetBounds(); }
1999 * Set size constraints on the window size such that it is never less than
2000 * the specified minimum size and never larger than the specified maximum
2001 * size. The size constraints are sizes of the outer rectangle including
2002 * the window frame and title bar. Use 0 for an unconstrained minimum size
2003 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
2004 * does not necessarily change the size of a window to conform to this size,
2005 * thus Resize should be called afterwards.
2007 * @param aConstraints: the size constraints in device pixels
2009 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
2012 * Return the size constraints currently observed by the widget.
2014 * @return the constraints in device pixels
2016 virtual const SizeConstraints GetSizeConstraints() = 0;
2019 * If this is owned by a BrowserChild, return that. Otherwise return
2020 * null.
2022 virtual BrowserChild* GetOwningBrowserChild() { return nullptr; }
2025 * If this isn't directly compositing to its window surface,
2026 * return the compositor which is doing that on our behalf.
2028 virtual CompositorBridgeChild* GetRemoteRenderer() { return nullptr; }
2031 * If this widget has its own vsync source, return it, otherwise return
2032 * nullptr. An example of such local source would be Wayland frame callbacks.
2034 virtual RefPtr<mozilla::gfx::VsyncSource> GetVsyncSource() { return nullptr; }
2037 * Returns true if the widget requires synchronous repaints on resize,
2038 * false otherwise.
2040 virtual bool SynchronouslyRepaintOnResize() { return true; }
2043 * Some platforms (only cocoa right now) round widget coordinates to the
2044 * nearest even pixels (see bug 892994), this function allows us to
2045 * determine how widget coordinates will be rounded.
2047 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2049 virtual void UpdateZoomConstraints(
2050 const uint32_t& aPresShellId, const ScrollableLayerGuid::ViewID& aViewId,
2051 const mozilla::Maybe<ZoomConstraints>& aConstraints){};
2054 * GetTextEventDispatcher() returns TextEventDispatcher belonging to the
2055 * widget. Note that this never returns nullptr.
2057 virtual TextEventDispatcher* GetTextEventDispatcher() = 0;
2060 * GetNativeTextEventDispatcherListener() returns a
2061 * TextEventDispatcherListener instance which is used when the widget
2062 * instance handles native IME and/or keyboard events.
2064 virtual TextEventDispatcherListener*
2065 GetNativeTextEventDispatcherListener() = 0;
2067 virtual void ZoomToRect(const uint32_t& aPresShellId,
2068 const ScrollableLayerGuid::ViewID& aViewId,
2069 const CSSRect& aRect, const uint32_t& aFlags) = 0;
2072 * OnWindowedPluginKeyEvent() is called when native key event is
2073 * received in the focused plugin process directly in PluginInstanceChild.
2075 * @param aKeyEventData The native key event data. The actual type
2076 * copied into NativeEventData depends on the
2077 * caller. Please check PluginInstanceChild.
2078 * @param aCallback Callback interface. When this returns
2079 * NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY,
2080 * the event handler has to call this callback.
2081 * Otherwise, the caller should do that instead.
2082 * @return NS_ERROR_* if this fails to handle the event.
2083 * NS_SUCCESS_EVENT_CONSUMED if the key event is
2084 * consumed.
2085 * NS_OK if the key event isn't consumed.
2086 * NS_SUCCESS_EVENT_HANDLED_ASYNCHRONOUSLY if the
2087 * key event will be handled asynchronously.
2089 virtual nsresult OnWindowedPluginKeyEvent(
2090 const mozilla::NativeEventData& aKeyEventData,
2091 nsIKeyEventInPluginCallback* aCallback);
2094 * LookUpDictionary shows the dictionary for the word around current point.
2096 * @param aText the word to look up dictiorary.
2097 * @param aFontRangeArray text decoration of aText
2098 * @param aIsVertical true if the word is vertical layout
2099 * @param aPoint top-left point of aText
2101 virtual void LookUpDictionary(
2102 const nsAString& aText,
2103 const nsTArray<mozilla::FontRange>& aFontRangeArray,
2104 const bool aIsVertical, const LayoutDeviceIntPoint& aPoint) {}
2106 virtual void RequestFxrOutput() {
2107 MOZ_ASSERT(false, "This function should only execute in Windows");
2110 #if defined(MOZ_WIDGET_ANDROID)
2112 * RecvToolbarAnimatorMessageFromCompositor receive message from compositor
2113 * thread.
2115 * @param aMessage message being sent to Android UI thread.
2117 virtual void RecvToolbarAnimatorMessageFromCompositor(int32_t aMessage) = 0;
2120 * UpdateRootFrameMetrics steady state frame metrics send from compositor
2121 * thread
2123 * @param aScrollOffset page scroll offset value in screen pixels.
2124 * @param aZoom current page zoom.
2126 virtual void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset,
2127 const CSSToScreenScale& aZoom) = 0;
2130 * RecvScreenPixels Buffer containing the pixel from the frame buffer. Used
2131 * for android robocop tests.
2133 * @param aMem shared memory containing the frame buffer pixels.
2134 * @param aSize size of the buffer in screen pixels.
2136 virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem,
2137 const ScreenIntSize& aSize) = 0;
2139 virtual void UpdateDynamicToolbarMaxHeight(mozilla::ScreenIntCoord aHeight) {}
2140 virtual mozilla::ScreenIntCoord GetDynamicToolbarMaxHeight() const {
2141 return 0;
2143 #endif
2145 static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();
2147 protected:
2149 * Like GetDefaultScale, but taking into account only the system settings
2150 * and ignoring Gecko preferences.
2152 virtual double GetDefaultScaleInternal() { return 1.0; }
2154 // keep the list of children. We also keep track of our siblings.
2155 // The ownership model is as follows: parent holds a strong ref to
2156 // the first element of the list, and each element holds a strong
2157 // ref to the next element in the list. The prevsibling and
2158 // lastchild pointers are weak, which is fine as long as they are
2159 // maintained properly.
2160 nsCOMPtr<nsIWidget> mFirstChild;
2161 nsIWidget* MOZ_NON_OWNING_REF mLastChild;
2162 nsCOMPtr<nsIWidget> mNextSibling;
2163 nsIWidget* MOZ_NON_OWNING_REF mPrevSibling;
2164 // When Destroy() is called, the sub class should set this true.
2165 bool mOnDestroyCalled;
2166 nsWindowType mWindowType;
2167 int32_t mZIndex;
2170 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2172 #endif // nsIWidget_h__