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__
|
|
|
|
|
2013-09-25 04:21:18 -07:00
|
|
|
#include "mozilla/EventForwards.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"
|
2009-07-21 17:44:55 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2012-06-22 18:13:56 -07:00
|
|
|
#include "nsIRollupListener.h"
|
2013-06-16 19:50:32 -07:00
|
|
|
#include "nsIObserver.h"
|
2013-09-24 03:04:14 -07:00
|
|
|
#include "nsIWidgetListener.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
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-11-17 18:01:44 -08:00
|
|
|
namespace mozilla {
|
2012-08-15 11:52:37 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-11-17 18:01:44 -08:00
|
|
|
namespace a11y {
|
2012-08-15 11:52:37 -07:00
|
|
|
class Accessible;
|
2012-11-17 18:01:44 -08:00
|
|
|
}
|
2012-08-15 11:52:37 -07:00
|
|
|
#endif
|
|
|
|
|
2012-01-19 06:45:37 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-12-14 12:40:56 -08:00
|
|
|
// Windows specific constant indicating the maximum number of touch points the
|
|
|
|
// inject api will allow. This also sets the maximum numerical value for touch
|
|
|
|
// ids we can use when injecting touch points on Windows.
|
|
|
|
#define TOUCH_INJECT_MAX_POINTS 256
|
|
|
|
|
2013-06-16 19:50:32 -07:00
|
|
|
class nsBaseWidget;
|
|
|
|
|
|
|
|
class WidgetShutdownObserver MOZ_FINAL : public nsIObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WidgetShutdownObserver(nsBaseWidget* aWidget)
|
|
|
|
: mWidget(aWidget)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
nsBaseWidget *mWidget;
|
|
|
|
};
|
|
|
|
|
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);
|
|
|
|
|
2014-03-19 09:48:08 -07:00
|
|
|
void SetZIndex(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);
|
2013-04-25 23:49:47 -07:00
|
|
|
virtual int32_t SizeMode() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mSizeMode;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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);
|
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();
|
2013-04-24 11:42:40 -07:00
|
|
|
virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
2014-01-23 10:26:41 -08:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::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
|
|
|
|
2013-04-17 14:39:13 -07:00
|
|
|
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
|
2012-01-19 06:45:37 -08:00
|
|
|
virtual void CreateCompositor();
|
2013-03-20 15:45:07 -07:00
|
|
|
virtual void CreateCompositor(int aWidth, int aHeight);
|
2013-04-21 19:40:51 -07:00
|
|
|
virtual void PrepareWindowEffects() {}
|
|
|
|
virtual void CleanupWindowEffects() {}
|
2013-12-08 17:40:59 -08:00
|
|
|
virtual bool PreRender(LayerManagerComposite* aManager) { return true; }
|
|
|
|
virtual void PostRender(LayerManagerComposite* aManager) {}
|
|
|
|
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) {}
|
|
|
|
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) {}
|
2013-07-08 21:21:05 -07:00
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing();
|
|
|
|
virtual void EndRemoteDrawing() { };
|
|
|
|
virtual void CleanupRemoteDrawing() { };
|
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();
|
2014-01-28 08:09:34 -08:00
|
|
|
NS_IMETHOD SetModal(bool aModal);
|
|
|
|
virtual uint32_t GetMaxTouchPoints() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType);
|
2013-04-15 05:17:22 -07:00
|
|
|
// Return whether this widget interprets parameters to Move and Resize APIs
|
|
|
|
// as "global display pixels" rather than "device pixels", and therefore
|
|
|
|
// applies its GetDefaultScale() value to them before using them as mBounds
|
|
|
|
// etc (which are always stored in device pixels).
|
|
|
|
// Note that APIs that -get- the widget's position/size/bounds, rather than
|
|
|
|
// -setting- them (i.e. moving or resizing the widget) will always return
|
|
|
|
// values in the widget's device pixels.
|
|
|
|
bool BoundsUseDisplayPixels() const {
|
|
|
|
return mWindowType <= eWindowType_popup;
|
|
|
|
}
|
2012-12-12 01:57:38 -08:00
|
|
|
NS_IMETHOD MoveClient(double aX, double aY);
|
|
|
|
NS_IMETHOD ResizeClient(double aWidth, double aHeight, bool aRepaint);
|
|
|
|
NS_IMETHOD ResizeClient(double aX, double aY, double aWidth, double 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);
|
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) {}
|
2013-10-01 20:46:03 -07:00
|
|
|
NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
int32_t aHorizontal,
|
|
|
|
int32_t aVertical);
|
2013-10-01 23:38:27 -07:00
|
|
|
NS_IMETHOD BeginMoveDrag(mozilla::WidgetMouseEvent* 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; }
|
2014-02-17 16:00:15 -08:00
|
|
|
NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
2014-03-14 06:13:31 -07:00
|
|
|
NS_IMETHOD_(bool) ExecuteNativeKeyBinding(
|
|
|
|
NativeKeyBindingsType aType,
|
|
|
|
const mozilla::WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
|
|
|
void* aCallbackData) MOZ_OVERRIDE { return false; }
|
2012-11-15 10:55:15 -08:00
|
|
|
NS_IMETHOD SetLayersAcceleration(bool aEnabled);
|
|
|
|
virtual bool GetLayersAcceleration() { return mUseLayersAcceleration; }
|
|
|
|
virtual bool ComputeShouldAccelerate(bool aDefault);
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2013-07-11 00:46:34 -07:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() MOZ_OVERRIDE { return nsIMEUpdatePreference(); }
|
2009-07-15 02:54:30 -07:00
|
|
|
NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2013-03-15 02:03:16 -07:00
|
|
|
NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
|
|
|
double aOriginalDeltaY,
|
|
|
|
double& aOverriddenDeltaX,
|
|
|
|
double& aOverriddenDeltaY);
|
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();
|
2014-02-27 23:45:08 -08:00
|
|
|
void NotifyWindowMoved(int32_t aX, int32_t aY);
|
2012-08-15 11:52:35 -07:00
|
|
|
|
|
|
|
// 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.
|
2013-06-27 08:03:58 -07:00
|
|
|
mozilla::a11y::Accessible* GetRootAccessible();
|
2012-08-15 11:52:37 -07:00
|
|
|
#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;
|
2012-12-26 21:55:41 -08:00
|
|
|
nsRefPtr<BasicLayerManager> mLayerManager;
|
2010-03-01 00:03:49 -08:00
|
|
|
};
|
|
|
|
friend class AutoLayerManagerSetup;
|
|
|
|
|
2010-10-15 03:34:29 -07:00
|
|
|
class AutoUseBasicLayerManager {
|
|
|
|
public:
|
|
|
|
AutoUseBasicLayerManager(nsBaseWidget* aWidget);
|
|
|
|
~AutoUseBasicLayerManager();
|
|
|
|
private:
|
|
|
|
nsBaseWidget* mWidget;
|
2012-12-16 22:35:39 -08:00
|
|
|
bool mPreviousTemporarilyUseBasicLayerManager;
|
2010-10-15 03:34:29 -07:00
|
|
|
};
|
|
|
|
friend class AutoUseBasicLayerManager;
|
|
|
|
|
2013-03-04 10:32:20 -08:00
|
|
|
virtual bool ShouldUseOffMainThreadCompositing();
|
2012-10-26 06:15:22 -07:00
|
|
|
|
|
|
|
static nsIRollupListener* GetActiveRollupListener();
|
|
|
|
|
2013-06-16 19:50:32 -07:00
|
|
|
void Shutdown();
|
|
|
|
|
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; }
|
|
|
|
|
2013-12-14 12:40:56 -08:00
|
|
|
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
|
|
|
nsIntPoint aPointerScreenPoint,
|
|
|
|
double aPointerPressure,
|
|
|
|
uint32_t aPointerOrientation)
|
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
|
|
|
protected:
|
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();
|
|
|
|
}
|
|
|
|
|
2013-09-01 15:20:45 -07:00
|
|
|
LayerManager* CreateBasicLayerManager();
|
2010-09-14 16:40:23 -07:00
|
|
|
|
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
|
|
|
{
|
2013-01-15 04:22:03 -08:00
|
|
|
*aWidth = std::max(mSizeConstraints.mMinSize.width,
|
|
|
|
std::min(mSizeConstraints.mMaxSize.width, *aWidth));
|
|
|
|
*aHeight = std::max(mSizeConstraints.mMinSize.height,
|
|
|
|
std::min(mSizeConstraints.mMaxSize.height, *aHeight));
|
2012-07-30 17:43:29 -07:00
|
|
|
}
|
|
|
|
|
2012-10-04 00:05:24 -07:00
|
|
|
virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
|
|
|
|
|
2013-08-17 23:46:16 -07:00
|
|
|
virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
|
2013-05-03 10:34:33 -07:00
|
|
|
|
2013-08-08 16:32:26 -07:00
|
|
|
/**
|
|
|
|
* Notify the widget that this window is being used with OMTC.
|
|
|
|
*/
|
|
|
|
virtual void WindowUsesOMTC() {}
|
|
|
|
|
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;
|
2014-03-17 17:23:03 -07:00
|
|
|
nsRefPtr<WidgetShutdownObserver> mShutdownObserver;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCursor mCursor;
|
|
|
|
nsBorderStyle mBorderStyle;
|
2012-11-15 10:55:15 -08:00
|
|
|
bool mUseLayersAcceleration;
|
2012-02-27 13:33:19 -08:00
|
|
|
bool mForceLayersAcceleration;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mTemporarilyUseBasicLayerManager;
|
2014-02-20 17:26:41 -08:00
|
|
|
// Windows with out-of-process tabs always require OMTC. This flag designates
|
|
|
|
// such windows.
|
|
|
|
bool mRequireOffMainThreadCompositing;
|
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;
|
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:
|
2013-10-01 20:46:03 -07:00
|
|
|
static nsAutoString debug_GuiEventToString(mozilla::WidgetGUIEvent* 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
|
|
|
|
2013-10-01 20:46:03 -07:00
|
|
|
static void debug_DumpEvent(FILE* aFileOut,
|
|
|
|
nsIWidget* aWidget,
|
|
|
|
mozilla::WidgetGUIEvent* aGuiEvent,
|
|
|
|
const nsAutoCString& aWidgetName,
|
|
|
|
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__
|