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"
|
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 {
|
|
|
|
class AndroidGeckoEvent;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
class nsWindow :
|
|
|
|
public nsBaseWidget
|
|
|
|
{
|
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:
|
|
|
|
class GeckoViewSupport;
|
|
|
|
// Object that implements native GeckoView calls and associated states.
|
2015-09-21 17:13:32 +03:00
|
|
|
// nullptr for nsWindows that were not opened from GeckoView.
|
2015-12-24 06:03:34 +03:00
|
|
|
mozilla::UniquePtr<GeckoViewSupport> mGeckoViewSupport;
|
2015-09-21 17:13:32 +03:00
|
|
|
|
2015-12-24 06:03:34 +03:00
|
|
|
class GLControllerSupport;
|
|
|
|
// Object that implements native GLController calls.
|
|
|
|
mozilla::UniquePtr<GLControllerSupport> mGLControllerSupport;
|
|
|
|
|
2016-01-15 21:05:45 +03:00
|
|
|
class NPZCSupport;
|
|
|
|
// Object that implements native NativePanZoomController calls.
|
|
|
|
// Owned by the Java NativePanZoomController instance.
|
|
|
|
NPZCSupport* mNPZCSupport;
|
|
|
|
|
2015-12-24 06:03:34 +03:00
|
|
|
public:
|
2010-06-04 00:56:36 +04:00
|
|
|
static void OnGlobalAndroidEvent(mozilla::AndroidGeckoEvent *ae);
|
2012-04-20 20:49:50 +04:00
|
|
|
static nsWindow* TopWindow();
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-04-14 05:33:02 +03:00
|
|
|
bool OnContextmenuEvent(mozilla::AndroidGeckoEvent *ae);
|
|
|
|
void OnLongTapEvent(mozilla::AndroidGeckoEvent *ae);
|
2012-01-25 04:31:33 +04:00
|
|
|
bool OnMultitouchEvent(mozilla::AndroidGeckoEvent *ae);
|
2012-10-03 00:18:21 +04:00
|
|
|
void OnNativeGestureEvent(mozilla::AndroidGeckoEvent *ae);
|
2012-06-16 02:34:22 +04:00
|
|
|
void OnMouseEvent(mozilla::AndroidGeckoEvent *ae);
|
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
|
2015-11-16 11:35:18 +03:00
|
|
|
NS_IMETHOD Create(nsIWidget* aParent,
|
2010-06-04 00:56:36 +04:00
|
|
|
nsNativeWidget aNativeParent,
|
2015-11-16 11:35:18 +03:00
|
|
|
const LayoutDeviceIntRect& aRect,
|
|
|
|
nsWidgetInitData* aInitData) override;
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD Destroy(void) override;
|
|
|
|
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;
|
|
|
|
NS_IMETHOD SetModal(bool aModal) 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;
|
2015-08-29 04:12:41 +03:00
|
|
|
NS_IMETHOD 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;
|
2015-11-13 12:37:02 +03:00
|
|
|
NS_IMETHOD GetScreenBounds(LayoutDeviceIntRect& aRect) override;
|
|
|
|
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);
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen = nullptr) override;
|
|
|
|
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; }
|
|
|
|
virtual void* GetNativeData(uint32_t aDataType) override;
|
|
|
|
NS_IMETHOD SetTitle(const nsAString& aTitle) override { return NS_OK; }
|
|
|
|
NS_IMETHOD SetIcon(const nsAString& aIconSpec) override { return NS_OK; }
|
|
|
|
NS_IMETHOD EnableDragDrop(bool aEnable) 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,
|
|
|
|
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
|
|
|
|
bool* aAllowRetaining = nullptr) override;
|
2010-06-04 00:56:36 +04:00
|
|
|
|
2015-08-15 05:06:20 +03:00
|
|
|
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) override;
|
2011-11-15 07:12:14 +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
|
|
|
|
2016-03-22 21:08:38 +03:00
|
|
|
virtual mozilla::layers::CompositorBridgeParent* NewCompositorBridgeParent(
|
|
|
|
int aSurfaceWidth, int aSurfaceHeight) override;
|
2013-04-18 01:39:13 +04:00
|
|
|
|
2015-04-11 05:14:00 +03:00
|
|
|
static bool IsCompositionPaused();
|
2015-06-11 18:20:04 +03:00
|
|
|
static void InvalidateAndScheduleComposite();
|
2015-04-11 05:14:00 +03:00
|
|
|
static void SchedulePauseComposition();
|
|
|
|
static void ScheduleResumeComposition();
|
2012-10-25 20:23:47 +04:00
|
|
|
static float ComputeRenderIntegrity();
|
2012-04-17 10:04:05 +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,
|
|
|
|
ScreenIntPoint aPointerScreenPoint,
|
|
|
|
double aPointerPressure,
|
|
|
|
uint32_t aPointerOrientation,
|
|
|
|
nsIObserver* aObserver) override;
|
|
|
|
|
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
|
|
|
|
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();
|
|
|
|
|
2015-12-24 06:03:33 +03:00
|
|
|
mozilla::widget::LayerRenderer::Frame::GlobalRef mLayerRendererFrame;
|
2012-02-10 11:55:13 +04:00
|
|
|
};
|
|
|
|
|
2010-06-04 00:56:36 +04:00
|
|
|
#endif /* NSWINDOW_H_ */
|