Bumping gaia.json for 1 gaia revision(s) a=gaia-bump
[gecko.git] / widget / nsBaseWidget.h
blob69641c68aca0ded55651b02acf6dc92709dd4aa2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsBaseWidget_h__
6 #define nsBaseWidget_h__
8 #include "mozilla/EventForwards.h"
9 #include "mozilla/WidgetUtils.h"
10 #include "nsRect.h"
11 #include "nsIWidget.h"
12 #include "nsWidgetsCID.h"
13 #include "nsIFile.h"
14 #include "nsString.h"
15 #include "nsCOMPtr.h"
16 #include "nsAutoPtr.h"
17 #include "nsIRollupListener.h"
18 #include "nsIObserver.h"
19 #include "nsIWidgetListener.h"
20 #include "nsPIDOMWindow.h"
21 #include <algorithm>
22 class nsIContent;
23 class nsAutoRollup;
24 class gfxContext;
26 namespace mozilla {
27 #ifdef ACCESSIBILITY
28 namespace a11y {
29 class Accessible;
31 #endif
33 namespace layers {
34 class BasicLayerManager;
35 class CompositorChild;
36 class CompositorParent;
37 class APZCTreeManager;
38 class GeckoContentController;
39 class APZEventState;
40 struct ScrollableLayerGuid;
41 struct SetTargetAPZCCallback;
44 class CompositorVsyncDispatcher;
47 namespace base {
48 class Thread;
51 // Windows specific constant indicating the maximum number of touch points the
52 // inject api will allow. This also sets the maximum numerical value for touch
53 // ids we can use when injecting touch points on Windows.
54 #define TOUCH_INJECT_MAX_POINTS 256
56 class nsBaseWidget;
58 class WidgetShutdownObserver MOZ_FINAL : public nsIObserver
60 ~WidgetShutdownObserver() {}
62 public:
63 explicit WidgetShutdownObserver(nsBaseWidget* aWidget)
64 : mWidget(aWidget)
65 { }
67 NS_DECL_ISUPPORTS
68 NS_DECL_NSIOBSERVER
70 nsBaseWidget *mWidget;
73 /**
74 * Common widget implementation used as base class for native
75 * or crossplatform implementations of Widgets.
76 * All cross-platform behavior that all widgets need to implement
77 * should be placed in this class.
78 * (Note: widget implementations are not required to use this
79 * class, but it gives them a head start.)
82 class nsBaseWidget : public nsIWidget
84 friend class nsAutoRollup;
86 protected:
87 typedef base::Thread Thread;
88 typedef mozilla::layers::BasicLayerManager BasicLayerManager;
89 typedef mozilla::layers::BufferMode BufferMode;
90 typedef mozilla::layers::CompositorChild CompositorChild;
91 typedef mozilla::layers::CompositorParent CompositorParent;
92 typedef mozilla::layers::APZCTreeManager APZCTreeManager;
93 typedef mozilla::layers::GeckoContentController GeckoContentController;
94 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
95 typedef mozilla::layers::APZEventState APZEventState;
96 typedef mozilla::layers::SetTargetAPZCCallback SetTargetAPZCCallback;
97 typedef mozilla::ScreenRotation ScreenRotation;
99 virtual ~nsBaseWidget();
101 public:
102 nsBaseWidget();
104 NS_DECL_ISUPPORTS
106 // nsIWidget interface
107 NS_IMETHOD CaptureMouse(bool aCapture) MOZ_OVERRIDE;
108 virtual nsIWidgetListener* GetWidgetListener() MOZ_OVERRIDE;
109 virtual void SetWidgetListener(nsIWidgetListener* alistener) MOZ_OVERRIDE;
110 NS_IMETHOD Destroy() MOZ_OVERRIDE;
111 NS_IMETHOD SetParent(nsIWidget* aNewParent) MOZ_OVERRIDE;
112 virtual nsIWidget* GetParent(void) MOZ_OVERRIDE;
113 virtual nsIWidget* GetTopLevelWidget() MOZ_OVERRIDE;
114 virtual nsIWidget* GetSheetWindowParent(void) MOZ_OVERRIDE;
115 virtual float GetDPI() MOZ_OVERRIDE;
116 virtual void AddChild(nsIWidget* aChild) MOZ_OVERRIDE;
117 virtual void RemoveChild(nsIWidget* aChild) MOZ_OVERRIDE;
119 void SetZIndex(int32_t aZIndex) MOZ_OVERRIDE;
120 NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
121 nsIWidget *aWidget, bool aActivate) MOZ_OVERRIDE;
123 NS_IMETHOD SetSizeMode(int32_t aMode) MOZ_OVERRIDE;
124 virtual int32_t SizeMode() MOZ_OVERRIDE
126 return mSizeMode;
129 virtual nsCursor GetCursor() MOZ_OVERRIDE;
130 NS_IMETHOD SetCursor(nsCursor aCursor) MOZ_OVERRIDE;
131 NS_IMETHOD SetCursor(imgIContainer* aCursor,
132 uint32_t aHotspotX, uint32_t aHotspotY) MOZ_OVERRIDE;
133 virtual void ClearCachedCursor() MOZ_OVERRIDE { mUpdateCursor = true; }
134 virtual void SetTransparencyMode(nsTransparencyMode aMode) MOZ_OVERRIDE;
135 virtual nsTransparencyMode GetTransparencyMode() MOZ_OVERRIDE;
136 virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects) MOZ_OVERRIDE;
137 NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) MOZ_OVERRIDE;
138 virtual void SetShowsToolbarButton(bool aShow) MOZ_OVERRIDE {}
139 virtual void SetShowsFullScreenButton(bool aShow) MOZ_OVERRIDE {}
140 virtual void SetWindowAnimationType(WindowAnimationType aType) MOZ_OVERRIDE {}
141 NS_IMETHOD HideWindowChrome(bool aShouldHide) MOZ_OVERRIDE;
142 NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aScreen = nullptr) MOZ_OVERRIDE;
143 virtual nsDeviceContext* GetDeviceContext() MOZ_OVERRIDE;
144 virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
145 LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
146 LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
147 bool* aAllowRetaining = nullptr) MOZ_OVERRIDE;
149 CompositorVsyncDispatcher* GetCompositorVsyncDispatcher() MOZ_OVERRIDE;
150 void CreateCompositorVsyncDispatcher();
151 virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
152 virtual void CreateCompositor();
153 virtual void CreateCompositor(int aWidth, int aHeight);
154 virtual void PrepareWindowEffects() MOZ_OVERRIDE {}
155 virtual void CleanupWindowEffects() MOZ_OVERRIDE {}
156 virtual bool PreRender(LayerManagerComposite* aManager) MOZ_OVERRIDE { return true; }
157 virtual void PostRender(LayerManagerComposite* aManager) MOZ_OVERRIDE {}
158 virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) MOZ_OVERRIDE {}
159 virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) MOZ_OVERRIDE {}
160 virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() MOZ_OVERRIDE;
161 virtual void EndRemoteDrawing() MOZ_OVERRIDE { };
162 virtual void CleanupRemoteDrawing() MOZ_OVERRIDE { };
163 virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) MOZ_OVERRIDE {}
164 NS_IMETHOD SetModal(bool aModal) MOZ_OVERRIDE;
165 virtual uint32_t GetMaxTouchPoints() const MOZ_OVERRIDE;
166 NS_IMETHOD SetWindowClass(const nsAString& xulWinType) MOZ_OVERRIDE;
167 virtual nsresult SetWindowClipRegion(const nsTArray<nsIntRect>& aRects, bool aIntersectWithExisting) MOZ_OVERRIDE;
168 // Return whether this widget interprets parameters to Move and Resize APIs
169 // as "global display pixels" rather than "device pixels", and therefore
170 // applies its GetDefaultScale() value to them before using them as mBounds
171 // etc (which are always stored in device pixels).
172 // Note that APIs that -get- the widget's position/size/bounds, rather than
173 // -setting- them (i.e. moving or resizing the widget) will always return
174 // values in the widget's device pixels.
175 bool BoundsUseDisplayPixels() const {
176 return mWindowType <= eWindowType_popup;
178 NS_IMETHOD MoveClient(double aX, double aY) MOZ_OVERRIDE;
179 NS_IMETHOD ResizeClient(double aWidth, double aHeight, bool aRepaint) MOZ_OVERRIDE;
180 NS_IMETHOD ResizeClient(double aX, double aY, double aWidth, double aHeight, bool aRepaint) MOZ_OVERRIDE;
181 NS_IMETHOD GetBounds(nsIntRect &aRect) MOZ_OVERRIDE;
182 NS_IMETHOD GetClientBounds(nsIntRect &aRect) MOZ_OVERRIDE;
183 NS_IMETHOD GetScreenBounds(nsIntRect &aRect) MOZ_OVERRIDE;
184 NS_IMETHOD GetRestoredBounds(nsIntRect &aRect) MOZ_OVERRIDE;
185 NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) MOZ_OVERRIDE;
186 NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) MOZ_OVERRIDE;
187 virtual nsIntPoint GetClientOffset() MOZ_OVERRIDE;
188 NS_IMETHOD EnableDragDrop(bool aEnable) MOZ_OVERRIDE;
189 NS_IMETHOD GetAttention(int32_t aCycleCount) MOZ_OVERRIDE;
190 virtual bool HasPendingInputEvent() MOZ_OVERRIDE;
191 NS_IMETHOD SetIcon(const nsAString &anIconSpec) MOZ_OVERRIDE;
192 NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) MOZ_OVERRIDE;
193 virtual void SetDrawsInTitlebar(bool aState) MOZ_OVERRIDE {}
194 virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) MOZ_OVERRIDE;
195 virtual void FreeNativeData(void * data, uint32_t aDataType) MOZ_OVERRIDE {}
196 NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
197 int32_t aHorizontal,
198 int32_t aVertical) MOZ_OVERRIDE;
199 NS_IMETHOD BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) MOZ_OVERRIDE;
200 virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
201 virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
202 NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
203 NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
204 int32_t aPanelX, int32_t aPanelY,
205 nsString& aCommitted) MOZ_OVERRIDE
206 { return NS_ERROR_NOT_IMPLEMENTED; }
207 NS_IMETHOD SetPluginFocused(bool& aFocused) MOZ_OVERRIDE
208 { return NS_ERROR_NOT_IMPLEMENTED; }
209 NS_IMETHOD AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
210 NS_IMETHOD_(bool) ExecuteNativeKeyBinding(
211 NativeKeyBindingsType aType,
212 const mozilla::WidgetKeyboardEvent& aEvent,
213 DoCommandCallback aCallback,
214 void* aCallbackData) MOZ_OVERRIDE { return false; }
215 virtual bool ComputeShouldAccelerate(bool aDefault);
216 NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
217 virtual nsIMEUpdatePreference GetIMEUpdatePreference() MOZ_OVERRIDE { return nsIMEUpdatePreference(); }
218 NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
219 NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
220 double aOriginalDeltaY,
221 double& aOverriddenDeltaX,
222 double& aOverriddenDeltaY) MOZ_OVERRIDE;
223 virtual already_AddRefed<nsIWidget>
224 CreateChild(const nsIntRect &aRect,
225 nsDeviceContext *aContext,
226 nsWidgetInitData *aInitData = nullptr,
227 bool aForceUseIWidgetParent = false) MOZ_OVERRIDE;
228 NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents, nsDeviceContext *aContext) MOZ_OVERRIDE;
229 virtual nsIWidgetListener* GetAttachedWidgetListener() MOZ_OVERRIDE;
230 virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) MOZ_OVERRIDE;
231 NS_IMETHOD RegisterTouchWindow() MOZ_OVERRIDE;
232 NS_IMETHOD UnregisterTouchWindow() MOZ_OVERRIDE;
234 void NotifyWindowDestroyed();
235 void NotifySizeMoveDone();
236 void NotifyWindowMoved(int32_t aX, int32_t aY);
238 // Should be called by derived implementations to notify on system color and
239 // theme changes.
240 void NotifySysColorChanged();
241 void NotifyThemeChanged();
242 void NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
243 UIStateChangeType aShowFocusRings);
245 #ifdef ACCESSIBILITY
246 // Get the accessible for the window.
247 mozilla::a11y::Accessible* GetRootAccessible();
248 #endif
250 nsPopupLevel PopupLevel() { return mPopupLevel; }
252 virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) MOZ_OVERRIDE
254 return aClientSize;
257 // return true if this is a popup widget with a native titlebar
258 bool IsPopupWithTitleBar() const
260 return (mWindowType == eWindowType_popup &&
261 mBorderStyle != eBorderStyle_default &&
262 mBorderStyle & eBorderStyle_title);
265 NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) MOZ_OVERRIDE = 0;
267 virtual uint32_t GetGLFrameBufferFormat() MOZ_OVERRIDE;
269 virtual const SizeConstraints& GetSizeConstraints() const MOZ_OVERRIDE;
270 virtual void SetSizeConstraints(const SizeConstraints& aConstraints) MOZ_OVERRIDE;
273 * Use this when GetLayerManager() returns a BasicLayerManager
274 * (nsBaseWidget::GetLayerManager() does). This sets up the widget's
275 * layer manager to temporarily render into aTarget.
277 * |aNaturalWidgetBounds| is the un-rotated bounds of |aWidget|.
278 * |aRotation| is the "virtual rotation" to apply when rendering to
279 * the target. When |aRotation| is ROTATION_0,
280 * |aNaturalWidgetBounds| is not used.
282 class AutoLayerManagerSetup {
283 public:
284 AutoLayerManagerSetup(nsBaseWidget* aWidget, gfxContext* aTarget,
285 BufferMode aDoubleBuffering,
286 ScreenRotation aRotation = mozilla::ROTATION_0);
287 ~AutoLayerManagerSetup();
288 private:
289 nsBaseWidget* mWidget;
290 nsRefPtr<BasicLayerManager> mLayerManager;
292 friend class AutoLayerManagerSetup;
294 class AutoUseBasicLayerManager {
295 public:
296 explicit AutoUseBasicLayerManager(nsBaseWidget* aWidget);
297 ~AutoUseBasicLayerManager();
298 private:
299 nsBaseWidget* mWidget;
300 bool mPreviousTemporarilyUseBasicLayerManager;
302 friend class AutoUseBasicLayerManager;
304 virtual bool ShouldUseOffMainThreadCompositing();
306 static nsIRollupListener* GetActiveRollupListener();
308 void Shutdown();
310 protected:
312 void ResolveIconName(const nsAString &aIconName,
313 const nsAString &aIconSuffix,
314 nsIFile **aResult);
315 virtual void OnDestroy();
316 virtual void BaseCreate(nsIWidget *aParent,
317 const nsIntRect &aRect,
318 nsDeviceContext *aContext,
319 nsWidgetInitData *aInitData);
321 virtual void ConfigureAPZCTreeManager();
322 virtual already_AddRefed<GeckoContentController> CreateRootContentController();
324 // Dispatch an event that has been routed through APZ directly from the
325 // widget.
326 nsEventStatus DispatchEventForAPZ(mozilla::WidgetGUIEvent* aEvent,
327 const ScrollableLayerGuid& aGuid,
328 uint64_t aInputBlockId);
330 const nsIntRegion RegionFromArray(const nsTArray<nsIntRect>& aRects);
331 void ArrayFromRegion(const nsIntRegion& aRegion, nsTArray<nsIntRect>& aRects);
333 virtual nsIContent* GetLastRollup() MOZ_OVERRIDE
335 return mLastRollup;
338 virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
339 int32_t aNativeKeyCode,
340 uint32_t aModifierFlags,
341 const nsAString& aCharacters,
342 const nsAString& aUnmodifiedCharacters) MOZ_OVERRIDE
343 { return NS_ERROR_UNEXPECTED; }
345 virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
346 uint32_t aNativeMessage,
347 uint32_t aModifierFlags) MOZ_OVERRIDE
348 { return NS_ERROR_UNEXPECTED; }
350 virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint) MOZ_OVERRIDE
351 { return NS_ERROR_UNEXPECTED; }
353 virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint,
354 uint32_t aNativeMessage,
355 double aDeltaX,
356 double aDeltaY,
357 double aDeltaZ,
358 uint32_t aModifierFlags,
359 uint32_t aAdditionalFlags) MOZ_OVERRIDE
360 { return NS_ERROR_UNEXPECTED; }
362 virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
363 TouchPointerState aPointerState,
364 nsIntPoint aPointerScreenPoint,
365 double aPointerPressure,
366 uint32_t aPointerOrientation) MOZ_OVERRIDE
367 { return NS_ERROR_UNEXPECTED; }
369 protected:
370 // Utility to check if an array of clip rects is equal to our
371 // internally stored clip rect array mClipRects.
372 bool IsWindowClipRegionEqual(const nsTArray<nsIntRect>& aRects);
374 // Stores the clip rectangles in aRects into mClipRects.
375 void StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects);
377 virtual already_AddRefed<nsIWidget>
378 AllocateChildPopupWidget()
380 static NS_DEFINE_IID(kCPopUpCID, NS_CHILD_CID);
381 nsCOMPtr<nsIWidget> widget = do_CreateInstance(kCPopUpCID);
382 return widget.forget();
385 LayerManager* CreateBasicLayerManager();
387 nsPopupType PopupType() const { return mPopupType; }
389 void NotifyRollupGeometryChange()
391 // XULPopupManager isn't interested in this notification, so only
392 // send it if gRollupListener is set.
393 if (gRollupListener) {
394 gRollupListener->NotifyGeometryChange();
399 * Apply the current size constraints to the given size.
401 * @param aWidth width to constrain
402 * @param aHeight height to constrain
404 void ConstrainSize(int32_t* aWidth, int32_t* aHeight) const
406 *aWidth = std::max(mSizeConstraints.mMinSize.width,
407 std::min(mSizeConstraints.mMaxSize.width, *aWidth));
408 *aHeight = std::max(mSizeConstraints.mMinSize.height,
409 std::min(mSizeConstraints.mMaxSize.height, *aHeight));
412 virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
414 virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
417 * Notify the widget that this window is being used with OMTC.
419 virtual void WindowUsesOMTC() {}
421 nsIDocument* GetDocument() const;
423 protected:
425 * Starts the OMTC compositor destruction sequence.
427 * When this function returns, the compositor should not be
428 * able to access the opengl context anymore.
429 * It is safe to call it several times if platform implementations
430 * require the compositor to be destroyed before ~nsBaseWidget is
431 * reached (This is the case with gtk2 for instance).
433 void DestroyCompositor();
435 nsIWidgetListener* mWidgetListener;
436 nsIWidgetListener* mAttachedWidgetListener;
437 nsDeviceContext* mContext;
438 nsRefPtr<LayerManager> mLayerManager;
439 nsRefPtr<LayerManager> mBasicLayerManager;
440 nsRefPtr<CompositorChild> mCompositorChild;
441 nsRefPtr<CompositorParent> mCompositorParent;
442 nsRefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
443 nsRefPtr<APZCTreeManager> mAPZC;
444 nsRefPtr<APZEventState> mAPZEventState;
445 nsRefPtr<SetTargetAPZCCallback> mSetTargetAPZCCallback;
446 nsRefPtr<WidgetShutdownObserver> mShutdownObserver;
447 nsCursor mCursor;
448 bool mUpdateCursor;
449 nsBorderStyle mBorderStyle;
450 bool mUseLayersAcceleration;
451 bool mForceLayersAcceleration;
452 bool mTemporarilyUseBasicLayerManager;
453 // Windows with out-of-process tabs always require OMTC. This flag designates
454 // such windows.
455 bool mRequireOffMainThreadCompositing;
456 bool mUseAttachedEvents;
457 bool mContextInitialized;
458 nsIntRect mBounds;
459 nsIntRect* mOriginalBounds;
460 // When this pointer is null, the widget is not clipped
461 nsAutoArrayPtr<nsIntRect> mClipRects;
462 uint32_t mClipRectCount;
463 nsSizeMode mSizeMode;
464 nsPopupLevel mPopupLevel;
465 nsPopupType mPopupType;
466 SizeConstraints mSizeConstraints;
468 static nsIRollupListener* gRollupListener;
470 // the last rolled up popup. Only set this when an nsAutoRollup is in scope,
471 // so it can be cleared automatically.
472 static nsIContent* mLastRollup;
474 #ifdef DEBUG
475 protected:
476 static nsAutoString debug_GuiEventToString(mozilla::WidgetGUIEvent* aGuiEvent);
477 static bool debug_WantPaintFlashing();
479 static void debug_DumpInvalidate(FILE * aFileOut,
480 nsIWidget * aWidget,
481 const nsIntRect * aRect,
482 const nsAutoCString & aWidgetName,
483 int32_t aWindowID);
485 static void debug_DumpEvent(FILE* aFileOut,
486 nsIWidget* aWidget,
487 mozilla::WidgetGUIEvent* aGuiEvent,
488 const nsAutoCString& aWidgetName,
489 int32_t aWindowID);
491 static void debug_DumpPaintEvent(FILE * aFileOut,
492 nsIWidget * aWidget,
493 const nsIntRegion & aPaintEvent,
494 const nsAutoCString & aWidgetName,
495 int32_t aWindowID);
497 static bool debug_GetCachedBoolPref(const char* aPrefName);
498 #endif
501 // A situation can occur when a mouse event occurs over a menu label while the
502 // menu popup is already open. The expected behaviour is to close the popup.
503 // This happens by calling nsIRollupListener::Rollup before the mouse event is
504 // processed. However, in cases where the mouse event is not consumed, this
505 // event will then get targeted at the menu label causing the menu to open
506 // again. To prevent this, we store in mLastRollup a reference to the popup
507 // that was closed during the Rollup call, and prevent this popup from
508 // reopening while processing the mouse event.
509 // mLastRollup should only be set while an nsAutoRollup is in scope;
510 // when it goes out of scope mLastRollup is cleared automatically.
511 // As mLastRollup is static, it can be retrieved by calling
512 // nsIWidget::GetLastRollup on any widget.
513 class nsAutoRollup
515 bool wasClear;
517 public:
519 nsAutoRollup();
520 ~nsAutoRollup();
523 #endif // nsBaseWidget_h__