Bumping manifests a=b2g-bump
[gecko.git] / widget / nsIWidget.h
blob6a039e0af4a1ecc670e531ec8e6f207a5b50adfa
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 "nsRect.h"
12 #include "nsStringGlue.h"
14 #include "nsCOMPtr.h"
15 #include "nsAutoPtr.h"
16 #include "nsWidgetInitData.h"
17 #include "nsTArray.h"
18 #include "nsITimer.h"
19 #include "nsXULAppAPI.h"
20 #include "mozilla/EventForwards.h"
21 #include "mozilla/layers/LayersTypes.h"
22 #include "mozilla/RefPtr.h"
23 #include "mozilla/TimeStamp.h"
24 #include "Units.h"
26 // forward declarations
27 class nsFontMetrics;
28 class nsDeviceContext;
29 struct nsFont;
30 class nsIRollupListener;
31 class imgIContainer;
32 class nsIContent;
33 class ViewWrapper;
34 class nsIWidgetListener;
35 class nsIntRegion;
36 class nsIScreen;
38 namespace mozilla {
39 class CompositorVsyncDispatcher;
40 namespace dom {
41 class TabChild;
43 namespace plugins {
44 class PluginWidgetChild;
46 namespace layers {
47 class Composer2D;
48 class CompositorChild;
49 class LayerManager;
50 class LayerManagerComposite;
51 class PLayerTransactionChild;
53 namespace gfx {
54 class DrawTarget;
58 /**
59 * Callback function that processes events.
61 * The argument is actually a subtype (subclass) of WidgetEvent which carries
62 * platform specific information about the event. Platform specific code
63 * knows how to deal with it.
65 * The return value determines whether or not the default action should take
66 * place.
68 typedef nsEventStatus (* EVENT_CALLBACK)(mozilla::WidgetGUIEvent* aEvent);
70 // Hide the native window system's real window type so as to avoid
71 // including native window system types and APIs. This is necessary
72 // to ensure cross-platform code.
73 typedef void* nsNativeWidget;
75 /**
76 * Flags for the getNativeData function.
77 * See getNativeData()
79 #define NS_NATIVE_WINDOW 0
80 #define NS_NATIVE_GRAPHIC 1
81 #define NS_NATIVE_TMP_WINDOW 2
82 #define NS_NATIVE_WIDGET 3
83 #define NS_NATIVE_DISPLAY 4
84 #define NS_NATIVE_REGION 5
85 #define NS_NATIVE_OFFSETX 6
86 #define NS_NATIVE_OFFSETY 7
87 #define NS_NATIVE_PLUGIN_PORT 8
88 #define NS_NATIVE_SCREEN 9
89 // The toplevel GtkWidget containing this nsIWidget:
90 #define NS_NATIVE_SHELLWIDGET 10
91 // Has to match to NPNVnetscapeWindow, and shareable across processes
92 // HWND on Windows and XID on X11
93 #define NS_NATIVE_SHAREABLE_WINDOW 11
94 #ifdef XP_MACOSX
95 #define NS_NATIVE_PLUGIN_PORT_QD 100
96 #define NS_NATIVE_PLUGIN_PORT_CG 101
97 #endif
98 #ifdef XP_WIN
99 #define NS_NATIVE_TSF_THREAD_MGR 100
100 #define NS_NATIVE_TSF_CATEGORY_MGR 101
101 #define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
102 #define NS_NATIVE_ICOREWINDOW 103 // winrt specific
103 #endif
105 #define NS_IWIDGET_IID \
106 { 0x316E4600, 0x15DB, 0x47AE, \
107 { 0xBF, 0xE4, 0x5B, 0xCD, 0xFF, 0x80, 0x80, 0x83 } };
110 * Window shadow styles
111 * Also used for the -moz-window-shadow CSS property
114 #define NS_STYLE_WINDOW_SHADOW_NONE 0
115 #define NS_STYLE_WINDOW_SHADOW_DEFAULT 1
116 #define NS_STYLE_WINDOW_SHADOW_MENU 2
117 #define NS_STYLE_WINDOW_SHADOW_TOOLTIP 3
118 #define NS_STYLE_WINDOW_SHADOW_SHEET 4
121 * Transparency modes
124 enum nsTransparencyMode {
125 eTransparencyOpaque = 0, // Fully opaque
126 eTransparencyTransparent, // Parts of the window may be transparent
127 eTransparencyGlass, // Transparent parts of the window have Vista AeroGlass effect applied
128 eTransparencyBorderlessGlass // As above, but without a border around the opaque areas when there would otherwise be one with eTransparencyGlass
132 * Cursor types.
135 enum nsCursor { ///(normal cursor, usually rendered as an arrow)
136 eCursor_standard,
137 ///(system is busy, usually rendered as a hourglass or watch)
138 eCursor_wait,
139 ///(Selecting something, usually rendered as an IBeam)
140 eCursor_select,
141 ///(can hyper-link, usually rendered as a human hand)
142 eCursor_hyperlink,
143 ///(north/south/west/east edge sizing)
144 eCursor_n_resize,
145 eCursor_s_resize,
146 eCursor_w_resize,
147 eCursor_e_resize,
148 ///(corner sizing)
149 eCursor_nw_resize,
150 eCursor_se_resize,
151 eCursor_ne_resize,
152 eCursor_sw_resize,
153 eCursor_crosshair,
154 eCursor_move,
155 eCursor_help,
156 eCursor_copy, // CSS3
157 eCursor_alias,
158 eCursor_context_menu,
159 eCursor_cell,
160 eCursor_grab,
161 eCursor_grabbing,
162 eCursor_spinning,
163 eCursor_zoom_in,
164 eCursor_zoom_out,
165 eCursor_not_allowed,
166 eCursor_col_resize,
167 eCursor_row_resize,
168 eCursor_no_drop,
169 eCursor_vertical_text,
170 eCursor_all_scroll,
171 eCursor_nesw_resize,
172 eCursor_nwse_resize,
173 eCursor_ns_resize,
174 eCursor_ew_resize,
175 eCursor_none,
176 // This one better be the last one in this list.
177 eCursorCount
180 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
181 eZPlacementBottom = 0, // bottom of the window stack
182 eZPlacementBelow, // just below another widget
183 eZPlacementTop // top of the window stack
187 * Before the OS goes to sleep, this topic is notified.
189 #define NS_WIDGET_SLEEP_OBSERVER_TOPIC "sleep_notification"
192 * After the OS wakes up, this topic is notified.
194 #define NS_WIDGET_WAKE_OBSERVER_TOPIC "wake_notification"
197 * Before the OS suspends the current process, this topic is notified. Some
198 * OS will kill processes that are suspended instead of resuming them.
199 * For that reason this topic may be useful to safely close down resources.
201 #define NS_WIDGET_SUSPEND_PROCESS_OBSERVER_TOPIC "suspend_process_notification"
204 * After the current process resumes from being suspended, this topic is
205 * notified.
207 #define NS_WIDGET_RESUME_PROCESS_OBSERVER_TOPIC "resume_process_notification"
210 * Preference for receiving IME updates
212 * If mWantUpdates is not NOTIFY_NOTHING, nsTextStateManager will observe text
213 * change and/or selection change and call nsIWidget::NotifyIME() with
214 * NOTIFY_IME_OF_SELECTION_CHANGE and/or NOTIFY_IME_OF_TEXT_CHANGE.
215 * Please note that the text change observing cost is very expensive especially
216 * on an HTML editor has focus.
217 * If the IME implementation on a particular platform doesn't care about
218 * NOTIFY_IME_OF_SELECTION_CHANGE and/or NOTIFY_IME_OF_TEXT_CHANGE,
219 * they should set mWantUpdates to NOTIFY_NOTHING to avoid the cost.
220 * If the IME implementation needs notifications even while our process is
221 * deactive, it should also set NOTIFY_DURING_DEACTIVE.
223 struct nsIMEUpdatePreference {
225 typedef uint8_t Notifications;
227 enum MOZ_ENUM_TYPE(Notifications)
229 NOTIFY_NOTHING = 0,
230 NOTIFY_SELECTION_CHANGE = 1 << 0,
231 NOTIFY_TEXT_CHANGE = 1 << 1,
232 NOTIFY_POSITION_CHANGE = 1 << 2,
233 // NOTIFY_MOUSE_BUTTON_EVENT_ON_CHAR is used when mouse button is pressed
234 // or released on a character in the focused editor. The notification is
235 // notified to IME as a mouse event. If it's consumed by IME, NotifyIME()
236 // returns NS_SUCCESS_EVENT_CONSUMED. Otherwise, it returns NS_OK if it's
237 // handled without any error.
238 NOTIFY_MOUSE_BUTTON_EVENT_ON_CHAR = 1 << 3,
239 // Following values indicate when widget needs or doesn't need notification.
240 NOTIFY_CHANGES_CAUSED_BY_COMPOSITION = 1 << 6,
241 // NOTE: NOTIFY_DURING_DEACTIVE isn't supported in environments where two
242 // or more compositions are possible. E.g., Mac and Linux (GTK).
243 NOTIFY_DURING_DEACTIVE = 1 << 7,
244 // Changes are notified in following conditions if the instance is
245 // just constructed. If some platforms don't need change notifications
246 // in some of following conditions, the platform should remove following
247 // flags before returing the instance from nsIWidget::GetUpdatePreference().
248 DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES =
249 NOTIFY_CHANGES_CAUSED_BY_COMPOSITION
252 nsIMEUpdatePreference()
253 : mWantUpdates(DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES)
257 explicit nsIMEUpdatePreference(Notifications aWantUpdates)
258 : mWantUpdates(aWantUpdates | DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES)
262 void DontNotifyChangesCausedByComposition()
264 mWantUpdates &= ~DEFAULT_CONDITIONS_OF_NOTIFYING_CHANGES;
267 bool WantSelectionChange() const
269 return !!(mWantUpdates & NOTIFY_SELECTION_CHANGE);
272 bool WantTextChange() const
274 return !!(mWantUpdates & NOTIFY_TEXT_CHANGE);
277 bool WantPositionChanged() const
279 return !!(mWantUpdates & NOTIFY_POSITION_CHANGE);
282 bool WantChanges() const
284 return WantSelectionChange() || WantTextChange();
287 bool WantMouseButtonEventOnChar() const
289 return !!(mWantUpdates & NOTIFY_MOUSE_BUTTON_EVENT_ON_CHAR);
292 bool WantChangesCausedByComposition() const
294 return WantChanges() &&
295 !!(mWantUpdates & NOTIFY_CHANGES_CAUSED_BY_COMPOSITION);
298 bool WantDuringDeactive() const
300 return !!(mWantUpdates & NOTIFY_DURING_DEACTIVE);
303 Notifications mWantUpdates;
308 * Contains IMEStatus plus information about the current
309 * input context that the IME can use as hints if desired.
312 namespace mozilla {
313 namespace widget {
315 struct IMEState {
317 * IME enabled states, the mEnabled value of
318 * SetInputContext()/GetInputContext() should be one value of following
319 * values.
321 * WARNING: If you change these values, you also need to edit:
322 * nsIDOMWindowUtils.idl
323 * nsContentUtils::GetWidgetStatusFromIMEStatus
325 enum Enabled {
327 * 'Disabled' means the user cannot use IME. So, the IME open state should
328 * be 'closed' during 'disabled'.
330 DISABLED,
332 * 'Enabled' means the user can use IME.
334 ENABLED,
336 * 'Password' state is a special case for the password editors.
337 * E.g., on mac, the password editors should disable the non-Roman
338 * keyboard layouts at getting focus. Thus, the password editor may have
339 * special rules on some platforms.
341 PASSWORD,
343 * This state is used when a plugin is focused.
344 * When a plug-in is focused content, we should send native events
345 * directly. Because we don't process some native events, but they may
346 * be needed by the plug-in.
348 PLUGIN
350 Enabled mEnabled;
353 * IME open states the mOpen value of SetInputContext() should be one value of
354 * OPEN, CLOSE or DONT_CHANGE_OPEN_STATE. GetInputContext() should return
355 * OPEN, CLOSE or OPEN_STATE_NOT_SUPPORTED.
357 enum Open {
359 * 'Unsupported' means the platform cannot return actual IME open state.
360 * This value is used only by GetInputContext().
362 OPEN_STATE_NOT_SUPPORTED,
364 * 'Don't change' means the widget shouldn't change IME open state when
365 * SetInputContext() is called.
367 DONT_CHANGE_OPEN_STATE = OPEN_STATE_NOT_SUPPORTED,
369 * 'Open' means that IME should compose in its primary language (or latest
370 * input mode except direct ASCII character input mode). Even if IME is
371 * opened by this value, users should be able to close IME by theirselves.
372 * Web contents can specify this value by |ime-mode: active;|.
374 OPEN,
376 * 'Closed' means that IME shouldn't handle key events (or should handle
377 * as ASCII character inputs on mobile device). Even if IME is closed by
378 * this value, users should be able to open IME by theirselves.
379 * Web contents can specify this value by |ime-mode: inactive;|.
381 CLOSED
383 Open mOpen;
385 IMEState() : mEnabled(ENABLED), mOpen(DONT_CHANGE_OPEN_STATE) { }
387 explicit IMEState(Enabled aEnabled, Open aOpen = DONT_CHANGE_OPEN_STATE) :
388 mEnabled(aEnabled), mOpen(aOpen)
392 // Returns true if the user can input characters.
393 // This means that a plain text editor, an HTML editor, a password editor or
394 // a plain text editor whose ime-mode is "disabled".
395 bool IsEditable() const
397 return mEnabled == ENABLED || mEnabled == PASSWORD;
399 // Returns true if the user might be able to input characters.
400 // This means that a plain text editor, an HTML editor, a password editor,
401 // a plain text editor whose ime-mode is "disabled" or a windowless plugin
402 // has focus.
403 bool MaybeEditable() const
405 return IsEditable() || mEnabled == PLUGIN;
409 struct InputContext {
410 InputContext()
411 : mNativeIMEContext(nullptr)
414 bool IsPasswordEditor() const
416 return mHTMLInputType.LowerCaseEqualsLiteral("password");
419 IMEState mIMEState;
421 /* The type of the input if the input is a html input field */
422 nsString mHTMLInputType;
424 /* The type of the inputmode */
425 nsString mHTMLInputInputmode;
427 /* A hint for the action that is performed when the input is submitted */
428 nsString mActionHint;
430 /* Native IME context for the widget. This doesn't come from the argument of
431 SetInputContext(). If there is only one context in the process, this may
432 be nullptr. */
433 void* mNativeIMEContext;
436 struct InputContextAction {
438 * mCause indicates what action causes calling nsIWidget::SetInputContext().
439 * It must be one of following values.
441 enum Cause {
442 // The cause is unknown but originated from content. Focus might have been
443 // changed by content script.
444 CAUSE_UNKNOWN,
445 // The cause is unknown but originated from chrome. Focus might have been
446 // changed by chrome script.
447 CAUSE_UNKNOWN_CHROME,
448 // The cause is user's keyboard operation.
449 CAUSE_KEY,
450 // The cause is user's mouse operation.
451 CAUSE_MOUSE
453 Cause mCause;
456 * mFocusChange indicates what happened for focus.
458 enum FocusChange {
459 FOCUS_NOT_CHANGED,
460 // A content got focus.
461 GOT_FOCUS,
462 // Focused content lost focus.
463 LOST_FOCUS,
464 // Menu got pseudo focus that means focused content isn't changed but
465 // keyboard events will be handled by menu.
466 MENU_GOT_PSEUDO_FOCUS,
467 // Menu lost pseudo focus that means focused content will handle keyboard
468 // events.
469 MENU_LOST_PSEUDO_FOCUS
471 FocusChange mFocusChange;
473 bool ContentGotFocusByTrustedCause() const {
474 return (mFocusChange == GOT_FOCUS &&
475 mCause != CAUSE_UNKNOWN);
478 bool UserMightRequestOpenVKB() const {
479 return (mFocusChange == FOCUS_NOT_CHANGED &&
480 mCause == CAUSE_MOUSE);
483 InputContextAction() :
484 mCause(CAUSE_UNKNOWN), mFocusChange(FOCUS_NOT_CHANGED)
488 explicit InputContextAction(Cause aCause,
489 FocusChange aFocusChange = FOCUS_NOT_CHANGED) :
490 mCause(aCause), mFocusChange(aFocusChange)
496 * Size constraints for setting the minimum and maximum size of a widget.
497 * Values are in device pixels.
499 struct SizeConstraints {
500 SizeConstraints()
501 : mMaxSize(NS_MAXSIZE, NS_MAXSIZE)
505 SizeConstraints(nsIntSize aMinSize,
506 nsIntSize aMaxSize)
507 : mMinSize(aMinSize),
508 mMaxSize(aMaxSize)
512 nsIntSize mMinSize;
513 nsIntSize mMaxSize;
516 // IMEMessage is shared by IMEStateManager and TextComposition.
517 // Update values in GeckoEditable.java if you make changes here.
518 // XXX Negative values are used in Android...
519 typedef int8_t IMEMessageType;
520 enum IMEMessage MOZ_ENUM_TYPE(IMEMessageType)
522 // An editable content is getting focus
523 NOTIFY_IME_OF_FOCUS = 1,
524 // An editable content is losing focus
525 NOTIFY_IME_OF_BLUR,
526 // Selection in the focused editable content is changed
527 NOTIFY_IME_OF_SELECTION_CHANGE,
528 // Text in the focused editable content is changed
529 NOTIFY_IME_OF_TEXT_CHANGE,
530 // Composition string has been updated
531 NOTIFY_IME_OF_COMPOSITION_UPDATE,
532 // Position or size of focused element may be changed.
533 NOTIFY_IME_OF_POSITION_CHANGE,
534 // Mouse button event is fired on a character in focused editor
535 NOTIFY_IME_OF_MOUSE_BUTTON_EVENT,
536 // Request to commit current composition to IME
537 // (some platforms may not support)
538 REQUEST_TO_COMMIT_COMPOSITION,
539 // Request to cancel current composition to IME
540 // (some platforms may not support)
541 REQUEST_TO_CANCEL_COMPOSITION
544 struct IMENotification
546 IMENotification()
547 : mMessage(static_cast<IMEMessage>(-1))
550 MOZ_IMPLICIT IMENotification(IMEMessage aMessage)
551 : mMessage(aMessage)
553 switch (aMessage) {
554 case NOTIFY_IME_OF_SELECTION_CHANGE:
555 mSelectionChangeData.mCausedByComposition = false;
556 break;
557 case NOTIFY_IME_OF_TEXT_CHANGE:
558 mTextChangeData.mStartOffset = 0;
559 mTextChangeData.mOldEndOffset = 0;
560 mTextChangeData.mNewEndOffset = 0;
561 mTextChangeData.mCausedByComposition = false;
562 break;
563 case NOTIFY_IME_OF_MOUSE_BUTTON_EVENT:
564 mMouseButtonEventData.mEventMessage = 0;
565 mMouseButtonEventData.mOffset = UINT32_MAX;
566 mMouseButtonEventData.mCursorPos.Set(nsIntPoint(0, 0));
567 mMouseButtonEventData.mCharRect.Set(nsIntRect(0, 0, 0, 0));
568 mMouseButtonEventData.mButton = -1;
569 mMouseButtonEventData.mButtons = 0;
570 mMouseButtonEventData.mModifiers = 0;
571 default:
572 break;
576 IMEMessage mMessage;
578 union
580 // NOTIFY_IME_OF_SELECTION_CHANGE specific data
581 struct
583 bool mCausedByComposition;
584 } mSelectionChangeData;
586 // NOTIFY_IME_OF_TEXT_CHANGE specific data
587 struct
589 uint32_t mStartOffset;
590 uint32_t mOldEndOffset;
591 uint32_t mNewEndOffset;
593 bool mCausedByComposition;
595 uint32_t OldLength() const { return mOldEndOffset - mStartOffset; }
596 uint32_t NewLength() const { return mNewEndOffset - mStartOffset; }
597 int32_t AdditionalLength() const
599 return static_cast<int32_t>(mNewEndOffset - mOldEndOffset);
601 bool IsInInt32Range() const
603 return mStartOffset <= INT32_MAX &&
604 mOldEndOffset <= INT32_MAX &&
605 mNewEndOffset <= INT32_MAX;
607 } mTextChangeData;
609 // NOTIFY_IME_OF_MOUSE_BUTTON_EVENT specific data
610 struct
612 // The value of WidgetEvent::message
613 uint32_t mEventMessage;
614 // Character offset from the start of the focused editor under the cursor
615 uint32_t mOffset;
616 // Cursor position in pixels relative to the widget
617 struct
619 int32_t mX;
620 int32_t mY;
622 void Set(const nsIntPoint& aPoint)
624 mX = aPoint.x;
625 mY = aPoint.y;
627 nsIntPoint AsIntPoint() const
629 return nsIntPoint(mX, mY);
631 } mCursorPos;
632 // Character rect in pixels under the cursor relative to the widget
633 struct
635 int32_t mX;
636 int32_t mY;
637 int32_t mWidth;
638 int32_t mHeight;
640 void Set(const nsIntRect& aRect)
642 mX = aRect.x;
643 mY = aRect.y;
644 mWidth = aRect.width;
645 mHeight = aRect.height;
647 nsIntRect AsIntRect() const
649 return nsIntRect(mX, mY, mWidth, mHeight);
651 } mCharRect;
652 // The value of WidgetMouseEventBase::button and buttons
653 int16_t mButton;
654 int16_t mButtons;
655 // The value of WidgetInputEvent::modifiers
656 Modifiers mModifiers;
657 } mMouseButtonEventData;
660 bool IsCausedByComposition() const
662 switch (mMessage) {
663 case NOTIFY_IME_OF_SELECTION_CHANGE:
664 return mSelectionChangeData.mCausedByComposition;
665 case NOTIFY_IME_OF_TEXT_CHANGE:
666 return mTextChangeData.mCausedByComposition;
667 default:
668 return false;
673 } // namespace widget
674 } // namespace mozilla
677 * The base class for all the widgets. It provides the interface for
678 * all basic and necessary functionality.
680 class nsIWidget : public nsISupports {
681 protected:
682 typedef mozilla::dom::TabChild TabChild;
684 public:
685 typedef mozilla::layers::Composer2D Composer2D;
686 typedef mozilla::layers::CompositorChild CompositorChild;
687 typedef mozilla::layers::LayerManager LayerManager;
688 typedef mozilla::layers::LayerManagerComposite LayerManagerComposite;
689 typedef mozilla::layers::LayersBackend LayersBackend;
690 typedef mozilla::layers::PLayerTransactionChild PLayerTransactionChild;
691 typedef mozilla::widget::IMEMessage IMEMessage;
692 typedef mozilla::widget::IMENotification IMENotification;
693 typedef mozilla::widget::IMEState IMEState;
694 typedef mozilla::widget::InputContext InputContext;
695 typedef mozilla::widget::InputContextAction InputContextAction;
696 typedef mozilla::widget::SizeConstraints SizeConstraints;
697 typedef mozilla::CompositorVsyncDispatcher CompositorVsyncDispatcher;
699 // Used in UpdateThemeGeometries.
700 struct ThemeGeometry {
701 // The -moz-appearance value for the themed widget
702 uint8_t mWidgetType;
703 // The device-pixel rect within the window for the themed widget
704 nsIntRect mRect;
706 ThemeGeometry(uint8_t aWidgetType, const nsIntRect& aRect)
707 : mWidgetType(aWidgetType)
708 , mRect(aRect)
712 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWIDGET_IID)
714 nsIWidget()
715 : mLastChild(nullptr)
716 , mPrevSibling(nullptr)
717 , mOnDestroyCalled(false)
718 , mWindowType(eWindowType_child)
719 , mZIndex(0)
722 ClearNativeTouchSequence();
727 * Create and initialize a widget.
729 * All the arguments can be null in which case a top level window
730 * with size 0 is created. The event callback function has to be
731 * provided only if the caller wants to deal with the events this
732 * widget receives. The event callback is basically a preprocess
733 * hook called synchronously. The return value determines whether
734 * the event goes to the default window procedure or it is hidden
735 * to the os. The assumption is that if the event handler returns
736 * false the widget does not see the event. The widget should not
737 * automatically clear the window to the background color. The
738 * calling code must handle paint messages and clear the background
739 * itself.
741 * In practice at least one of aParent and aNativeParent will be null. If
742 * both are null the widget isn't parented (e.g. context menus or
743 * independent top level windows).
745 * The dimensions given in aRect are specified in the parent's
746 * coordinate system, or for parentless widgets such as top-level
747 * windows, in global CSS pixels.
749 * @param aParent parent nsIWidget
750 * @param aNativeParent native parent widget
751 * @param aRect the widget dimension
752 * @param aContext
753 * @param aInitData data that is used for widget initialization
756 NS_IMETHOD Create(nsIWidget *aParent,
757 nsNativeWidget aNativeParent,
758 const nsIntRect &aRect,
759 nsDeviceContext *aContext,
760 nsWidgetInitData *aInitData = nullptr) = 0;
763 * Allocate, initialize, and return a widget that is a child of
764 * |this|. The returned widget (if nonnull) has gone through the
765 * equivalent of CreateInstance(widgetCID) + Create(...).
767 * |CreateChild()| lets widget backends decide whether to parent
768 * the new child widget to this, nonnatively parent it, or both.
769 * This interface exists to support the PuppetWidget backend,
770 * which is entirely non-native. All other params are the same as
771 * for |Create()|.
773 * |aForceUseIWidgetParent| forces |CreateChild()| to only use the
774 * |nsIWidget*| this, not its native widget (if it exists), when
775 * calling |Create()|. This is a timid hack around poorly
776 * understood code, and shouldn't be used in new code.
778 virtual already_AddRefed<nsIWidget>
779 CreateChild(const nsIntRect &aRect,
780 nsDeviceContext *aContext,
781 nsWidgetInitData *aInitData = nullptr,
782 bool aForceUseIWidgetParent = false) = 0;
785 * Attach to a top level widget.
787 * In cases where a top level chrome widget is being used as a content
788 * container, attach a secondary listener and update the device
789 * context. The primary widget listener will continue to be called for
790 * notifications relating to the top-level window, whereas other
791 * notifications such as painting and events will instead be called via
792 * the attached listener. SetAttachedWidgetListener should be used to
793 * assign the attached listener.
795 * aUseAttachedEvents if true, events are sent to the attached listener
796 * instead of the normal listener.
797 * aContext The new device context for the view
799 NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents,
800 nsDeviceContext *aContext) = 0;
803 * Accessor functions to get and set the attached listener. Used by
804 * nsView in connection with AttachViewToTopLevel above.
806 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) = 0;
807 virtual nsIWidgetListener* GetAttachedWidgetListener() = 0;
810 * Accessor functions to get and set the listener which handles various
811 * actions for the widget.
813 //@{
814 virtual nsIWidgetListener* GetWidgetListener() = 0;
815 virtual void SetWidgetListener(nsIWidgetListener* alistener) = 0;
816 //@}
819 * Close and destroy the internal native window.
820 * This method does not delete the widget.
823 NS_IMETHOD Destroy(void) = 0;
826 * Destroyed() returns true if Destroy() has been called already.
827 * Otherwise, false.
829 bool Destroyed() const { return mOnDestroyCalled; }
833 * Reparent a widget
835 * Change the widget's parent. Null parents are allowed.
837 * @param aNewParent new parent
839 NS_IMETHOD SetParent(nsIWidget* aNewParent) = 0;
841 NS_IMETHOD RegisterTouchWindow() = 0;
842 NS_IMETHOD UnregisterTouchWindow() = 0;
845 * Return the parent Widget of this Widget or nullptr if this is a
846 * top level window
848 * @return the parent widget or nullptr if it does not have a parent
851 virtual nsIWidget* GetParent(void) = 0;
854 * Return the top level Widget of this Widget
856 * @return the top level widget
858 virtual nsIWidget* GetTopLevelWidget() = 0;
861 * Return the top (non-sheet) parent of this Widget if it's a sheet,
862 * or nullptr if this isn't a sheet (or some other error occurred).
863 * Sheets are only supported on some platforms (currently only OS X).
865 * @return the top (non-sheet) parent widget or nullptr
868 virtual nsIWidget* GetSheetWindowParent(void) = 0;
871 * Return the physical DPI of the screen containing the window ...
872 * the number of device pixels per inch.
874 virtual float GetDPI() = 0;
877 * Returns the CompositorVsyncDispatcher associated with this widget
879 virtual CompositorVsyncDispatcher* GetCompositorVsyncDispatcher() = 0;
882 * Return the default scale factor for the window. This is the
883 * default number of device pixels per CSS pixel to use. This should
884 * depend on OS/platform settings such as the Mac's "UI scale factor"
885 * or Windows' "font DPI". This will take into account Gecko preferences
886 * overriding the system setting.
888 mozilla::CSSToLayoutDeviceScale GetDefaultScale();
891 * Return the Gecko override of the system default scale, if any;
892 * returns <= 0.0 if the system scale should be used as-is.
893 * nsIWidget::GetDefaultScale() [above] takes this into account.
894 * It is exposed here so that code that wants to check for a
895 * default-scale override without having a widget on hand can
896 * easily access the same value.
897 * Note that any scale override is a browser-wide value, whereas
898 * the default GetDefaultScale value (when no override is present)
899 * may vary between widgets (or screens).
901 static double DefaultScaleOverride();
904 * Return the first child of this widget. Will return null if
905 * there are no children.
907 nsIWidget* GetFirstChild() const {
908 return mFirstChild;
912 * Return the last child of this widget. Will return null if
913 * there are no children.
915 nsIWidget* GetLastChild() const {
916 return mLastChild;
920 * Return the next sibling of this widget
922 nsIWidget* GetNextSibling() const {
923 return mNextSibling;
927 * Set the next sibling of this widget
929 void SetNextSibling(nsIWidget* aSibling) {
930 mNextSibling = aSibling;
934 * Return the previous sibling of this widget
936 nsIWidget* GetPrevSibling() const {
937 return mPrevSibling;
941 * Set the previous sibling of this widget
943 void SetPrevSibling(nsIWidget* aSibling) {
944 mPrevSibling = aSibling;
948 * Show or hide this widget
950 * @param aState true to show the Widget, false to hide it
953 NS_IMETHOD Show(bool aState) = 0;
956 * Make the window modal
959 NS_IMETHOD SetModal(bool aModal) = 0;
962 * The maximum number of simultaneous touch contacts supported by the device.
963 * In the case of devices with multiple digitizers (e.g. multiple touch screens),
964 * the value will be the maximum of the set of maximum supported contacts by
965 * each individual digitizer.
967 virtual uint32_t GetMaxTouchPoints() const = 0;
970 * Returns whether the window is visible
973 virtual bool IsVisible() const = 0;
976 * Perform platform-dependent sanity check on a potential window position.
977 * This is guaranteed to work only for top-level windows.
979 * @param aAllowSlop: if true, allow the window to slop offscreen;
980 * the window should be partially visible. if false,
981 * force the entire window onscreen (or at least
982 * the upper-left corner, if it's too large).
983 * @param aX in: an x position expressed in screen coordinates.
984 * out: the x position constrained to fit on the screen(s).
985 * @param aY in: an y position expressed in screen coordinates.
986 * out: the y position constrained to fit on the screen(s).
987 * @return vapid success indication. but see also the parameters.
990 NS_IMETHOD ConstrainPosition(bool aAllowSlop,
991 int32_t *aX,
992 int32_t *aY) = 0;
995 * NOTE:
997 * For a top-level window widget, the "parent's coordinate system" is the
998 * "global" display pixel coordinate space, *not* device pixels (which
999 * may be inconsistent between multiple screens, at least in the Mac OS
1000 * case with mixed hi-dpi and lo-dpi displays). This applies to all the
1001 * following Move and Resize widget APIs.
1003 * The display-/device-pixel distinction becomes important for (at least)
1004 * Mac OS X with Hi-DPI (retina) displays, and Windows when the UI scale
1005 * factor is set to other than 100%.
1007 * The Move and Resize methods take floating-point parameters, rather than
1008 * integer ones. This is important when manipulating top-level widgets,
1009 * where the coordinate system may not be an integral multiple of the
1010 * device-pixel space.
1014 * Move this widget.
1016 * Coordinates refer to the top-left of the widget. For toplevel windows
1017 * with decorations, this is the top-left of the titlebar and frame .
1019 * @param aX the new x position expressed in the parent's coordinate system
1020 * @param aY the new y position expressed in the parent's coordinate system
1023 NS_IMETHOD Move(double aX, double aY) = 0;
1026 * Reposition this widget so that the client area has the given offset.
1028 * @param aX the new x offset of the client area expressed as an
1029 * offset from the origin of the client area of the parent
1030 * widget (for root widgets and popup widgets it is in
1031 * screen coordinates)
1032 * @param aY the new y offset of the client area expressed as an
1033 * offset from the origin of the client area of the parent
1034 * widget (for root widgets and popup widgets it is in
1035 * screen coordinates)
1038 NS_IMETHOD MoveClient(double aX, double aY) = 0;
1041 * Resize this widget. Any size constraints set for the window by a
1042 * previous call to SetSizeConstraints will be applied.
1044 * @param aWidth the new width expressed in the parent's coordinate system
1045 * @param aHeight the new height expressed in the parent's coordinate system
1046 * @param aRepaint whether the widget should be repainted
1049 NS_IMETHOD Resize(double aWidth,
1050 double aHeight,
1051 bool aRepaint) = 0;
1054 * Move or resize this widget. Any size constraints set for the window by
1055 * a previous call to SetSizeConstraints will be applied.
1057 * @param aX the new x position expressed in the parent's coordinate system
1058 * @param aY the new y position expressed in the parent's coordinate system
1059 * @param aWidth the new width expressed in the parent's coordinate system
1060 * @param aHeight the new height expressed in the parent's coordinate system
1061 * @param aRepaint whether the widget should be repainted if the size changes
1064 NS_IMETHOD Resize(double aX,
1065 double aY,
1066 double aWidth,
1067 double aHeight,
1068 bool aRepaint) = 0;
1071 * Resize the widget so that the inner client area has the given size.
1073 * @param aWidth the new width of the client area.
1074 * @param aHeight the new height of the client area.
1075 * @param aRepaint whether the widget should be repainted
1078 NS_IMETHOD ResizeClient(double aWidth,
1079 double aHeight,
1080 bool aRepaint) = 0;
1083 * Resize and reposition the widget so tht inner client area has the given
1084 * offset and size.
1086 * @param aX the new x offset of the client area expressed as an
1087 * offset from the origin of the client area of the parent
1088 * widget (for root widgets and popup widgets it is in
1089 * screen coordinates)
1090 * @param aY the new y offset of the client area expressed as an
1091 * offset from the origin of the client area of the parent
1092 * widget (for root widgets and popup widgets it is in
1093 * screen coordinates)
1094 * @param aWidth the new width of the client area.
1095 * @param aHeight the new height of the client area.
1096 * @param aRepaint whether the widget should be repainted
1099 NS_IMETHOD ResizeClient(double aX,
1100 double aY,
1101 double aWidth,
1102 double aHeight,
1103 bool aRepaint) = 0;
1106 * Sets the widget's z-index.
1108 virtual void SetZIndex(int32_t aZIndex) = 0;
1111 * Gets the widget's z-index.
1113 int32_t GetZIndex()
1115 return mZIndex;
1119 * Position this widget just behind the given widget. (Used to
1120 * control z-order for top-level widgets. Get/SetZIndex by contrast
1121 * control z-order for child widgets of other widgets.)
1122 * @param aPlacement top, bottom, or below a widget
1123 * (if top or bottom, param aWidget is ignored)
1124 * @param aWidget widget to place this widget behind
1125 * (only if aPlacement is eZPlacementBelow).
1126 * null is equivalent to aPlacement of eZPlacementTop
1127 * @param aActivate true to activate the widget after placing it
1129 NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
1130 nsIWidget *aWidget, bool aActivate) = 0;
1133 * Minimize, maximize or normalize the window size.
1134 * Takes a value from nsSizeMode (see nsIWidgetListener.h)
1136 NS_IMETHOD SetSizeMode(int32_t aMode) = 0;
1139 * Return size mode (minimized, maximized, normalized).
1140 * Returns a value from nsSizeMode (see nsIWidgetListener.h)
1142 virtual int32_t SizeMode() = 0;
1145 * Enable or disable this Widget
1147 * @param aState true to enable the Widget, false to disable it.
1150 NS_IMETHOD Enable(bool aState) = 0;
1153 * Ask whether the widget is enabled
1155 virtual bool IsEnabled() const = 0;
1158 * Request activation of this window or give focus to this widget.
1160 * @param aRaise If true, this function requests activation of this
1161 * widget's toplevel window.
1162 * If false, the appropriate toplevel window (which in
1163 * the case of popups may not be this widget's toplevel
1164 * window) is already active.
1166 NS_IMETHOD SetFocus(bool aRaise = false) = 0;
1169 * Get this widget's outside dimensions relative to its parent widget. For
1170 * popup widgets the returned rect is in screen coordinates and not
1171 * relative to its parent widget.
1173 * @param aRect On return it holds the x, y, width and height of
1174 * this widget.
1176 NS_IMETHOD GetBounds(nsIntRect &aRect) = 0;
1179 * Get this widget's outside dimensions in global coordinates. This
1180 * includes any title bar on the window.
1182 * @param aRect On return it holds the x, y, width and height of
1183 * this widget.
1185 NS_IMETHOD GetScreenBounds(nsIntRect &aRect) = 0;
1188 * Similar to GetScreenBounds except that this function will always
1189 * get the size when the widget is in the nsSizeMode_Normal size mode
1190 * even if the current size mode is not nsSizeMode_Normal.
1191 * This method will fail if the size mode is not nsSizeMode_Normal and
1192 * the platform doesn't have the ability.
1193 * This method will always succeed if the current size mode is
1194 * nsSizeMode_Normal.
1196 * @param aRect On return it holds the x, y, width and height of
1197 * this widget.
1199 NS_IMETHOD GetRestoredBounds(nsIntRect &aRect) = 0;
1202 * Get this widget's client area bounds, if the window has a 3D border
1203 * appearance this returns the area inside the border. The position is the
1204 * position of the client area relative to the client area of the parent
1205 * widget (for root widgets and popup widgets it is in screen coordinates).
1207 * @param aRect On return it holds the x. y, width and height of
1208 * the client area of this widget.
1210 NS_IMETHOD GetClientBounds(nsIntRect &aRect) = 0;
1213 * Get the non-client area dimensions of the window.
1216 NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) = 0;
1219 * Sets the non-client area dimensions of the window. Pass -1 to restore
1220 * the system default frame size for that border. Pass zero to remove
1221 * a border, or pass a specific value adjust a border. Units are in
1222 * pixels. (DPI dependent)
1224 * Platform notes:
1225 * Windows: shrinking top non-client height will remove application
1226 * icon and window title text. Glass desktops will refuse to set
1227 * dimensions between zero and size < system default.
1230 NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) = 0;
1233 * Get the client offset from the window origin.
1235 * @return the x and y of the offset.
1238 virtual nsIntPoint GetClientOffset() = 0;
1241 * Set the background color for this widget
1243 * @param aColor the new background color
1247 virtual void SetBackgroundColor(const nscolor &aColor) { }
1250 * Get the cursor for this widget.
1252 * @return this widget's cursor.
1255 virtual nsCursor GetCursor(void) = 0;
1258 * Set the cursor for this widget
1260 * @param aCursor the new cursor for this widget
1263 NS_IMETHOD SetCursor(nsCursor aCursor) = 0;
1266 * If a cursor type is currently cached locally for this widget, clear the
1267 * cached cursor to force an update on the next SetCursor call.
1270 virtual void ClearCachedCursor() = 0;
1273 * Sets an image as the cursor for this widget.
1275 * @param aCursor the cursor to set
1276 * @param aX the X coordinate of the hotspot (from left).
1277 * @param aY the Y coordinate of the hotspot (from top).
1278 * @retval NS_ERROR_NOT_IMPLEMENTED if setting images as cursors is not
1279 * supported
1281 NS_IMETHOD SetCursor(imgIContainer* aCursor,
1282 uint32_t aHotspotX, uint32_t aHotspotY) = 0;
1284 /**
1285 * Get the window type of this widget.
1287 nsWindowType WindowType() { return mWindowType; }
1290 * Determines if this widget is one of the three types of plugin widgets.
1292 bool IsPlugin() {
1293 return mWindowType == eWindowType_plugin ||
1294 mWindowType == eWindowType_plugin_ipc_chrome ||
1295 mWindowType == eWindowType_plugin_ipc_content;
1299 * Set the transparency mode of the top-level window containing this widget.
1300 * So, e.g., if you call this on the widget for an IFRAME, the top level
1301 * browser window containing the IFRAME actually gets set. Be careful.
1303 * This can fail if the platform doesn't support
1304 * transparency/glass. By default widgets are not
1305 * transparent. This will also fail if the toplevel window is not
1306 * a Mozilla window, e.g., if the widget is in an embedded
1307 * context.
1309 * After transparency/glass has been enabled, the initial alpha channel
1310 * value for all pixels is 1, i.e., opaque.
1311 * If the window is resized then the alpha channel values for
1312 * all pixels are reset to 1.
1313 * Pixel RGB color values are already premultiplied with alpha channel values.
1315 virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
1318 * Get the transparency mode of the top-level window that contains this
1319 * widget.
1321 virtual nsTransparencyMode GetTransparencyMode() = 0;
1324 * This represents a command to set the bounds and clip region of
1325 * a child widget.
1327 struct Configuration {
1328 nsIWidget* mChild;
1329 nsIntRect mBounds;
1330 nsTArray<nsIntRect> mClipRegion;
1334 * Sets the clip region of each mChild (which must actually be a child
1335 * of this widget) to the union of the pixel rects given in
1336 * mClipRegion, all relative to the top-left of the child
1337 * widget. Clip regions are not implemented on all platforms and only
1338 * need to actually work for children that are plugins.
1340 * Also sets the bounds of each child to mBounds.
1342 * This will invalidate areas of the children that have changed, but
1343 * does not need to invalidate any part of this widget.
1345 * Children should be moved in the order given; the array is
1346 * sorted so to minimize unnecessary invalidation if children are
1347 * moved in that order.
1349 virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) = 0;
1350 virtual nsresult SetWindowClipRegion(const nsTArray<nsIntRect>& aRects,
1351 bool aIntersectWithExisting) = 0;
1354 * Appends to aRects the rectangles constituting this widget's clip
1355 * region. If this widget is not clipped, appends a single rectangle
1356 * (0, 0, bounds.width, bounds.height).
1358 virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects) = 0;
1361 * Set the shadow style of the window.
1363 * Ignored on child widgets and on non-Mac platforms.
1365 NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) = 0;
1368 * On Mac OS X, this method shows or hides the pill button in the titlebar
1369 * that's used to collapse the toolbar.
1371 * Ignored on child widgets and on non-Mac platforms.
1373 virtual void SetShowsToolbarButton(bool aShow) = 0;
1376 * On Mac OS X Lion, this method shows or hides the full screen button in
1377 * the titlebar that handles native full screen mode.
1379 * Ignored on child widgets, non-Mac platforms, & pre-Lion Mac.
1381 virtual void SetShowsFullScreenButton(bool aShow) = 0;
1383 enum WindowAnimationType {
1384 eGenericWindowAnimation,
1385 eDocumentWindowAnimation
1389 * Sets the kind of top-level window animation this widget should have. On
1390 * Mac OS X, this causes a particular kind of animation to be shown when the
1391 * window is first made visible.
1393 * Ignored on child widgets and on non-Mac platforms.
1395 virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1398 * Specifies whether the window title should be drawn even if the window
1399 * contents extend into the titlebar. Ignored on windows that don't draw
1400 * in the titlebar. Only implemented on OS X.
1402 virtual void SetDrawsTitle(bool aDrawTitle) {}
1405 * Indicates whether the widget should attempt to make titlebar controls
1406 * easier to see on dark titlebar backgrounds.
1408 virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) {}
1410 /**
1411 * Hide window chrome (borders, buttons) for this widget.
1414 NS_IMETHOD HideWindowChrome(bool aShouldHide) = 0;
1417 * Put the toplevel window into or out of fullscreen mode.
1418 * If aTargetScreen is given, attempt to go fullscreen on that screen,
1419 * if possible. (If not, it behaves as if aTargetScreen is null.)
1420 * If !aFullScreen, aTargetScreen is ignored.
1421 * aTargetScreen support is currently only implemented on Windows.
1423 NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen = nullptr) = 0;
1426 * Invalidate a specified rect for a widget so that it will be repainted
1427 * later.
1429 NS_IMETHOD Invalidate(const nsIntRect & aRect) = 0;
1431 enum LayerManagerPersistence
1433 LAYER_MANAGER_CURRENT = 0,
1434 LAYER_MANAGER_PERSISTENT
1438 * Return the widget's LayerManager. The layer tree for that
1439 * LayerManager is what gets rendered to the widget.
1441 * @param aAllowRetaining an outparam that states whether the returned
1442 * layer manager should be used for retained layers
1444 inline LayerManager* GetLayerManager(bool* aAllowRetaining = nullptr)
1446 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE,
1447 LAYER_MANAGER_CURRENT, aAllowRetaining);
1450 inline LayerManager* GetLayerManager(LayerManagerPersistence aPersistence,
1451 bool* aAllowRetaining = nullptr)
1453 return GetLayerManager(nullptr, mozilla::layers::LayersBackend::LAYERS_NONE,
1454 aPersistence, aAllowRetaining);
1458 * Like GetLayerManager(), but prefers creating a layer manager of
1459 * type |aBackendHint| instead of what would normally be created.
1460 * LayersBackend::LAYERS_NONE means "no hint".
1462 virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager,
1463 LayersBackend aBackendHint,
1464 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
1465 bool* aAllowRetaining = nullptr) = 0;
1468 * Called before each layer manager transaction to allow any preparation
1469 * for DrawWindowUnderlay/Overlay that needs to be on the main thread.
1471 * Always called on the main thread.
1473 virtual void PrepareWindowEffects() = 0;
1476 * Called when shutting down the LayerManager to clean-up any cached resources.
1478 * Always called from the compositing thread, which may be the main-thread if
1479 * OMTC is not enabled.
1481 virtual void CleanupWindowEffects() = 0;
1484 * Called before rendering using OMTC. Returns false when the widget is
1485 * not ready to be rendered (for example while the window is closed).
1487 * Always called from the compositing thread, which may be the main-thread if
1488 * OMTC is not enabled.
1490 virtual bool PreRender(LayerManagerComposite* aManager) = 0;
1493 * Called after rendering using OMTC. Not called when rendering was
1494 * cancelled by a negative return value from PreRender.
1496 * Always called from the compositing thread, which may be the main-thread if
1497 * OMTC is not enabled.
1499 virtual void PostRender(LayerManagerComposite* aManager) = 0;
1502 * Called before the LayerManager draws the layer tree.
1504 * Always called from the compositing thread.
1506 virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0;
1509 * Called after the LayerManager draws the layer tree
1511 * Always called from the compositing thread.
1513 virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) = 0;
1516 * Return a DrawTarget for the window which can be composited into.
1518 * Called by BasicCompositor on the compositor thread for OMTC drawing
1519 * before each composition.
1521 virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() = 0;
1524 * Ensure that what was painted into the DrawTarget returned from
1525 * StartRemoteDrawing reaches the screen.
1527 * Called by BasicCompositor on the compositor thread for OMTC drawing
1528 * after each composition.
1530 virtual void EndRemoteDrawing() = 0;
1533 * Clean up any resources used by Start/EndRemoteDrawing.
1535 * Called by BasicCompositor on the compositor thread for OMTC drawing
1536 * when the compositor is destroyed.
1538 virtual void CleanupRemoteDrawing() = 0;
1541 * Called when Gecko knows which themed widgets exist in this window.
1542 * The passed array contains an entry for every themed widget of the right
1543 * type (currently only NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR and
1544 * NS_THEME_TOOLBAR) within the window, except for themed widgets which are
1545 * transformed or have effects applied to them (e.g. CSS opacity or
1546 * filters).
1547 * This could sometimes be called during display list construction
1548 * outside of painting.
1549 * If called during painting, it will be called before we actually
1550 * paint anything.
1552 virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) = 0;
1555 * Informs the widget about the region of the window that is opaque.
1557 * @param aOpaqueRegion the region of the window that is opaque.
1559 virtual void UpdateOpaqueRegion(const nsIntRegion &aOpaqueRegion) {}
1562 * Informs the widget about the region of the window that is draggable.
1564 virtual void UpdateWindowDraggingRegion(const nsIntRegion& aRegion) {}
1566 /**
1567 * Internal methods
1570 //@{
1571 virtual void AddChild(nsIWidget* aChild) = 0;
1572 virtual void RemoveChild(nsIWidget* aChild) = 0;
1573 virtual void* GetNativeData(uint32_t aDataType) = 0;
1574 virtual void FreeNativeData(void * data, uint32_t aDataType) = 0;//~~~
1576 // GetDeviceContext returns a weak pointer to this widget's device context
1577 virtual nsDeviceContext* GetDeviceContext() = 0;
1579 //@}
1582 * Set the widget's title.
1583 * Must be called after Create.
1585 * @param aTitle string displayed as the title of the widget
1588 NS_IMETHOD SetTitle(const nsAString& aTitle) = 0;
1591 * Set the widget's icon.
1592 * Must be called after Create.
1594 * @param anIconSpec string specifying the icon to use; convention is to pass
1595 * a resource: URL from which a platform-dependent resource
1596 * file name will be constructed
1599 NS_IMETHOD SetIcon(const nsAString& anIconSpec) = 0;
1602 * Return this widget's origin in screen coordinates.
1604 * @return screen coordinates stored in the x,y members
1607 virtual nsIntPoint WidgetToScreenOffset() = 0;
1610 * Given the specified client size, return the corresponding window size,
1611 * which includes the area for the borders and titlebar. This method
1612 * should work even when the window is not yet visible.
1614 virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) = 0;
1617 * Dispatches an event to the widget
1620 NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* event,
1621 nsEventStatus & aStatus) = 0;
1624 * Enables the dropping of files to a widget (XXX this is temporary)
1627 NS_IMETHOD EnableDragDrop(bool aEnable) = 0;
1630 * Enables/Disables system mouse capture.
1631 * @param aCapture true enables mouse capture, false disables mouse capture
1634 NS_IMETHOD CaptureMouse(bool aCapture) = 0;
1637 * Classify the window for the window manager. Mostly for X11.
1639 NS_IMETHOD SetWindowClass(const nsAString& xulWinType) = 0;
1642 * Enables/Disables system capture of any and all events that would cause a
1643 * popup to be rolled up. aListener should be set to a non-null value for
1644 * any popups that are not managed by the popup manager.
1645 * @param aDoCapture true enables capture, false disables capture
1648 NS_IMETHOD CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) = 0;
1651 * Bring this window to the user's attention. This is intended to be a more
1652 * gentle notification than popping the window to the top or putting up an
1653 * alert. See, for example, Win32 FlashWindow or the NotificationManager on
1654 * the Mac. The notification should be suppressed if the window is already
1655 * in the foreground and should be dismissed when the user brings this window
1656 * to the foreground.
1657 * @param aCycleCount Maximum number of times to animate the window per system
1658 * conventions. If set to -1, cycles indefinitely until
1659 * window is brought into the foreground.
1661 NS_IMETHOD GetAttention(int32_t aCycleCount) = 0;
1664 * Ask whether there user input events pending. All input events are
1665 * included, including those not targeted at this nsIwidget instance.
1667 virtual bool HasPendingInputEvent() = 0;
1670 * Set the background color of the window titlebar for this widget. On Mac,
1671 * for example, this will remove the grey gradient and bottom border and
1672 * instead show a single, solid color.
1674 * Ignored on any platform that does not support it. Ignored by widgets that
1675 * do not represent windows.
1677 * @param aColor The color to set the title bar background to. Alpha values
1678 * other than fully transparent (0) are respected if possible
1679 * on the platform. An alpha of 0 will cause the window to
1680 * draw with the default style for the platform.
1682 * @param aActive Whether the color should be applied to active or inactive
1683 * windows.
1685 NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) = 0;
1688 * If set to true, the window will draw its contents into the titlebar
1689 * instead of below it.
1691 * Ignored on any platform that does not support it. Ignored by widgets that
1692 * do not represent windows.
1693 * May result in a resize event, so should only be called from places where
1694 * reflow and painting is allowed.
1696 * @param aState Whether drawing into the titlebar should be activated.
1698 virtual void SetDrawsInTitlebar(bool aState) = 0;
1701 * Determine whether the widget shows a resize widget. If it does,
1702 * aResizerRect returns the resizer's rect.
1704 * Returns false on any platform that does not support it.
1706 * @param aResizerRect The resizer's rect in device pixels.
1707 * @return Whether a resize widget is shown.
1709 virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) = 0;
1712 * Return the popup that was last rolled up, or null if there isn't one.
1714 virtual nsIContent* GetLastRollup() = 0;
1717 * Begin a window resizing drag, based on the event passed in.
1719 NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
1720 int32_t aHorizontal,
1721 int32_t aVertical) = 0;
1724 * Begin a window moving drag, based on the event passed in.
1726 NS_IMETHOD BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) = 0;
1728 enum Modifiers {
1729 CAPS_LOCK = 0x01, // when CapsLock is active
1730 NUM_LOCK = 0x02, // when NumLock is active
1731 SHIFT_L = 0x0100,
1732 SHIFT_R = 0x0200,
1733 CTRL_L = 0x0400,
1734 CTRL_R = 0x0800,
1735 ALT_L = 0x1000, // includes Option
1736 ALT_R = 0x2000,
1737 COMMAND_L = 0x4000,
1738 COMMAND_R = 0x8000,
1739 HELP = 0x10000,
1740 FUNCTION = 0x100000,
1741 NUMERIC_KEY_PAD = 0x01000000 // when the key is coming from the keypad
1744 * Utility method intended for testing. Dispatches native key events
1745 * to this widget to simulate the press and release of a key.
1746 * @param aNativeKeyboardLayout a *platform-specific* constant.
1747 * On Mac, this is the resource ID for a 'uchr' or 'kchr' resource.
1748 * On Windows, it is converted to a hex string and passed to
1749 * LoadKeyboardLayout, see
1750 * http://msdn.microsoft.com/en-us/library/ms646305(VS.85).aspx
1751 * @param aNativeKeyCode a *platform-specific* keycode.
1752 * On Windows, this is the virtual key code.
1753 * @param aModifiers some combination of the above 'Modifiers' flags;
1754 * not all flags will apply to all platforms. Mac ignores the _R
1755 * modifiers. Windows ignores COMMAND, NUMERIC_KEY_PAD, HELP and
1756 * FUNCTION.
1757 * @param aCharacters characters that the OS would decide to generate
1758 * from the event. On Windows, this is the charCode passed by
1759 * WM_CHAR.
1760 * @param aUnmodifiedCharacters characters that the OS would decide
1761 * to generate from the event if modifier keys (other than shift)
1762 * were assumed inactive. Needed on Mac, ignored on Windows.
1763 * @return NS_ERROR_NOT_AVAILABLE to indicate that the keyboard
1764 * layout is not supported and the event was not fired
1766 virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
1767 int32_t aNativeKeyCode,
1768 uint32_t aModifierFlags,
1769 const nsAString& aCharacters,
1770 const nsAString& aUnmodifiedCharacters) = 0;
1773 * Utility method intended for testing. Dispatches native mouse events
1774 * may even move the mouse cursor. On Mac the events are guaranteed to
1775 * be sent to the window containing this widget, but on Windows they'll go
1776 * to whatever's topmost on the screen at that position, so for
1777 * cross-platform testing ensure that your window is at the top of the
1778 * z-order.
1779 * @param aPoint screen location of the mouse, in device
1780 * pixels, with origin at the top left
1781 * @param aNativeMessage *platform-specific* event type (e.g. on Mac,
1782 * NSMouseMoved; on Windows, MOUSEEVENTF_MOVE, MOUSEEVENTF_LEFTDOWN etc)
1783 * @param aModifierFlags *platform-specific* modifier flags (ignored
1784 * on Windows)
1786 virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
1787 uint32_t aNativeMessage,
1788 uint32_t aModifierFlags) = 0;
1791 * A shortcut to SynthesizeNativeMouseEvent, abstracting away the native message.
1792 * aPoint is location in device pixels to which the mouse pointer moves to.
1794 virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) = 0;
1797 * Utility method intended for testing. Dispatching native mouse scroll
1798 * events may move the mouse cursor.
1800 * @param aPoint Mouse cursor position in screen coordinates.
1801 * In device pixels, the origin at the top left of
1802 * the primary display.
1803 * @param aNativeMessage Platform native message.
1804 * @param aDeltaX The delta value for X direction. If the native
1805 * message doesn't indicate X direction scrolling,
1806 * this may be ignored.
1807 * @param aDeltaY The delta value for Y direction. If the native
1808 * message doesn't indicate Y direction scrolling,
1809 * this may be ignored.
1810 * @param aDeltaZ The delta value for Z direction. If the native
1811 * message doesn't indicate Z direction scrolling,
1812 * this may be ignored.
1813 * @param aModifierFlags Must be values of Modifiers, or zero.
1814 * @param aAdditionalFlags See nsIDOMWidnowUtils' consts and their
1815 * document.
1817 virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint,
1818 uint32_t aNativeMessage,
1819 double aDeltaX,
1820 double aDeltaY,
1821 double aDeltaZ,
1822 uint32_t aModifierFlags,
1823 uint32_t aAdditionalFlags) = 0;
1826 * TouchPointerState states for SynthesizeNativeTouchPoint. Match
1827 * touch states in nsIDOMWindowUtils.idl.
1829 enum TouchPointerState {
1830 // The pointer is in a hover state above the digitizer
1831 TOUCH_HOVER = 0x01,
1832 // The pointer is in contact with the digitizer
1833 TOUCH_CONTACT = 0x02,
1834 // The pointer has been removed from the digitizer detection area
1835 TOUCH_REMOVE = 0x04,
1836 // The pointer has been canceled. Will cancel any pending os level
1837 // gestures that would triggered as a result of completion of the
1838 // input sequence. This may not cancel moz platform related events
1839 // that might get tirggered by input already delivered.
1840 TOUCH_CANCEL = 0x08
1844 * Create a new or update an existing touch pointer on the digitizer.
1845 * To trigger os level gestures, individual touch points should
1846 * transition through a complete set of touch states which should be
1847 * sent as individual messages.
1849 * @param aPointerId The touch point id to create or update.
1850 * @param aPointerState one or more of the touch states listed above
1851 * @param aScreenX, aScreenY screen coords of this event
1852 * @param aPressure 0.0 -> 1.0 float val indicating pressure
1853 * @param aOrientation 0 -> 359 degree value indicating the
1854 * orientation of the pointer. Use 90 for normal taps.
1856 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
1857 TouchPointerState aPointerState,
1858 nsIntPoint aPointerScreenPoint,
1859 double aPointerPressure,
1860 uint32_t aPointerOrientation) = 0;
1863 * Cancels all active simulated touch input points and pending long taps.
1864 * Native widgets should track existing points such that they can clear the
1865 * digitizer state when this call is made.
1867 virtual nsresult ClearNativeTouchSequence();
1870 * Helper for simulating a simple tap event with one touch point. When
1871 * aLongTap is true, simulates a native long tap with a duration equal to
1872 * ui.click_hold_context_menus.delay. This pref is compatible with the
1873 * apzc long tap duration. Defaults to 1.5 seconds.
1875 nsresult SynthesizeNativeTouchTap(nsIntPoint aPointerScreenPoint,
1876 bool aLongTap);
1878 private:
1879 class LongTapInfo
1881 public:
1882 LongTapInfo(int32_t aPointerId, nsIntPoint& aPoint,
1883 mozilla::TimeDuration aDuration) :
1884 mPointerId(aPointerId),
1885 mPosition(aPoint),
1886 mDuration(aDuration),
1887 mStamp(mozilla::TimeStamp::Now())
1891 int32_t mPointerId;
1892 nsIntPoint mPosition;
1893 mozilla::TimeDuration mDuration;
1894 mozilla::TimeStamp mStamp;
1897 static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);
1899 nsAutoPtr<LongTapInfo> mLongTapTouchPoint;
1900 nsCOMPtr<nsITimer> mLongTapTimer;
1901 static int32_t sPointerIdCounter;
1903 public:
1905 * Activates a native menu item at the position specified by the index
1906 * string. The index string is a string of positive integers separated
1907 * by the "|" (pipe) character. The last integer in the string represents
1908 * the item index in a submenu located using the integers preceding it.
1910 * Example: 1|0|4
1911 * In this string, the first integer represents the top-level submenu
1912 * in the native menu bar. Since the integer is 1, it is the second submeu
1913 * in the native menu bar. Within that, the first item (index 0) is a
1914 * submenu, and we want to activate the 5th item within that submenu.
1916 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) = 0;
1919 * This is used for native menu system testing.
1921 * Updates a native menu at the position specified by the index string.
1922 * The index string is a string of positive integers separated by the "|"
1923 * (pipe) character.
1925 * Example: 1|0|4
1926 * In this string, the first integer represents the top-level submenu
1927 * in the native menu bar. Since the integer is 1, it is the second submeu
1928 * in the native menu bar. Within that, the first item (index 0) is a
1929 * submenu, and we want to update submenu at index 4 within that submenu.
1931 * If this is called with an empty string it forces a full reload of the
1932 * menu system.
1934 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) = 0;
1937 * Notify IME of the specified notification.
1939 * @return If the notification is mouse button event and it's consumed by
1940 * IME, this returns NS_SUCCESS_EVENT_CONSUMED.
1942 NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) = 0;
1945 * Start plugin IME. If this results in a string getting committed, the
1946 * result is in aCommitted (otherwise aCommitted is empty).
1948 * aKeyboardEvent The event with which plugin IME is to be started
1949 * panelX and panelY Location in screen coordinates of the IME input panel
1950 * (should be just under the plugin)
1951 * aCommitted The string committed during IME -- otherwise empty
1953 NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
1954 int32_t aPanelX, int32_t aPanelY,
1955 nsString& aCommitted) = 0;
1958 * Tells the widget whether or not a plugin (inside the widget) has the
1959 * keyboard focus. Should be sent when the keyboard focus changes too or
1960 * from a plugin.
1962 * aFocused Whether or not a plugin is focused
1964 NS_IMETHOD SetPluginFocused(bool& aFocused) = 0;
1967 * Notifies the input context changes.
1969 NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
1970 const InputContextAction& aAction) = 0;
1973 * Get current input context.
1975 NS_IMETHOD_(InputContext) GetInputContext() = 0;
1978 * Given a WidgetKeyboardEvent, this method synthesizes a corresponding
1979 * native (OS-level) event for it. This method allows tests to simulate
1980 * keystrokes that trigger native key bindings (which require a native
1981 * event).
1983 NS_IMETHOD AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) = 0;
1986 * Execute native key bindings for aType.
1988 typedef void (*DoCommandCallback)(mozilla::Command, void*);
1989 enum NativeKeyBindingsType
1991 NativeKeyBindingsForSingleLineEditor,
1992 NativeKeyBindingsForMultiLineEditor,
1993 NativeKeyBindingsForRichTextEditor
1995 NS_IMETHOD_(bool) ExecuteNativeKeyBinding(
1996 NativeKeyBindingsType aType,
1997 const mozilla::WidgetKeyboardEvent& aEvent,
1998 DoCommandCallback aCallback,
1999 void* aCallbackData) = 0;
2002 * Get toggled key states.
2003 * aKeyCode should be NS_VK_CAPS_LOCK or NS_VK_NUM_LOCK or
2004 * NS_VK_SCROLL_LOCK.
2005 * aLEDState is the result for current LED state of the key.
2006 * If the LED is 'ON', it returns TRUE, otherwise, FALSE.
2007 * If the platform doesn't support the LED state (or we cannot get the
2008 * state), this method returns NS_ERROR_NOT_IMPLEMENTED.
2010 NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) = 0;
2013 * Retrieves preference for IME updates
2015 virtual nsIMEUpdatePreference GetIMEUpdatePreference() = 0;
2018 * Call this method when a dialog is opened which has a default button.
2019 * The button's rectangle should be supplied in aButtonRect.
2021 NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) = 0;
2024 * Compute the overridden system mouse scroll speed on the root content of
2025 * web pages. The widget may set the same value as aOriginalDelta. E.g.,
2026 * when the system scrolling settings were customized, widget can respect
2027 * the will of the user.
2029 * This is called only when the mouse wheel event scrolls the root content
2030 * of the web pages by line. In other words, this isn't called when the
2031 * mouse wheel event is used for zoom, page scroll and other special
2032 * actions. And also this isn't called when the user doesn't use the
2033 * system wheel speed settings.
2035 * @param aOriginalDeltaX The X delta value of the current mouse wheel
2036 * scrolling event.
2037 * @param aOriginalDeltaX The Y delta value of the current mouse wheel
2038 * scrolling event.
2039 * @param aOverriddenDeltaX The overridden mouse scrolling speed along X
2040 * axis. This value may be same as aOriginalDeltaX.
2041 * @param aOverriddenDeltaY The overridden mouse scrolling speed along Y
2042 * axis. This value may be same as aOriginalDeltaY.
2044 NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
2045 double aOriginalDeltaY,
2046 double& aOverriddenDeltaX,
2047 double& aOverriddenDeltaY) = 0;
2050 * Return true if this process shouldn't use platform widgets, and
2051 * so should use PuppetWidgets instead. If this returns true, the
2052 * result of creating and using a platform widget is undefined,
2053 * and likely to end in crashes or other buggy behavior.
2055 static bool
2056 UsePuppetWidgets()
2058 return XRE_GetProcessType() == GeckoProcessType_Content;
2062 * Allocate and return a "puppet widget" that doesn't directly
2063 * correlate to a platform widget; platform events and data must
2064 * be fed to it. Currently used in content processes. NULL is
2065 * returned if puppet widgets aren't supported in this build
2066 * config, on this platform, or for this process type.
2068 * This function is called "Create" to match CreateInstance().
2069 * The returned widget must still be nsIWidget::Create()d.
2071 static already_AddRefed<nsIWidget>
2072 CreatePuppetWidget(TabChild* aTabChild);
2075 * Allocate and return a "plugin proxy widget", a subclass of PuppetWidget
2076 * used in wrapping a PPluginWidget connection for remote widgets. Note
2077 * this call creates the base object, it does not create the widget. Use
2078 * nsIWidget's Create to do this.
2080 static already_AddRefed<nsIWidget>
2081 CreatePluginProxyWidget(TabChild* aTabChild,
2082 mozilla::plugins::PluginWidgetChild* aActor);
2085 * Reparent this widget's native widget.
2086 * @param aNewParent the native widget of aNewParent is the new native
2087 * parent widget
2089 NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) = 0;
2092 * Return the internal format of the default framebuffer for this
2093 * widget.
2095 virtual uint32_t GetGLFrameBufferFormat() { return 0; /*GL_NONE*/ }
2098 * Return true if widget has it's own GL context
2100 virtual bool HasGLContext() { return false; }
2103 * Returns true to indicate that this widget paints an opaque background
2104 * that we want to be visible under the page, so layout should not force
2105 * a default background.
2107 virtual bool WidgetPaintsBackground() { return false; }
2109 virtual bool NeedsPaint() {
2110 if (!IsVisible()) {
2111 return false;
2113 nsIntRect bounds;
2114 nsresult rv = GetBounds(bounds);
2115 NS_ENSURE_SUCCESS(rv, false);
2116 return !bounds.IsEmpty();
2120 * Get the natural bounds of this widget. This method is only
2121 * meaningful for widgets for which Gecko implements screen
2122 * rotation natively. When this is the case, GetBounds() returns
2123 * the widget bounds taking rotation into account, and
2124 * GetNaturalBounds() returns the bounds *not* taking rotation
2125 * into account.
2127 * No code outside of the composition pipeline should know or care
2128 * about this. If you're not an agent of the compositor, you
2129 * probably shouldn't call this method.
2131 virtual nsIntRect GetNaturalBounds() {
2132 nsIntRect bounds;
2133 GetBounds(bounds);
2134 return bounds;
2138 * Set size constraints on the window size such that it is never less than
2139 * the specified minimum size and never larger than the specified maximum
2140 * size. The size constraints are sizes of the outer rectangle including
2141 * the window frame and title bar. Use 0 for an unconstrained minimum size
2142 * and NS_MAXSIZE for an unconstrained maximum size. Note that this method
2143 * does not necessarily change the size of a window to conform to this size,
2144 * thus Resize should be called afterwards.
2146 * @param aConstraints: the size constraints in device pixels
2148 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) = 0;
2151 * Return the size constraints currently observed by the widget.
2153 * @return the constraints in device pixels
2155 virtual const SizeConstraints& GetSizeConstraints() const = 0;
2158 * If this is owned by a TabChild, return that. Otherwise return
2159 * null.
2161 virtual TabChild* GetOwningTabChild() { return nullptr; }
2164 * If this isn't directly compositing to its window surface,
2165 * return the compositor which is doing that on our behalf.
2167 virtual CompositorChild* GetRemoteRenderer()
2168 { return nullptr; }
2171 * If this widget has a more efficient composer available for its
2172 * native framebuffer, return it.
2174 * This can be called from a non-main thread, but that thread must
2175 * hold a strong reference to this.
2177 virtual Composer2D* GetComposer2D()
2178 { return nullptr; }
2181 * Some platforms (only cocoa right now) round widget coordinates to the
2182 * nearest even pixels (see bug 892994), this function allows us to
2183 * determine how widget coordinates will be rounded.
2185 virtual int32_t RoundsWidgetCoordinatesTo() { return 1; }
2187 protected:
2189 * Like GetDefaultScale, but taking into account only the system settings
2190 * and ignoring Gecko preferences.
2192 virtual double GetDefaultScaleInternal() { return 1.0; }
2194 // keep the list of children. We also keep track of our siblings.
2195 // The ownership model is as follows: parent holds a strong ref to
2196 // the first element of the list, and each element holds a strong
2197 // ref to the next element in the list. The prevsibling and
2198 // lastchild pointers are weak, which is fine as long as they are
2199 // maintained properly.
2200 nsCOMPtr<nsIWidget> mFirstChild;
2201 nsIWidget* mLastChild;
2202 nsCOMPtr<nsIWidget> mNextSibling;
2203 nsIWidget* mPrevSibling;
2204 // When Destroy() is called, the sub class should set this true.
2205 bool mOnDestroyCalled;
2206 nsWindowType mWindowType;
2207 int32_t mZIndex;
2210 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)
2212 #endif // nsIWidget_h__