2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
1998-09-23 23:19:23 +04:00
|
|
|
#ifndef nsBaseWidget_h__
|
|
|
|
#define nsBaseWidget_h__
|
|
|
|
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2012-07-24 23:01:09 +04:00
|
|
|
#include "mozilla/WidgetUtils.h"
|
1998-11-24 17:57:09 +03:00
|
|
|
#include "nsRect.h"
|
1998-09-23 23:19:23 +04:00
|
|
|
#include "nsIWidget.h"
|
2010-08-20 23:29:02 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
1998-09-23 23:19:23 +04:00
|
|
|
#include "nsString.h"
|
1999-05-27 01:12:54 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2009-07-22 04:44:55 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2012-06-23 05:13:56 +04:00
|
|
|
#include "nsIRollupListener.h"
|
2013-06-17 06:50:32 +04:00
|
|
|
#include "nsIObserver.h"
|
2013-09-24 14:04:14 +04:00
|
|
|
#include "nsIWidgetListener.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2015-02-18 09:27:53 +03:00
|
|
|
#include "nsWeakReference.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2007-12-03 19:33:42 +03:00
|
|
|
class nsIContent;
|
|
|
|
class nsAutoRollup;
|
2010-03-01 11:03:49 +03:00
|
|
|
class gfxContext;
|
2007-12-03 19:33:42 +03:00
|
|
|
|
2012-11-18 06:01:44 +04:00
|
|
|
namespace mozilla {
|
2012-08-15 22:52:37 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-11-18 06:01:44 +04:00
|
|
|
namespace a11y {
|
2012-08-15 22:52:37 +04:00
|
|
|
class Accessible;
|
2012-11-18 06:01:44 +04:00
|
|
|
}
|
2012-08-15 22:52:37 +04:00
|
|
|
#endif
|
|
|
|
|
2012-01-19 18:45:37 +04:00
|
|
|
namespace layers {
|
2012-07-31 04:42:26 +04:00
|
|
|
class BasicLayerManager;
|
2012-01-19 18:45:37 +04:00
|
|
|
class CompositorChild;
|
|
|
|
class CompositorParent;
|
2014-12-15 12:47:15 +03:00
|
|
|
class APZCTreeManager;
|
|
|
|
class GeckoContentController;
|
2015-02-07 03:45:23 +03:00
|
|
|
class APZEventState;
|
2014-12-19 02:25:03 +03:00
|
|
|
struct ScrollableLayerGuid;
|
2015-02-07 02:11:30 +03:00
|
|
|
struct SetTargetAPZCCallback;
|
2012-01-19 18:45:37 +04:00
|
|
|
}
|
2014-12-18 19:30:05 +03:00
|
|
|
|
2014-12-19 23:52:42 +03:00
|
|
|
class CompositorVsyncDispatcher;
|
2012-01-19 18:45:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class Thread;
|
|
|
|
}
|
|
|
|
|
2013-12-15 00:40:56 +04: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-17 06:50:32 +04:00
|
|
|
class nsBaseWidget;
|
|
|
|
|
|
|
|
class WidgetShutdownObserver MOZ_FINAL : public nsIObserver
|
|
|
|
{
|
2014-06-24 20:36:44 +04:00
|
|
|
~WidgetShutdownObserver() {}
|
|
|
|
|
2013-06-17 06:50:32 +04:00
|
|
|
public:
|
2014-09-01 07:33:13 +04:00
|
|
|
explicit WidgetShutdownObserver(nsBaseWidget* aWidget)
|
2013-06-17 06:50:32 +04:00
|
|
|
: mWidget(aWidget)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
nsBaseWidget *mWidget;
|
|
|
|
};
|
|
|
|
|
1998-09-23 23:19:23 +04: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.)
|
|
|
|
*/
|
|
|
|
|
2015-02-18 09:27:53 +03:00
|
|
|
class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
|
1998-09-23 23:19:23 +04:00
|
|
|
{
|
2007-12-03 19:33:42 +03:00
|
|
|
friend class nsAutoRollup;
|
1998-09-23 23:19:23 +04:00
|
|
|
|
2010-07-16 01:08:04 +04:00
|
|
|
protected:
|
2012-07-24 23:01:09 +04:00
|
|
|
typedef base::Thread Thread;
|
2010-07-16 01:08:04 +04:00
|
|
|
typedef mozilla::layers::BasicLayerManager BasicLayerManager;
|
2012-07-31 04:42:26 +04:00
|
|
|
typedef mozilla::layers::BufferMode BufferMode;
|
2012-01-19 18:45:37 +04:00
|
|
|
typedef mozilla::layers::CompositorChild CompositorChild;
|
|
|
|
typedef mozilla::layers::CompositorParent CompositorParent;
|
2014-12-15 12:47:15 +03:00
|
|
|
typedef mozilla::layers::APZCTreeManager APZCTreeManager;
|
|
|
|
typedef mozilla::layers::GeckoContentController GeckoContentController;
|
2014-12-19 02:25:03 +03:00
|
|
|
typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
|
2015-02-07 03:45:23 +03:00
|
|
|
typedef mozilla::layers::APZEventState APZEventState;
|
2015-02-07 02:11:30 +03:00
|
|
|
typedef mozilla::layers::SetTargetAPZCCallback SetTargetAPZCCallback;
|
2012-07-24 23:01:09 +04:00
|
|
|
typedef mozilla::ScreenRotation ScreenRotation;
|
2010-07-16 01:08:04 +04:00
|
|
|
|
2014-06-24 20:36:44 +04:00
|
|
|
virtual ~nsBaseWidget();
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
public:
|
1999-09-28 05:31:41 +04:00
|
|
|
nsBaseWidget();
|
2012-07-31 04:42:26 +04:00
|
|
|
|
1999-09-28 05:31:41 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2012-07-31 04:42:26 +04:00
|
|
|
|
1999-09-28 05:31:41 +04:00
|
|
|
// nsIWidget interface
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture) MOZ_OVERRIDE;
|
|
|
|
virtual nsIWidgetListener* GetWidgetListener() MOZ_OVERRIDE;
|
|
|
|
virtual void SetWidgetListener(nsIWidgetListener* alistener) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD Destroy() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetParent(nsIWidget* aNewParent) MOZ_OVERRIDE;
|
|
|
|
virtual nsIWidget* GetParent(void) MOZ_OVERRIDE;
|
|
|
|
virtual nsIWidget* GetTopLevelWidget() MOZ_OVERRIDE;
|
|
|
|
virtual nsIWidget* GetSheetWindowParent(void) MOZ_OVERRIDE;
|
|
|
|
virtual float GetDPI() MOZ_OVERRIDE;
|
|
|
|
virtual void AddChild(nsIWidget* aChild) MOZ_OVERRIDE;
|
|
|
|
virtual void RemoveChild(nsIWidget* aChild) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
void SetZIndex(int32_t aZIndex) MOZ_OVERRIDE;
|
2003-10-07 05:19:51 +04:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
2015-01-02 09:25:48 +03:00
|
|
|
nsIWidget *aWidget, bool aActivate) MOZ_OVERRIDE;
|
1999-09-28 05:31:41 +04:00
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD SetSizeMode(int32_t aMode) MOZ_OVERRIDE;
|
2013-04-26 10:49:47 +04:00
|
|
|
virtual int32_t SizeMode() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mSizeMode;
|
|
|
|
}
|
2000-03-09 04:55:48 +03:00
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
virtual nsCursor GetCursor() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor) MOZ_OVERRIDE;
|
2005-07-01 08:29:42 +04:00
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
2015-01-02 09:25:48 +03:00
|
|
|
uint32_t aHotspotX, uint32_t aHotspotY) MOZ_OVERRIDE;
|
|
|
|
virtual void ClearCachedCursor() MOZ_OVERRIDE { mUpdateCursor = true; }
|
|
|
|
virtual void SetTransparencyMode(nsTransparencyMode aMode) MOZ_OVERRIDE;
|
|
|
|
virtual nsTransparencyMode GetTransparencyMode() MOZ_OVERRIDE;
|
|
|
|
virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) MOZ_OVERRIDE;
|
|
|
|
virtual void SetShowsToolbarButton(bool aShow) MOZ_OVERRIDE {}
|
|
|
|
virtual void SetShowsFullScreenButton(bool aShow) MOZ_OVERRIDE {}
|
|
|
|
virtual void SetWindowAnimationType(WindowAnimationType aType) MOZ_OVERRIDE {}
|
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aScreen = nullptr) MOZ_OVERRIDE;
|
2013-04-24 22:42:40 +04:00
|
|
|
virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
2014-01-23 22:26:41 +04:00
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
2011-08-09 23:38:26 +04:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
2015-01-02 09:25:48 +03:00
|
|
|
bool* aAllowRetaining = nullptr) MOZ_OVERRIDE;
|
2011-03-25 18:03:35 +03:00
|
|
|
|
2014-12-19 23:52:42 +03:00
|
|
|
CompositorVsyncDispatcher* GetCompositorVsyncDispatcher() MOZ_OVERRIDE;
|
2015-01-02 09:25:48 +03:00
|
|
|
void CreateCompositorVsyncDispatcher();
|
2013-04-18 01:39:13 +04:00
|
|
|
virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight);
|
2012-01-19 18:45:37 +04:00
|
|
|
virtual void CreateCompositor();
|
2013-03-21 02:45:07 +04:00
|
|
|
virtual void CreateCompositor(int aWidth, int aHeight);
|
2015-01-02 09:25:48 +03:00
|
|
|
virtual void PrepareWindowEffects() MOZ_OVERRIDE {}
|
|
|
|
virtual void CleanupWindowEffects() MOZ_OVERRIDE {}
|
|
|
|
virtual bool PreRender(LayerManagerComposite* aManager) MOZ_OVERRIDE { return true; }
|
|
|
|
virtual void PostRender(LayerManagerComposite* aManager) MOZ_OVERRIDE {}
|
|
|
|
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, nsIntRect aRect) MOZ_OVERRIDE {}
|
|
|
|
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, nsIntRect aRect) MOZ_OVERRIDE {}
|
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::DrawTarget> StartRemoteDrawing() MOZ_OVERRIDE;
|
|
|
|
virtual void EndRemoteDrawing() MOZ_OVERRIDE { };
|
|
|
|
virtual void CleanupRemoteDrawing() MOZ_OVERRIDE { };
|
|
|
|
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) MOZ_OVERRIDE {}
|
|
|
|
NS_IMETHOD SetModal(bool aModal) MOZ_OVERRIDE;
|
|
|
|
virtual uint32_t GetMaxTouchPoints() const MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult SetWindowClipRegion(const nsTArray<nsIntRect>& aRects, bool aIntersectWithExisting) MOZ_OVERRIDE;
|
2013-04-15 16:17:22 +04: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;
|
|
|
|
}
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD MoveClient(double aX, double aY) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD ResizeClient(double aWidth, double aHeight, bool aRepaint) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD ResizeClient(double aX, double aY, double aWidth, double aHeight, bool aRepaint) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetBounds(nsIntRect &aRect) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetClientBounds(nsIntRect &aRect) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetScreenBounds(nsIntRect &aRect) MOZ_OVERRIDE;
|
2014-05-20 11:32:17 +04:00
|
|
|
NS_IMETHOD GetRestoredBounds(nsIntRect &aRect) MOZ_OVERRIDE;
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD GetNonClientMargins(nsIntMargin &margins) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins) MOZ_OVERRIDE;
|
|
|
|
virtual nsIntPoint GetClientOffset() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD EnableDragDrop(bool aEnable) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetAttention(int32_t aCycleCount) MOZ_OVERRIDE;
|
|
|
|
virtual bool HasPendingInputEvent() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetIcon(const nsAString &anIconSpec) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive) MOZ_OVERRIDE;
|
|
|
|
virtual void SetDrawsInTitlebar(bool aState) MOZ_OVERRIDE {}
|
|
|
|
virtual bool ShowsResizeIndicator(nsIntRect* aResizerRect) MOZ_OVERRIDE;
|
|
|
|
virtual void FreeNativeData(void * data, uint32_t aDataType) MOZ_OVERRIDE {}
|
2013-10-02 07:46:03 +04:00
|
|
|
NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
int32_t aHorizontal,
|
2015-01-02 09:25:48 +03:00
|
|
|
int32_t aVertical) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult ActivateNativeMenuItemAt(const nsAString& indexString) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
virtual nsresult ForceUpdateNativeMenuAt(const nsAString& indexString) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
2015-01-28 09:27:31 +03:00
|
|
|
NS_IMETHOD NotifyIME(const IMENotification& aIMENotification) MOZ_OVERRIDE MOZ_FINAL;
|
2015-02-20 19:37:02 +03:00
|
|
|
NS_IMETHOD StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
|
|
|
|
int32_t aPanelX, int32_t aPanelY,
|
|
|
|
nsString& aCommitted) MOZ_OVERRIDE
|
|
|
|
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
NS_IMETHOD SetPluginFocused(bool& aFocused) MOZ_OVERRIDE
|
|
|
|
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
2014-04-22 00:40:09 +04:00
|
|
|
NS_IMETHOD AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
2014-03-14 17:13:31 +04:00
|
|
|
NS_IMETHOD_(bool) ExecuteNativeKeyBinding(
|
|
|
|
NativeKeyBindingsType aType,
|
|
|
|
const mozilla::WidgetKeyboardEvent& aEvent,
|
|
|
|
DoCommandCallback aCallback,
|
|
|
|
void* aCallbackData) MOZ_OVERRIDE { return false; }
|
2012-11-15 22:55:15 +04:00
|
|
|
virtual bool ComputeShouldAccelerate(bool aDefault);
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD GetToggledKeyState(uint32_t aKeyCode, bool* aLEDState) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
2013-07-11 11:46:34 +04:00
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() MOZ_OVERRIDE { return nsIMEUpdatePreference(); }
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; }
|
2013-03-15 13:03:16 +04:00
|
|
|
NS_IMETHOD OverrideSystemMouseScrollSpeed(double aOriginalDeltaX,
|
|
|
|
double aOriginalDeltaY,
|
|
|
|
double& aOverriddenDeltaX,
|
2015-01-02 09:25:48 +03:00
|
|
|
double& aOverriddenDeltaY) MOZ_OVERRIDE;
|
2010-08-20 23:29:02 +04:00
|
|
|
virtual already_AddRefed<nsIWidget>
|
|
|
|
CreateChild(const nsIntRect &aRect,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsWidgetInitData *aInitData = nullptr,
|
2015-01-02 09:25:48 +03:00
|
|
|
bool aForceUseIWidgetParent = false) MOZ_OVERRIDE;
|
2015-02-05 08:33:49 +03:00
|
|
|
NS_IMETHOD AttachViewToTopLevel(bool aUseAttachedEvents) MOZ_OVERRIDE;
|
2015-01-02 09:25:48 +03:00
|
|
|
virtual nsIWidgetListener* GetAttachedWidgetListener() MOZ_OVERRIDE;
|
|
|
|
virtual void SetAttachedWidgetListener(nsIWidgetListener* aListener) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD RegisterTouchWindow() MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD UnregisterTouchWindow() MOZ_OVERRIDE;
|
2015-01-28 09:27:30 +03:00
|
|
|
NS_IMETHOD_(TextEventDispatcher*) GetTextEventDispatcher() MOZ_OVERRIDE MOZ_FINAL;
|
1999-09-21 15:25:03 +04:00
|
|
|
|
2015-03-07 01:26:59 +03:00
|
|
|
// Dispatch an event that must be first be routed through APZ.
|
|
|
|
nsEventStatus DispatchAPZAwareEvent(mozilla::WidgetInputEvent* aEvent) MOZ_OVERRIDE;
|
|
|
|
|
2012-08-15 22:52:41 +04:00
|
|
|
void NotifyWindowDestroyed();
|
2012-08-15 22:52:35 +04:00
|
|
|
void NotifySizeMoveDone();
|
2014-02-28 11:45:08 +04:00
|
|
|
void NotifyWindowMoved(int32_t aX, int32_t aY);
|
2012-08-15 22:52:35 +04:00
|
|
|
|
2015-01-29 22:41:53 +03:00
|
|
|
// Register plugin windows for remote updates from the compositor
|
|
|
|
virtual void RegisterPluginWindowForRemoteUpdates() MOZ_OVERRIDE;
|
|
|
|
virtual void UnregisterPluginWindowForRemoteUpdates() MOZ_OVERRIDE;
|
|
|
|
|
2015-01-29 22:41:57 +03:00
|
|
|
virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal) MOZ_OVERRIDE {};
|
|
|
|
|
2012-08-15 22:52:35 +04:00
|
|
|
// Should be called by derived implementations to notify on system color and
|
|
|
|
// theme changes.
|
|
|
|
void NotifySysColorChanged();
|
|
|
|
void NotifyThemeChanged();
|
2012-08-15 22:52:40 +04:00
|
|
|
void NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
|
|
|
|
UIStateChangeType aShowFocusRings);
|
2012-08-15 22:52:35 +04:00
|
|
|
|
2012-08-15 22:52:37 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Get the accessible for the window.
|
2013-06-27 19:03:58 +04:00
|
|
|
mozilla::a11y::Accessible* GetRootAccessible();
|
2012-08-15 22:52:37 +04:00
|
|
|
#endif
|
|
|
|
|
2010-07-27 17:38:03 +04:00
|
|
|
nsPopupLevel PopupLevel() { return mPopupLevel; }
|
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize) MOZ_OVERRIDE
|
2010-07-27 17:38:03 +04:00
|
|
|
{
|
|
|
|
return aClientSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return true if this is a popup widget with a native titlebar
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsPopupWithTitleBar() const
|
2010-07-27 17:38:03 +04:00
|
|
|
{
|
|
|
|
return (mWindowType == eWindowType_popup &&
|
|
|
|
mBorderStyle != eBorderStyle_default &&
|
|
|
|
mBorderStyle & eBorderStyle_title);
|
|
|
|
}
|
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) MOZ_OVERRIDE = 0;
|
2012-01-26 06:05:34 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual uint32_t GetGLFrameBufferFormat() MOZ_OVERRIDE;
|
2012-01-26 06:05:34 +04:00
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
virtual const SizeConstraints& GetSizeConstraints() const MOZ_OVERRIDE;
|
|
|
|
virtual void SetSizeConstraints(const SizeConstraints& aConstraints) MOZ_OVERRIDE;
|
2012-07-31 04:43:29 +04:00
|
|
|
|
2010-03-01 11:03:49 +03: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 23:01:09 +04: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 11:03:49 +03:00
|
|
|
*/
|
|
|
|
class AutoLayerManagerSetup {
|
|
|
|
public:
|
2010-07-16 01:08:04 +04:00
|
|
|
AutoLayerManagerSetup(nsBaseWidget* aWidget, gfxContext* aTarget,
|
2012-07-31 04:42:26 +04:00
|
|
|
BufferMode aDoubleBuffering,
|
2012-07-24 23:01:09 +04:00
|
|
|
ScreenRotation aRotation = mozilla::ROTATION_0);
|
2010-03-01 11:03:49 +03:00
|
|
|
~AutoLayerManagerSetup();
|
|
|
|
private:
|
|
|
|
nsBaseWidget* mWidget;
|
2012-12-27 09:55:41 +04:00
|
|
|
nsRefPtr<BasicLayerManager> mLayerManager;
|
2010-03-01 11:03:49 +03:00
|
|
|
};
|
|
|
|
friend class AutoLayerManagerSetup;
|
|
|
|
|
2010-10-15 14:34:29 +04:00
|
|
|
class AutoUseBasicLayerManager {
|
|
|
|
public:
|
2014-09-01 07:33:13 +04:00
|
|
|
explicit AutoUseBasicLayerManager(nsBaseWidget* aWidget);
|
2010-10-15 14:34:29 +04:00
|
|
|
~AutoUseBasicLayerManager();
|
|
|
|
private:
|
|
|
|
nsBaseWidget* mWidget;
|
2012-12-17 10:35:39 +04:00
|
|
|
bool mPreviousTemporarilyUseBasicLayerManager;
|
2010-10-15 14:34:29 +04:00
|
|
|
};
|
|
|
|
friend class AutoUseBasicLayerManager;
|
|
|
|
|
2013-03-04 22:32:20 +04:00
|
|
|
virtual bool ShouldUseOffMainThreadCompositing();
|
2012-10-26 17:15:22 +04:00
|
|
|
|
|
|
|
static nsIRollupListener* GetActiveRollupListener();
|
|
|
|
|
2013-06-17 06:50:32 +04:00
|
|
|
void Shutdown();
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
protected:
|
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
void ResolveIconName(const nsAString &aIconName,
|
|
|
|
const nsAString &aIconSuffix,
|
|
|
|
nsIFile **aResult);
|
2015-02-05 08:18:30 +03:00
|
|
|
virtual void OnDestroy();
|
|
|
|
void BaseCreate(nsIWidget *aParent,
|
|
|
|
const nsIntRect &aRect,
|
|
|
|
nsWidgetInitData *aInitData);
|
1998-09-23 23:19:23 +04:00
|
|
|
|
2014-12-15 12:47:15 +03:00
|
|
|
virtual void ConfigureAPZCTreeManager();
|
|
|
|
virtual already_AddRefed<GeckoContentController> CreateRootContentController();
|
|
|
|
|
2015-03-07 01:26:59 +03:00
|
|
|
// Dispatch an event that has already been routed through APZ.
|
|
|
|
nsEventStatus ProcessUntransformedAPZEvent(mozilla::WidgetInputEvent* aEvent,
|
|
|
|
const ScrollableLayerGuid& aGuid,
|
|
|
|
uint64_t aInputBlockId);
|
2014-12-19 02:25:03 +03:00
|
|
|
|
2014-11-12 23:59:19 +03:00
|
|
|
const nsIntRegion RegionFromArray(const nsTArray<nsIntRect>& aRects);
|
|
|
|
void ArrayFromRegion(const nsIntRegion& aRegion, nsTArray<nsIntRect>& aRects);
|
|
|
|
|
2015-01-02 09:25:48 +03:00
|
|
|
virtual nsIContent* GetLastRollup() MOZ_OVERRIDE
|
2007-12-03 19:33:42 +03:00
|
|
|
{
|
|
|
|
return mLastRollup;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
|
|
|
|
int32_t aNativeKeyCode,
|
|
|
|
uint32_t aModifierFlags,
|
2008-05-07 08:46:37 +04:00
|
|
|
const nsAString& aCharacters,
|
2015-01-02 09:25:48 +03:00
|
|
|
const nsAString& aUnmodifiedCharacters) MOZ_OVERRIDE
|
2008-05-07 08:46:37 +04:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
2008-05-06 03:01:07 +04:00
|
|
|
|
2015-02-15 21:52:28 +03:00
|
|
|
virtual nsresult SynthesizeNativeMouseEvent(mozilla::LayoutDeviceIntPoint aPoint,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aNativeMessage,
|
2015-01-02 09:25:48 +03:00
|
|
|
uint32_t aModifierFlags) MOZ_OVERRIDE
|
2009-09-23 06:31:37 +04:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2015-02-15 21:52:28 +03:00
|
|
|
virtual nsresult SynthesizeNativeMouseMove(mozilla::LayoutDeviceIntPoint aPoint) MOZ_OVERRIDE
|
2012-04-12 01:55:21 +04:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2015-02-15 21:52:28 +03:00
|
|
|
virtual nsresult SynthesizeNativeMouseScrollEvent(mozilla::LayoutDeviceIntPoint aPoint,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aNativeMessage,
|
2012-03-22 04:59:12 +04:00
|
|
|
double aDeltaX,
|
|
|
|
double aDeltaY,
|
|
|
|
double aDeltaZ,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aModifierFlags,
|
2015-01-02 09:25:48 +03:00
|
|
|
uint32_t aAdditionalFlags) MOZ_OVERRIDE
|
2012-03-22 04:59:12 +04:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2013-12-15 00:40:56 +04:00
|
|
|
virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
|
|
|
nsIntPoint aPointerScreenPoint,
|
|
|
|
double aPointerPressure,
|
2015-01-02 09:25:48 +03:00
|
|
|
uint32_t aPointerOrientation) MOZ_OVERRIDE
|
2013-12-15 00:40:56 +04:00
|
|
|
{ return NS_ERROR_UNEXPECTED; }
|
|
|
|
|
2015-01-28 09:27:31 +03:00
|
|
|
virtual nsresult NotifyIMEInternal(const IMENotification& aIMENotification)
|
|
|
|
{ return NS_ERROR_NOT_IMPLEMENTED; }
|
|
|
|
|
2013-12-15 00:40:56 +04:00
|
|
|
protected:
|
2015-01-28 18:15:54 +03:00
|
|
|
// Utility to check if an array of clip rects is equal to our
|
|
|
|
// internally stored clip rect array mClipRects.
|
|
|
|
bool IsWindowClipRegionEqual(const nsTArray<nsIntRect>& aRects);
|
|
|
|
|
|
|
|
// Stores the clip rectangles in aRects into mClipRects.
|
|
|
|
void StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects);
|
2009-07-22 04:44:55 +04:00
|
|
|
|
2010-08-20 23:29:02 +04: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-02 02:20:45 +04:00
|
|
|
LayerManager* CreateBasicLayerManager();
|
2010-09-15 03:40:23 +04:00
|
|
|
|
2012-05-31 21:52:09 +04:00
|
|
|
nsPopupType PopupType() const { return mPopupType; }
|
|
|
|
|
2012-10-26 17:15:22 +04:00
|
|
|
void NotifyRollupGeometryChange()
|
2012-06-23 05:13:56 +04:00
|
|
|
{
|
2012-10-26 17:15:22 +04:00
|
|
|
// XULPopupManager isn't interested in this notification, so only
|
|
|
|
// send it if gRollupListener is set.
|
|
|
|
if (gRollupListener) {
|
|
|
|
gRollupListener->NotifyGeometryChange();
|
2012-06-23 05:13:56 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-31 04:43:29 +04:00
|
|
|
/**
|
|
|
|
* Apply the current size constraints to the given size.
|
|
|
|
*
|
|
|
|
* @param aWidth width to constrain
|
|
|
|
* @param aHeight height to constrain
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
void ConstrainSize(int32_t* aWidth, int32_t* aHeight) const
|
2012-07-31 04:43:29 +04:00
|
|
|
{
|
2013-01-15 16:22:03 +04: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-31 04:43:29 +04:00
|
|
|
}
|
|
|
|
|
2012-10-04 11:05:24 +04:00
|
|
|
virtual CompositorChild* GetRemoteRenderer() MOZ_OVERRIDE;
|
|
|
|
|
2013-08-18 10:46:16 +04:00
|
|
|
virtual void GetPreferredCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aHints);
|
2013-05-03 21:34:33 +04:00
|
|
|
|
2013-08-09 03:32:26 +04:00
|
|
|
/**
|
|
|
|
* Notify the widget that this window is being used with OMTC.
|
|
|
|
*/
|
|
|
|
virtual void WindowUsesOMTC() {}
|
|
|
|
|
2015-02-07 02:11:30 +03:00
|
|
|
nsIDocument* GetDocument() const;
|
|
|
|
|
2011-09-01 02:58:19 +04:00
|
|
|
protected:
|
2012-05-23 18:17:44 +04: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 22:52:42 +04:00
|
|
|
nsIWidgetListener* mWidgetListener;
|
2012-08-15 22:53:14 +04:00
|
|
|
nsIWidgetListener* mAttachedWidgetListener;
|
2010-03-01 11:03:49 +03:00
|
|
|
nsRefPtr<LayerManager> mLayerManager;
|
2010-10-15 14:34:29 +04:00
|
|
|
nsRefPtr<LayerManager> mBasicLayerManager;
|
2012-01-19 18:45:37 +04:00
|
|
|
nsRefPtr<CompositorChild> mCompositorChild;
|
|
|
|
nsRefPtr<CompositorParent> mCompositorParent;
|
2014-12-19 23:52:42 +03:00
|
|
|
nsRefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
|
2014-12-15 12:47:15 +03:00
|
|
|
nsRefPtr<APZCTreeManager> mAPZC;
|
2015-02-07 03:45:23 +03:00
|
|
|
nsRefPtr<APZEventState> mAPZEventState;
|
2015-02-07 02:11:30 +03:00
|
|
|
nsRefPtr<SetTargetAPZCCallback> mSetTargetAPZCCallback;
|
2014-03-18 04:23:03 +04:00
|
|
|
nsRefPtr<WidgetShutdownObserver> mShutdownObserver;
|
2015-01-28 09:27:30 +03:00
|
|
|
nsRefPtr<TextEventDispatcher> mTextEventDispatcher;
|
1999-09-28 05:31:41 +04:00
|
|
|
nsCursor mCursor;
|
2014-05-28 05:12:29 +04:00
|
|
|
bool mUpdateCursor;
|
1999-09-28 05:31:41 +04:00
|
|
|
nsBorderStyle mBorderStyle;
|
2012-11-15 22:55:15 +04:00
|
|
|
bool mUseLayersAcceleration;
|
2012-02-28 01:33:19 +04:00
|
|
|
bool mForceLayersAcceleration;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mTemporarilyUseBasicLayerManager;
|
2014-02-21 05:26:41 +04:00
|
|
|
// Windows with out-of-process tabs always require OMTC. This flag designates
|
|
|
|
// such windows.
|
|
|
|
bool mRequireOffMainThreadCompositing;
|
2012-08-15 22:53:09 +04:00
|
|
|
bool mUseAttachedEvents;
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntRect mBounds;
|
|
|
|
nsIntRect* mOriginalBounds;
|
2009-07-22 04:44:55 +04:00
|
|
|
// When this pointer is null, the widget is not clipped
|
|
|
|
nsAutoArrayPtr<nsIntRect> mClipRects;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mClipRectCount;
|
2000-03-09 04:55:48 +03:00
|
|
|
nsSizeMode mSizeMode;
|
2010-07-27 17:38:03 +04:00
|
|
|
nsPopupLevel mPopupLevel;
|
2012-05-31 21:52:09 +04:00
|
|
|
nsPopupType mPopupType;
|
2012-07-31 04:43:29 +04:00
|
|
|
SizeConstraints mSizeConstraints;
|
2007-12-03 19:33:42 +03:00
|
|
|
|
2012-10-26 17:15:22 +04:00
|
|
|
static nsIRollupListener* gRollupListener;
|
|
|
|
|
2007-12-03 19:33:42 +03: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-09-01 02:58:19 +04:00
|
|
|
|
2002-01-24 04:18:36 +03:00
|
|
|
#ifdef DEBUG
|
1999-09-09 06:32:54 +04:00
|
|
|
protected:
|
2013-10-02 07:46:03 +04:00
|
|
|
static nsAutoString debug_GuiEventToString(mozilla::WidgetGUIEvent* aGuiEvent);
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool debug_WantPaintFlashing();
|
1999-09-09 06:32:54 +04:00
|
|
|
|
|
|
|
static void debug_DumpInvalidate(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2009-01-15 06:27:09 +03:00
|
|
|
const nsIntRect * aRect,
|
2012-09-02 06:35:17 +04:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aWindowID);
|
1999-09-09 06:32:54 +04:00
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
static void debug_DumpEvent(FILE* aFileOut,
|
|
|
|
nsIWidget* aWidget,
|
|
|
|
mozilla::WidgetGUIEvent* aGuiEvent,
|
|
|
|
const nsAutoCString& aWidgetName,
|
|
|
|
int32_t aWindowID);
|
2011-09-01 02:58:19 +04:00
|
|
|
|
1999-09-09 06:32:54 +04:00
|
|
|
static void debug_DumpPaintEvent(FILE * aFileOut,
|
|
|
|
nsIWidget * aWidget,
|
2012-08-15 22:52:42 +04:00
|
|
|
const nsIntRegion & aPaintEvent,
|
2012-09-02 06:35:17 +04:00
|
|
|
const nsAutoCString & aWidgetName,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aWindowID);
|
1999-09-09 06:32:54 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool debug_GetCachedBoolPref(const char* aPrefName);
|
1999-07-09 16:11:12 +04:00
|
|
|
#endif
|
1998-09-23 23:19:23 +04:00
|
|
|
};
|
|
|
|
|
2007-12-03 19:33:42 +03: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-29 10:19:26 +04:00
|
|
|
bool wasClear;
|
2007-12-03 19:33:42 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsAutoRollup();
|
|
|
|
~nsAutoRollup();
|
|
|
|
};
|
|
|
|
|
1998-09-23 23:19:23 +04:00
|
|
|
#endif // nsBaseWidget_h__
|