2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifndef nsBaseWidget_h__
|
|
|
|
#define nsBaseWidget_h__
|
|
|
|
|
2012-07-24 12:01:09 -07:00
|
|
|
#include "mozilla/WidgetUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsIWidget.h"
|
2010-08-20 12:29:02 -07:00
|
|
|
#include "nsWidgetsCID.h"
|
2012-06-05 19:08:30 -07:00
|
|
|
#include "nsIFile.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsGUIEvent.h"
|
2009-07-21 17:44:55 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-06-22 18:13:56 -07:00
|
|
|
#include "nsIRollupListener.h"
|
2007-12-03 08:33:42 -08:00
|
|
|
class nsIContent;
|
|
|
|
class nsAutoRollup;
|
2010-03-01 00:03:49 -08:00
|
|
|
class gfxContext;
|
2007-12-03 08:33:42 -08:00
|
|
|
|
2012-08-15 11:52:37 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
class Accessible;
|
|
|
|
#endif
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
2012-07-30 17:42:26 -07:00
|
|
|
class BasicLayerManager;
|
2012-01-19 06:45:37 -08:00
|
|
|
class CompositorChild;
|
|
|
|
class CompositorParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class Thread;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Common widget implementation used as base class for native
|
|
|
|
* or crossplatform implementations of Widgets.
|
|
|
|
* All cross-platform behavior that all widgets need to implement
|
|
|
|
* should be placed in this class.
|
|
|
|
* (Note: widget implementations are not required to use this
|
|
|
|
* class, but it gives them a head start.)
|
|
|
|
*/
|
|
|
|
|
2011-03-25 08:03:35 -07:00
|
|
|
class nsBaseWidget : public nsIWidget
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-12-03 08:33:42 -08:00
|
|
|
friend class nsAutoRollup;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-07-15 14:08:04 -07:00
|
|
|
protected:
|
2012-07-24 12:01:09 -07:00
|
|
|
typedef base::Thread Thread;
|
2010-07-15 14:08:04 -07:00
|
|
|
typedef mozilla::layers::BasicLayerManager BasicLayerManager;
|
2012-07-30 17:42:26 -07:00
|
|
|
typedef mozilla::layers::BufferMode BufferMode;
|
2012-01-19 06:45:37 -08:00
|
|
|
typedef mozilla::layers::CompositorChild CompositorChild;
|
|
|
|
typedef mozilla::layers::CompositorParent CompositorParent;
|
2012-07-24 12:01:09 -07:00
|
|
|
typedef mozilla::ScreenRotation ScreenRotation;
|
2010-07-15 14:08:04 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
nsBaseWidget();
|
|
|
|
virtual ~nsBaseWidget();
|
2012-07-30 17:42:26 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECL_ISUPPORTS
|
2012-07-30 17:42:26 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// nsIWidget interface
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture);
|
2012-08-15 11:52:42 -07:00
|
|
|
virtual nsIWidgetListener* GetWidgetListener();
|
|
|
|
virtual void SetWidgetListener(nsIWidgetListener* alistener);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD Destroy();
|
|
|
|
NS_IMETHOD SetParent(nsIWidget* aNewParent);
|
|
|
|
virtual nsIWidget* GetParent(void);
|
2009-08-03 15:25:20 -07:00
|
|
|
virtual nsIWidget* GetTopLevelWidget();
|
2008-05-02 04:32:50 -07:00
|
|
|
virtual nsIWidget* GetSheetWindowParent(void);
|
2010-08-13 02:57:48 -07:00
|
|
|
virtual float GetDPI();
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void AddChild(nsIWidget* aChild);
|
|
|
|
virtual void RemoveChild(nsIWidget* aChild);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD SetZIndex(int32_t aZIndex);
|
|
|
|
NS_IMETHOD GetZIndex(int32_t* aZIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
2011-09-28 23:19:26 -07:00
|
|
|
nsIWidget *aWidget, bool aActivate);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD SetSizeMode(int32_t aMode);
|
|
|
|
NS_IMETHOD GetSizeMode(int32_t* aMode);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual nscolor GetForegroundColor(void);
|
|
|
|
NS_IMETHOD SetForegroundColor(const nscolor &aColor);
|
|
|
|
virtual nscolor GetBackgroundColor(void);
|
|
|
|
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
|
|
|
|
virtual nsCursor GetCursor();
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor);
|
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD GetWindowType(nsWindowType& aWindowType);
|
2008-08-12 17:44:14 -07:00
|
|
|
virtual void SetTransparencyMode(nsTransparencyMode aMode);
|
|
|
|
virtual nsTransparencyMode GetTransparencyMode();
|
2009-07-21 17:44:55 -07:00
|
|
|
virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects);
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD SetWindowShadowStyle(int32_t aStyle);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void SetShowsToolbarButton(bool aShow) {}
|
2012-03-20 16:21:14 -07:00
|
|
|
virtual void SetShowsFullScreenButton(bool aShow) {}
|
2012-02-16 19:47:39 -08:00
|
|
|
virtual void SetWindowAnimationType(WindowAnimationType aType) {}
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide);
|
|
|
|
NS_IMETHOD MakeFullScreen(bool aFullScreen);
|
2011-04-16 18:22:44 -07:00
|
|
|
virtual nsDeviceContext* GetDeviceContext();
|
2012-07-30 07:20:58 -07:00
|
|
|
virtual LayerManager* GetLayerManager(PLayersChild* aShadowManager = nullptr,
|
2012-07-18 09:31:40 -07:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LAYERS_NONE,
|
2011-08-09 12:38:26 -07:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
2012-07-30 07:20:58 -07:00
|
|
|
bool* aAllowRetaining = nullptr);
|
2011-03-25 08:03:35 -07:00
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
virtual void CreateCompositor();
|
2012-02-09 19:47:50 -08:00
|
|
|
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect) {}
|
2012-01-21 18:01:17 -08:00
|
|
|
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) {}
|
2011-01-11 05:03:16 -08:00
|
|
|
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual gfxASurface* GetThebesSurface();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetModal(bool aModal);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD MoveClient(int32_t aX, int32_t aY);
|
|
|
|
NS_IMETHOD ResizeClient(int32_t aWidth, int32_t aHeight, bool aRepaint);
|
|
|
|
NS_IMETHOD ResizeClient(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight, bool aRepaint);
|
2009-01-14 19:27:09 -08:00
|
|
|
NS_IMETHOD GetBounds(nsIntRect &aRect);
|
|
|
|
NS_IMETHOD GetClientBounds(nsIntRect &aRect);
|
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect);
|
2011-12-01 13:35:42 -08:00
|
|
|
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins);
|
|
|
|
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
|
2010-07-27 06:38:03 -07:00
|
|
|
virtual nsIntPoint GetClientOffset();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD EnableDragDrop(bool aEnable);
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetAttention(int32_t aCycleCount);
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool HasPendingInputEvent();
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD SetIcon(const nsAString &anIconSpec);
|
2007-09-27 09:01:32 -07:00
|
|
|
NS_IMETHOD BeginSecureKeyboardInput();
|
|
|
|
NS_IMETHOD EndSecureKeyboardInput();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive);
|
|
|
|
virtual void SetDrawsInTitlebar(bool aState) {}
|
|
|
|
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect);
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void FreeNativeData(void * data, uint32_t aDataType) {}
|
|
|
|
NS_IMETHOD BeginResizeDrag(nsGUIEvent* aEvent, int32_t aHorizontal, int32_t aVertical);
|
2010-07-17 01:11:54 -07:00
|
|
|
NS_IMETHOD BeginMoveDrag(nsMouseEvent* aEvent);
|
2008-06-28 00:55:30 -07:00
|
|
|
virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2008-10-29 22:36:01 -07:00
|
|
|
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2009-02-10 12:56:51 -08:00
|
|
|
NS_IMETHOD ResetInputState() { return NS_OK; }
|
|
|
|
NS_IMETHOD CancelIMEComposition() { return NS_OK; }
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetAcceleratedRendering(bool aEnabled);
|
|
|
|
virtual bool GetAcceleratedRendering();
|
|
|
|
virtual bool GetShouldAccelerate();
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD OnIMEFocusChange(bool aFocus) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD OnIMETextChange(uint32_t aStart, uint32_t aOldEnd, uint32_t aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2009-02-10 12:56:51 -08:00
|
|
|
NS_IMETHOD OnIMESelectionChange(void) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2011-10-17 07:59:28 -07:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() { return nsIMEUpdatePreference(false, false); }
|
2009-07-15 02:54:30 -07:00
|
|
|
NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD OverrideSystemMouseScrollSpeed(int32_t aOriginalDelta, bool aIsHorizontal, int32_t &aOverriddenDelta);
|
2010-08-20 12:29:02 -07:00
|
|
|
virtual already_AddRefed<nsIWidget>
|
|
|
|
CreateChild(const nsIntRect &aRect,
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext *aContext,
|
2012-07-30 07:20:58 -07:00
|
|
|
nsWidgetInitData *aInitData = nullptr,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aForceUseIWidgetParent = false);
|
2012-08-15 11:53:09 -07:00
|
|
|
NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents, nsDeviceContext *aContext);
|
2012-08-15 11:53:14 -07:00
|
|
|
virtual nsIWidgetListener* GetAttachedWidgetListener();
|
|
|
|
virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener);
|
2010-08-02 06:34:54 -07:00
|
|
|
NS_IMETHOD RegisterTouchWindow();
|
|
|
|
NS_IMETHOD UnregisterTouchWindow();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-15 11:52:41 -07:00
|
|
|
void NotifyWindowDestroyed();
|
2012-08-15 11:52:35 -07:00
|
|
|
void NotifySizeMoveDone();
|
|
|
|
|
|
|
|
// Should be called by derived implementations to notify on system color and
|
|
|
|
// theme changes.
|
|
|
|
void NotifySysColorChanged();
|
|
|
|
void NotifyThemeChanged();
|
2012-08-15 11:52:40 -07:00
|
|
|
void NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
|
|
|
|
UIStateChangeType aShowFocusRings);
|
2012-08-15 11:52:35 -07:00
|
|
|
|
2012-08-15 11:52:37 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Get the accessible for the window.
|
|
|
|
Accessible* GetAccessible();
|
|
|
|
#endif
|
|
|
|
|
2010-07-27 06:38:03 -07:00
|
|
|
nsPopupLevel PopupLevel() { return mPopupLevel; }
|
|
|
|
|
2010-07-27 06:38:03 -07:00
|
|
|
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize)
|
|
|
|
{
|
|
|
|
return aClientSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return true if this is a popup widget with a native titlebar
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsPopupWithTitleBar() const
|
2010-07-27 06:38:03 -07:00
|
|
|
{
|
|
|
|
return (mWindowType == eWindowType_popup &&
|
|
|
|
mBorderStyle != eBorderStyle_default &&
|
|
|
|
mBorderStyle & eBorderStyle_title);
|
|
|
|
}
|
|
|
|
|
2010-09-18 04:28:50 -07:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) = 0;
|
2012-01-25 18:05:34 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual uint32_t GetGLFrameBufferFormat() MOZ_OVERRIDE;
|
2012-01-25 18:05:34 -08:00
|
|
|
|
2012-07-30 17:43:29 -07:00
|
|
|
virtual const SizeConstraints& GetSizeConstraints() const;
|
|
|
|
virtual void SetSizeConstraints(const SizeConstraints& aConstraints);
|
|
|
|
|
2010-03-01 00:03:49 -08:00
|
|
|
/**
|
|
|
|
* Use this when GetLayerManager() returns a BasicLayerManager
|
|
|
|
* (nsBaseWidget::GetLayerManager() does). This sets up the widget's
|
|
|
|
* layer manager to temporarily render into aTarget.
|
2012-07-24 12:01:09 -07:00
|
|
|
*
|
|
|
|
* |aNaturalWidgetBounds| is the un-rotated bounds of |aWidget|.
|
|
|
|
* |aRotation| is the "virtual rotation" to apply when rendering to
|
|
|
|
* the target. When |aRotation| is ROTATION_0,
|
|
|
|
* |aNaturalWidgetBounds| is not used.
|
2010-03-01 00:03:49 -08:00
|
|
|
*/
|
|
|
|
class AutoLayerManagerSetup {
|
|
|
|
public:
|
2010-07-15 14:08:04 -07:00
|
|
|
AutoLayerManagerSetup(nsBaseWidget* aWidget, gfxContext* aTarget,
|
2012-07-30 17:42:26 -07:00
|
|
|
BufferMode aDoubleBuffering,
|
2012-07-24 12:01:09 -07:00
|
|
|
ScreenRotation aRotation = mozilla::ROTATION_0);
|
2010-03-01 00:03:49 -08:00
|
|
|
~AutoLayerManagerSetup();
|
|
|
|
private:
|
|
|
|
nsBaseWidget* mWidget;
|
|
|
|
};
|
|
|
|
friend class AutoLayerManagerSetup;
|
|
|
|
|
2010-10-15 03:34:29 -07:00
|
|
|
class AutoUseBasicLayerManager {
|
|
|
|
public:
|
|
|
|
AutoUseBasicLayerManager(nsBaseWidget* aWidget);
|
|
|
|
~AutoUseBasicLayerManager();
|
|
|
|
private:
|
|
|
|
nsBaseWidget* mWidget;
|
|
|
|
};
|
|
|
|
friend class AutoUseBasicLayerManager;
|
|
|
|
|
2012-03-05 19:20:29 -08:00
|
|
|
nsWindowType GetWindowType() { return mWindowType; }
|
|
|
|
|
2012-06-13 12:53:11 -07:00
|
|
|
virtual bool UseOffMainThreadCompositing();
|
2012-10-26 06:15:22 -07:00
|
|
|
|
|
|
|
static nsIRollupListener* GetActiveRollupListener();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual void ResolveIconName(const nsAString &aIconName,
|
|
|
|
const nsAString &aIconSuffix,
|
2012-06-05 19:08:30 -07:00
|
|
|
nsIFile **aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual void OnDestroy();
|
|
|
|
virtual void BaseCreate(nsIWidget *aParent,
|
2009-01-14 19:27:09 -08:00
|
|
|
const nsIntRect &aRect,
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext *aContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsWidgetInitData *aInitData);
|
|
|
|
|
2007-12-03 08:33:42 -08:00
|
|
|
virtual nsIContent* GetLastRollup()
|
|
|
|
{
|
|
|
|
return mLastRollup;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
|
|
|
|
int32_t aNativeKeyCode,
|
|
|
|
uint32_t aModifierFlags,
|
2008-05-06 21:46:37 -07:00
|
|
|
const nsAString& aCharacters,
|
|
|
|
const nsAString& aUnmodifiedCharacters)
|
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
2008-05-05 16:01:07 -07:00
|
|
|
|
2009-09-22 19:31:37 -07:00
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aNativeMessage,
|
|
|
|
uint32_t aModifierFlags)
|
2009-09-22 19:31:37 -07:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2012-04-11 14:55:21 -07:00
|
|
|
virtual nsresult SynthesizeNativeMouseMove(nsIntPoint aPoint)
|
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2012-03-21 17:59:12 -07:00
|
|
|
virtual nsresult SynthesizeNativeMouseScrollEvent(nsIntPoint aPoint,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aNativeMessage,
|
2012-03-21 17:59:12 -07:00
|
|
|
double aDeltaX,
|
|
|
|
double aDeltaY,
|
|
|
|
double aDeltaZ,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aModifierFlags,
|
|
|
|
uint32_t aAdditionalFlags)
|
2012-03-21 17:59:12 -07:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2009-07-26 14:19:15 -07:00
|
|
|
// Stores the clip rectangles in aRects into mClipRects. Returns true
|
|
|
|
// if the new rectangles are different from the old rectangles.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects);
|
2009-07-21 17:44:55 -07:00
|
|
|
|
2010-08-20 12:29:02 -07:00
|
|
|
virtual already_AddRefed<nsIWidget>
|
|
|
|
AllocateChildPopupWidget()
|
|
|
|
{
|
|
|
|
static NS_DEFINE_IID(kCPopUpCID, NS_CHILD_CID);
|
|
|
|
nsCOMPtr<nsIWidget> widget = do_CreateInstance(kCPopUpCID);
|
|
|
|
return widget.forget();
|
|
|
|
}
|
|
|
|
|
2010-09-14 16:40:23 -07:00
|
|
|
BasicLayerManager* CreateBasicLayerManager();
|
|
|
|
|
2012-05-31 10:52:09 -07:00
|
|
|
nsPopupType PopupType() const { return mPopupType; }
|
|
|
|
|
2012-10-26 06:15:22 -07:00
|
|
|
void NotifyRollupGeometryChange()
|
2012-06-22 18:13:56 -07:00
|
|
|
{
|
2012-10-26 06:15:22 -07:00
|
|
|
// XULPopupManager isn't interested in this notification, so only
|
|
|
|
// send it if gRollupListener is set.
|
|
|
|
if (gRollupListener) {
|
|
|
|
gRollupListener->NotifyGeometryChange();
|
2012-06-22 18:13:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 17:43:29 -07:00
|
|
|
/**
|
|
|
|
* Apply the current size constraints to the given size.
|
|
|
|
*
|
|
|
|
* @param aWidth width to constrain
|
|
|
|
* @param aHeight height to constrain
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void ConstrainSize(int32_t* aWidth, int32_t* aHeight) const
|
2012-07-30 17:43:29 -07:00
|
|
|
{
|
|
|
|
*aWidth = NS_MAX(mSizeConstraints.mMinSize.width,
|
|
|
|
NS_MIN(mSizeConstraints.mMaxSize.width, *aWidth));
|
|
|
|
*aHeight = NS_MAX(mSizeConstraints.mMinSize.height,
|
|
|
|
NS_MIN(mSizeConstraints.mMaxSize.height, *aHeight));
|
|
|
|
}
|
|
|
|
|
2012-10-04 00:05:24 -07:00
|
|
|
virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
|
|
|
|
|
2011-08-31 15:58:19 -07:00
|
|
|
protected:
|
2012-05-23 07:17:44 -07:00
|
|
|
/**
|
|
|
|
* Starts the OMTC compositor destruction sequence.
|
|
|
|
*
|
|
|
|
* When this function returns, the compositor should not be
|
|
|
|
* able to access the opengl context anymore.
|
|
|
|
* It is safe to call it several times if platform implementations
|
|
|
|
* require the compositor to be destroyed before ~nsBaseWidget is
|
|
|
|
* reached (This is the case with gtk2 for instance).
|
|
|
|
*/
|
|
|
|
void DestroyCompositor();
|
|
|
|
|
2012-08-15 11:52:42 -07:00
|
|
|
nsIWidgetListener* mWidgetListener;
|
2012-08-15 11:53:14 -07:00
|
|
|
nsIWidgetListener* mAttachedWidgetListener;
|
2011-04-16 18:22:44 -07:00
|
|
|
nsDeviceContext* mContext;
|
2010-03-01 00:03:49 -08:00
|
|
|
nsRefPtr<LayerManager> mLayerManager;
|
2010-10-15 03:34:29 -07:00
|
|
|
nsRefPtr<LayerManager> mBasicLayerManager;
|
2012-01-19 06:45:37 -08:00
|
|
|
nsRefPtr<CompositorChild> mCompositorChild;
|
|
|
|
nsRefPtr<CompositorParent> mCompositorParent;
|
2007-03-22 10:30:00 -07:00
|
|
|
nscolor mBackground;
|
|
|
|
nscolor mForeground;
|
|
|
|
nsCursor mCursor;
|
|
|
|
nsWindowType mWindowType;
|
|
|
|
nsBorderStyle mBorderStyle;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mUseAcceleratedRendering;
|
2012-02-27 13:33:19 -08:00
|
|
|
bool mForceLayersAcceleration;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mTemporarilyUseBasicLayerManager;
|
2012-08-15 11:53:09 -07:00
|
|
|
bool mUseAttachedEvents;
|
2012-09-29 04:36:09 -07:00
|
|
|
bool mContextInitialized;
|
2009-01-14 19:27:09 -08:00
|
|
|
nsIntRect mBounds;
|
|
|
|
nsIntRect* mOriginalBounds;
|
2009-07-21 17:44:55 -07:00
|
|
|
// When this pointer is null, the widget is not clipped
|
|
|
|
nsAutoArrayPtr<nsIntRect> mClipRects;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mClipRectCount;
|
|
|
|
int32_t mZIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSizeMode mSizeMode;
|
2010-07-27 06:38:03 -07:00
|
|
|
nsPopupLevel mPopupLevel;
|
2012-05-31 10:52:09 -07:00
|
|
|
nsPopupType mPopupType;
|
2012-07-30 17:43:29 -07:00
|
|
|
SizeConstraints mSizeConstraints;
|
2007-12-03 08:33:42 -08:00
|
|
|
|
2012-10-26 06:15:22 -07:00
|
|
|
static nsIRollupListener* gRollupListener;
|
|
|
|
|
2007-12-03 08:33:42 -08:00
|
|
|
// the last rolled up popup. Only set this when an nsAutoRollup is in scope,
|
|
|
|
// so it can be cleared automatically.
|
|
|
|
static nsIContent* mLastRollup;
|
2011-08-31 15:58:19 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
protected:
|
|
|
|
static nsAutoString debug_GuiEventToString(nsGUIEvent * aGuiEvent);
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool debug_WantPaintFlashing();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void debug_DumpInvalidate(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2009-01-14 19:27:09 -08:00
|
|
|
const nsIntRect * aRect,
|
2012-09-01 19:35:17 -07:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aWindowID);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
static void debug_DumpEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
|
|
|
nsGUIEvent * aGuiEvent,
|
2012-09-01 19:35:17 -07:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aWindowID);
|
2011-08-31 15:58:19 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static void debug_DumpPaintEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2012-08-15 11:52:42 -07:00
|
|
|
const nsIntRegion & aPaintEvent,
|
2012-09-01 19:35:17 -07:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aWindowID);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool debug_GetCachedBoolPref(const char* aPrefName);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2007-12-03 08:33:42 -08:00
|
|
|
// A situation can occur when a mouse event occurs over a menu label while the
|
|
|
|
// menu popup is already open. The expected behaviour is to close the popup.
|
|
|
|
// This happens by calling nsIRollupListener::Rollup before the mouse event is
|
|
|
|
// processed. However, in cases where the mouse event is not consumed, this
|
|
|
|
// event will then get targeted at the menu label causing the menu to open
|
|
|
|
// again. To prevent this, we store in mLastRollup a reference to the popup
|
|
|
|
// that was closed during the Rollup call, and prevent this popup from
|
|
|
|
// reopening while processing the mouse event.
|
|
|
|
// mLastRollup should only be set while an nsAutoRollup is in scope;
|
|
|
|
// when it goes out of scope mLastRollup is cleared automatically.
|
|
|
|
// As mLastRollup is static, it can be retrieved by calling
|
|
|
|
// nsIWidget::GetLastRollup on any widget.
|
|
|
|
class nsAutoRollup
|
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool wasClear;
|
2007-12-03 08:33:42 -08:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsAutoRollup();
|
|
|
|
~nsAutoRollup();
|
|
|
|
};
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // nsBaseWidget_h__
|