/* -*- 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__
namespace mozilla { class CompositorVsyncDispatcher; class LiveResizeListener; class FallbackRenderer; class SwipeTracker; struct SwipeEventQueue; class WidgetWheelEvent;
#ifdef ACCESSIBILITY namespace a11y { class LocalAccessible;
} #endif
namespace gfx { class DrawTarget; class SourceSurface;
} // namespace gfx
namespace layers { class CompositorBridgeChild; class CompositorBridgeParent; class IAPZCTreeManager; class GeckoContentController; class APZEventState; struct APZEventResult; class CompositorSession; class ImageContainer; class WebRenderLayerManager; struct ScrollableLayerGuid; class RemoteCompositorSession;
} // namespace layers
namespace widget { class CompositorWidgetDelegate; class InProcessCompositorWidget; class WidgetRenderingContext;
} // namespace widget
class CompositorVsyncDispatcher;
} // namespace mozilla
namespace base { class Thread;
} // 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 256
class nsBaseWidget;
// Helper class used in shutting down gfx related code. class WidgetShutdownObserver final : public nsIObserver {
~WidgetShutdownObserver();
/** * 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.)
*/
class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { template <class EventType, class InputType> friendclass DispatchEventOnMainThread; friendclass mozilla::widget::InProcessCompositorWidget; friendclass mozilla::layers::RemoteCompositorSession;
// 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. Callers should hold a reference to the widget, since this // function could deallocate the widget if it is unparented. virtualvoid NotifyCompositorSessionLost(
mozilla::layers::CompositorSession* aSession);
already_AddRefed<mozilla::CompositorVsyncDispatcher>
GetCompositorVsyncDispatcher(); virtualvoid CreateCompositorVsyncDispatcher(); virtualvoid CreateCompositor(); virtualvoid CreateCompositor(int aWidth, int aHeight); virtualvoid SetCompositorWidgetDelegate(CompositorWidgetDelegate*) {} void PrepareWindowEffects() override {} void UpdateThemeGeometries( const nsTArray<ThemeGeometry>& aThemeGeometries) override {} void SetModal(bool aModal) override {}
uint32_t GetMaxTouchPoints() const override; void SetWindowClass(const nsAString& xulWinType, const nsAString& xulWinClass, const nsAString& xulWinName) 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. bool BoundsUseDesktopPixels() const { return mWindowType <= WindowType::Popup;
} // Default implementation, to be overridden by platforms where desktop coords // are virtualized and may not correspond to device pixels on the screen.
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() override { return mozilla::DesktopToLayoutDeviceScale(1.0);
}
mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScaleByScreen()
override;
// Dispatch an event that must be first be routed through APZ.
ContentAndAPZEventStatus DispatchInputEvent(
mozilla::WidgetInputEvent* aEvent) override; void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) override;
void SwipeFinished() override; void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) override; void TrackScrollEventAsSwipe(const mozilla::PanGestureInput& aSwipeStartEvent,
uint32_t aAllowedDirections,
uint64_t aInputBlockId); struct SwipeInfo { bool wantsSwipe;
uint32_t allowedDirections;
};
SwipeInfo SendMayStartSwipe(const mozilla::PanGestureInput& aSwipeStartEvent); // Returns a WidgetWheelEvent which needs to be handled by APZ regardless of // whether |aPanInput| event was used for SwipeTracker or not.
mozilla::WidgetWheelEvent MayStartSwipeForAPZ( const mozilla::PanGestureInput& aPanInput, const mozilla::layers::APZEventResult& aApzResult);
// Returns true if |aPanInput| event was used for SwipeTracker, false // otherwise. bool MayStartSwipeForNonAPZ(const mozilla::PanGestureInput& aPanInput);
// Should be called by derived implementations to notify on system color and // theme changes. (Only one invocation per change is needed, not one // invocation per change per window.) void NotifyThemeChanged(mozilla::widget::ThemeChangeKind);
void NotifyAPZOfDPIChange();
#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) bool IsSmallPopup() const;
/** * 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.
*/ class AutoLayerManagerSetup { public:
AutoLayerManagerSetup(nsBaseWidget* aWidget, gfxContext* aTarget,
BufferMode aDoubleBuffering);
~AutoLayerManagerSetup();
// 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. void NotifyLiveResizeStarted(); void NotifyLiveResizeStopped();
// Dispatch an event that has already been routed through APZ.
nsEventStatus ProcessUntransformedAPZEvent(
mozilla::WidgetInputEvent* aEvent, const mozilla::layers::APZEventResult& aApzResult);
nsresult SynthesizeNativeTouchPadPinch(TouchpadGesturePhase aEventPhase, float aScale,
LayoutDeviceIntPoint aPoint,
int32_t aModifierFlags) override {
MOZ_RELEASE_ASSERT( false, "This method is not implemented on the current platform"); return NS_ERROR_UNEXPECTED;
}
nsresult SynthesizeNativePenInput(uint32_t aPointerId,
TouchPointerState aPointerState,
LayoutDeviceIntPoint aPoint, double aPressure, uint32_t aRotation,
int32_t aTiltX, int32_t aTiltY,
int32_t aButton,
nsIObserver* aObserver) override {
MOZ_RELEASE_ASSERT( false, "This method is not implemented on the current platform"); return NS_ERROR_UNEXPECTED;
}
nsresult SynthesizeNativeTouchpadDoubleTap(LayoutDeviceIntPoint aPoint,
uint32_t aModifierFlags) override {
MOZ_RELEASE_ASSERT( false, "This method is not implemented on the current platform"); return NS_ERROR_UNEXPECTED;
}
nsresult SynthesizeNativeTouchpadPan(TouchpadGesturePhase aEventPhase,
LayoutDeviceIntPoint aPoint, double aDeltaX, double aDeltaY,
int32_t aModifierFlags,
nsIObserver* aObserver) override {
MOZ_RELEASE_ASSERT( false, "This method is not implemented on the current platform"); return NS_ERROR_UNEXPECTED;
}
/** * GetPseudoIMEContext() returns pseudo IME context when TextEventDispatcher * has non-native input transaction. Otherwise, returns nullptr.
*/ void* GetPseudoIMEContext();
/** * Notify the widget that this window is being used with OMTC.
*/ virtualvoid WindowUsesOMTC() {} virtualvoid RegisterTouchWindow() {}
mozilla::dom::Document* GetDocument() const;
void EnsureTextEventDispatcher();
// Notify the compositor that a device reset has occurred. void OnRenderingDeviceReset();
bool UseAPZ() const;
bool AllowWebRenderForThisWindow();
/** * 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::MultiTouchInput UpdateSynthesizedTouchState(
mozilla::MultiTouchInput* aState, mozilla::TimeStamp aTimeStamp,
uint32_t aPointerId, TouchPointerState aPointerState,
LayoutDeviceIntPoint aPoint, double aPointerPressure,
uint32_t aPointerOrientation);
/** * 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.
*/ void DispatchTouchInput(
mozilla::MultiTouchInput& aInput,
uint16_t aInputSource =
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.
*/ void DispatchPanGestureInput(mozilla::PanGestureInput& aInput); void DispatchPinchGestureInput(mozilla::PinchGestureInput& aInput);
protected: // Returns whether compositing should use an external surface size. virtualbool UseExternalCompositingSurface() 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).
*/ virtualvoid DestroyCompositor(); void DestroyLayerManager(); void ReleaseContentController(); void RevokeTransactionIdAllocator();
bool mUpdateCursor; bool mUseAttachedEvents; bool mIMEHasFocus; bool mIMEHasQuit; // if the window is fully occluded (rendering may be paused in response) bool mIsFullyOccluded; bool mNeedFastSnaphot; // This flag is only used when APZ is off. It indicates that the current pan // gesture was processed as a swipe. Sometimes the swipe animation can finish // before momentum events of the pan gesture have stopped firing, so this // flag tells us that we shouldn't allow the remaining events to cause // scrolling. It is reset to false once a new gesture starts (as indicated by // a PANGESTURE_(MAY)START event). bool mCurrentPanGestureBelongsToSwipe;
// 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;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.