/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//* 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/. */#ifndef nsBaseWidget_h__#define nsBaseWidget_h__#include"InputData.h"#include"mozilla/EventForwards.h"#include"mozilla/Mutex.h"#include"mozilla/RefPtr.h"#include"mozilla/UniquePtr.h"#include"mozilla/WidgetUtils.h"#include"mozilla/dom/MouseEventBinding.h"#include"mozilla/layers/APZCCallbackHelper.h"#include"mozilla/layers/CompositorOptions.h"#include"mozilla/layers/NativeLayer.h"#include"mozilla/widget/ThemeChangeKind.h"#include"nsRect.h"#include"nsIWidget.h"#include"nsWidgetsCID.h"#include"nsIFile.h"#include"nsString.h"#include"nsCOMPtr.h"#include"nsIRollupListener.h"#include"nsIObserver.h"#include"nsIWidgetListener.h"#include"nsPIDOMWindow.h"#include"nsWeakReference.h"#include<algorithm>#if defined(XP_WIN)// Scroll capture constantsconstuint32_tkScrollCaptureFillColor=0xFFa0a0a0;// grayconstmozilla::gfx::SurfaceFormatkScrollCaptureFormat=mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32;#endifclassnsIContent;classgfxContext;namespacemozilla{classCompositorVsyncDispatcher;classLiveResizeListener;classFallbackRenderer;#ifdef ACCESSIBILITYnamespacea11y{classLocalAccessible;}#endifnamespacegfx{classDrawTarget;classSourceSurface;}// namespace gfxnamespacelayers{classCompositorBridgeChild;classCompositorBridgeParent;classIAPZCTreeManager;classGeckoContentController;classAPZEventState;structAPZEventResult;classCompositorSession;classImageContainer;classWebRenderLayerManager;structScrollableLayerGuid;classRemoteCompositorSession;}// namespace layersnamespacewidget{classCompositorWidgetDelegate;classInProcessCompositorWidget;classWidgetRenderingContext;}// namespace widgetclassCompositorVsyncDispatcher;}// namespace mozillanamespacebase{classThread;}// namespace base// 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 256classnsBaseWidget;// Helper class used in shutting down gfx related code.classWidgetShutdownObserverfinal:publicnsIObserver{~WidgetShutdownObserver();public:explicitWidgetShutdownObserver(nsBaseWidget*aWidget);NS_DECL_ISUPPORTSNS_DECL_NSIOBSERVERvoidRegister();voidUnregister();nsBaseWidget*mWidget;boolmRegistered;};// Helper class used for observing locales change.classLocalesChangedObserverfinal:publicnsIObserver{~LocalesChangedObserver();public:explicitLocalesChangedObserver(nsBaseWidget*aWidget);NS_DECL_ISUPPORTSNS_DECL_NSIOBSERVERvoidRegister();voidUnregister();nsBaseWidget*mWidget;boolmRegistered;};/** * 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.) */classnsBaseWidget:publicnsIWidget,publicnsSupportsWeakReference{template<classEventType,classInputType>friendclassDispatchEventOnMainThread;friendclassmozilla::widget::InProcessCompositorWidget;friendclassmozilla::layers::RemoteCompositorSession;protected:typedefbase::ThreadThread;typedefmozilla::gfx::DrawTargetDrawTarget;typedefmozilla::gfx::SourceSurfaceSourceSurface;typedefmozilla::layers::BufferModeBufferMode;typedefmozilla::layers::CompositorBridgeChildCompositorBridgeChild;typedefmozilla::layers::CompositorBridgeParentCompositorBridgeParent;typedefmozilla::layers::IAPZCTreeManagerIAPZCTreeManager;typedefmozilla::layers::GeckoContentControllerGeckoContentController;typedefmozilla::layers::ScrollableLayerGuidScrollableLayerGuid;typedefmozilla::layers::APZEventStateAPZEventState;typedefmozilla::layers::SetAllowedTouchBehaviorCallbackSetAllowedTouchBehaviorCallback;typedefmozilla::CSSIntRectCSSIntRect;typedefmozilla::CSSRectCSSRect;typedefmozilla::ScreenRotationScreenRotation;typedefmozilla::widget::CompositorWidgetDelegateCompositorWidgetDelegate;typedefmozilla::layers::CompositorSessionCompositorSession;typedefmozilla::layers::ImageContainerImageContainer;virtual~nsBaseWidget();public:nsBaseWidget();NS_DECL_THREADSAFE_ISUPPORTS// nsIWidget interfacevoidCaptureMouse(boolaCapture)override{}voidCaptureRollupEvents(nsIRollupListener*aListener,boolaDoCapture)override{}nsIWidgetListener*GetWidgetListener()override;voidSetWidgetListener(nsIWidgetListener*alistener)override;voidDestroy()override;voidSetParent(nsIWidget*aNewParent)override{};nsIWidget*GetParent()override;nsIWidget*GetTopLevelWidget()override;nsIWidget*GetSheetWindowParent(void)override;floatGetDPI()override;voidAddChild(nsIWidget*aChild)override;voidRemoveChild(nsIWidget*aChild)override;voidSetZIndex(int32_taZIndex)override;voidPlaceBehind(nsTopLevelWidgetZPlacementaPlacement,nsIWidget*aWidget,boolaActivate)override{}voidSetSizeMode(nsSizeModeaMode)override;nsSizeModeSizeMode()override{returnmSizeMode;}voidGetWorkspaceID(nsAString&workspaceID)override;voidMoveToWorkspace(constnsAString&workspaceID)override;boolIsTiled()constoverride{returnmIsTiled;}boolIsFullyOccluded()constoverride{returnmIsFullyOccluded;}voidSetCursor(constCursor&)override;voidClearCachedCursor()final{mCursor={};mUpdateCursor=true;}voidSetTransparencyMode(nsTransparencyModeaMode)override;nsTransparencyModeGetTransparencyMode()override;voidGetWindowClipRegion(nsTArray<LayoutDeviceIntRect>*aRects)override;voidSetWindowShadowStyle(mozilla::StyleWindowShadowaStyle)override{}voidSetShowsToolbarButton(boolaShow)override{}voidSetSupportsNativeFullscreen(boolaSupportsNativeFullscreen)override{}voidSetWindowAnimationType(WindowAnimationTypeaType)override{}voidHideWindowChrome(boolaShouldHide)override{}boolPrepareForFullscreenTransition(nsISupports**aData)override{returnfalse;}voidPerformFullscreenTransition(FullscreenTransitionStageaStage,uint16_taDuration,nsISupports*aData,nsIRunnable*aCallback)override;voidCleanupFullscreenTransition()override{}already_AddRefed<nsIScreen>GetWidgetScreen()override;nsresultMakeFullScreen(boolaFullScreen,nsIScreen*aScreen=nullptr)override;voidInfallibleMakeFullScreen(boolaFullScreen,nsIScreen*aScreen=nullptr);WindowRenderer*GetWindowRenderer()override;// A remote compositor session tied to this window has been lost and IPC// messages will no longer work. The widget must clean up any lingering// resources and possibly schedule another paint.//// A reference to the session object is held until this function has// returned.voidNotifyCompositorSessionLost(mozilla::layers::CompositorSession*aSession);already_AddRefed<mozilla::CompositorVsyncDispatcher>GetCompositorVsyncDispatcher();virtualvoidCreateCompositorVsyncDispatcher();virtualvoidCreateCompositor();virtualvoidCreateCompositor(intaWidth,intaHeight);virtualvoidSetCompositorWidgetDelegate(CompositorWidgetDelegate*){}voidPrepareWindowEffects()override{}voidUpdateThemeGeometries(constnsTArray<ThemeGeometry>&aThemeGeometries)override{}voidSetModal(boolaModal)override{}uint32_tGetMaxTouchPoints()constoverride;voidSetWindowClass(constnsAString&xulWinType)override{}nsresultSetWindowClipRegion(constnsTArray<LayoutDeviceIntRect>&aRects,boolaIntersectWithExisting)override;// Return whether this widget interprets parameters to Move and Resize APIs// as "desktop 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.boolBoundsUseDesktopPixels()const{returnmWindowType<=eWindowType_popup;}// Default implementation, to be overridden by platforms where desktop coords// are virtualized and may not correspond to device pixels on the screen.mozilla::DesktopToLayoutDeviceScaleGetDesktopToDeviceScale()override{returnmozilla::DesktopToLayoutDeviceScale(1.0);}mozilla::DesktopToLayoutDeviceScaleGetDesktopToDeviceScaleByScreen()override;voidConstrainPosition(boolaAllowSlop,int32_t*aX,int32_t*aY)override{}voidMoveClient(constDesktopPoint&aOffset)override;voidResizeClient(constDesktopSize&aSize,boolaRepaint)override;voidResizeClient(constDesktopRect&aRect,boolaRepaint)override;LayoutDeviceIntRectGetBounds()override;LayoutDeviceIntRectGetClientBounds()override;LayoutDeviceIntRectGetScreenBounds()override;[[nodiscard]]nsresultGetRestoredBounds(LayoutDeviceIntRect&aRect)override;nsresultSetNonClientMargins(LayoutDeviceIntMargin&aMargins)override;LayoutDeviceIntPointGetClientOffset()override;voidEnableDragDrop(boolaEnable)override{};nsresultAsyncEnableDragDrop(boolaEnable)override;[[nodiscard]]nsresultGetAttention(int32_taCycleCount)override{returnNS_OK;}boolHasPendingInputEvent()override;voidSetIcon(constnsAString&aIconSpec)override{}voidSetDrawsInTitlebar(boolaState)override{}boolShowsResizeIndicator(LayoutDeviceIntRect*aResizerRect)override;voidFreeNativeData(void*data,uint32_taDataType)override{}[[nodiscard]]nsresultBeginResizeDrag(mozilla::WidgetGUIEvent*aEvent,int32_taHorizontal,int32_taVertical)override{returnNS_ERROR_NOT_IMPLEMENTED;}nsresultActivateNativeMenuItemAt(constnsAString&indexString)override{returnNS_ERROR_NOT_IMPLEMENTED;}nsresultForceUpdateNativeMenuAt(constnsAString&indexString)override{returnNS_ERROR_NOT_IMPLEMENTED;}nsresultNotifyIME(constIMENotification&aIMENotification)final;[[nodiscard]]nsresultAttachNativeKeyEvent(mozilla::WidgetKeyboardEvent&aEvent)override{returnNS_ERROR_NOT_IMPLEMENTED;}boolComputeShouldAccelerate();virtualboolWidgetTypeSupportsAcceleration(){returntrue;}[[nodiscard]]nsresultOnDefaultButtonLoaded(constLayoutDeviceIntRect&aButtonRect)override{returnNS_ERROR_NOT_IMPLEMENTED;}already_AddRefed<nsIWidget>CreateChild(constLayoutDeviceIntRect&aRect,nsWidgetInitData*aInitData=nullptr,boolaForceUseIWidgetParent=false)override;voidAttachViewToTopLevel(boolaUseAttachedEvents)override;nsIWidgetListener*GetAttachedWidgetListener()override;voidSetAttachedWidgetListener(nsIWidgetListener*aListener)override;nsIWidgetListener*GetPreviouslyAttachedWidgetListener()override;voidSetPreviouslyAttachedWidgetListener(nsIWidgetListener*)override;NativeIMEContextGetNativeIMEContext()override;TextEventDispatcher*GetTextEventDispatcher()final;TextEventDispatcherListener*GetNativeTextEventDispatcherListener()override;voidZoomToRect(constuint32_t&aPresShellId,constScrollableLayerGuid::ViewID&aViewId,constCSSRect&aRect,constuint32_t&aFlags)override;// Dispatch an event that must be first be routed through APZ.ContentAndAPZEventStatusDispatchInputEvent(mozilla::WidgetInputEvent*aEvent)override;voidDispatchEventToAPZOnly(mozilla::WidgetInputEvent*aEvent)override;voidSetConfirmedTargetAPZC(uint64_taInputBlockId,constnsTArray<ScrollableLayerGuid>&aTargets)constoverride;voidUpdateZoomConstraints(constuint32_t&aPresShellId,constScrollableLayerGuid::ViewID&aViewId,constmozilla::Maybe<ZoomConstraints>&aConstraints)override;boolAsyncPanZoomEnabled()constoverride;voidNotifyWindowDestroyed();voidNotifySizeMoveDone();voidNotifyWindowMoved(int32_taX,int32_taY);// Register plugin windows for remote updates from the compositorvoidRegisterPluginWindowForRemoteUpdates()override;voidUnregisterPluginWindowForRemoteUpdates()override;voidSetNativeData(uint32_taDataType,uintptr_taVal)override{}// Should be called by derived implementations to notify on system color and// theme changes.voidNotifyThemeChanged(mozilla::widget::ThemeChangeKind);voidNotifyUIStateChanged(UIStateChangeTypeaShowFocusRings);#ifdef ACCESSIBILITY// Get the accessible for the window.mozilla::a11y::LocalAccessible*GetRootAccessible();#endif// Return true if this is a simple widget (that is typically not worth// accelerating)boolIsSmallPopup()const;nsPopupLevelPopupLevel(){returnmPopupLevel;}LayoutDeviceIntSizeClientToWindowSize(constLayoutDeviceIntSize&aClientSize)override{returnaClientSize;}// return true if this is a popup widget with a native titlebarboolIsPopupWithTitleBar()const{return(mWindowType==eWindowType_popup&&mBorderStyle!=eBorderStyle_default&&mBorderStyle&eBorderStyle_title);}voidReparentNativeWidget(nsIWidget*aNewParent)override{}constSizeConstraintsGetSizeConstraints()override;voidSetSizeConstraints(constSizeConstraints&aConstraints)override;voidStartAsyncScrollbarDrag(constAsyncDragMetrics&aDragMetrics)override;boolStartAsyncAutoscroll(constScreenPoint&aAnchorLocation,constScrollableLayerGuid&aGuid)override;voidStopAsyncAutoscroll(constScrollableLayerGuid&aGuid)override;mozilla::layers::LayersIdGetRootLayerTreeId()override;/** * Use this when GetLayerManager() returns a BasicLayerManager * (nsBaseWidget::GetLayerManager() does). This sets up the widget's * layer manager to temporarily render into aTarget. * * |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. */classAutoLayerManagerSetup{public:AutoLayerManagerSetup(nsBaseWidget*aWidget,gfxContext*aTarget,BufferModeaDoubleBuffering);~AutoLayerManagerSetup();private:nsBaseWidget*mWidget;mozilla::FallbackRenderer*mRenderer=nullptr;};friendclassAutoLayerManagerSetup;virtualboolShouldUseOffMainThreadCompositing();staticnsIRollupListener*GetActiveRollupListener();voidShutdown();voidQuitIME();#if defined(XP_WIN)uint64_tCreateScrollCaptureContainer()override;#endif// These functions should be called at the start and end of a "live" widget// resize (i.e. when the window contents are repainting during the resize,// such as when the user drags a window border). It will suppress the// displayport during the live resize to avoid unneccessary overpainting.voidNotifyLiveResizeStarted();voidNotifyLiveResizeStopped();#if defined(MOZ_WIDGET_ANDROID)voidRecvToolbarAnimatorMessageFromCompositor(int32_t)override{};voidUpdateRootFrameMetrics(constScreenPoint&aScrollOffset,constCSSToScreenScale&aZoom)override{};voidRecvScreenPixels(mozilla::ipc::Shmem&&aMem,constScreenIntSize&aSize,boolaNeedsYFlip)override{};#endifvirtualvoidLocalesChanged(){}protected:// These are methods for CompositorWidgetWrapper, and should only be// accessed from that class. Derived widgets can choose which methods to// implement, or none if supporting out-of-process compositing.virtualboolPreRender(mozilla::widget::WidgetRenderingContext*aContext){returntrue;}virtualvoidPostRender(mozilla::widget::WidgetRenderingContext*aContext){}virtualRefPtr<mozilla::layers::NativeLayerRoot>GetNativeLayerRoot(){returnnullptr;}virtualalready_AddRefed<DrawTarget>StartRemoteDrawing();virtualalready_AddRefed<DrawTarget>StartRemoteDrawingInRegion(constLayoutDeviceIntRegion&aInvalidRegion,BufferMode*aBufferMode){returnStartRemoteDrawing();}virtualvoidEndRemoteDrawing(){}virtualvoidEndRemoteDrawingInRegion(DrawTarget*aDrawTarget,constLayoutDeviceIntRegion&aInvalidRegion){EndRemoteDrawing();}virtualvoidCleanupRemoteDrawing(){}virtualvoidCleanupWindowEffects(){}virtualboolInitCompositor(mozilla::layers::Compositor*aCompositor){returntrue;}virtualuint32_tGetGLFrameBufferFormat();virtualboolCompositorInitiallyPaused(){returnfalse;}protected:voidResolveIconName(constnsAString&aIconName,constnsAString&aIconSuffix,nsIFile**aResult);virtualvoidOnDestroy();voidBaseCreate(nsIWidget*aParent,nsWidgetInitData*aInitData);virtualvoidConfigureAPZCTreeManager();virtualvoidConfigureAPZControllerThread();virtualalready_AddRefed<GeckoContentController>CreateRootContentController();// Dispatch an event that has already been routed through APZ.nsEventStatusProcessUntransformedAPZEvent(mozilla::WidgetInputEvent*aEvent,constmozilla::layers::APZEventResult&aApzResult);constLayoutDeviceIntRegionRegionFromArray(constnsTArray<LayoutDeviceIntRect>&aRects);voidArrayFromRegion(constLayoutDeviceIntRegion&aRegion,nsTArray<LayoutDeviceIntRect>&aRects);nsresultSynthesizeNativeKeyEvent(int32_taNativeKeyboardLayout,int32_taNativeKeyCode,uint32_taModifierFlags,constnsAString&aCharacters,constnsAString&aUnmodifiedCharacters,nsIObserver*aObserver)override{mozilla::widget::AutoObserverNotifiernotifier(aObserver,"keyevent");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeMouseEvent(LayoutDeviceIntPointaPoint,NativeMouseMessageaNativeMessage,mozilla::MouseButtonaButton,nsIWidget::ModifiersaModifierFlags,nsIObserver*aObserver)override{mozilla::widget::AutoObserverNotifiernotifier(aObserver,"mouseevent");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeMouseMove(LayoutDeviceIntPointaPoint,nsIObserver*aObserver)override{mozilla::widget::AutoObserverNotifiernotifier(aObserver,"mouseevent");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeMouseScrollEvent(LayoutDeviceIntPointaPoint,uint32_taNativeMessage,doubleaDeltaX,doubleaDeltaY,doubleaDeltaZ,uint32_taModifierFlags,uint32_taAdditionalFlags,nsIObserver*aObserver)override{mozilla::widget::AutoObserverNotifiernotifier(aObserver,"mousescrollevent");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeTouchPoint(uint32_taPointerId,TouchPointerStateaPointerState,LayoutDeviceIntPointaPoint,doubleaPointerPressure,uint32_taPointerOrientation,nsIObserver*aObserver)override{mozilla::widget::AutoObserverNotifiernotifier(aObserver,"touchpoint");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeTouchPadPinch(TouchpadGesturePhaseaEventPhase,floataScale,LayoutDeviceIntPointaPoint,int32_taModifierFlags)override{MOZ_RELEASE_ASSERT(false,"This method is not implemented on the current platform");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativePenInput(uint32_taPointerId,TouchPointerStateaPointerState,LayoutDeviceIntPointaPoint,doubleaPressure,uint32_taRotation,int32_taTiltX,int32_taTiltY,nsIObserver*aObserver)override{MOZ_RELEASE_ASSERT(false,"This method is not implemented on the current platform");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeTouchpadDoubleTap(LayoutDeviceIntPointaPoint,uint32_taModifierFlags)override{MOZ_RELEASE_ASSERT(false,"This method is not implemented on the current platform");returnNS_ERROR_UNEXPECTED;}nsresultSynthesizeNativeTouchpadPan(TouchpadGesturePhaseaEventPhase,LayoutDeviceIntPointaPoint,doubleaDeltaX,doubleaDeltaY,int32_taModifierFlags)override{MOZ_RELEASE_ASSERT(false,"This method is not implemented on the current platform");returnNS_ERROR_UNEXPECTED;}/** * GetPseudoIMEContext() returns pseudo IME context when TextEventDispatcher * has non-native input transaction. Otherwise, returns nullptr. */void*GetPseudoIMEContext();protected:// Utility to check if an array of clip rects is equal to our// internally stored clip rect array mClipRects.boolIsWindowClipRegionEqual(constnsTArray<LayoutDeviceIntRect>&aRects);// Stores the clip rectangles in aRects into mClipRects.voidStoreWindowClipRegion(constnsTArray<LayoutDeviceIntRect>&aRects);virtualalready_AddRefed<nsIWidget>AllocateChildPopupWidget(){returnnsIWidget::CreateChildWindow();}WindowRenderer*CreateBasicLayerManager();nsPopupTypePopupType()const{returnmPopupType;}boolHasRemoteContent()const{returnmHasRemoteContent;}voidNotifyRollupGeometryChange(){// XULPopupManager isn't interested in this notification, so only// send it if gRollupListener is set.if(gRollupListener){gRollupListener->NotifyGeometryChange();}}/** * Apply the current size constraints to the given size. * * @param aWidth width to constrain * @param aHeight height to constrain */voidConstrainSize(int32_t*aWidth,int32_t*aHeight)override{SizeConstraintsc=GetSizeConstraints();*aWidth=std::max(c.mMinSize.width,std::min(c.mMaxSize.width,*aWidth));*aHeight=std::max(c.mMinSize.height,std::min(c.mMaxSize.height,*aHeight));}CompositorBridgeChild*GetRemoteRenderer()override;voidClearCachedWebrenderResources()override;/** * Notify the widget that this window is being used with OMTC. */virtualvoidWindowUsesOMTC(){}virtualvoidRegisterTouchWindow(){}mozilla::dom::Document*GetDocument()const;voidEnsureTextEventDispatcher();// Notify the compositor that a device reset has occurred.voidOnRenderingDeviceReset();boolUseAPZ();boolAllowWebRenderForThisWindow();/** * For widgets that support synthesizing native touch events, this function * can be used to manage the current state of synthetic pointers. Each widget * must maintain its own MultiTouchInput instance and pass it in as the state, * along with the desired parameters for the changes. This function returns * a new MultiTouchInput object that is ready to be dispatched. */mozilla::MultiTouchInputUpdateSynthesizedTouchState(mozilla::MultiTouchInput*aState,uint32_taTime,mozilla::TimeStampaTimeStamp,uint32_taPointerId,TouchPointerStateaPointerState,LayoutDeviceIntPointaPoint,doubleaPointerPressure,uint32_taPointerOrientation);/** * Dispatch the given MultiTouchInput through APZ to Gecko (if APZ is enabled) * or directly to gecko (if APZ is not enabled). This function must only * be called from the main thread, and if APZ is enabled, that must also be * the APZ controller thread. */voidDispatchTouchInput(mozilla::MultiTouchInput&aInput,uint16_taInputSource=mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH);/** * Dispatch the given PanGestureInput through APZ to Gecko (if APZ is enabled) * or directly to gecko (if APZ is not enabled). This function must only * be called from the main thread, and if APZ is enabled, that must also be * the APZ controller thread. */voidDispatchPanGestureInput(mozilla::PanGestureInput&aInput);voidDispatchPinchGestureInput(mozilla::PinchGestureInput&aInput);#if defined(XP_WIN)voidUpdateScrollCapture()override;/** * To be overridden by derived classes to return a snapshot that can be used * during scrolling. Returning null means we won't update the container. * @return an already AddRefed SourceSurface containing the snapshot */virtualalready_AddRefed<SourceSurface>CreateScrollSnapshot(){returnnullptr;};/** * Used by derived classes to create a fallback scroll image. * @param aSnapshotDrawTarget DrawTarget to fill with fallback image. */voidDefaultFillScrollCapture(DrawTarget*aSnapshotDrawTarget);RefPtr<ImageContainer>mScrollCaptureContainer;#endifprotected:// Returns whether compositing should use an external surface size.virtualboolUseExternalCompositingSurface()const{returnfalse;}/** * 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). */virtualvoidDestroyCompositor();voidDestroyLayerManager();voidReleaseContentController();voidRevokeTransactionIdAllocator();voidFreeShutdownObserver();voidFreeLocalesChangedObserver();nsIWidgetListener*mWidgetListener;nsIWidgetListener*mAttachedWidgetListener;nsIWidgetListener*mPreviouslyAttachedWidgetListener;RefPtr<WindowRenderer>mWindowRenderer;RefPtr<CompositorSession>mCompositorSession;RefPtr<CompositorBridgeChild>mCompositorBridgeChild;mozilla::UniquePtr<mozilla::Mutex>mCompositorVsyncDispatcherLock;RefPtr<mozilla::CompositorVsyncDispatcher>mCompositorVsyncDispatcher;RefPtr<IAPZCTreeManager>mAPZC;RefPtr<GeckoContentController>mRootContentController;RefPtr<APZEventState>mAPZEventState;SetAllowedTouchBehaviorCallbackmSetAllowedTouchBehaviorCallback;RefPtr<WidgetShutdownObserver>mShutdownObserver;RefPtr<LocalesChangedObserver>mLocalesChangedObserver;RefPtr<TextEventDispatcher>mTextEventDispatcher;CursormCursor;nsBorderStylemBorderStyle;LayoutDeviceIntRectmBounds;LayoutDeviceIntRect*mOriginalBounds;// When this pointer is null, the widget is not clippedmozilla::UniquePtr<LayoutDeviceIntRect[]>mClipRects;uint32_tmClipRectCount;nsSizeModemSizeMode;boolmIsTiled;nsPopupLevelmPopupLevel;nsPopupTypemPopupType;SizeConstraintsmSizeConstraints;boolmHasRemoteContent;boolmFissionWindow;boolmUpdateCursor;boolmUseAttachedEvents;boolmIMEHasFocus;boolmIMEHasQuit;boolmIsFullyOccluded;staticnsIRollupListener*gRollupListener;structInitialZoomConstraints{InitialZoomConstraints(constuint32_t&aPresShellID,constScrollableLayerGuid::ViewID&aViewID,constZoomConstraints&aConstraints):mPresShellID(aPresShellID),mViewID(aViewID),mConstraints(aConstraints){}uint32_tmPresShellID;ScrollableLayerGuid::ViewIDmViewID;ZoomConstraintsmConstraints;};mozilla::Maybe<InitialZoomConstraints>mInitialZoomConstraints;// This points to the resize listeners who have been notified that a live// resize is in progress. This should always be empty when a live-resize is// not in progress.nsTArray<RefPtr<mozilla::LiveResizeListener>>mLiveResizeListeners;#ifdef DEBUGprotected:staticnsAutoStringdebug_GuiEventToString(mozilla::WidgetGUIEvent*aGuiEvent);staticbooldebug_WantPaintFlashing();staticvoiddebug_DumpInvalidate(FILE*aFileOut,nsIWidget*aWidget,constLayoutDeviceIntRect*aRect,constchar*aWidgetName,int32_taWindowID);staticvoiddebug_DumpEvent(FILE*aFileOut,nsIWidget*aWidget,mozilla::WidgetGUIEvent*aGuiEvent,constchar*aWidgetName,int32_taWindowID);staticvoiddebug_DumpPaintEvent(FILE*aFileOut,nsIWidget*aWidget,constnsIntRegion&aPaintEvent,constchar*aWidgetName,int32_taWindowID);staticbooldebug_GetCachedBoolPref(constchar*aPrefName);#endifprivate:already_AddRefed<mozilla::layers::WebRenderLayerManager>CreateCompositorSession(intaWidth,intaHeight,mozilla::layers::CompositorOptions*aOptionsOut);};#endif // nsBaseWidget_h__