1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsBaseWidget_h__
6 #define nsBaseWidget_h__
9 #include "mozilla/EventForwards.h"
10 #include "mozilla/Mutex.h"
11 #include "mozilla/RefPtr.h"
12 #include "mozilla/UniquePtr.h"
13 #include "mozilla/WidgetUtils.h"
14 #include "mozilla/dom/MouseEventBinding.h"
15 #include "mozilla/layers/APZCCallbackHelper.h"
16 #include "mozilla/layers/CompositorOptions.h"
17 #include "mozilla/layers/NativeLayer.h"
18 #include "mozilla/widget/ThemeChangeKind.h"
19 #include "mozilla/widget/WindowOcclusionState.h"
21 #include "nsIWidget.h"
22 #include "nsWidgetsCID.h"
26 #include "nsIRollupListener.h"
27 #include "nsIObserver.h"
28 #include "nsIWidgetListener.h"
29 #include "nsPIDOMWindow.h"
30 #include "nsWeakReference.h"
38 class CompositorVsyncDispatcher
;
39 class LiveResizeListener
;
40 class FallbackRenderer
;
42 struct SwipeEventQueue
;
43 class WidgetWheelEvent
;
47 class LocalAccessible
;
57 class CompositorBridgeChild
;
58 class CompositorBridgeParent
;
59 class IAPZCTreeManager
;
60 class GeckoContentController
;
62 struct APZEventResult
;
63 class CompositorSession
;
65 class WebRenderLayerManager
;
66 struct ScrollableLayerGuid
;
67 class RemoteCompositorSession
;
71 class CompositorWidgetDelegate
;
72 class InProcessCompositorWidget
;
73 class WidgetRenderingContext
;
76 class CompositorVsyncDispatcher
;
77 } // namespace mozilla
83 // Windows specific constant indicating the maximum number of touch points the
84 // inject api will allow. This also sets the maximum numerical value for touch
85 // ids we can use when injecting touch points on Windows.
86 #define TOUCH_INJECT_MAX_POINTS 256
90 // Helper class used in shutting down gfx related code.
91 class WidgetShutdownObserver final
: public nsIObserver
{
92 ~WidgetShutdownObserver();
95 explicit WidgetShutdownObserver(nsBaseWidget
* aWidget
);
103 nsBaseWidget
* mWidget
;
107 // Helper class used for observing locales change.
108 class LocalesChangedObserver final
: public nsIObserver
{
109 ~LocalesChangedObserver();
112 explicit LocalesChangedObserver(nsBaseWidget
* aWidget
);
120 nsBaseWidget
* mWidget
;
125 * Common widget implementation used as base class for native
126 * or crossplatform implementations of Widgets.
127 * All cross-platform behavior that all widgets need to implement
128 * should be placed in this class.
129 * (Note: widget implementations are not required to use this
130 * class, but it gives them a head start.)
133 class nsBaseWidget
: public nsIWidget
, public nsSupportsWeakReference
{
134 template <class EventType
, class InputType
>
135 friend class DispatchEventOnMainThread
;
136 friend class mozilla::widget::InProcessCompositorWidget
;
137 friend class mozilla::layers::RemoteCompositorSession
;
140 typedef base::Thread Thread
;
141 typedef mozilla::gfx::DrawTarget DrawTarget
;
142 typedef mozilla::gfx::SourceSurface SourceSurface
;
143 typedef mozilla::layers::BufferMode BufferMode
;
144 typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild
;
145 typedef mozilla::layers::CompositorBridgeParent CompositorBridgeParent
;
146 typedef mozilla::layers::IAPZCTreeManager IAPZCTreeManager
;
147 typedef mozilla::layers::GeckoContentController GeckoContentController
;
148 typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid
;
149 typedef mozilla::layers::APZEventState APZEventState
;
150 typedef mozilla::CSSIntRect CSSIntRect
;
151 typedef mozilla::CSSRect CSSRect
;
152 typedef mozilla::ScreenRotation ScreenRotation
;
153 typedef mozilla::widget::CompositorWidgetDelegate CompositorWidgetDelegate
;
154 typedef mozilla::layers::CompositorSession CompositorSession
;
155 typedef mozilla::layers::ImageContainer ImageContainer
;
157 virtual ~nsBaseWidget();
162 explicit nsBaseWidget(BorderStyle aBorderStyle
);
164 NS_DECL_THREADSAFE_ISUPPORTS
166 // nsIWidget interface
167 void CaptureRollupEvents(bool aDoCapture
) override
{}
168 nsIWidgetListener
* GetWidgetListener() const override
;
169 void SetWidgetListener(nsIWidgetListener
* alistener
) override
;
170 void Destroy() override
;
171 float GetDPI() override
;
173 void GetWorkspaceID(nsAString
& workspaceID
) override
;
174 void MoveToWorkspace(const nsAString
& workspaceID
) override
;
175 bool IsTiled() const override
{ return mIsTiled
; }
177 bool IsFullyOccluded() const override
{ return mIsFullyOccluded
; }
179 void SetCursor(const Cursor
&) override
;
180 void SetCustomCursorAllowed(bool) override
;
181 void ClearCachedCursor() final
{
183 mUpdateCursor
= true;
185 void SetTransparencyMode(TransparencyMode aMode
) override
;
186 TransparencyMode
GetTransparencyMode() override
;
187 void SetWindowShadowStyle(mozilla::WindowShadow
) override
{}
188 void SetShowsToolbarButton(bool aShow
) override
{}
189 void SetSupportsNativeFullscreen(bool aSupportsNativeFullscreen
) override
{}
190 void SetWindowAnimationType(WindowAnimationType aType
) override
{}
191 void HideWindowChrome(bool aShouldHide
) override
{}
192 bool PrepareForFullscreenTransition(nsISupports
** aData
) override
{
195 void PerformFullscreenTransition(FullscreenTransitionStage aStage
,
196 uint16_t aDuration
, nsISupports
* aData
,
197 nsIRunnable
* aCallback
) override
;
198 void CleanupFullscreenTransition() override
{}
199 already_AddRefed
<Screen
> GetWidgetScreen() override
;
200 nsresult
MakeFullScreen(bool aFullScreen
) override
;
201 void InfallibleMakeFullScreen(bool aFullScreen
);
203 LayersId
GetLayersId() const override
;
204 WindowRenderer
* GetWindowRenderer() override
;
205 bool HasWindowRenderer() const final
{ return !!mWindowRenderer
; }
207 // A remote compositor session tied to this window has been lost and IPC
208 // messages will no longer work. The widget must clean up any lingering
209 // resources and possibly schedule another paint.
211 // A reference to the session object is held until this function has
212 // returned. Callers should hold a reference to the widget, since this
213 // function could deallocate the widget if it is unparented.
214 virtual void NotifyCompositorSessionLost(
215 mozilla::layers::CompositorSession
* aSession
);
217 already_AddRefed
<mozilla::CompositorVsyncDispatcher
>
218 GetCompositorVsyncDispatcher();
219 virtual void CreateCompositorVsyncDispatcher();
220 virtual void CreateCompositor();
221 virtual void CreateCompositor(int aWidth
, int aHeight
);
222 virtual void SetCompositorWidgetDelegate(CompositorWidgetDelegate
*) {}
223 void PrepareWindowEffects() override
{}
224 void UpdateThemeGeometries(
225 const nsTArray
<ThemeGeometry
>& aThemeGeometries
) override
{}
226 void SetModal(bool aModal
) override
{}
227 uint32_t GetMaxTouchPoints() const override
;
228 void SetWindowClass(const nsAString
& xulWinType
, const nsAString
& xulWinClass
,
229 const nsAString
& xulWinName
) override
{}
230 // Return whether this widget interprets parameters to Move and Resize APIs
231 // as "desktop pixels" rather than "device pixels", and therefore
232 // applies its GetDefaultScale() value to them before using them as mBounds
233 // etc (which are always stored in device pixels).
234 // Note that APIs that -get- the widget's position/size/bounds, rather than
235 // -setting- them (i.e. moving or resizing the widget) will always return
236 // values in the widget's device pixels.
237 bool BoundsUseDesktopPixels() const {
238 return mWindowType
<= WindowType::Popup
;
240 // Default implementation, to be overridden by platforms where desktop coords
241 // are virtualized and may not correspond to device pixels on the screen.
242 mozilla::DesktopToLayoutDeviceScale
GetDesktopToDeviceScale() override
{
243 return mozilla::DesktopToLayoutDeviceScale(1.0);
245 mozilla::DesktopToLayoutDeviceScale
GetDesktopToDeviceScaleByScreen()
248 void ConstrainPosition(DesktopIntPoint
&) override
{}
249 // Utility function for derived-class overrides of ConstrainPosition.
250 static DesktopIntPoint
ConstrainPositionToBounds(
251 const DesktopIntPoint
&, const mozilla::DesktopIntSize
&,
252 const DesktopIntRect
&);
253 void MoveClient(const DesktopPoint
& aOffset
) override
;
254 void ResizeClient(const DesktopSize
& aSize
, bool aRepaint
) override
;
255 void ResizeClient(const DesktopRect
& aRect
, bool aRepaint
) override
;
256 LayoutDeviceIntRect
GetBounds() override
;
257 LayoutDeviceIntRect
GetClientBounds() override
;
258 LayoutDeviceIntRect
GetScreenBounds() override
;
259 [[nodiscard
]] nsresult
GetRestoredBounds(LayoutDeviceIntRect
& aRect
) override
;
260 LayoutDeviceIntPoint
GetClientOffset() override
;
261 void EnableDragDrop(bool aEnable
) override
{};
262 nsresult
AsyncEnableDragDrop(bool aEnable
) override
;
263 [[nodiscard
]] nsresult
GetAttention(int32_t aCycleCount
) override
{
266 bool HasPendingInputEvent() override
;
267 void SetIcon(const nsAString
& aIconSpec
) override
{}
268 bool ShowsResizeIndicator(LayoutDeviceIntRect
* aResizerRect
) override
;
269 void FreeNativeData(void* data
, uint32_t aDataType
) override
{}
270 nsresult
ActivateNativeMenuItemAt(const nsAString
& indexString
) override
{
271 return NS_ERROR_NOT_IMPLEMENTED
;
273 nsresult
ForceUpdateNativeMenuAt(const nsAString
& indexString
) override
{
274 return NS_ERROR_NOT_IMPLEMENTED
;
276 nsresult
NotifyIME(const IMENotification
& aIMENotification
) final
;
277 [[nodiscard
]] nsresult
AttachNativeKeyEvent(
278 mozilla::WidgetKeyboardEvent
& aEvent
) override
{
279 return NS_ERROR_NOT_IMPLEMENTED
;
281 bool ComputeShouldAccelerate();
282 virtual bool WidgetTypeSupportsAcceleration() { return true; }
283 [[nodiscard
]] nsresult
OnDefaultButtonLoaded(
284 const LayoutDeviceIntRect
& aButtonRect
) override
{
285 return NS_ERROR_NOT_IMPLEMENTED
;
287 already_AddRefed
<nsIWidget
> CreateChild(const LayoutDeviceIntRect
& aRect
,
289 void AttachViewToTopLevel(bool aUseAttachedEvents
) override
;
290 nsIWidgetListener
* GetAttachedWidgetListener() const override
;
291 void SetAttachedWidgetListener(nsIWidgetListener
* aListener
) override
;
292 nsIWidgetListener
* GetPreviouslyAttachedWidgetListener() override
;
293 void SetPreviouslyAttachedWidgetListener(nsIWidgetListener
*) override
;
294 NativeIMEContext
GetNativeIMEContext() override
;
295 TextEventDispatcher
* GetTextEventDispatcher() final
;
296 TextEventDispatcherListener
* GetNativeTextEventDispatcherListener() override
;
297 void ZoomToRect(const uint32_t& aPresShellId
,
298 const ScrollableLayerGuid::ViewID
& aViewId
,
299 const CSSRect
& aRect
, const uint32_t& aFlags
) override
;
301 // Dispatch an event that must be first be routed through APZ.
302 ContentAndAPZEventStatus
DispatchInputEvent(
303 mozilla::WidgetInputEvent
* aEvent
) override
;
304 void DispatchEventToAPZOnly(mozilla::WidgetInputEvent
* aEvent
) override
;
306 bool DispatchWindowEvent(mozilla::WidgetGUIEvent
& event
) override
;
308 void SetConfirmedTargetAPZC(
309 uint64_t aInputBlockId
,
310 const nsTArray
<ScrollableLayerGuid
>& aTargets
) const override
;
312 void UpdateZoomConstraints(
313 const uint32_t& aPresShellId
, const ScrollableLayerGuid::ViewID
& aViewId
,
314 const mozilla::Maybe
<ZoomConstraints
>& aConstraints
) override
;
316 bool AsyncPanZoomEnabled() const override
;
318 void SwipeFinished() override
;
319 void ReportSwipeStarted(uint64_t aInputBlockId
, bool aStartSwipe
) override
;
320 void TrackScrollEventAsSwipe(const mozilla::PanGestureInput
& aSwipeStartEvent
,
321 uint32_t aAllowedDirections
,
322 uint64_t aInputBlockId
);
325 uint32_t allowedDirections
;
327 SwipeInfo
SendMayStartSwipe(const mozilla::PanGestureInput
& aSwipeStartEvent
);
328 // Returns a WidgetWheelEvent which needs to be handled by APZ regardless of
329 // whether |aPanInput| event was used for SwipeTracker or not.
330 mozilla::WidgetWheelEvent
MayStartSwipeForAPZ(
331 const mozilla::PanGestureInput
& aPanInput
,
332 const mozilla::layers::APZEventResult
& aApzResult
);
334 // Returns true if |aPanInput| event was used for SwipeTracker, false
336 bool MayStartSwipeForNonAPZ(const mozilla::PanGestureInput
& aPanInput
);
338 void NotifyWindowDestroyed();
339 void NotifySizeMoveDone();
341 using ByMoveToRect
= nsIWidgetListener::ByMoveToRect
;
342 void NotifyWindowMoved(int32_t aX
, int32_t aY
,
343 ByMoveToRect
= ByMoveToRect::No
);
345 // Should be called by derived implementations to notify on system color and
346 // theme changes. (Only one invocation per change is needed, not one
347 // invocation per change per window.)
348 void NotifyThemeChanged(mozilla::widget::ThemeChangeKind
);
350 void NotifyAPZOfDPIChange();
353 // Get the accessible for the window.
354 mozilla::a11y::LocalAccessible
* GetRootAccessible();
357 // Return true if this is a simple widget (that is typically not worth
359 bool IsSmallPopup() const;
361 PopupLevel
GetPopupLevel() { return mPopupLevel
; }
363 const SizeConstraints
GetSizeConstraints() override
;
364 void SetSizeConstraints(const SizeConstraints
& aConstraints
) override
;
366 void StartAsyncScrollbarDrag(const AsyncDragMetrics
& aDragMetrics
) override
;
368 bool StartAsyncAutoscroll(const ScreenPoint
& aAnchorLocation
,
369 const ScrollableLayerGuid
& aGuid
) override
;
371 void StopAsyncAutoscroll(const ScrollableLayerGuid
& aGuid
) override
;
373 mozilla::layers::LayersId
GetRootLayerTreeId() override
;
376 * Use this when GetLayerManager() returns a BasicLayerManager
377 * (nsBaseWidget::GetLayerManager() does). This sets up the widget's
378 * layer manager to temporarily render into aTarget.
380 * |aNaturalWidgetBounds| is the un-rotated bounds of |aWidget|.
381 * |aRotation| is the "virtual rotation" to apply when rendering to
382 * the target. When |aRotation| is ROTATION_0,
383 * |aNaturalWidgetBounds| is not used.
385 class AutoLayerManagerSetup
{
387 AutoLayerManagerSetup(nsBaseWidget
* aWidget
, gfxContext
* aTarget
,
388 BufferMode aDoubleBuffering
);
389 ~AutoLayerManagerSetup();
392 nsBaseWidget
* mWidget
;
393 mozilla::FallbackRenderer
* mRenderer
= nullptr;
395 friend class AutoLayerManagerSetup
;
397 virtual bool ShouldUseOffMainThreadCompositing();
399 static nsIRollupListener
* GetActiveRollupListener();
405 // These functions should be called at the start and end of a "live" widget
406 // resize (i.e. when the window contents are repainting during the resize,
407 // such as when the user drags a window border). It will suppress the
408 // displayport during the live resize to avoid unneccessary overpainting.
409 void NotifyLiveResizeStarted();
410 void NotifyLiveResizeStopped();
412 #if defined(MOZ_WIDGET_ANDROID)
413 void RecvToolbarAnimatorMessageFromCompositor(int32_t) override
{};
414 void UpdateRootFrameMetrics(const ScreenPoint
& aScrollOffset
,
415 const CSSToScreenScale
& aZoom
) override
{};
416 void RecvScreenPixels(mozilla::ipc::Shmem
&& aMem
, const ScreenIntSize
& aSize
,
417 bool aNeedsYFlip
) override
{};
420 virtual void LocalesChanged() {}
422 virtual void NotifyOcclusionState(mozilla::widget::OcclusionState aState
) {}
425 // These are methods for CompositorWidgetWrapper, and should only be
426 // accessed from that class. Derived widgets can choose which methods to
427 // implement, or none if supporting out-of-process compositing.
428 virtual bool PreRender(mozilla::widget::WidgetRenderingContext
* aContext
) {
431 virtual void PostRender(mozilla::widget::WidgetRenderingContext
* aContext
) {}
432 virtual RefPtr
<mozilla::layers::NativeLayerRoot
> GetNativeLayerRoot() {
435 virtual already_AddRefed
<DrawTarget
> StartRemoteDrawing();
436 virtual already_AddRefed
<DrawTarget
> StartRemoteDrawingInRegion(
437 const LayoutDeviceIntRegion
& aInvalidRegion
, BufferMode
* aBufferMode
) {
438 return StartRemoteDrawing();
440 virtual void EndRemoteDrawing() {}
441 virtual void EndRemoteDrawingInRegion(
442 DrawTarget
* aDrawTarget
, const LayoutDeviceIntRegion
& aInvalidRegion
) {
445 virtual void CleanupRemoteDrawing() {}
446 virtual void CleanupWindowEffects() {}
447 virtual bool InitCompositor(mozilla::layers::Compositor
* aCompositor
) {
450 virtual uint32_t GetGLFrameBufferFormat();
451 virtual bool CompositorInitiallyPaused() { return false; }
454 void ResolveIconName(const nsAString
& aIconName
, const nsAString
& aIconSuffix
,
456 virtual void OnDestroy();
457 void BaseCreate(nsIWidget
* aParent
, InitData
* aInitData
);
459 virtual void ConfigureAPZCTreeManager();
460 virtual void ConfigureAPZControllerThread();
461 virtual already_AddRefed
<GeckoContentController
>
462 CreateRootContentController();
464 // Dispatch an event that has already been routed through APZ.
465 nsEventStatus
ProcessUntransformedAPZEvent(
466 mozilla::WidgetInputEvent
* aEvent
,
467 const mozilla::layers::APZEventResult
& aApzResult
);
469 nsresult
SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout
,
470 int32_t aNativeKeyCode
,
471 uint32_t aModifierFlags
,
472 const nsAString
& aCharacters
,
473 const nsAString
& aUnmodifiedCharacters
,
474 nsIObserver
* aObserver
) override
{
475 mozilla::widget::AutoObserverNotifier
notifier(aObserver
, "keyevent");
476 return NS_ERROR_UNEXPECTED
;
479 nsresult
SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint
,
480 NativeMouseMessage aNativeMessage
,
481 mozilla::MouseButton aButton
,
482 nsIWidget::Modifiers aModifierFlags
,
483 nsIObserver
* aObserver
) override
{
484 mozilla::widget::AutoObserverNotifier
notifier(aObserver
, "mouseevent");
485 return NS_ERROR_UNEXPECTED
;
488 nsresult
SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint
,
489 nsIObserver
* aObserver
) override
{
490 mozilla::widget::AutoObserverNotifier
notifier(aObserver
, "mouseevent");
491 return NS_ERROR_UNEXPECTED
;
494 nsresult
SynthesizeNativeMouseScrollEvent(
495 LayoutDeviceIntPoint aPoint
, uint32_t aNativeMessage
, double aDeltaX
,
496 double aDeltaY
, double aDeltaZ
, uint32_t aModifierFlags
,
497 uint32_t aAdditionalFlags
, nsIObserver
* aObserver
) override
{
498 mozilla::widget::AutoObserverNotifier
notifier(aObserver
,
500 return NS_ERROR_UNEXPECTED
;
503 nsresult
SynthesizeNativeTouchPoint(uint32_t aPointerId
,
504 TouchPointerState aPointerState
,
505 LayoutDeviceIntPoint aPoint
,
506 double aPointerPressure
,
507 uint32_t aPointerOrientation
,
508 nsIObserver
* aObserver
) override
{
509 mozilla::widget::AutoObserverNotifier
notifier(aObserver
, "touchpoint");
510 return NS_ERROR_UNEXPECTED
;
513 nsresult
SynthesizeNativeTouchPadPinch(TouchpadGesturePhase aEventPhase
,
515 LayoutDeviceIntPoint aPoint
,
516 int32_t aModifierFlags
) override
{
518 false, "This method is not implemented on the current platform");
519 return NS_ERROR_UNEXPECTED
;
522 nsresult
SynthesizeNativePenInput(uint32_t aPointerId
,
523 TouchPointerState aPointerState
,
524 LayoutDeviceIntPoint aPoint
,
525 double aPressure
, uint32_t aRotation
,
526 int32_t aTiltX
, int32_t aTiltY
,
528 nsIObserver
* aObserver
) override
{
530 false, "This method is not implemented on the current platform");
531 return NS_ERROR_UNEXPECTED
;
534 nsresult
SynthesizeNativeTouchpadDoubleTap(LayoutDeviceIntPoint aPoint
,
535 uint32_t aModifierFlags
) override
{
537 false, "This method is not implemented on the current platform");
538 return NS_ERROR_UNEXPECTED
;
541 nsresult
SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase
,
542 LayoutDeviceIntPoint aPoint
,
543 double aDeltaX
, double aDeltaY
,
544 int32_t aModifierFlags
,
545 nsIObserver
* aObserver
) override
{
547 false, "This method is not implemented on the current platform");
548 return NS_ERROR_UNEXPECTED
;
552 * GetPseudoIMEContext() returns pseudo IME context when TextEventDispatcher
553 * has non-native input transaction. Otherwise, returns nullptr.
555 void* GetPseudoIMEContext();
558 virtual already_AddRefed
<nsIWidget
> AllocateChildPopupWidget() {
559 return nsIWidget::CreateChildWindow();
562 WindowRenderer
* CreateFallbackRenderer();
564 PopupType
GetPopupType() const { return mPopupType
; }
566 bool HasRemoteContent() const { return mHasRemoteContent
; }
569 * Apply the current size constraints to the given size.
571 * @param aWidth width to constrain
572 * @param aHeight height to constrain
574 void ConstrainSize(int32_t* aWidth
, int32_t* aHeight
) override
{
575 SizeConstraints c
= GetSizeConstraints();
576 *aWidth
= std::clamp(*aWidth
, c
.mMinSize
.width
, c
.mMaxSize
.width
);
577 *aHeight
= std::clamp(*aHeight
, c
.mMinSize
.height
, c
.mMaxSize
.height
);
580 CompositorBridgeChild
* GetRemoteRenderer() override
;
582 void ClearCachedWebrenderResources() override
;
584 void ClearWebrenderAnimationResources() override
;
586 bool SetNeedFastSnaphot() override
;
589 * Notify the widget that this window is being used with OMTC.
591 virtual void WindowUsesOMTC() {}
592 virtual void RegisterTouchWindow() {}
594 mozilla::dom::Document
* GetDocument() const;
596 void EnsureTextEventDispatcher();
598 // Notify the compositor that a device reset has occurred.
599 void OnRenderingDeviceReset();
603 bool AllowWebRenderForThisWindow();
606 * For widgets that support synthesizing native touch events, this function
607 * can be used to manage the current state of synthetic pointers. Each widget
608 * must maintain its own MultiTouchInput instance and pass it in as the state,
609 * along with the desired parameters for the changes. This function returns
610 * a new MultiTouchInput object that is ready to be dispatched.
612 mozilla::MultiTouchInput
UpdateSynthesizedTouchState(
613 mozilla::MultiTouchInput
* aState
, mozilla::TimeStamp aTimeStamp
,
614 uint32_t aPointerId
, TouchPointerState aPointerState
,
615 LayoutDeviceIntPoint aPoint
, double aPointerPressure
,
616 uint32_t aPointerOrientation
);
619 * Dispatch the given MultiTouchInput through APZ to Gecko (if APZ is enabled)
620 * or directly to gecko (if APZ is not enabled). This function must only
621 * be called from the main thread, and if APZ is enabled, that must also be
622 * the APZ controller thread.
624 void DispatchTouchInput(
625 mozilla::MultiTouchInput
& aInput
,
626 uint16_t aInputSource
=
627 mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH
);
630 * Dispatch the given PanGestureInput through APZ to Gecko (if APZ is enabled)
631 * or directly to gecko (if APZ is not enabled). This function must only
632 * be called from the main thread, and if APZ is enabled, that must also be
633 * the APZ controller thread.
635 void DispatchPanGestureInput(mozilla::PanGestureInput
& aInput
);
636 void DispatchPinchGestureInput(mozilla::PinchGestureInput
& aInput
);
638 static bool ConvertStatus(nsEventStatus aStatus
) {
639 return aStatus
== nsEventStatus_eConsumeNoDefault
;
643 // Returns whether compositing should use an external surface size.
644 virtual bool UseExternalCompositingSurface() const { return false; }
647 * Starts the OMTC compositor destruction sequence.
649 * When this function returns, the compositor should not be
650 * able to access the opengl context anymore.
651 * It is safe to call it several times if platform implementations
652 * require the compositor to be destroyed before ~nsBaseWidget is
653 * reached (This is the case with gtk2 for instance).
655 virtual void DestroyCompositor();
656 void DestroyLayerManager();
657 void ReleaseContentController();
658 void RevokeTransactionIdAllocator();
660 void FreeShutdownObserver();
661 void FreeLocalesChangedObserver();
663 bool IsPIPWindow() const { return mIsPIPWindow
; };
665 nsIWidgetListener
* mWidgetListener
;
666 nsIWidgetListener
* mAttachedWidgetListener
;
667 nsIWidgetListener
* mPreviouslyAttachedWidgetListener
;
668 RefPtr
<WindowRenderer
> mWindowRenderer
;
669 RefPtr
<CompositorSession
> mCompositorSession
;
670 RefPtr
<CompositorBridgeChild
> mCompositorBridgeChild
;
672 mozilla::UniquePtr
<mozilla::Mutex
> mCompositorVsyncDispatcherLock
;
673 RefPtr
<mozilla::CompositorVsyncDispatcher
> mCompositorVsyncDispatcher
;
675 RefPtr
<IAPZCTreeManager
> mAPZC
;
676 RefPtr
<GeckoContentController
> mRootContentController
;
677 RefPtr
<APZEventState
> mAPZEventState
;
678 RefPtr
<WidgetShutdownObserver
> mShutdownObserver
;
679 RefPtr
<LocalesChangedObserver
> mLocalesChangedObserver
;
680 RefPtr
<TextEventDispatcher
> mTextEventDispatcher
;
681 RefPtr
<mozilla::SwipeTracker
> mSwipeTracker
;
682 mozilla::UniquePtr
<mozilla::SwipeEventQueue
> mSwipeEventQueue
;
684 bool mCustomCursorAllowed
= true;
685 BorderStyle mBorderStyle
;
686 LayoutDeviceIntRect mBounds
;
688 PopupLevel mPopupLevel
;
689 PopupType mPopupType
;
690 SizeConstraints mSizeConstraints
;
691 bool mHasRemoteContent
;
693 struct FullscreenSavedState
{
694 DesktopRect windowRect
;
695 DesktopRect screenRect
;
697 mozilla::Maybe
<FullscreenSavedState
> mSavedBounds
;
700 bool mUseAttachedEvents
;
703 // if the window is fully occluded (rendering may be paused in response)
704 bool mIsFullyOccluded
;
705 bool mNeedFastSnaphot
;
706 // This flag is only used when APZ is off. It indicates that the current pan
707 // gesture was processed as a swipe. Sometimes the swipe animation can finish
708 // before momentum events of the pan gesture have stopped firing, so this
709 // flag tells us that we shouldn't allow the remaining events to cause
710 // scrolling. It is reset to false once a new gesture starts (as indicated by
711 // a PANGESTURE_(MAY)START event).
712 bool mCurrentPanGestureBelongsToSwipe
;
714 // It's PictureInPicture window.
715 bool mIsPIPWindow
: 1;
717 struct InitialZoomConstraints
{
718 InitialZoomConstraints(const uint32_t& aPresShellID
,
719 const ScrollableLayerGuid::ViewID
& aViewID
,
720 const ZoomConstraints
& aConstraints
)
721 : mPresShellID(aPresShellID
),
723 mConstraints(aConstraints
) {}
725 uint32_t mPresShellID
;
726 ScrollableLayerGuid::ViewID mViewID
;
727 ZoomConstraints mConstraints
;
730 mozilla::Maybe
<InitialZoomConstraints
> mInitialZoomConstraints
;
732 // This points to the resize listeners who have been notified that a live
733 // resize is in progress. This should always be empty when a live-resize is
735 nsTArray
<RefPtr
<mozilla::LiveResizeListener
>> mLiveResizeListeners
;
739 static void debug_DumpInvalidate(FILE* aFileOut
, nsIWidget
* aWidget
,
740 const LayoutDeviceIntRect
* aRect
,
741 const char* aWidgetName
, int32_t aWindowID
);
743 static void debug_DumpEvent(FILE* aFileOut
, nsIWidget
* aWidget
,
744 mozilla::WidgetGUIEvent
* aGuiEvent
,
745 const char* aWidgetName
, int32_t aWindowID
);
747 static void debug_DumpPaintEvent(FILE* aFileOut
, nsIWidget
* aWidget
,
748 const nsIntRegion
& aPaintEvent
,
749 const char* aWidgetName
, int32_t aWindowID
);
751 static bool debug_GetCachedBoolPref(const char* aPrefName
);
755 already_AddRefed
<mozilla::layers::WebRenderLayerManager
>
756 CreateCompositorSession(int aWidth
, int aHeight
,
757 mozilla::layers::CompositorOptions
* aOptionsOut
);
760 #endif // nsBaseWidget_h__