LCOV - code coverage report
Current view: top level - widget - nsBaseWidget.h (source / functions) Hit Total Coverage
Test: output.info Lines: 28 117 23.9 %
Date: 2017-07-14 16:53:18 Functions: 15 66 22.7 %
Legend: Lines: hit not hit

          Line data    Source code
       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__
       7             : 
       8             : #include "InputData.h"
       9             : #include "mozilla/EventForwards.h"
      10             : #include "mozilla/RefPtr.h"
      11             : #include "mozilla/UniquePtr.h"
      12             : #include "mozilla/WidgetUtils.h"
      13             : #include "mozilla/layers/APZCCallbackHelper.h"
      14             : #include "nsRect.h"
      15             : #include "nsIWidget.h"
      16             : #include "nsWidgetsCID.h"
      17             : #include "nsIFile.h"
      18             : #include "nsString.h"
      19             : #include "nsCOMPtr.h"
      20             : #include "nsIRollupListener.h"
      21             : #include "nsIObserver.h"
      22             : #include "nsIWidgetListener.h"
      23             : #include "nsPIDOMWindow.h"
      24             : #include "nsWeakReference.h"
      25             : #include <algorithm>
      26             : 
      27             : #if defined(XP_WIN)
      28             : // Scroll capture constants
      29             : const uint32_t kScrollCaptureFillColor = 0xFFa0a0a0; // gray
      30             : const mozilla::gfx::SurfaceFormat kScrollCaptureFormat =
      31             :   mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32;
      32             : #endif
      33             : 
      34             : class nsIContent;
      35             : class gfxContext;
      36             : 
      37             : namespace mozilla {
      38             : class CompositorVsyncDispatcher;
      39             : class LiveResizeListener;
      40             : 
      41             : #ifdef ACCESSIBILITY
      42             : namespace a11y {
      43             : class Accessible;
      44             : }
      45             : #endif
      46             : 
      47             : namespace gfx {
      48             : class DrawTarget;
      49             : class SourceSurface;
      50             : } // namespace gfx
      51             : 
      52             : namespace layers {
      53             : class BasicLayerManager;
      54             : class CompositorBridgeChild;
      55             : class CompositorBridgeParent;
      56             : class IAPZCTreeManager;
      57             : class GeckoContentController;
      58             : class APZEventState;
      59             : class CompositorSession;
      60             : class ImageContainer;
      61             : struct ScrollableLayerGuid;
      62             : class RemoteCompositorSession;
      63             : } // namespace layers
      64             : 
      65             : namespace widget {
      66             : class CompositorWidgetDelegate;
      67             : class InProcessCompositorWidget;
      68             : class WidgetRenderingContext;
      69             : } // namespace widget
      70             : 
      71             : class CompositorVsyncDispatcher;
      72             : } // namespace mozilla
      73             : 
      74             : namespace base {
      75             : class Thread;
      76             : } // namespace base
      77             : 
      78             : // Windows specific constant indicating the maximum number of touch points the
      79             : // inject api will allow. This also sets the maximum numerical value for touch
      80             : // ids we can use when injecting touch points on Windows.
      81             : #define TOUCH_INJECT_MAX_POINTS 256
      82             : 
      83             : class nsBaseWidget;
      84             : 
      85             : // Helper class used in shutting down gfx related code.
      86             : class WidgetShutdownObserver final : public nsIObserver
      87             : {
      88             :   ~WidgetShutdownObserver();
      89             : 
      90             : public:
      91             :   explicit WidgetShutdownObserver(nsBaseWidget* aWidget);
      92             : 
      93             :   NS_DECL_ISUPPORTS
      94             :   NS_DECL_NSIOBSERVER
      95             : 
      96             :   void Register();
      97             :   void Unregister();
      98             : 
      99             :   nsBaseWidget *mWidget;
     100             :   bool mRegistered;
     101             : };
     102             : 
     103             : /**
     104             :  * Common widget implementation used as base class for native
     105             :  * or crossplatform implementations of Widgets.
     106             :  * All cross-platform behavior that all widgets need to implement
     107             :  * should be placed in this class.
     108             :  * (Note: widget implementations are not required to use this
     109             :  * class, but it gives them a head start.)
     110             :  */
     111             : 
     112             : class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
     113             : {
     114             :   friend class DispatchWheelEventOnMainThread;
     115             :   friend class mozilla::widget::InProcessCompositorWidget;
     116             :   friend class mozilla::layers::RemoteCompositorSession;
     117             : 
     118             : protected:
     119             :   typedef base::Thread Thread;
     120             :   typedef mozilla::gfx::DrawTarget DrawTarget;
     121             :   typedef mozilla::gfx::SourceSurface SourceSurface;
     122             :   typedef mozilla::layers::BasicLayerManager BasicLayerManager;
     123             :   typedef mozilla::layers::BufferMode BufferMode;
     124             :   typedef mozilla::layers::CompositorBridgeChild CompositorBridgeChild;
     125             :   typedef mozilla::layers::CompositorBridgeParent CompositorBridgeParent;
     126             :   typedef mozilla::layers::IAPZCTreeManager IAPZCTreeManager;
     127             :   typedef mozilla::layers::GeckoContentController GeckoContentController;
     128             :   typedef mozilla::layers::ScrollableLayerGuid ScrollableLayerGuid;
     129             :   typedef mozilla::layers::APZEventState APZEventState;
     130             :   typedef mozilla::layers::SetAllowedTouchBehaviorCallback SetAllowedTouchBehaviorCallback;
     131             :   typedef mozilla::CSSIntRect CSSIntRect;
     132             :   typedef mozilla::CSSRect CSSRect;
     133             :   typedef mozilla::ScreenRotation ScreenRotation;
     134             :   typedef mozilla::widget::CompositorWidgetDelegate CompositorWidgetDelegate;
     135             :   typedef mozilla::layers::CompositorSession CompositorSession;
     136             :   typedef mozilla::layers::ImageContainer ImageContainer;
     137             : 
     138             :   virtual ~nsBaseWidget();
     139             : 
     140             : public:
     141             :   nsBaseWidget();
     142             : 
     143             :   NS_DECL_ISUPPORTS
     144             : 
     145             :   // nsIWidget interface
     146           0 :   virtual void            CaptureMouse(bool aCapture) override {}
     147           0 :   virtual void            CaptureRollupEvents(nsIRollupListener* aListener,
     148           0 :                                               bool aDoCapture) override {}
     149             :   virtual nsIWidgetListener*  GetWidgetListener() override;
     150             :   virtual void            SetWidgetListener(nsIWidgetListener* alistener) override;
     151             :   virtual void            Destroy() override;
     152           0 :   virtual void            SetParent(nsIWidget* aNewParent) override {};
     153             :   virtual nsIWidget*      GetParent(void) override;
     154             :   virtual nsIWidget*      GetTopLevelWidget() override;
     155             :   virtual nsIWidget*      GetSheetWindowParent(void) override;
     156             :   virtual float           GetDPI() override;
     157             :   virtual void            AddChild(nsIWidget* aChild) override;
     158             :   virtual void            RemoveChild(nsIWidget* aChild) override;
     159             : 
     160             :   void                    SetZIndex(int32_t aZIndex) override;
     161           0 :   virtual void            PlaceBehind(nsTopLevelWidgetZPlacement aPlacement,
     162             :                                       nsIWidget *aWidget, bool aActivate)
     163           0 :                                       override {}
     164             : 
     165             :   virtual void            SetSizeMode(nsSizeMode aMode) override;
     166          10 :   virtual nsSizeMode      SizeMode() override
     167             :   {
     168          10 :     return mSizeMode;
     169             :   }
     170             : 
     171           3 :   virtual bool            IsFullyOccluded() const override
     172             :   {
     173           3 :     return mIsFullyOccluded;
     174             :   }
     175             : 
     176             :   virtual nsCursor        GetCursor() override;
     177             :   virtual void            SetCursor(nsCursor aCursor) override;
     178             :   virtual nsresult        SetCursor(imgIContainer* aCursor,
     179             :                                     uint32_t aHotspotX, uint32_t aHotspotY) override;
     180           0 :   virtual void            ClearCachedCursor() override { mUpdateCursor = true; }
     181             :   virtual void            SetTransparencyMode(nsTransparencyMode aMode) override;
     182             :   virtual nsTransparencyMode GetTransparencyMode() override;
     183             :   virtual void            GetWindowClipRegion(nsTArray<LayoutDeviceIntRect>* aRects) override;
     184          20 :   virtual void            SetWindowShadowStyle(int32_t aStyle) override {}
     185           2 :   virtual void            SetShowsToolbarButton(bool aShow) override {}
     186           2 :   virtual void            SetShowsFullScreenButton(bool aShow) override {}
     187           1 :   virtual void            SetWindowAnimationType(WindowAnimationType aType) override {}
     188           0 :   virtual void            HideWindowChrome(bool aShouldHide) override {}
     189           0 :   virtual bool PrepareForFullscreenTransition(nsISupports** aData) override { return false; }
     190             :   virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
     191             :                                            uint16_t aDuration,
     192             :                                            nsISupports* aData,
     193             :                                            nsIRunnable* aCallback) override;
     194             :   virtual already_AddRefed<nsIScreen> GetWidgetScreen() override;
     195             :   virtual nsresult        MakeFullScreen(bool aFullScreen,
     196             :                                          nsIScreen* aScreen = nullptr) override;
     197             :   void                    InfallibleMakeFullScreen(bool aFullScreen,
     198             :                                                    nsIScreen* aScreen = nullptr);
     199             : 
     200             :   virtual LayerManager*   GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
     201             :                                           LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
     202             :                                           LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
     203             : 
     204             :   // A remote compositor session tied to this window has been lost and IPC
     205             :   // messages will no longer work. The widget must clean up any lingering
     206             :   // resources and possibly schedule another paint.
     207             :   //
     208             :   // A reference to the session object is held until this function has
     209             :   // returned.
     210             :   void NotifyCompositorSessionLost(mozilla::layers::CompositorSession* aSession);
     211             : 
     212             :   mozilla::CompositorVsyncDispatcher* GetCompositorVsyncDispatcher();
     213             :   void            CreateCompositorVsyncDispatcher();
     214             :   virtual void            CreateCompositor();
     215             :   virtual void            CreateCompositor(int aWidth, int aHeight);
     216          29 :   virtual void            PrepareWindowEffects() override {}
     217          26 :   virtual void            UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override {}
     218           0 :   virtual void            SetModal(bool aModal) override {}
     219             :   virtual uint32_t        GetMaxTouchPoints() const override;
     220           0 :   virtual void            SetWindowClass(const nsAString& xulWinType)
     221           0 :                             override {}
     222             :   virtual nsresult        SetWindowClipRegion(const nsTArray<LayoutDeviceIntRect>& aRects, bool aIntersectWithExisting) override;
     223             :   // Return whether this widget interprets parameters to Move and Resize APIs
     224             :   // as "desktop pixels" rather than "device pixels", and therefore
     225             :   // applies its GetDefaultScale() value to them before using them as mBounds
     226             :   // etc (which are always stored in device pixels).
     227             :   // Note that APIs that -get- the widget's position/size/bounds, rather than
     228             :   // -setting- them (i.e. moving or resizing the widget) will always return
     229             :   // values in the widget's device pixels.
     230           1 :   bool                    BoundsUseDesktopPixels() const {
     231           1 :     return mWindowType <= eWindowType_popup;
     232             :   }
     233             :   // Default implementation, to be overridden by platforms where desktop coords
     234             :   // are virtualized and may not correspond to device pixels on the screen.
     235           0 :   mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override {
     236           0 :     return mozilla::DesktopToLayoutDeviceScale(1.0);
     237             :   }
     238           0 :   virtual void            ConstrainPosition(bool aAllowSlop,
     239             :                                             int32_t *aX,
     240           0 :                                             int32_t *aY) override {}
     241             :   virtual void            MoveClient(double aX, double aY) override;
     242             :   virtual void            ResizeClient(double aWidth, double aHeight, bool aRepaint) override;
     243             :   virtual void            ResizeClient(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override;
     244             :   virtual LayoutDeviceIntRect GetBounds() override;
     245             :   virtual LayoutDeviceIntRect GetClientBounds() override;
     246             :   virtual LayoutDeviceIntRect GetScreenBounds() override;
     247             :   virtual MOZ_MUST_USE nsresult GetRestoredBounds(LayoutDeviceIntRect& aRect) override;
     248             :   virtual nsresult        SetNonClientMargins(LayoutDeviceIntMargin& aMargins) override;
     249             :   virtual LayoutDeviceIntPoint GetClientOffset() override;
     250           6 :   virtual void            EnableDragDrop(bool aEnable) override {};
     251             :   virtual MOZ_MUST_USE nsresult
     252           0 :                           GetAttention(int32_t aCycleCount) override
     253           0 :                           { return NS_OK; }
     254             :   virtual bool            HasPendingInputEvent() override;
     255           0 :   virtual void            SetIcon(const nsAString &aIconSpec) override {}
     256           0 :   virtual void            SetWindowTitlebarColor(nscolor aColor, bool aActive)
     257           0 :                             override {}
     258           0 :   virtual void            SetDrawsInTitlebar(bool aState) override {}
     259             :   virtual bool            ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
     260           0 :   virtual void            FreeNativeData(void * data, uint32_t aDataType) override {}
     261             :   virtual MOZ_MUST_USE nsresult
     262           0 :                           BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
     263             :                                           int32_t aHorizontal,
     264             :                                           int32_t aVertical) override
     265           0 :                           { return NS_ERROR_NOT_IMPLEMENTED; }
     266             :   virtual MOZ_MUST_USE nsresult
     267           0 :                           BeginMoveDrag(mozilla::WidgetMouseEvent* aEvent) override
     268           0 :                           { return NS_ERROR_NOT_IMPLEMENTED; }
     269           0 :   virtual nsresult        ActivateNativeMenuItemAt(const nsAString& indexString) override { return NS_ERROR_NOT_IMPLEMENTED; }
     270           0 :   virtual nsresult        ForceUpdateNativeMenuAt(const nsAString& indexString) override { return NS_ERROR_NOT_IMPLEMENTED; }
     271             :   virtual nsresult        NotifyIME(const IMENotification& aIMENotification)
     272             :                             override final;
     273             :   virtual MOZ_MUST_USE nsresult
     274           0 :                           StartPluginIME(const mozilla::WidgetKeyboardEvent& aKeyboardEvent,
     275             :                                          int32_t aPanelX, int32_t aPanelY,
     276             :                                          nsString& aCommitted) override
     277           0 :                           { return NS_ERROR_NOT_IMPLEMENTED; }
     278           0 :   virtual void            SetPluginFocused(bool& aFocused) override {}
     279           0 :   virtual void            SetCandidateWindowForPlugin(
     280             :                             const mozilla::widget::CandidateWindowPosition&
     281             :                               aPosition) override
     282           0 :                           { }
     283           0 :   virtual void            DefaultProcOfPluginEvent(
     284             :                             const mozilla::WidgetPluginEvent& aEvent) override
     285           0 :                           { }
     286           0 :   virtual MOZ_MUST_USE nsresult AttachNativeKeyEvent(mozilla::WidgetKeyboardEvent& aEvent) override { return NS_ERROR_NOT_IMPLEMENTED; }
     287             :   bool                    ComputeShouldAccelerate();
     288           0 :   virtual bool            WidgetTypeSupportsAcceleration() { return true; }
     289           0 :   virtual MOZ_MUST_USE nsresult OnDefaultButtonLoaded(const LayoutDeviceIntRect& aButtonRect) override { return NS_ERROR_NOT_IMPLEMENTED; }
     290             :   virtual already_AddRefed<nsIWidget>
     291             :   CreateChild(const LayoutDeviceIntRect& aRect,
     292             :               nsWidgetInitData* aInitData = nullptr,
     293             :               bool aForceUseIWidgetParent = false) override;
     294             :   virtual void            AttachViewToTopLevel(bool aUseAttachedEvents) override;
     295             :   virtual nsIWidgetListener* GetAttachedWidgetListener() override;
     296             :   virtual void               SetAttachedWidgetListener(nsIWidgetListener* aListener) override;
     297             :   virtual nsIWidgetListener* GetPreviouslyAttachedWidgetListener() override;
     298             :   virtual void               SetPreviouslyAttachedWidgetListener(nsIWidgetListener* aListener) override;
     299             :   virtual TextEventDispatcher* GetTextEventDispatcher() override final;
     300             :   virtual TextEventDispatcherListener*
     301             :     GetNativeTextEventDispatcherListener() override;
     302             :   virtual void ZoomToRect(const uint32_t& aPresShellId,
     303             :                           const FrameMetrics::ViewID& aViewId,
     304             :                           const CSSRect& aRect,
     305             :                           const uint32_t& aFlags) override;
     306             :   // Dispatch an event that must be first be routed through APZ.
     307             :   nsEventStatus DispatchInputEvent(mozilla::WidgetInputEvent* aEvent) override;
     308             :   void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) override;
     309             : 
     310             :   void SetConfirmedTargetAPZC(uint64_t aInputBlockId,
     311             :                               const nsTArray<ScrollableLayerGuid>& aTargets) const override;
     312             : 
     313             :   void UpdateZoomConstraints(const uint32_t& aPresShellId,
     314             :                              const FrameMetrics::ViewID& aViewId,
     315             :                              const mozilla::Maybe<ZoomConstraints>& aConstraints) override;
     316             : 
     317             :   bool AsyncPanZoomEnabled() const override;
     318             : 
     319             :   void NotifyWindowDestroyed();
     320             :   void NotifySizeMoveDone();
     321             :   void NotifyWindowMoved(int32_t aX, int32_t aY);
     322             : 
     323             :   // Register plugin windows for remote updates from the compositor
     324             :   virtual void RegisterPluginWindowForRemoteUpdates() override;
     325             :   virtual void UnregisterPluginWindowForRemoteUpdates() override;
     326             : 
     327           0 :   virtual void SetNativeData(uint32_t aDataType, uintptr_t aVal) override {};
     328             : 
     329             :   // Should be called by derived implementations to notify on system color and
     330             :   // theme changes.
     331             :   void NotifySysColorChanged();
     332             :   void NotifyThemeChanged();
     333             :   void NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
     334             :                             UIStateChangeType aShowFocusRings);
     335             : 
     336             : #ifdef ACCESSIBILITY
     337             :   // Get the accessible for the window.
     338             :   mozilla::a11y::Accessible* GetRootAccessible();
     339             : #endif
     340             : 
     341             :   // Return true if this is a simple widget (that is typically not worth
     342             :   // accelerating)
     343             :   bool IsSmallPopup() const;
     344             : 
     345             :   nsPopupLevel PopupLevel() { return mPopupLevel; }
     346             : 
     347             :   virtual LayoutDeviceIntSize
     348          20 :   ClientToWindowSize(const LayoutDeviceIntSize& aClientSize) override
     349             :   {
     350          20 :     return aClientSize;
     351             :   }
     352             : 
     353             :   // return true if this is a popup widget with a native titlebar
     354             :   bool IsPopupWithTitleBar() const
     355             :   {
     356             :     return (mWindowType == eWindowType_popup &&
     357             :             mBorderStyle != eBorderStyle_default &&
     358             :             mBorderStyle & eBorderStyle_title);
     359             :   }
     360             : 
     361           0 :   virtual void ReparentNativeWidget(nsIWidget* aNewParent) override {}
     362             : 
     363             :   virtual const SizeConstraints GetSizeConstraints() override;
     364             :   virtual void SetSizeConstraints(const SizeConstraints& aConstraints) override;
     365             : 
     366             :   virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override;
     367             : 
     368             :   /**
     369             :    * Use this when GetLayerManager() returns a BasicLayerManager
     370             :    * (nsBaseWidget::GetLayerManager() does). This sets up the widget's
     371             :    * layer manager to temporarily render into aTarget.
     372             :    *
     373             :    * |aNaturalWidgetBounds| is the un-rotated bounds of |aWidget|.
     374             :    * |aRotation| is the "virtual rotation" to apply when rendering to
     375             :    * the target.  When |aRotation| is ROTATION_0,
     376             :    * |aNaturalWidgetBounds| is not used.
     377             :    */
     378             :   class AutoLayerManagerSetup {
     379             :   public:
     380             :     AutoLayerManagerSetup(nsBaseWidget* aWidget, gfxContext* aTarget,
     381             :                           BufferMode aDoubleBuffering,
     382             :                           ScreenRotation aRotation = mozilla::ROTATION_0);
     383             :     ~AutoLayerManagerSetup();
     384             :   private:
     385             :     nsBaseWidget* mWidget;
     386             :     RefPtr<BasicLayerManager> mLayerManager;
     387             :   };
     388             :   friend class AutoLayerManagerSetup;
     389             : 
     390             :   virtual bool            ShouldUseOffMainThreadCompositing();
     391             : 
     392             :   static nsIRollupListener* GetActiveRollupListener();
     393             : 
     394             :   void Shutdown();
     395             : 
     396             : #if defined(XP_WIN)
     397             :   uint64_t CreateScrollCaptureContainer() override;
     398             : #endif
     399             : 
     400             :   // These functions should be called at the start and end of a "live" widget
     401             :   // resize (i.e. when the window contents are repainting during the resize,
     402             :   // such as when the user drags a window border). It will suppress the
     403             :   // displayport during the live resize to avoid unneccessary overpainting.
     404             :   void NotifyLiveResizeStarted();
     405             :   void NotifyLiveResizeStopped();
     406             : 
     407             : #if defined(MOZ_WIDGET_ANDROID)
     408             :   void RecvToolbarAnimatorMessageFromCompositor(int32_t) override {};
     409             :   void UpdateRootFrameMetrics(const ScreenPoint& aScrollOffset, const CSSToScreenScale& aZoom) override {};
     410             :   void RecvScreenPixels(mozilla::ipc::Shmem&& aMem, const ScreenIntSize& aSize) override {};
     411             : #endif
     412             : 
     413             : protected:
     414             :   // These are methods for CompositorWidgetWrapper, and should only be
     415             :   // accessed from that class. Derived widgets can choose which methods to
     416             :   // implement, or none if supporting out-of-process compositing.
     417           0 :   virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) {
     418           0 :     return true;
     419             :   }
     420           0 :   virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext)
     421           0 :   {}
     422           0 :   virtual void DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext* aContext,
     423             :                                   LayoutDeviceIntRect aRect)
     424           0 :   {}
     425           0 :   virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext,
     426             :                                  LayoutDeviceIntRect aRect)
     427           0 :   {}
     428             :   virtual already_AddRefed<DrawTarget> StartRemoteDrawing();
     429             :   virtual already_AddRefed<DrawTarget>
     430           0 :   StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion, BufferMode* aBufferMode)
     431             :   {
     432           0 :     return StartRemoteDrawing();
     433             :   }
     434           0 :   virtual void EndRemoteDrawing()
     435           0 :   {}
     436           0 :   virtual void EndRemoteDrawingInRegion(DrawTarget* aDrawTarget,
     437             :                                         LayoutDeviceIntRegion& aInvalidRegion)
     438             :   {
     439           0 :     EndRemoteDrawing();
     440           0 :   }
     441           0 :   virtual void CleanupRemoteDrawing()
     442           0 :   {}
     443           0 :   virtual void CleanupWindowEffects()
     444           0 :   {}
     445           0 :   virtual bool InitCompositor(mozilla::layers::Compositor* aCompositor) {
     446           0 :     return true;
     447             :   }
     448             :   virtual uint32_t GetGLFrameBufferFormat();
     449             : 
     450             : protected:
     451             :   void            ResolveIconName(const nsAString &aIconName,
     452             :                                   const nsAString &aIconSuffix,
     453             :                                   nsIFile **aResult);
     454             :   virtual void    OnDestroy();
     455             :   void            BaseCreate(nsIWidget *aParent,
     456             :                              nsWidgetInitData* aInitData);
     457             : 
     458             :   virtual void ConfigureAPZCTreeManager();
     459             :   virtual void ConfigureAPZControllerThread();
     460             :   virtual already_AddRefed<GeckoContentController> CreateRootContentController();
     461             : 
     462             :   // Dispatch an event that has already been routed through APZ.
     463             :   nsEventStatus ProcessUntransformedAPZEvent(mozilla::WidgetInputEvent* aEvent,
     464             :                                              const ScrollableLayerGuid& aGuid,
     465             :                                              uint64_t aInputBlockId,
     466             :                                              nsEventStatus aApzResponse);
     467             : 
     468             :   const LayoutDeviceIntRegion RegionFromArray(const nsTArray<LayoutDeviceIntRect>& aRects);
     469             :   void ArrayFromRegion(const LayoutDeviceIntRegion& aRegion,
     470             :                        nsTArray<LayoutDeviceIntRect>& aRects);
     471             : 
     472           0 :   virtual nsresult SynthesizeNativeKeyEvent(int32_t aNativeKeyboardLayout,
     473             :                                             int32_t aNativeKeyCode,
     474             :                                             uint32_t aModifierFlags,
     475             :                                             const nsAString& aCharacters,
     476             :                                             const nsAString& aUnmodifiedCharacters,
     477             :                                             nsIObserver* aObserver) override
     478             :   {
     479           0 :     mozilla::widget::AutoObserverNotifier notifier(aObserver, "keyevent");
     480           0 :     return NS_ERROR_UNEXPECTED;
     481             :   }
     482             : 
     483           0 :   virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
     484             :                                               uint32_t aNativeMessage,
     485             :                                               uint32_t aModifierFlags,
     486             :                                               nsIObserver* aObserver) override
     487             :   {
     488           0 :     mozilla::widget::AutoObserverNotifier notifier(aObserver, "mouseevent");
     489           0 :     return NS_ERROR_UNEXPECTED;
     490             :   }
     491             : 
     492           0 :   virtual nsresult SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
     493             :                                              nsIObserver* aObserver) override
     494             :   {
     495           0 :     mozilla::widget::AutoObserverNotifier notifier(aObserver, "mouseevent");
     496           0 :     return NS_ERROR_UNEXPECTED;
     497             :   }
     498             : 
     499           0 :   virtual nsresult SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint aPoint,
     500             :                                                     uint32_t aNativeMessage,
     501             :                                                     double aDeltaX,
     502             :                                                     double aDeltaY,
     503             :                                                     double aDeltaZ,
     504             :                                                     uint32_t aModifierFlags,
     505             :                                                     uint32_t aAdditionalFlags,
     506             :                                                     nsIObserver* aObserver) override
     507             :   {
     508           0 :     mozilla::widget::AutoObserverNotifier notifier(aObserver, "mousescrollevent");
     509           0 :     return NS_ERROR_UNEXPECTED;
     510             :   }
     511             : 
     512           0 :   virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
     513             :                                               TouchPointerState aPointerState,
     514             :                                               LayoutDeviceIntPoint aPoint,
     515             :                                               double aPointerPressure,
     516             :                                               uint32_t aPointerOrientation,
     517             :                                               nsIObserver* aObserver) override
     518             :   {
     519           0 :     mozilla::widget::AutoObserverNotifier notifier(aObserver, "touchpoint");
     520           0 :     return NS_ERROR_UNEXPECTED;
     521             :   }
     522             : 
     523           0 :   virtual nsresult NotifyIMEInternal(const IMENotification& aIMENotification)
     524           0 :   { return NS_ERROR_NOT_IMPLEMENTED; }
     525             : 
     526             :   /**
     527             :    * GetPseudoIMEContext() returns pseudo IME context when TextEventDispatcher
     528             :    * has non-native input transaction.  Otherwise, returns nullptr.
     529             :    */
     530             :   void* GetPseudoIMEContext();
     531             : 
     532             : protected:
     533             :   // Utility to check if an array of clip rects is equal to our
     534             :   // internally stored clip rect array mClipRects.
     535             :   bool IsWindowClipRegionEqual(const nsTArray<LayoutDeviceIntRect>& aRects);
     536             : 
     537             :   // Stores the clip rectangles in aRects into mClipRects.
     538             :   void StoreWindowClipRegion(const nsTArray<LayoutDeviceIntRect>& aRects);
     539             : 
     540             :   virtual already_AddRefed<nsIWidget>
     541           0 :   AllocateChildPopupWidget()
     542             :   {
     543             :     static NS_DEFINE_IID(kCPopUpCID, NS_CHILD_CID);
     544           0 :     nsCOMPtr<nsIWidget> widget = do_CreateInstance(kCPopUpCID);
     545           0 :     return widget.forget();
     546             :   }
     547             : 
     548             :   LayerManager* CreateBasicLayerManager();
     549             : 
     550             :   nsPopupType PopupType() const { return mPopupType; }
     551             : 
     552           0 :   bool HasRemoteContent() const { return mHasRemoteContent; }
     553             : 
     554           1 :   void NotifyRollupGeometryChange()
     555             :   {
     556             :     // XULPopupManager isn't interested in this notification, so only
     557             :     // send it if gRollupListener is set.
     558           1 :     if (gRollupListener) {
     559           0 :       gRollupListener->NotifyGeometryChange();
     560             :     }
     561           1 :   }
     562             : 
     563             :   /**
     564             :    * Apply the current size constraints to the given size.
     565             :    *
     566             :    * @param aWidth width to constrain
     567             :    * @param aHeight height to constrain
     568             :    */
     569           3 :   void ConstrainSize(int32_t* aWidth, int32_t* aHeight)
     570             :   {
     571           3 :     SizeConstraints c = GetSizeConstraints();
     572           3 :     *aWidth = std::max(c.mMinSize.width,
     573           3 :                        std::min(c.mMaxSize.width, *aWidth));
     574           3 :     *aHeight = std::max(c.mMinSize.height,
     575           3 :                         std::min(c.mMaxSize.height, *aHeight));
     576           3 :   }
     577             : 
     578             :   virtual CompositorBridgeChild* GetRemoteRenderer() override;
     579             : 
     580             :   /**
     581             :    * Notify the widget that this window is being used with OMTC.
     582             :    */
     583           1 :   virtual void WindowUsesOMTC() {}
     584           0 :   virtual void RegisterTouchWindow() {}
     585             : 
     586             :   nsIDocument* GetDocument() const;
     587             : 
     588             :   void EnsureTextEventDispatcher();
     589             : 
     590             :   // Notify the compositor that a device reset has occurred.
     591             :   void OnRenderingDeviceReset();
     592             : 
     593             :   bool UseAPZ();
     594             : 
     595             :   /**
     596             :    * For widgets that support synthesizing native touch events, this function
     597             :    * can be used to manage the current state of synthetic pointers. Each widget
     598             :    * must maintain its own MultiTouchInput instance and pass it in as the state,
     599             :    * along with the desired parameters for the changes. This function returns
     600             :    * a new MultiTouchInput object that is ready to be dispatched.
     601             :    */
     602             :   mozilla::MultiTouchInput
     603             :   UpdateSynthesizedTouchState(mozilla::MultiTouchInput* aState,
     604             :                               uint32_t aTime,
     605             :                               mozilla::TimeStamp aTimeStamp,
     606             :                               uint32_t aPointerId,
     607             :                               TouchPointerState aPointerState,
     608             :                               LayoutDeviceIntPoint aPoint,
     609             :                               double aPointerPressure,
     610             :                               uint32_t aPointerOrientation);
     611             : 
     612             :   /**
     613             :    * Dispatch the given MultiTouchInput through APZ to Gecko (if APZ is enabled)
     614             :    * or directly to gecko (if APZ is not enabled). This function must only
     615             :    * be called from the main thread, and if APZ is enabled, that must also be
     616             :    * the APZ controller thread.
     617             :    */
     618             :   void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
     619             : 
     620             : #if defined(XP_WIN)
     621             :   void UpdateScrollCapture() override;
     622             : 
     623             :   /**
     624             :    * To be overridden by derived classes to return a snapshot that can be used
     625             :    * during scrolling. Returning null means we won't update the container.
     626             :    * @return an already AddRefed SourceSurface containing the snapshot
     627             :    */
     628             :   virtual already_AddRefed<SourceSurface> CreateScrollSnapshot()
     629             :   {
     630             :     return nullptr;
     631             :   };
     632             : 
     633             :   /**
     634             :    * Used by derived classes to create a fallback scroll image.
     635             :    * @param aSnapshotDrawTarget DrawTarget to fill with fallback image.
     636             :    */
     637             :   void DefaultFillScrollCapture(DrawTarget* aSnapshotDrawTarget);
     638             : 
     639             :   RefPtr<ImageContainer> mScrollCaptureContainer;
     640             : #endif
     641             : 
     642             : protected:
     643             :   // Returns whether compositing should use an external surface size.
     644           1 :   virtual bool UseExternalCompositingSurface() const {
     645           1 :     return false;
     646             :   }
     647             : 
     648             :   /**
     649             :    * Starts the OMTC compositor destruction sequence.
     650             :    *
     651             :    * When this function returns, the compositor should not be
     652             :    * able to access the opengl context anymore.
     653             :    * It is safe to call it several times if platform implementations
     654             :    * require the compositor to be destroyed before ~nsBaseWidget is
     655             :    * reached (This is the case with gtk2 for instance).
     656             :    */
     657             :   virtual void DestroyCompositor();
     658             :   void DestroyLayerManager();
     659             :   void ReleaseContentController();
     660             :   void RevokeTransactionIdAllocator();
     661             : 
     662             :   void FreeShutdownObserver();
     663             : 
     664             :   nsIWidgetListener* mWidgetListener;
     665             :   nsIWidgetListener* mAttachedWidgetListener;
     666             :   nsIWidgetListener* mPreviouslyAttachedWidgetListener;
     667             :   RefPtr<LayerManager> mLayerManager;
     668             :   RefPtr<CompositorSession> mCompositorSession;
     669             :   RefPtr<CompositorBridgeChild> mCompositorBridgeChild;
     670             :   RefPtr<mozilla::CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
     671             :   RefPtr<IAPZCTreeManager> mAPZC;
     672             :   RefPtr<GeckoContentController> mRootContentController;
     673             :   RefPtr<APZEventState> mAPZEventState;
     674             :   SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback;
     675             :   RefPtr<WidgetShutdownObserver> mShutdownObserver;
     676             :   RefPtr<TextEventDispatcher> mTextEventDispatcher;
     677             :   nsCursor          mCursor;
     678             :   nsBorderStyle     mBorderStyle;
     679             :   LayoutDeviceIntRect mBounds;
     680             :   LayoutDeviceIntRect* mOriginalBounds;
     681             :   // When this pointer is null, the widget is not clipped
     682             :   mozilla::UniquePtr<LayoutDeviceIntRect[]> mClipRects;
     683             :   uint32_t          mClipRectCount;
     684             :   nsSizeMode        mSizeMode;
     685             :   nsPopupLevel      mPopupLevel;
     686             :   nsPopupType       mPopupType;
     687             :   SizeConstraints   mSizeConstraints;
     688             :   bool              mHasRemoteContent;
     689             : 
     690             :   CompositorWidgetDelegate* mCompositorWidgetDelegate;
     691             : 
     692             :   bool              mUpdateCursor;
     693             :   bool              mUseAttachedEvents;
     694             :   bool              mIMEHasFocus;
     695             :   bool              mIsFullyOccluded;
     696             : #if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
     697             :   bool              mAccessibilityInUseFlag;
     698             : #endif
     699             :   static nsIRollupListener* gRollupListener;
     700             : 
     701           0 :   struct InitialZoomConstraints {
     702           0 :     InitialZoomConstraints(const uint32_t& aPresShellID,
     703             :                            const FrameMetrics::ViewID& aViewID,
     704             :                            const ZoomConstraints& aConstraints)
     705           0 :       : mPresShellID(aPresShellID), mViewID(aViewID), mConstraints(aConstraints)
     706             :     {
     707           0 :     }
     708             : 
     709             :     uint32_t mPresShellID;
     710             :     FrameMetrics::ViewID mViewID;
     711             :     ZoomConstraints mConstraints;
     712             :   };
     713             : 
     714             :   mozilla::Maybe<InitialZoomConstraints> mInitialZoomConstraints;
     715             : 
     716             :   // This points to the resize listeners who have been notified that a live
     717             :   // resize is in progress. This should always be empty when a live-resize is
     718             :   // not in progress.
     719             :   nsTArray<RefPtr<mozilla::LiveResizeListener>> mLiveResizeListeners;
     720             : 
     721             : #ifdef DEBUG
     722             : protected:
     723             :   static nsAutoString debug_GuiEventToString(mozilla::WidgetGUIEvent* aGuiEvent);
     724             :   static bool debug_WantPaintFlashing();
     725             : 
     726             :   static void debug_DumpInvalidate(FILE* aFileOut,
     727             :                                    nsIWidget* aWidget,
     728             :                                    const LayoutDeviceIntRect* aRect,
     729             :                                    const char* aWidgetName,
     730             :                                    int32_t aWindowID);
     731             : 
     732             :   static void debug_DumpEvent(FILE* aFileOut,
     733             :                               nsIWidget* aWidget,
     734             :                               mozilla::WidgetGUIEvent* aGuiEvent,
     735             :                               const char* aWidgetName,
     736             :                               int32_t aWindowID);
     737             : 
     738             :   static void debug_DumpPaintEvent(FILE *                aFileOut,
     739             :                                    nsIWidget *           aWidget,
     740             :                                    const nsIntRegion &   aPaintEvent,
     741             :                                    const char *          aWidgetName,
     742             :                                    int32_t               aWindowID);
     743             : 
     744             :   static bool debug_GetCachedBoolPref(const char* aPrefName);
     745             : #endif
     746             : };
     747             : 
     748             : #endif // nsBaseWidget_h__

Generated by: LCOV version 1.13