2010-06-04 00:56:36 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
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/. */
|
2010-06-04 00:56:36 +04:00
|
|
|
|
|
|
|
#ifndef NSWINDOW_H_
|
|
|
|
#define NSWINDOW_H_
|
|
|
|
|
|
|
|
#include "nsBaseWidget.h"
|
|
|
|
#include "gfxPoint.h"
|
2012-06-29 12:32:21 +04:00
|
|
|
#include "nsIIdleServiceInternal.h"
|
2010-06-04 00:56:36 +04:00
|
|
|
#include "nsTArray.h"
|
2012-02-10 11:55:13 +04:00
|
|
|
#include "AndroidJavaWrappers.h"
|
2013-11-12 22:41:01 +04:00
|
|
|
#include "GeneratedJNIWrappers.h"
|
2013-10-22 17:27:36 +04:00
|
|
|
#include "mozilla/EventForwards.h"
|
2016-08-19 01:03:04 +03:00
|
|
|
#include "mozilla/Mutex.h"
|
2013-08-13 17:32:03 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2013-10-22 17:27:36 +04:00
|
|
|
#include "mozilla/TextRange.h"
|
2015-09-21 17:13:32 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2012-02-10 11:55:13 +04:00
|
|
|
|
2012-04-19 21:49:31 +04:00
|
|
|
struct ANPEvent;
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
namespace mozilla {
|
2015-04-01 01:20:27 +03:00
|
|
|
class TextComposition;
|
2015-11-13 23:10:51 +03:00
|
|
|
class WidgetTouchEvent;
|
2012-03-14 08:15:11 +04:00
|
|
|
|
|
|
|
namespace layers {
|
2016-03-22 21:08:38 +03:00
|
|
|
class CompositorBridgeParent;
|
|
|
|
class CompositorBridgeChild;
|
2012-07-31 04:42:26 +04:00
|
|
|
class LayerManager;
|
2013-07-30 22:03:40 +04:00
|
|
|
class APZCTreeManager;
|
2012-03-14 08:15:11 +04:00
|
|
|
}
|
2010-06-04 00:56:36 +04:00
|
|
|
}
|
|
|
|
|
2016-04-30 02:23:17 +03:00
|
|
|
class nsWindow : public nsBaseWidget
|
2010-06-04 00:56:36 +04:00
|
|
|
{
|
2014-08-26 23:07:59 +04:00
|
|
|
private:
|
|
|
|
virtual ~nsWindow();
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
public:
|
2010-12-07 05:05:52 +03:00
|
|
|
using nsBaseWidget::GetLayerManager;
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
nsWindow();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2015-09-21 17:13:32 +03:00
|
|
|
static void InitNatives();
|
2015-12-24 06:03:34 +03:00
|
|
|
|
|
|
|
private:
|
2016-05-05 18:39:02 +03:00
|
|
|
// An Event subclass that guards against stale events.
|
|
|
|
template<typename Lambda,
|
|
|
|
bool IsStatic = Lambda::isStatic,
|
|
|
|
typename InstanceType = typename Lambda::ThisArgType,
|
|
|
|
class Impl = typename Lambda::TargetClass>
|
|
|
|
class WindowEvent;
|
|
|
|
|
2016-08-19 01:03:04 +03:00
|
|
|
// Smart pointer for holding a pointer back to the nsWindow inside a native
|
|
|
|
// object class. The nsWindow pointer is automatically cleared when the
|
|
|
|
// nsWindow is destroyed, and a WindowPtr<Impl>::Locked class is provided
|
|
|
|
// for thread-safe access to the nsWindow pointer off of the Gecko thread.
|
|
|
|
template<class Impl> class WindowPtr;
|
|
|
|
|
|
|
|
// Smart pointer for holding a pointer to a native object class. The
|
|
|
|
// pointer is automatically cleared when the object is destroyed.
|
|
|
|
template<class Impl>
|
|
|
|
class NativePtr final
|
|
|
|
{
|
|
|
|
friend WindowPtr<Impl>;
|
|
|
|
|
|
|
|
static const char sName[];
|
|
|
|
|
|
|
|
WindowPtr<Impl>* mPtr;
|
|
|
|
Impl* mImpl;
|
|
|
|
mozilla::Mutex mImplLock;
|
|
|
|
|
|
|
|
public:
|
|
|
|
class Locked;
|
|
|
|
|
|
|
|
NativePtr() : mPtr(nullptr), mImpl(nullptr), mImplLock(sName) {}
|
|
|
|
~NativePtr() { MOZ_ASSERT(!mPtr); }
|
|
|
|
|
|
|
|
operator Impl*() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return mImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
Impl* operator->() const { return operator Impl*(); }
|
|
|
|
|
|
|
|
template<class Instance, typename... Args>
|
|
|
|
void Attach(Instance aInstance, nsWindow* aWindow, Args&&... aArgs);
|
|
|
|
void Detach();
|
|
|
|
};
|
2015-09-21 17:13:32 +03:00
|
|
|
|
2016-08-01 21:21:31 +03:00
|
|
|
class LayerViewSupport;
|
2016-08-19 01:03:04 +03:00
|
|
|
// Object that implements native LayerView calls.
|
|
|
|
// Owned by the Java LayerView instance.
|
|
|
|
NativePtr<LayerViewSupport> mLayerViewSupport;
|
2015-12-24 06:03:34 +03:00
|
|
|
|
2016-01-15 21:05:45 +03:00
|
|
|
class NPZCSupport;
|
|
|
|
// Object that implements native NativePanZoomController calls.
|
|
|
|
// Owned by the Java NativePanZoomController instance.
|
2016-08-19 01:03:04 +03:00
|
|
|
NativePtr<NPZCSupport> mNPZCSupport;
|
|
|
|
|
|
|
|
class GeckoViewSupport;
|
|
|
|
// Object that implements native GeckoView calls and associated states.
|
|
|
|
// nullptr for nsWindows that were not opened from GeckoView.
|
|
|
|
// Because other objects get destroyed in the mGeckOViewSupport destructor,
|
|
|
|
// keep it last in the list, so its destructor is called first.
|
|
|
|
mozilla::UniquePtr<GeckoViewSupport> mGeckoViewSupport;
|
2016-01-15 21:05:45 +03:00
|
|
|
|
2016-08-20 00:17:24 +03:00
|
|
|
// Class that implements native PresentationMediaPlayerManager calls.
|
|
|
|
class PMPMSupport;
|
|
|
|
|
2015-12-24 06:03:34 +03:00
|
|
|
public:
|
2012-04-20 20:49:50 +04:00
|
|
|
static nsWindow* TopWindow();
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-09-23 21:49:05 +03:00
|
|
|
void OnSizeChanged(const mozilla::gfx::IntSize& aSize);
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-11-10 08:37:32 +03:00
|
|
|
void InitEvent(mozilla::WidgetGUIEvent& event,
|
2015-11-13 12:37:02 +03:00
|
|
|
LayoutDeviceIntPoint* aPoint = 0);
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2016-01-26 04:30:55 +03:00
|
|
|
void UpdateOverscrollVelocity(const float aX, const float aY);
|
|
|
|
void UpdateOverscrollOffset(const float aX, const float aY);
|
2016-03-25 01:00:27 +03:00
|
|
|
void SetScrollingRootContent(const bool isRootContent);
|
2016-01-26 04:30:55 +03:00
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
//
|
|
|
|
// nsIWidget
|
|
|
|
//
|
|
|
|
|
2016-01-13 10:32:55 +03:00
|
|
|
using nsBaseWidget::Create; // for Create signature not overridden here
|
2016-08-19 02:03:17 +03:00
|
|
|
virtual MOZ_MUST_USE nsresult Create(nsIWidget* aParent,
|
|
|
|
nsNativeWidget aNativeParent,
|
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData) override;
|
2016-08-10 03:04:11 +03:00
|
|
|
virtual void Destroy() override;
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&) override;
|
|
|
|
NS_IMETHOD SetParent(nsIWidget* aNewParent) override;
|
|
|
|
virtual nsIWidget *GetParent(void) override;
|
|
|
|
virtual float GetDPI() override;
|
|
|
|
virtual double GetDefaultScaleInternal() override;
|
|
|
|
NS_IMETHOD Show(bool aState) override;
|
|
|
|
virtual bool IsVisible() const override;
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t *aX,
|
2015-08-15 05:06:20 +03:00
|
|
|
int32_t *aY) override;
|
2012-12-12 13:57:38 +04:00
|
|
|
NS_IMETHOD Move(double aX,
|
2015-08-15 05:06:20 +03:00
|
|
|
double aY) override;
|
2012-12-12 13:57:38 +04:00
|
|
|
NS_IMETHOD Resize(double aWidth,
|
|
|
|
double aHeight,
|
2015-08-15 05:06:20 +03:00
|
|
|
bool aRepaint) override;
|
2012-12-12 13:57:38 +04:00
|
|
|
NS_IMETHOD Resize(double aX,
|
|
|
|
double aY,
|
|
|
|
double aWidth,
|
|
|
|
double aHeight,
|
2015-08-15 05:06:20 +03:00
|
|
|
bool aRepaint) override;
|
|
|
|
void SetZIndex(int32_t aZIndex) override;
|
2010-06-04 00:56:36 +04:00
|
|
|
NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
|
|
|
|
nsIWidget *aWidget,
|
2015-08-15 05:06:20 +03:00
|
|
|
bool aActivate) override;
|
2016-08-22 02:15:49 +03:00
|
|
|
virtual void SetSizeMode(nsSizeMode aMode) override;
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD Enable(bool aState) override;
|
|
|
|
virtual bool IsEnabled() const override;
|
2015-11-17 08:18:31 +03:00
|
|
|
NS_IMETHOD Invalidate(const LayoutDeviceIntRect& aRect) override;
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD SetFocus(bool aRaise = false) override;
|
2016-08-19 02:03:04 +03:00
|
|
|
virtual LayoutDeviceIntRect GetScreenBounds() override;
|
2015-11-13 12:37:02 +03:00
|
|
|
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
|
2013-10-02 07:46:03 +04:00
|
|
|
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
|
2015-08-15 05:06:20 +03:00
|
|
|
nsEventStatus& aStatus) override;
|
2013-10-02 07:46:03 +04:00
|
|
|
nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent);
|
2016-08-19 02:27:28 +03:00
|
|
|
virtual nsresult MakeFullScreen(bool aFullScreen,
|
|
|
|
nsIScreen* aTargetScreen = nullptr)
|
|
|
|
override;
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD SetWindowClass(const nsAString& xulWinType) override;
|
2010-06-04 00:56:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD SetCursor(nsCursor aCursor) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2010-06-04 00:56:36 +04:00
|
|
|
NS_IMETHOD SetCursor(imgIContainer* aCursor,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aHotspotX,
|
2015-08-15 05:06:20 +03:00
|
|
|
uint32_t aHotspotY) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD SetHasTransparentBackground(bool aTransparent) { return NS_OK; }
|
|
|
|
NS_IMETHOD GetHasTransparentBackground(bool& aTransparent) { aTransparent = false; return NS_OK; }
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD HideWindowChrome(bool aShouldHide) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2016-08-20 00:17:24 +03:00
|
|
|
void* GetNativeData(uint32_t aDataType) override;
|
|
|
|
void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle) override { return NS_OK; }
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec) override { return NS_OK; }
|
|
|
|
NS_IMETHOD CaptureMouse(bool aCapture) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2010-06-04 00:56:36 +04:00
|
|
|
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
2015-08-15 05:06:20 +03:00
|
|
|
bool aDoCapture) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD GetAttention(int32_t aCycleCount) override { return NS_ERROR_NOT_IMPLEMENTED; }
|
2013-10-02 07:46:03 +04:00
|
|
|
NS_IMETHOD BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
int32_t aHorizontal,
|
2015-08-15 05:06:20 +03:00
|
|
|
int32_t aVertical) override
|
2013-10-02 07:46:03 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2011-11-27 15:51:52 +04:00
|
|
|
NS_IMETHOD_(void) SetInputContext(const InputContext& aContext,
|
2015-08-15 05:06:20 +03:00
|
|
|
const InputContextAction& aAction) override;
|
|
|
|
NS_IMETHOD_(InputContext) GetInputContext() override;
|
|
|
|
virtual nsIMEUpdatePreference GetIMEUpdatePreference() override;
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2016-03-11 02:06:13 +03:00
|
|
|
void SetSelectionDragState(bool aState);
|
|
|
|
LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
|
|
|
|
LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
|
2016-06-24 03:53:27 +03:00
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-08-15 05:06:20 +03:00
|
|
|
virtual bool NeedsPaint() override;
|
2015-11-17 07:34:00 +03:00
|
|
|
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
|
2015-11-19 06:10:38 +03:00
|
|
|
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
|
2012-03-14 08:15:11 +04:00
|
|
|
|
2015-08-15 05:06:20 +03:00
|
|
|
virtual bool WidgetPaintsBackground() override;
|
2011-12-21 23:05:23 +04:00
|
|
|
|
2015-04-24 12:43:31 +03:00
|
|
|
virtual uint32_t GetMaxTouchPoints() const override;
|
|
|
|
|
2015-09-03 17:30:41 +03:00
|
|
|
void UpdateZoomConstraints(const uint32_t& aPresShellId,
|
|
|
|
const FrameMetrics::ViewID& aViewId,
|
|
|
|
const mozilla::Maybe<ZoomConstraints>& aConstraints) override;
|
|
|
|
|
2016-02-23 18:17:46 +03:00
|
|
|
nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|
|
|
TouchPointerState aPointerState,
|
2016-04-15 13:39:36 +03:00
|
|
|
LayoutDeviceIntPoint aPoint,
|
2016-02-23 18:17:46 +03:00
|
|
|
double aPointerPressure,
|
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver) override;
|
2016-05-16 19:17:17 +03:00
|
|
|
nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
|
|
|
|
uint32_t aNativeMessage,
|
|
|
|
uint32_t aModifierFlags,
|
|
|
|
nsIObserver* aObserver) override;
|
|
|
|
nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
|
|
|
|
nsIObserver* aObserver) override;
|
2016-02-23 18:17:46 +03:00
|
|
|
|
2016-05-18 08:33:22 +03:00
|
|
|
CompositorBridgeParent* GetCompositorBridgeParent() const;
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
protected:
|
|
|
|
void BringToFront();
|
|
|
|
nsWindow *FindTopLevel();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsTopLevel();
|
2015-04-01 01:20:27 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::TextComposition> GetIMEComposition();
|
2012-11-02 00:11:02 +04:00
|
|
|
void RemoveIMEComposition();
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-04-20 23:16:17 +03:00
|
|
|
void ConfigureAPZControllerThread() override;
|
2015-11-13 23:10:51 +03:00
|
|
|
void DispatchHitTest(const mozilla::WidgetTouchEvent& aEvent);
|
2015-04-20 23:16:17 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
already_AddRefed<GeckoContentController> CreateRootContentController() override;
|
2014-12-15 12:49:51 +03:00
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
// Call this function when the users activity is the direct cause of an
|
|
|
|
// event (like a keypress or mouse click).
|
|
|
|
void UserActivity();
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsVisible;
|
2010-06-04 00:56:36 +04:00
|
|
|
nsTArray<nsWindow*> mChildren;
|
|
|
|
nsWindow* mParent;
|
2010-08-26 09:52:08 +04:00
|
|
|
|
2010-07-08 01:34:12 +04:00
|
|
|
double mStartDist;
|
2010-08-26 09:52:08 +04:00
|
|
|
double mLastDist;
|
2010-11-18 20:18:31 +03:00
|
|
|
|
2012-06-29 12:32:21 +04:00
|
|
|
nsCOMPtr<nsIIdleServiceInternal> mIdleService;
|
2010-08-26 09:52:08 +04:00
|
|
|
|
2015-07-02 23:00:44 +03:00
|
|
|
bool mAwaitingFullScreen;
|
|
|
|
bool mIsFullScreen;
|
|
|
|
|
2015-01-28 09:27:31 +03:00
|
|
|
virtual nsresult NotifyIMEInternal(
|
2015-03-21 19:28:04 +03:00
|
|
|
const IMENotification& aIMENotification) override;
|
2015-01-28 09:27:31 +03:00
|
|
|
|
2016-05-18 08:33:21 +03:00
|
|
|
bool UseExternalCompositingSurface() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
static void DumpWindows();
|
|
|
|
static void DumpWindows(const nsTArray<nsWindow*>& wins, int indent = 0);
|
|
|
|
static void LogWindow(nsWindow *win, int index, int indent);
|
|
|
|
|
|
|
|
private:
|
2013-03-21 02:45:07 +04:00
|
|
|
void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
|
2011-11-15 07:12:14 +04:00
|
|
|
void RedrawAll();
|
|
|
|
|
2016-07-21 20:49:04 +03:00
|
|
|
mozilla::java::LayerRenderer::Frame::GlobalRef mLayerRendererFrame;
|
2012-02-10 11:55:13 +04:00
|
|
|
};
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
#endif /* NSWINDOW_H_ */
|