Bug 798413 - Tests for export signature from MAR files. r=bsmith
[gecko.git] / widget / nsIWidget.h
blob4e80f57d5c26741788d15882e9ca36ab95a3c3a4
1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "nsISupports.h"
10 #include "nsColor.h"
11 #include "nsCoord.h"
12 #include "nsRect.h"
13 #include "nsPoint.h"
14 #include "nsStringGlue.h"
16 #include "prthread.h"
17 #include "nsEvent.h"
18 #include "nsCOMPtr.h"
19 #include "nsITheme.h"
20 #include "nsNativeWidget.h"
21 #include "nsWidgetInitData.h"
22 #include "nsTArray.h"
23 #include "nsXULAppAPI.h"
24 #include "LayersTypes.h"
26 // forward declarations
27 class nsFontMetrics;
28 class nsRenderingContext;
29 class nsDeviceContext;
30 struct nsFont;
31 class nsIRollupListener;
32 class nsGUIEvent;
33 class imgIContainer;
34 class gfxASurface;
35 class nsIContent;
36 class ViewWrapper;
37 class nsIWidgetListener;
38 class nsIntRegion;
40 namespace mozilla {
41 namespace dom {
42 class TabChild;
44 namespace layers {
45 class CompositorChild;
46 class LayerManager;
47 class PLayersChild;
51 /**
52 * Callback function that processes events.
54 * The argument is actually a subtype (subclass) of nsEvent which carries
55 * platform specific information about the event. Platform specific code
56 * knows how to deal with it.
58 * The return value determines whether or not the default action should take
59 * place.
61 typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
63 /**
64 * Flags for the getNativeData function.
65 * See getNativeData()
67 #define NS_NATIVE_WINDOW 0
68 #define NS_NATIVE_GRAPHIC 1
69 #define NS_NATIVE_TMP_WINDOW 2
70 #define NS_NATIVE_WIDGET 3
71 #define NS_NATIVE_DISPLAY 4
72 #define NS_NATIVE_REGION 5
73 #define NS_NATIVE_OFFSETX 6
74 #define NS_NATIVE_OFFSETY 7
75 #define NS_NATIVE_PLUGIN_PORT 8
76 #define NS_NATIVE_SCREEN 9
77 #define NS_NATIVE_SHELLWIDGET 10 // Get the shell GtkWidget
78 // Has to match to NPNVnetscapeWindow, and shareable across processes
79 // HWND on Windows and XID on X11
80 #define NS_NATIVE_SHAREABLE_WINDOW 11
81 #ifdef XP_MACOSX
82 #define NS_NATIVE_PLUGIN_PORT_QD 100
83 #define NS_NATIVE_PLUGIN_PORT_CG 101
84 #endif
85 #ifdef XP_WIN
86 #define NS_NATIVE_TSF_THREAD_MGR 100
87 #define NS_NATIVE_TSF_CATEGORY_MGR 101
88 #define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
89 #define NS_NATIVE_ICOREWINDOW 103 // winrt specific
90 #endif
92 #define NS_IWIDGET_IID \
93 { 0x4e05b167, 0x475b, 0x422b, \
94 { 0x88, 0xc0, 0xa5, 0xb1, 0x61, 0xcf, 0x87, 0x79 } }
97 * Window shadow styles
98 * Also used for the -moz-window-shadow CSS property
101 #define NS_STYLE_WINDOW_SHADOW_NONE 0
102 #define NS_STYLE_WINDOW_SHADOW_DEFAULT 1
103 #define NS_STYLE_WINDOW_SHADOW_MENU 2
104 #define NS_STYLE_WINDOW_SHADOW_TOOLTIP 3
105 #define NS_STYLE_WINDOW_SHADOW_SHEET 4
108 * Cursor types.
111 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
112 eCursor_standard,
113 ///(system is busy, usually rendered as a hourglass or watch)
114 eCursor_wait,
115 ///(Selecting something, usually rendered as an IBeam)
116 eCursor_select,
117 ///(can hyper-link, usually rendered as a human hand)
118 eCursor_hyperlink,
119 ///(north/south/west/east edge sizing)
120 eCursor_n_resize,
121 eCursor_s_resize,
122 eCursor_w_resize,
123 eCursor_e_resize,
124 ///(corner sizing)
125 eCursor_nw_resize,
126 eCursor_se_resize,
127 eCursor_ne_resize,
128 eCursor_sw_resize,
129 eCursor_crosshair,
130 eCursor_move,
131 eCursor_help,
132 eCursor_copy, // CSS3
133 eCursor_alias,
134 eCursor_context_menu,
135 eCursor_cell,
136 eCursor_grab,
137 eCursor_grabbing,
138 eCursor_spinning,
139 eCursor_zoom_in,
140 eCursor_zoom_out,
141 eCursor_not_allowed,
142 eCursor_col_resize,
143 eCursor_row_resize,
144 eCursor_no_drop,
145 eCursor_vertical_text,
146 eCursor_all_scroll,
147 eCursor_nesw_resize,
148 eCursor_nwse_resize,
149 eCursor_ns_resize,
150 eCursor_ew_resize,
151 eCursor_none,
152 // This one better be the last one in this list.
153 eCursorCount
156 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
157 eZPlacementBottom = 0, // bottom of the window stack
158 eZPlacementBelow, // just below another widget
159 eZPlacementTop // top of the window stack
163 * Preference for receiving IME updates
165 * If mWantUpdates is true, PuppetWidget will forward
166 * nsIWidget::OnIMETextChange and nsIWidget::OnIMESelectionChange to the chrome
167 * process. This incurs overhead from observers and IPDL. If the IME
168 * implementation on a particular platform doesn't care about OnIMETextChange
169 * and OnIMESelectionChange from content processes, they should set
170 * mWantUpdates to false to avoid these overheads.
172 * If mWantHints is true, PuppetWidget will forward the content of text fields
173 * to the chrome process to be cached. This way we return the cached content
174 * during query events. (see comments in bug 583976). This only makes sense
175 * for IME implementations that do use query events, otherwise there's a
176 * significant overhead. Platforms that don't use query events should set
177 * mWantHints to false.
179 struct nsIMEUpdatePreference {
181 nsIMEUpdatePreference()
182 : mWantUpdates(false), mWantHints(false)
185 nsIMEUpdatePreference(bool aWantUpdates, bool aWantHints)
186 : mWantUpdates(aWantUpdates), mWantHints(aWantHints)
189 bool mWantUpdates;
190 bool mWantHints;
195 * Contains IMEStatus plus information about the current
196 * input context that the IME can use as hints if desired.
199 namespace mozilla {
200 namespace widget {
202 struct IMEState {
204 * IME enabled states, the mEnabled value of
205 * SetInputContext()/GetInputContext() should be one value of following
206 * values.
208 * WARNING: If you change these values, you also need to edit:
209 * nsIDOMWindowUtils.idl
210 * nsContentUtils::GetWidgetStatusFromIMEStatus
212 enum Enabled {
214 * 'Disabled' means the user cannot use IME. So, the IME open state should
215 * be 'closed' during 'disabled'.
217 DISABLED,
219 * 'Enabled' means the user can use IME.
221 ENABLED,
223 * 'Password' state is a special case for the password editors.
224 * E.g., on mac, the password editors should disable the non-Roman
225 * keyboard layouts at getting focus. Thus, the password editor may have
226 * special rules on some platforms.
228 PASSWORD,
230 * This state is used when a plugin is focused.
231 * When a plug-in is focused content, we should send native events
232 * directly. Because we don't process some native events, but they may
233 * be needed by the plug-in.
235 PLUGIN
237 Enabled mEnabled;
240 * IME open states the mOpen value of SetInputContext() should be one value of
241 * OPEN, CLOSE or DONT_CHANGE_OPEN_STATE. GetInputContext() should return
242 * OPEN, CLOSE or OPEN_STATE_NOT_SUPPORTED.
244 enum Open {
246 * 'Unsupported' means the platform cannot return actual IME open state.
247 * This value is used only by GetInputContext().
249 OPEN_STATE_NOT_SUPPORTED,
251 * 'Don't change' means the widget shouldn't change IME open state when
252 * SetInputContext() is called.
254 DONT_CHANGE_OPEN_STATE = OPEN_STATE_NOT_SUPPORTED,
256 * 'Open' means that IME should compose in its primary language (or latest
257 * input mode except direct ASCII character input mode). Even if IME is
258 * opened by this value, users should be able to close IME by theirselves.
259 * Web contents can specify this value by |ime-mode: active;|.
261 OPEN,
263 * 'Closed' means that IME shouldn't handle key events (or should handle
264 * as ASCII character inputs on mobile device). Even if IME is closed by
265 * this value, users should be able to open IME by theirselves.
266 * Web contents can specify this value by |ime-mode: inactive;|.
268 CLOSED
270 Open mOpen;
272 IMEState() : mEnabled(ENABLED), mOpen(DONT_CHANGE_OPEN_STATE) { }
274 IMEState(Enabled aEnabled, Open aOpen = DONT_CHANGE_OPEN_STATE) :
275 mEnabled(aEnabled), mOpen(aOpen)
280 struct InputContext {
281 IMEState mIMEState;
283 /* The type of the input if the input is a html input field */
284 nsString mHTMLInputType;
286 /* The type of the inputmode */
287 nsString mHTMLInputInputmode;
289 /* A hint for the action that is performed when the input is submitted */
290 nsString mActionHint;
293 struct InputContextAction {
295 * mCause indicates what action causes calling nsIWidget::SetInputContext().
296 * It must be one of following values.
298 enum Cause {
299 // The cause is unknown but originated from content. Focus might have been
300 // changed by content script.
301 CAUSE_UNKNOWN,
302 // The cause is unknown but originated from chrome. Focus might have been
303 // changed by chrome script.
304 CAUSE_UNKNOWN_CHROME,
305 // The cause is user's keyboard operation.
306 CAUSE_KEY,
307 // The cause is user's mouse operation.
308 CAUSE_MOUSE
310 Cause mCause;
313 * mFocusChange indicates what happened for focus.
315 enum FocusChange {
316 FOCUS_NOT_CHANGED,
317 // A content got focus.
318 GOT_FOCUS,
319 // Focused content lost focus.
320 LOST_FOCUS,
321 // Menu got pseudo focus that means focused content isn't changed but
322 // keyboard events will be handled by menu.
323 MENU_GOT_PSEUDO_FOCUS,
324 // Menu lost pseudo focus that means focused content will handle keyboard
325 // events.
326 MENU_LOST_PSEUDO_FOCUS
328 FocusChange mFocusChange;
330 bool ContentGotFocusByTrustedCause() const {
331 return (mFocusChange == GOT_FOCUS &&
332 mCause != CAUSE_UNKNOWN);
335 bool UserMightRequestOpenVKB() const {
336 return (mFocusChange == FOCUS_NOT_CHANGED &&
337 mCause == CAUSE_MOUSE);
340 InputContextAction() :
341 mCause(CAUSE_UNKNOWN), mFocusChange(FOCUS_NOT_CHANGED)
345 InputContextAction(Cause aCause,
346 FocusChange aFocusChange = FOCUS_NOT_CHANGED) :
347 mCause(aCause), mFocusChange(aFocusChange)
353 * Size constraints for setting the minimum and maximum size of a widget.
354 * Values are in device pixels.
356 struct SizeConstraints {
357 SizeConstraints()
358 : mMaxSize(NS_MAXSIZE, NS_MAXSIZE)
362 SizeConstraints(nsIntSize aMinSize,
363 nsIntSize aMaxSize)
364 : mMinSize(aMinSize),
365 mMaxSize(aMaxSize)
369 nsIntSize mMinSize;
370 nsIntSize mMaxSize;
373 } // namespace widget
374 } // namespace mozilla
377 * The base class for all the widgets. It provides the interface for
378 * all basic and necessary functionality.
380 class nsIWidget : public nsISupports {
381 protected:
382 typedef mozilla::dom::TabChild TabChild;
384 public:
385 typedef mozilla::layers::CompositorChild CompositorChild;
386 typedef mozilla::layers::LayerManager LayerManager;
387 typedef mozilla::layers::LayersBackend LayersBackend;
388 typedef mozilla::layers::PLayersChild PLayersChild;
389 typedef mozilla::widget::IMEState IMEState;
390 typedef mozilla::widget::InputContext InputContext;
391 typedef mozilla::widget::InputContextAction InputContextAction;
392 typedef mozilla::widget::SizeConstraints SizeConstraints;
394 // Used in UpdateThemeGeometries.
395 struct ThemeGeometry {
396 // The -moz-appearance value for the themed widget
397 uint8_t mWidgetType;
398 // The device-pixel rect within the window for the themed widget
399 nsIntRect mRect;
401 ThemeGeometry(uint8_t aWidgetType, const nsIntRect& aRect)
402 : mWidgetType(aWidgetType)
403 , mRect(aRect)
407 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
409 nsIWidget()
410 : mLastChild(nullptr)
411 , mPrevSibling(nullptr)
416 * Create and initialize a widget.
418 * All the arguments can be NULL in which case a top level window
419 * with size 0 is created. The event callback function has to be
420 * provided only if the caller wants to deal with the events this
421 * widget receives. The event callback is basically a preprocess
422 * hook called synchronously. The return value determines whether
423 * the event goes to the default window procedure or it is hidden
424 * to the os. The assumption is that if the event handler returns
425 * false the widget does not see the event. The widget should not
426 * automatically clear the window to the background color. The
427 * calling code must handle paint messages and clear the background
428 * itself.
430 * In practice at least one of aParent and aNativeParent will be null. If
431 * both are null the widget isn't parented (e.g. context menus or
432 * independent top level windows).
434 * The dimensions given in aRect are specified in the parent's
435 * coordinate system, or for parentless widgets such as top-level
436 * windows, in global CSS pixels.
438 * @param aParent parent nsIWidget
439 * @param aNativeParent native parent widget
440 * @param aRect the widget dimension
441 * @param aContext
442 * @param aInitData data that is used for widget initialization
445 NS_IMETHOD Create(nsIWidget *aParent,
446 nsNativeWidget aNativeParent,
447 const nsIntRect &aRect,
448 nsDeviceContext *aContext,
449 nsWidgetInitData *aInitData = nullptr) = 0;
452 * Allocate, initialize, and return a widget that is a child of
453 * |this|. The returned widget (if nonnull) has gone through the
454 * equivalent of CreateInstance(widgetCID) + Create(...).
456 * |CreateChild()| lets widget backends decide whether to parent
457 * the new child widget to this, nonnatively parent it, or both.
458 * This interface exists to support the PuppetWidget backend,
459 * which is entirely non-native. All other params are the same as
460 * for |Create()|.
462 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
463 * |nsIWidget*| this, not its native widget (if it exists), when
464 * calling |Create()|. This is a timid hack around poorly
465 * understood code, and shouldn't be used in new code.
467 virtual already_AddRefed<nsIWidget>
468 CreateChild(const nsIntRect &aRect,
469 nsDeviceContext *aContext,
470 nsWidgetInitData *aInitData = nullptr,
471 bool aForceUseIWidgetParent = false) = 0;
474 * Attach to a top level widget.
476 * In cases where a top level chrome widget is being used as a content
477 * container, attach a secondary listener and update the device
478 * context. The primary widget listener will continue to be called for
479 * notifications relating to the top-level window, whereas other
480 * notifications such as painting and events will instead be called via
481 * the attached listener. SetAttachedWidgetListener should be used to
482 * assign the attached listener.
484 * aUseAttachedEvents if true, events are sent to the attached listener
485 * instead of the normal listener.
486 * aContext The new device context for the view
488 NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents,
489 nsDeviceContext *aContext) = 0;
492 * Accessor functions to get and set the attached listener. Used by
493 * nsIView in connection with AttachViewToTopLevel above.
495 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
496 virtual nsIWidgetListener* GetAttachedWidgetListener() = 0;
499 * Accessor functions to get and set the listener which handles various
500 * actions for the widget.
502 //@{
503 virtual nsIWidgetListener* GetWidgetListener() = 0;
504 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
505 //@}
508 * Close and destroy the internal native window.
509 * This method does not delete the widget.
512 NS_IMETHOD Destroy(void) = 0;
516 * Reparent a widget
518 * Change the widget's parent. Null parents are allowed.
520 * @param aNewParent new parent
522 NS_IMETHOD SetParent(nsIWidget* aNewParent) = 0;
524 NS_IMETHOD RegisterTouchWindow() = 0;
525 NS_IMETHOD UnregisterTouchWindow() = 0;
528 * Return the parent Widget of this Widget or nullptr if this is a
529 * top level window
531 * @return the parent widget or nullptr if it does not have a parent
534 virtual nsIWidget* GetParent(void) = 0;
537 * Return the top level Widget of this Widget
539 * @return the top level widget
541 virtual nsIWidget* GetTopLevelWidget() = 0;
544 * Return the top (non-sheet) parent of this Widget if it's a sheet,
545 * or nullptr if this isn't a sheet (or some other error occurred).
546 * Sheets are only supported on some platforms (currently only OS X).
548 * @return the top (non-sheet) parent widget or nullptr
551 virtual nsIWidget* GetSheetWindowParent(void) = 0;
554 * Return the physical DPI of the screen containing the window ...
555 * the number of device pixels per inch.
557 virtual float GetDPI() = 0;
560 * Return the default scale factor for the window. This is the
561 * default number of device pixels per CSS pixel to use. This should
562 * depend on OS/platform settings such as the Mac's "UI scale factor"
563 * or Windows' "font DPI".
565 virtual double GetDefaultScale() = 0;
568 * Return the first child of this widget. Will return null if
569 * there are no children.
571 nsIWidget* GetFirstChild() const {
572 return mFirstChild;
576 * Return the last child of this widget. Will return null if
577 * there are no children.
579 nsIWidget* GetLastChild() const {
580 return mLastChild;
584 * Return the next sibling of this widget
586 nsIWidget* GetNextSibling() const {
587 return mNextSibling;
591 * Set the next sibling of this widget
593 void SetNextSibling(nsIWidget* aSibling) {
594 mNextSibling = aSibling;
598 * Return the previous sibling of this widget
600 nsIWidget* GetPrevSibling() const {
601 return mPrevSibling;
605 * Set the previous sibling of this widget
607 void SetPrevSibling(nsIWidget* aSibling) {
608 mPrevSibling = aSibling;
612 * Show or hide this widget
614 * @param aState true to show the Widget, false to hide it
617 NS_IMETHOD Show(bool aState) = 0;
620 * Make the window modal
623 NS_IMETHOD SetModal(bool aModal) = 0;
626 * Returns whether the window is visible
629 virtual bool IsVisible() const = 0;
632 * Perform platform-dependent sanity check on a potential window position.
633 * This is guaranteed to work only for top-level windows.
635 * @param aAllowSlop: if true, allow the window to slop offscreen;
636 * the window should be partially visible. if false,
637 * force the entire window onscreen (or at least
638 * the upper-left corner, if it's too large).
639 * @param aX in: an x position expressed in screen coordinates.
640 * out: the x position constrained to fit on the screen(s).
641 * @param aY in: an y position expressed in screen coordinates.
642 * out: the y position constrained to fit on the screen(s).
643 * @return vapid success indication. but see also the parameters.
646 NS_IMETHOD ConstrainPosition(bool aAllowSlop,
647 int32_t *aX,
648 int32_t *aY) = 0;
651 * Move this widget.
653 * Coordinates refer to the top-left of the widget. For toplevel windows
654 * with decorations, this is the top-left of the titlebar and frame .
656 * @param aX the new x position expressed in the parent's coordinate system
657 * @param aY the new y position expressed in the parent's coordinate system
660 NS_IMETHOD Move(int32_t aX, int32_t aY) = 0;
663 * Reposition this widget so that the client area has the given offset.
665 * @param aX the new x offset of the client area expressed as an
666 * offset from the origin of the client area of the parent
667 * widget (for root widgets and popup widgets it is in
668 * screen coordinates)
669 * @param aY the new y offset of the client area expressed as an
670 * offset from the origin of the client area of the parent
671 * widget (for root widgets and popup widgets it is in
672 * screen coordinates)
675 NS_IMETHOD MoveClient(int32_t aX, int32_t aY) = 0;
678 * Resize this widget. Any size constraints set for the window by a
679 * previous call to SetSizeConstraints will be applied.
681 * @param aWidth the new width expressed in the parent's coordinate system
682 * @param aHeight the new height expressed in the parent's coordinate system
683 * @param aRepaint whether the widget should be repainted
686 NS_IMETHOD Resize(int32_t aWidth,
687 int32_t aHeight,
688 bool aRepaint) = 0;
691 * Move or resize this widget. Any size constraints set for the window by
692 * a previous call to SetSizeConstraints will be applied.
694 * @param aX the new x position expressed in the parent's coordinate system
695 * @param aY the new y position expressed in the parent's coordinate system
696 * @param aWidth the new width expressed in the parent's coordinate system
697 * @param aHeight the new height expressed in the parent's coordinate system
698 * @param aRepaint whether the widget should be repainted if the size changes
701 NS_IMETHOD Resize(int32_t aX,
702 int32_t aY,
703 int32_t aWidth,
704 int32_t aHeight,
705 bool aRepaint) = 0;
708 * Resize the widget so that the inner client area has the given size.
710 * @param aWidth the new width of the client area.
711 * @param aHeight the new height of the client area.
712 * @param aRepaint whether the widget should be repainted
715 NS_IMETHOD ResizeClient(int32_t aWidth,
716 int32_t aHeight,
717 bool aRepaint) = 0;
720 * Resize and reposition the widget so tht inner client area has the given
721 * offset and size.
723 * @param aX the new x offset of the client area expressed as an
724 * offset from the origin of the client area of the parent
725 * widget (for root widgets and popup widgets it is in
726 * screen coordinates)
727 * @param aY the new y 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 aWidth the new width of the client area.
732 * @param aHeight the new height of the client area.
733 * @param aRepaint whether the widget should be repainted
736 NS_IMETHOD ResizeClient(int32_t aX,
737 int32_t aY,
738 int32_t aWidth,
739 int32_t aHeight,
740 bool aRepaint) = 0;
743 * Sets the widget's z-index.
745 NS_IMETHOD SetZIndex(int32_t aZIndex) = 0;
748 * Gets the widget's z-index.
750 NS_IMETHOD GetZIndex(int32_t* aZIndex) = 0;
753 * Position this widget just behind the given widget. (Used to
754 * control z-order for top-level widgets. Get/SetZIndex by contrast
755 * control z-order for child widgets of other widgets.)
756 * @param aPlacement top, bottom, or below a widget
757 * (if top or bottom, param aWidget is ignored)
758 * @param aWidget widget to place this widget behind
759 * (only if aPlacement is eZPlacementBelow).
760 * null is equivalent to aPlacement of eZPlacementTop
761 * @param aActivate true to activate the widget after placing it
763 NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
764 nsIWidget *aWidget, bool aActivate) = 0;
767 * Minimize, maximize or normalize the window size.
768 * Takes a value from nsSizeMode (see nsGUIEvent.h)
770 NS_IMETHOD SetSizeMode(int32_t aMode) = 0;
773 * Return size mode (minimized, maximized, normalized).
774 * Returns a value from nsSizeMode (see nsGUIEvent.h)
776 NS_IMETHOD GetSizeMode(int32_t* aMode) = 0;
779 * Enable or disable this Widget
781 * @param aState true to enable the Widget, false to disable it.
784 NS_IMETHOD Enable(bool aState) = 0;
787 * Ask whether the widget is enabled
789 virtual bool IsEnabled() const = 0;
792 * Request activation of this window or give focus to this widget.
794 * @param aRaise If true, this function requests activation of this
795 * widget's toplevel window.
796 * If false, the appropriate toplevel window (which in
797 * the case of popups may not be this widget's toplevel
798 * window) is already active.
800 NS_IMETHOD SetFocus(bool aRaise = false) = 0;
803 * Get this widget's outside dimensions relative to its parent widget. For
804 * popup widgets the returned rect is in screen coordinates and not
805 * relative to its parent widget.
807 * @param aRect On return it holds the x, y, width and height of
808 * this widget.
810 NS_IMETHOD GetBounds(nsIntRect &aRect) = 0;
813 * Get this widget's outside dimensions in global coordinates. This
814 * includes any title bar on the window.
816 * @param aRect On return it holds the x, y, width and height of
817 * this widget.
819 NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0;
822 * Get this widget's client area bounds, if the window has a 3D border
823 * appearance this returns the area inside the border. The position is the
824 * position of the client area relative to the client area of the parent
825 * widget (for root widgets and popup widgets it is in screen coordinates).
827 * @param aRect On return it holds the x. y, width and height of
828 * the client area of this widget.
830 NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0;
833 * Get the non-client area dimensions of the window.
836 NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) = 0;
839 * Sets the non-client area dimensions of the window. Pass -1 to restore
840 * the system default frame size for that border. Pass zero to remove
841 * a border, or pass a specific value adjust a border. Units are in
842 * pixels. (DPI dependent)
844 * Platform notes:
845 * Windows: shrinking top non-client height will remove application
846 * icon and window title text. Glass desktops will refuse to set
847 * dimensions between zero and size < system default.
850 NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) = 0;
853 * Get the client offset from the window origin.
855 * @return the x and y of the offset.
858 virtual nsIntPoint GetClientOffset() = 0;
861 * Get the foreground color for this widget
863 * @return this widget's foreground color
866 virtual nscolor GetForegroundColor(void) = 0;
869 * Set the foreground color for this widget
871 * @param aColor the new foreground color
875 NS_IMETHOD SetForegroundColor(const nscolor &aColor) = 0;
878 * Get the background color for this widget
880 * @return this widget's background color
884 virtual nscolor GetBackgroundColor(void) = 0;
887 * Set the background color for this widget
889 * @param aColor the new background color
893 NS_IMETHOD SetBackgroundColor(const nscolor &aColor) = 0;
896 * Get the cursor for this widget.
898 * @return this widget's cursor.
901 virtual nsCursor GetCursor(void) = 0;
904 * Set the cursor for this widget
906 * @param aCursor the new cursor for this widget
909 NS_IMETHOD SetCursor(nsCursor aCursor) = 0;
912 * Sets an image as the cursor for this widget.
914 * @param aCursor the cursor to set
915 * @param aX the X coordinate of the hotspot (from left).
916 * @param aY the Y coordinate of the hotspot (from top).
917 * @retval NS_ERROR_NOT_IMPLEMENTED if setting images as cursors is not
918 * supported
920 NS_IMETHOD SetCursor(imgIContainer* aCursor,
921 uint32_t aHotspotX, uint32_t aHotspotY) = 0;
923 /**
924 * Get the window type of this widget
926 * @param aWindowType the window type of the widget
928 NS_IMETHOD GetWindowType(nsWindowType& aWindowType) = 0;
931 * Set the transparency mode of the top-level window containing this widget.
932 * So, e.g., if you call this on the widget for an IFRAME, the top level
933 * browser window containing the IFRAME actually gets set. Be careful.
935 * This can fail if the platform doesn't support
936 * transparency/glass. By default widgets are not
937 * transparent. This will also fail if the toplevel window is not
938 * a Mozilla window, e.g., if the widget is in an embedded
939 * context.
941 * After transparency/glass has been enabled, the initial alpha channel
942 * value for all pixels is 1, i.e., opaque.
943 * If the window is resized then the alpha channel values for
944 * all pixels are reset to 1.
945 * Pixel RGB color values are already premultiplied with alpha channel values.
947 virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
950 * Get the transparency mode of the top-level window that contains this
951 * widget.
953 virtual nsTransparencyMode GetTransparencyMode() = 0;
956 * This represents a command to set the bounds and clip region of
957 * a child widget.
959 struct Configuration {
960 nsIWidget* mChild;
961 nsIntRect mBounds;
962 nsTArray<nsIntRect> mClipRegion;
966 * Sets the clip region of each mChild (which must actually be a child
967 * of this widget) to the union of the pixel rects given in
968 * mClipRegion, all relative to the top-left of the child
969 * widget. Clip regions are not implemented on all platforms and only
970 * need to actually work for children that are plugins.
972 * Also sets the bounds of each child to mBounds.
974 * This will invalidate areas of the children that have changed, but
975 * does not need to invalidate any part of this widget.
977 * Children should be moved in the order given; the array is
978 * sorted so to minimize unnecessary invalidation if children are
979 * moved in that order.
981 virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) = 0;
984 * Appends to aRects the rectangles constituting this widget's clip
985 * region. If this widget is not clipped, appends a single rectangle
986 * (0, 0, bounds.width, bounds.height).
988 virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects) = 0;
991 * Set the shadow style of the window.
993 * Ignored on child widgets and on non-Mac platforms.
995 NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) = 0;
998 * On Mac OS X, this method shows or hides the pill button in the titlebar
999 * that's used to collapse the toolbar.
1001 * Ignored on child widgets and on non-Mac platforms.
1003 virtual void SetShowsToolbarButton(bool aShow) = 0;
1006 * On Mac OS X Lion, this method shows or hides the full screen button in
1007 * the titlebar that handles native full screen mode.
1009 * Ignored on child widgets, non-Mac platforms, & pre-Lion Mac.
1011 virtual void SetShowsFullScreenButton(bool aShow) = 0;
1013 enum WindowAnimationType {
1014 eGenericWindowAnimation,
1015 eDocumentWindowAnimation
1019 * Sets the kind of top-level window animation this widget should have. On
1020 * Mac OS X, this causes a particular kind of animation to be shown when the
1021 * window is first made visible.
1023 * Ignored on child widgets and on non-Mac platforms.
1025 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1027 /**
1028 * Hide window chrome (borders, buttons) for this widget.
1031 NS_IMETHOD HideWindowChrome(bool aShouldHide) = 0;
1034 * Put the toplevel window into or out of fullscreen mode.
1037 NS_IMETHOD MakeFullScreen(bool aFullScreen) = 0;
1040 * Invalidate a specified rect for a widget so that it will be repainted
1041 * later.
1043 NS_IMETHOD Invalidate(const nsIntRect & aRect) = 0;
1045 enum LayerManagerPersistence
1047 LAYER_MANAGER_CURRENT = 0,
1048 LAYER_MANAGER_PERSISTENT
1052 * Return the widget's LayerManager. The layer tree for that
1053 * LayerManager is what gets rendered to the widget.
1055 * @param aAllowRetaining an outparam that states whether the returned
1056 * layer manager should be used for retained layers
1058 inline LayerManager* GetLayerManager(bool* aAllowRetaining = nullptr)
1060 return GetLayerManager(nullptr, mozilla::layers::LAYERS_NONE,
1061 LAYER_MANAGER_CURRENT, aAllowRetaining);
1064 inline LayerManager* GetLayerManager(LayerManagerPersistence aPersistence,
1065 bool* aAllowRetaining = nullptr)
1067 return GetLayerManager(nullptr, mozilla::layers::LAYERS_NONE,
1068 aPersistence, aAllowRetaining);
1072 * Like GetLayerManager(), but prefers creating a layer manager of
1073 * type |aBackendHint| instead of what would normally be created.
1074 * LAYERS_NONE means "no hint".
1076 virtual LayerManager* GetLayerManager(PLayersChild* aShadowManager,
1077 LayersBackend aBackendHint,
1078 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
1079 bool* aAllowRetaining = nullptr) = 0;
1082 * Called before the LayerManager draws the layer tree.
1084 * @param aManager The drawing LayerManager.
1085 * @param aWidgetRect The current widget rect that is being drawn.
1087 virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) = 0;
1090 * Called after the LayerManager draws the layer tree
1092 * @param aManager The drawing LayerManager.
1093 * @param aRect Current widget rect that is being drawn.
1095 virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) = 0;
1098 * Called when Gecko knows which themed widgets exist in this window.
1099 * The passed array contains an entry for every themed widget of the right
1100 * type (currently only NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR and
1101 * NS_THEME_TOOLBAR) within the window, except for themed widgets which are
1102 * transformed or have effects applied to them (e.g. CSS opacity or
1103 * filters).
1104 * This could sometimes be called during display list construction
1105 * outside of painting.
1106 * If called during painting, it will be called before we actually
1107 * paint anything.
1109 virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1112 * Informs the widget about the region of the window that is opaque.
1114 * @param aOpaqueRegion the region of the window that is opaque.
1116 virtual void UpdateOpaqueRegion(const nsIntRegion &aOpaqueRegion) {}
1118 /**
1119 * Internal methods
1122 //@{
1123 virtual void AddChild(nsIWidget* aChild) = 0;
1124 virtual void RemoveChild(nsIWidget* aChild) = 0;
1125 virtual void* GetNativeData(uint32_t aDataType) = 0;
1126 virtual void FreeNativeData(void * data, uint32_t aDataType) = 0;//~~~
1128 // GetDeviceContext returns a weak pointer to this widget's device context
1129 virtual nsDeviceContext* GetDeviceContext() = 0;
1131 //@}
1134 * Set the widget's title.
1135 * Must be called after Create.
1137 * @param aTitle string displayed as the title of the widget
1140 NS_IMETHOD SetTitle(const nsAString& aTitle) = 0;
1143 * Set the widget's icon.
1144 * Must be called after Create.
1146 * @param anIconSpec string specifying the icon to use; convention is to pass
1147 * a resource: URL from which a platform-dependent resource
1148 * file name will be constructed
1151 NS_IMETHOD SetIcon(const nsAString& anIconSpec) = 0;
1154 * Return this widget's origin in screen coordinates.
1156 * @return screen coordinates stored in the x,y members
1159 virtual nsIntPoint WidgetToScreenOffset() = 0;
1162 * Given the specified client size, return the corresponding window size,
1163 * which includes the area for the borders and titlebar. This method
1164 * should work even when the window is not yet visible.
1166 virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) = 0;
1169 * Dispatches an event to the widget
1172 NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) = 0;
1175 * Enables the dropping of files to a widget (XXX this is temporary)
1178 NS_IMETHOD EnableDragDrop(bool aEnable) = 0;
1181 * Enables/Disables system mouse capture.
1182 * @param aCapture true enables mouse capture, false disables mouse capture
1185 NS_IMETHOD CaptureMouse(bool aCapture) = 0;
1188 * Classify the window for the window manager. Mostly for X11.
1190 NS_IMETHOD SetWindowClass(const nsAString& xulWinType) = 0;
1193 * Enables/Disables system capture of any and all events that would cause a
1194 * dropdown to be rolled up, This method ignores the aConsumeRollupEvent
1195 * parameter when aDoCapture is FALSE
1196 * @param aDoCapture true enables capture, false disables capture
1197 * @param aConsumeRollupEvent true consumes the rollup event, false dispatches rollup event
1200 NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, bool aDoCapture,
1201 bool aConsumeRollupEvent) = 0;
1204 * Bring this window to the user's attention. This is intended to be a more
1205 * gentle notification than popping the window to the top or putting up an
1206 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1207 * the Mac. The notification should be suppressed if the window is already
1208 * in the foreground and should be dismissed when the user brings this window
1209 * to the foreground.
1210 * @param aCycleCount Maximum number of times to animate the window per system
1211 * conventions. If set to -1, cycles indefinitely until
1212 * window is brought into the foreground.
1214 NS_IMETHOD GetAttention(int32_t aCycleCount) = 0;
1217 * Ask whether there user input events pending. All input events are
1218 * included, including those not targeted at this nsIwidget instance.
1220 virtual bool HasPendingInputEvent() = 0;
1223 * Called when when we need to begin secure keyboard input, such as when a password field
1224 * gets focus.
1226 * NOTE: Calls to this method may not be nested and you can only enable secure keyboard input
1227 * for one widget at a time.
1229 NS_IMETHOD BeginSecureKeyboardInput() = 0;
1232 * Called when when we need to end secure keyboard input, such as when a password field
1233 * loses focus.
1235 * NOTE: Calls to this method may not be nested and you can only enable secure keyboard input
1236 * for one widget at a time.
1238 NS_IMETHOD EndSecureKeyboardInput() = 0;
1241 * Set the background color of the window titlebar for this widget. On Mac,
1242 * for example, this will remove the grey gradient and bottom border and
1243 * instead show a single, solid color.
1245 * Ignored on any platform that does not support it. Ignored by widgets that
1246 * do not represent windows.
1248 * @param aColor The color to set the title bar background to. Alpha values
1249 * other than fully transparent (0) are respected if possible
1250 * on the platform. An alpha of 0 will cause the window to
1251 * draw with the default style for the platform.
1253 * @param aActive Whether the color should be applied to active or inactive
1254 * windows.
1256 NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) = 0;
1259 * If set to true, the window will draw its contents into the titlebar
1260 * instead of below it.
1262 * Ignored on any platform that does not support it. Ignored by widgets that
1263 * do not represent windows.
1264 * May result in a resize event, so should only be called from places where
1265 * reflow and painting is allowed.
1267 * @param aState Whether drawing into the titlebar should be activated.
1269 virtual void SetDrawsInTitlebar(bool aState) = 0;
1272 * Determine whether the widget shows a resize widget. If it does,
1273 * aResizerRect returns the resizer's rect.
1275 * Returns false on any platform that does not support it.
1277 * @param aResizerRect The resizer's rect in device pixels.
1278 * @return Whether a resize widget is shown.
1280 virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) = 0;
1283 * Get the Thebes surface associated with this widget.
1285 virtual gfxASurface *GetThebesSurface() = 0;
1288 * Return the popup that was last rolled up, or null if there isn't one.
1290 virtual nsIContent* GetLastRollup() = 0;
1293 * Begin a window resizing drag, based on the event passed in.
1295 NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, int32_t aHorizontal, int32_t aVertical) = 0;
1298 * Begin a window moving drag, based on the event passed in.
1300 NS_IMETHOD BeginMoveDrag(nsMouseEvent* aEvent) = 0;
1302 enum Modifiers {
1303 CAPS_LOCK = 0x01, // when CapsLock is active
1304 NUM_LOCK = 0x02, // when NumLock is active
1305 SHIFT_L = 0x0100,
1306 SHIFT_R = 0x0200,
1307 CTRL_L = 0x0400,
1308 CTRL_R = 0x0800,
1309 ALT_L = 0x1000, // includes Option
1310 ALT_R = 0x2000,
1311 COMMAND_L = 0x4000,
1312 COMMAND_R = 0x8000,
1313 HELP = 0x10000,
1314 FUNCTION = 0x100000,
1315 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1318 * Utility method intended for testing. Dispatches native key events
1319 * to this widget to simulate the press and release of a key.
1320 * @param aNativeKeyboardLayout a *platform-specific* constant.
1321 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1322 * On Windows, it is converted to a hex string and passed to
1323 * LoadKeyboardLayout, see
1324 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1325 * @param aNativeKeyCode a *platform-specific* keycode.
1326 * On Windows, this is the virtual key code.
1327 * @param aModifiers some combination of the above 'Modifiers' flags;
1328 * not all flags will apply to all platforms. Mac ignores the _R
1329 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1330 * FUNCTION.
1331 * @param aCharacters characters that the OS would decide to generate
1332 * from the event. On Windows, this is the charCode passed by
1333 * WM_CHAR.
1334 * @param aUnmodifiedCharacters characters that the OS would decide
1335 * to generate from the event if modifier keys (other than shift)
1336 * were assumed inactive. Needed on Mac, ignored on Windows.
1337 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1338 * layout is not supported and the event was not fired
1340 virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
1341 int32_t aNativeKeyCode,
1342 uint32_t aModifierFlags,
1343 const nsAString& aCharacters,
1344 const nsAString& aUnmodifiedCharacters) = 0;
1347 * Utility method intended for testing. Dispatches native mouse events
1348 * may even move the mouse cursor. On Mac the events are guaranteed to
1349 * be sent to the window containing this widget, but on Windows they'll go
1350 * to whatever's topmost on the screen at that position, so for
1351 * cross-platform testing ensure that your window is at the top of the
1352 * z-order.
1353 * @param aPoint screen location of the mouse, in device
1354 * pixels, with origin at the top left
1355 * @param aNativeMessage *platform-specific* event type (e.g. on Mac,
1356 * NSMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN etc)
1357 * @param aModifierFlags *platform-specific* modifier flags (ignored
1358 * on Windows)
1360 virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
1361 uint32_t aNativeMessage,
1362 uint32_t aModifierFlags) = 0;
1365 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native message.
1366 * aPoint is location in device pixels to which the mouse pointer moves to.
1368 virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) = 0;
1371 * Utility method intended for testing. Dispatching native mouse scroll
1372 * events may move the mouse cursor.
1374 * @param aPoint Mouse cursor position in screen coordinates.
1375 * In device pixels, the origin at the top left of
1376 * the primary display.
1377 * @param aNativeMessage Platform native message.
1378 * @param aDeltaX The delta value for X direction. If the native
1379 * message doesn't indicate X direction scrolling,
1380 * this may be ignored.
1381 * @param aDeltaY The delta value for Y direction. If the native
1382 * message doesn't indicate Y direction scrolling,
1383 * this may be ignored.
1384 * @param aDeltaZ The delta value for Z direction. If the native
1385 * message doesn't indicate Z direction scrolling,
1386 * this may be ignored.
1387 * @param aModifierFlags Must be values of Modifiers, or zero.
1388 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1389 * document.
1391 virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint,
1392 uint32_t aNativeMessage,
1393 double aDeltaX,
1394 double aDeltaY,
1395 double aDeltaZ,
1396 uint32_t aModifierFlags,
1397 uint32_t aAdditionalFlags) = 0;
1400 * Activates a native menu item at the position specified by the index
1401 * string. The index string is a string of positive integers separated
1402 * by the "|" (pipe) character. The last integer in the string represents
1403 * the item index in a submenu located using the integers preceding it.
1405 * Example: 1|0|4
1406 * In this string, the first integer represents the top-level submenu
1407 * in the native menu bar. Since the integer is 1, it is the second submeu
1408 * in the native menu bar. Within that, the first item (index 0) is a
1409 * submenu, and we want to activate the 5th item within that submenu.
1411 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1414 * This is used for native menu system testing.
1416 * Updates a native menu at the position specified by the index string.
1417 * The index string is a string of positive integers separated by the "|"
1418 * (pipe) character.
1420 * Example: 1|0|4
1421 * In this string, the first integer represents the top-level submenu
1422 * in the native menu bar. Since the integer is 1, it is the second submeu
1423 * in the native menu bar. Within that, the first item (index 0) is a
1424 * submenu, and we want to update submenu at index 4 within that submenu.
1426 * If this is called with an empty string it forces a full reload of the
1427 * menu system.
1429 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1432 * Force Input Method Editor to commit the uncommitted input
1434 NS_IMETHOD ResetInputState()=0;
1437 * Following methods relates to IME 'Opened'/'Closed' state.
1438 * 'Opened' means the user can input any character. I.e., users can input Japanese
1439 * and other characters. The user can change the state to 'Closed'.
1440 * 'Closed' means the user can input ASCII characters only. This is the same as a
1441 * non-IME environment. The user can change the state to 'Opened'.
1442 * For more information is here.
1443 * http://bugzilla.mozilla.org/show_bug.cgi?id=16940#c48
1447 * Destruct and don't commit the IME composition string.
1449 NS_IMETHOD CancelIMEComposition() = 0;
1452 * Notifies the input context changes.
1454 NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
1455 const InputContextAction& aAction) = 0;
1458 * Get current input context.
1460 NS_IMETHOD_(InputContext) GetInputContext() = 0;
1463 * Set accelerated rendering to 'True' or 'False'
1465 NS_IMETHOD SetAcceleratedRendering(bool aEnabled) = 0;
1468 * Get toggled key states.
1469 * aKeyCode should be NS_VK_CAPS_LOCK or NS_VK_NUM_LOCK or
1470 * NS_VK_SCROLL_LOCK.
1471 * aLEDState is the result for current LED state of the key.
1472 * If the LED is 'ON', it returns TRUE, otherwise, FALSE.
1473 * If the platform doesn't support the LED state (or we cannot get the
1474 * state), this method returns NS_ERROR_NOT_IMPLEMENTED.
1476 NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) = 0;
1479 * An editable node (i.e. input/textarea/design mode document)
1480 * is receiving or giving up focus
1481 * aFocus is true if node is receiving focus
1482 * aFocus is false if node is giving up focus (blur)
1484 * If this returns NS_ERROR_*, OnIMETextChange and OnIMESelectionChange
1485 * and OnIMEFocusChange(false) will be never called.
1487 * If this returns NS_SUCCESS_IME_NO_UPDATES, OnIMEFocusChange(false)
1488 * will be called but OnIMETextChange and OnIMESelectionChange will NOT.
1490 NS_IMETHOD OnIMEFocusChange(bool aFocus) = 0;
1493 * Text content of the focused node has changed
1494 * aStart is the starting offset of the change
1495 * aOldEnd is the ending offset of the change
1496 * aNewEnd is the caret offset after the change
1498 NS_IMETHOD OnIMETextChange(uint32_t aStart,
1499 uint32_t aOldEnd,
1500 uint32_t aNewEnd) = 0;
1503 * Selection has changed in the focused node
1505 NS_IMETHOD OnIMESelectionChange(void) = 0;
1508 * Retrieves preference for IME updates
1510 virtual nsIMEUpdatePreference GetIMEUpdatePreference() = 0;
1513 * Call this method when a dialog is opened which has a default button.
1514 * The button's rectangle should be supplied in aButtonRect.
1516 NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) = 0;
1519 * Compute the overridden system mouse scroll speed on the root content of
1520 * web pages. The widget may set the same value as aOriginalDelta. E.g.,
1521 * when the system scrolling settings were customized, widget can respect
1522 * the will of the user.
1524 * This is called only when the mouse wheel event scrolls the root content
1525 * of the web pages by line. In other words, this isn't called when the
1526 * mouse wheel event is used for zoom, page scroll and other special
1527 * actions. And also this isn't called when the user doesn't use the
1528 * system wheel speed settings.
1530 * @param aOriginalDelta The delta value of the current mouse wheel
1531 * scrolling event.
1532 * @param aIsHorizontal If TRUE, the scrolling direction is horizontal.
1533 * Otherwise, it's vertical.
1534 * @param aOverriddenDelta The overridden mouse scrolling speed. This value
1535 * may be same as aOriginalDelta.
1537 NS_IMETHOD OverrideSystemMouseScrollSpeed(int32_t aOriginalDelta,
1538 bool aIsHorizontal,
1539 int32_t &aOverriddenDelta) = 0;
1542 * Return true if this process shouldn't use platform widgets, and
1543 * so should use PuppetWidgets instead. If this returns true, the
1544 * result of creating and using a platform widget is undefined,
1545 * and likely to end in crashes or other buggy behavior.
1547 static bool
1548 UsePuppetWidgets()
1550 return XRE_GetProcessType() == GeckoProcessType_Content;
1554 * Allocate and return a "puppet widget" that doesn't directly
1555 * correlate to a platform widget; platform events and data must
1556 * be fed to it. Currently used in content processes. NULL is
1557 * returned if puppet widgets aren't supported in this build
1558 * config, on this platform, or for this process type.
1560 * This function is called "Create" to match CreateInstance().
1561 * The returned widget must still be nsIWidget::Create()d.
1563 static already_AddRefed<nsIWidget>
1564 CreatePuppetWidget(TabChild* aTabChild);
1567 * Reparent this widget's native widget.
1568 * @param aNewParent the native widget of aNewParent is the new native
1569 * parent widget
1571 NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) = 0;
1574 * Return the internal format of the default framebuffer for this
1575 * widget.
1577 virtual uint32_t GetGLFrameBufferFormat() { return 0; /*GL_NONE*/ }
1580 * Return true if widget has it's own GL context
1582 virtual bool HasGLContext() { return false; }
1585 * Returns true to indicate that this widget paints an opaque background
1586 * that we want to be visible under the page, so layout should not force
1587 * a default background.
1589 virtual bool WidgetPaintsBackground() { return false; }
1591 virtual bool NeedsPaint() {
1592 return true;
1595 * Get the natural bounds of this widget. This method is only
1596 * meaningful for widgets for which Gecko implements screen
1597 * rotation natively. When this is the case, GetBounds() returns
1598 * the widget bounds taking rotation into account, and
1599 * GetNaturalBounds() returns the bounds *not* taking rotation
1600 * into account.
1602 * No code outside of the composition pipeline should know or care
1603 * about this. If you're not an agent of the compositor, you
1604 * probably shouldn't call this method.
1606 virtual nsIntRect GetNaturalBounds() {
1607 nsIntRect bounds;
1608 GetBounds(bounds);
1609 return bounds;
1613 * Set size constraints on the window size such that it is never less than
1614 * the specified minimum size and never larger than the specified maximum
1615 * size. The size constraints are sizes of the outer rectangle including
1616 * the window frame and title bar. Use 0 for an unconstrained minimum size
1617 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
1618 * does not necessarily change the size of a window to conform to this size,
1619 * thus Resize should be called afterwards.
1621 * @param aConstraints: the size constraints in device pixels
1623 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
1626 * Return the size constraints currently observed by the widget.
1628 * @return the constraints in device pixels
1630 virtual const SizeConstraints& GetSizeConstraints() const = 0;
1633 * If this is owned by a TabChild, return that. Otherwise return
1634 * null.
1636 virtual TabChild* GetOwningTabChild() { return nullptr; }
1639 * If this isn't directly compositing to its window surface,
1640 * return the compositor which is doing that on our behalf.
1642 virtual CompositorChild* GetRemoteRenderer()
1643 { return nullptr; }
1645 protected:
1647 // keep the list of children. We also keep track of our siblings.
1648 // The ownership model is as follows: parent holds a strong ref to
1649 // the first element of the list, and each element holds a strong
1650 // ref to the next element in the list. The prevsibling and
1651 // lastchild pointers are weak, which is fine as long as they are
1652 // maintained properly.
1653 nsCOMPtr<nsIWidget> mFirstChild;
1654 nsIWidget* mLastChild;
1655 nsCOMPtr<nsIWidget> mNextSibling;
1656 nsIWidget* mPrevSibling;
1659 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
1661 #endif // nsIWidget_h__