diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/frame/web_frame_widget_base.h')
-rw-r--r-- | chromium/third_party/blink/renderer/core/frame/web_frame_widget_base.h | 189 |
1 files changed, 152 insertions, 37 deletions
diff --git a/chromium/third_party/blink/renderer/core/frame/web_frame_widget_base.h b/chromium/third_party/blink/renderer/core/frame/web_frame_widget_base.h index 43fbd634a4f..2663b0e651d 100644 --- a/chromium/third_party/blink/renderer/core/frame/web_frame_widget_base.h +++ b/chromium/third_party/blink/renderer/core/frame/web_frame_widget_base.h @@ -6,46 +6,67 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WEB_FRAME_WIDGET_BASE_H_ #include "base/single_thread_task_runner.h" +#include "cc/input/event_listener_properties.h" +#include "cc/input/layer_selection_bound.h" +#include "cc/input/overscroll_behavior.h" +#include "cc/trees/layer_tree_host.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" +#include "mojo/public/cpp/bindings/associated_remote.h" #include "services/network/public/mojom/referrer_policy.mojom-blink-forward.h" +#include "third_party/blink/public/common/input/web_gesture_device.h" +#include "third_party/blink/public/mojom/page/widget.mojom-blink.h" +#include "third_party/blink/public/platform/cross_variant_mojo_util.h" #include "third_party/blink/public/platform/web_coalesced_input_event.h" #include "third_party/blink/public/platform/web_drag_data.h" -#include "third_party/blink/public/platform/web_gesture_device.h" #include "third_party/blink/public/web/web_frame_widget.h" #include "third_party/blink/renderer/core/clipboard/data_object.h" #include "third_party/blink/renderer/core/core_export.h" +#include "third_party/blink/renderer/platform/graphics/apply_viewport_changes.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_image.h" #include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/timer.h" +#include "third_party/blink/renderer/platform/widget/frame_widget.h" +#include "third_party/blink/renderer/platform/widget/widget_base_client.h" #include "third_party/blink/renderer/platform/wtf/casting.h" -namespace cc { -class AnimationHost; -class Layer; -} - namespace gfx { class Point; +class PointF; } namespace blink { class AnimationWorkletMutatorDispatcherImpl; class HitTestResult; +class LocalFrameView; class Page; class PageWidgetEventHandler; class PaintWorkletPaintDispatcher; class WebLocalFrameImpl; class WebViewImpl; +class WidgetBase; struct IntrinsicSizingInfo; -struct WebFloatPoint; class CORE_EXPORT WebFrameWidgetBase : public GarbageCollected<WebFrameWidgetBase>, - public WebFrameWidget { + public WebFrameWidget, + public WidgetBaseClient, + public mojom::blink::FrameWidget, + public FrameWidget { public: - explicit WebFrameWidgetBase(WebWidgetClient&); - virtual ~WebFrameWidgetBase(); - - WebWidgetClient* Client() const { return client_; } + WebFrameWidgetBase( + WebWidgetClient&, + CrossVariantMojoAssociatedRemote< + mojom::blink::FrameWidgetHostInterfaceBase> frame_widget_host, + CrossVariantMojoAssociatedReceiver<mojom::blink::FrameWidgetInterfaceBase> + frame_widget, + CrossVariantMojoAssociatedRemote<mojom::blink::WidgetHostInterfaceBase> + widget_host, + CrossVariantMojoAssociatedReceiver<mojom::blink::WidgetInterfaceBase> + widget); + ~WebFrameWidgetBase() override; + + // Returns the WebFrame that this widget is attached to. It will be a local + // root since only local roots have a widget attached. WebLocalFrameImpl* LocalRootImpl() const { return local_root_; } // Returns the bounding box of the block type node touched by the WebPoint. @@ -70,35 +91,48 @@ class CORE_EXPORT WebFrameWidgetBase base::WeakPtr<PaintWorkletPaintDispatcher> EnsureCompositorPaintDispatcher( scoped_refptr<base::SingleThreadTaskRunner>* paint_task_runner); - // Sets the root layer. The |layer| can be null when detaching the root layer. - virtual void SetRootLayer(scoped_refptr<cc::Layer> layer) = 0; - - virtual cc::AnimationHost* AnimationHost() const = 0; - virtual HitTestResult CoreHitTestResultAt(const gfx::Point&) = 0; + // FrameWidget implementation. + WebWidgetClient* Client() const final { return client_; } + cc::AnimationHost* AnimationHost() const final; + void SetOverscrollBehavior( + const cc::OverscrollBehavior& overscroll_behavior) final; + void RequestAnimationAfterDelay(const base::TimeDelta&) final; + void RegisterSelection(cc::LayerSelection selection) final; + void RequestDecode(const cc::PaintImage&, + base::OnceCallback<void(bool)>) final; + void NotifySwapAndPresentationTimeInBlink( + WebReportTimeCallback swap_callback, + WebReportTimeCallback presentation_callback) final; + void RequestBeginMainFrameNotExpected(bool request) final; + int GetLayerTreeId() final; + void SetEventListenerProperties(cc::EventListenerClass, + cc::EventListenerProperties) final; + cc::EventListenerProperties EventListenerProperties( + cc::EventListenerClass) const final; + // WebFrameWidget implementation. void Close() override; WebLocalFrame* LocalRoot() const override; WebDragOperation DragTargetDragEnter(const WebDragData&, - const WebFloatPoint& point_in_viewport, - const WebFloatPoint& screen_point, + const gfx::PointF& point_in_viewport, + const gfx::PointF& screen_point, WebDragOperationsMask operations_allowed, int modifiers) override; - WebDragOperation DragTargetDragOver(const WebFloatPoint& point_in_viewport, - const WebFloatPoint& screen_point, + WebDragOperation DragTargetDragOver(const gfx::PointF& point_in_viewport, + const gfx::PointF& screen_point, WebDragOperationsMask operations_allowed, int modifiers) override; - void DragTargetDragLeave(const WebFloatPoint& point_in_viewport, - const WebFloatPoint& screen_point) override; + void DragTargetDragLeave(const gfx::PointF& point_in_viewport, + const gfx::PointF& screen_point) override; void DragTargetDrop(const WebDragData&, - const WebFloatPoint& point_in_viewport, - const WebFloatPoint& screen_point, + const gfx::PointF& point_in_viewport, + const gfx::PointF& screen_point, int modifiers) override; - void DragSourceEndedAt(const WebFloatPoint& point_in_viewport, - const WebFloatPoint& screen_point, + void DragSourceEndedAt(const gfx::PointF& point_in_viewport, + const gfx::PointF& screen_point, WebDragOperation) override; - void DragSourceSystemDragEnded() override; void SendOverscrollEventFromImplSide( const gfx::Vector2dF& overscroll_delta, cc::ElementId scroll_latched_element_id) override; @@ -106,6 +140,12 @@ class CORE_EXPORT WebFrameWidgetBase cc::ElementId scroll_latched_element_id) override; WebLocalFrame* FocusedWebLocalFrameInWidget() const override; + void SetCompositorHosts(cc::LayerTreeHost*, cc::AnimationHost*) override; + void ApplyViewportChangesForTesting( + const ApplyViewportChangesArgs& args) override; + void NotifySwapAndPresentationTime( + WebReportTimeCallback swap_callback, + WebReportTimeCallback presentation_callback) override; // Called when a drag-n-drop operation should begin. void StartDragging(network::mojom::ReferrerPolicy, @@ -123,9 +163,18 @@ class CORE_EXPORT WebFrameWidgetBase void DidNotAcquirePointerLock() override; void DidLosePointerLock() override; void ShowContextMenu(WebMenuSourceType) override; + void BeginFrame(base::TimeTicks frame_time) final; + void SetCompositorVisible(bool visible) override; + void UpdateVisualState() override; + void WillBeginCompositorFrame() final; - // Image decode functionality. - void RequestDecode(const PaintImage&, base::OnceCallback<void(bool)>); + // WidgetBaseClient methods. + void DispatchRafAlignedInput(base::TimeTicks frame_time) override; + void RecordTimeToFirstActivePaint(base::TimeDelta duration) override; + + // mojom::blink::FrameWidget methods. + void DragSourceSystemDragEnded() override; + void SetBackgroundOpaque(bool opaque) override; // Called when the FrameView for this Widget's local root is created. virtual void DidCreateLocalRootView() {} @@ -136,9 +185,64 @@ class CORE_EXPORT WebFrameWidgetBase // focused frame has a different local root. LocalFrame* FocusedLocalFrameInWidget() const; - void RequestAnimationAfterDelay(const base::TimeDelta&); - - virtual void Trace(blink::Visitor*); + virtual void Trace(Visitor*); + + // For when the embedder itself change scales on the page (e.g. devtools) + // and wants all of the content at the new scale to be crisp + void SetNeedsRecalculateRasterScales(); + + // Sets the background color to be filled in as gutter behind/around the + // painted content. Non-composited WebViews need not implement this, as they + // paint into another widget which has a background color of its own. + void SetBackgroundColor(SkColor color); + + // Starts an animation of the page scale to a target scale factor and scroll + // offset. + // If use_anchor is true, destination is a point on the screen that will + // remain fixed for the duration of the animation. + // If use_anchor is false, destination is the final top-left scroll position. + void StartPageScaleAnimation(const gfx::Vector2d& destination, + bool use_anchor, + float new_page_scale, + base::TimeDelta duration); + + // Called to update if scroll events should be sent. + void SetHaveScrollEventHandlers(bool); + + // Start deferring commits to the compositor, allowing document lifecycle + // updates without committing the layer tree. Commits are deferred + // until at most the given |timeout| has passed. If multiple calls are made + // when deferral is active then the initial timeout applies. + void StartDeferringCommits(base::TimeDelta timeout); + // Immediately stop deferring commits. + void StopDeferringCommits(cc::PaintHoldingCommitTrigger); + + // Prevents any updates to the input for the layer tree, and the layer tree + // itself, and the layer tree from becoming visible. + std::unique_ptr<cc::ScopedDeferMainFrameUpdate> DeferMainFrameUpdate(); + + // Sets the amount that the top and bottom browser controls are showing, from + // 0 (hidden) to 1 (fully shown). + void SetBrowserControlsShownRatio(float top_ratio, float bottom_ratio); + + // Set browser controls params. These params consist of top and bottom + // heights, min-heights, browser_controls_shrink_blink_size, and + // animate_browser_controls_height_changes. If + // animate_browser_controls_height_changes is set to true, changes to the + // browser controls height will be animated. If + // browser_controls_shrink_blink_size is set to true, then Blink shrunk the + // viewport clip layers by the top and bottom browser controls height. Top + // controls will translate the web page down and do not immediately scroll + // when hiding. The bottom controls scroll immediately and never translate the + // content (only clip it). + void SetBrowserControlsParams(cc::BrowserControlsParams params); + + cc::LayerTreeDebugState GetLayerTreeDebugState(); + void SetLayerTreeDebugState(const cc::LayerTreeDebugState& state); + + // Ask compositor to composite a frame for testing. This will generate a + // BeginMainFrame, and update the document lifecycle. + void SynchronouslyCompositeForTesting(base::TimeTicks frame_time); protected: enum DragAction { kDragEnter, kDragOver }; @@ -147,14 +251,13 @@ class CORE_EXPORT WebFrameWidgetBase // updating a drag over a target. If we're starting a drag, |isEntering| // should be true. WebDragOperation DragTargetDragEnterOrOver( - const WebFloatPoint& point_in_viewport, - const WebFloatPoint& screen_point, + const gfx::PointF& point_in_viewport, + const gfx::PointF& screen_point, DragAction, int modifiers); // Helper function to call VisualViewport::viewportToRootFrame(). - WebFloatPoint ViewportToRootFrame( - const WebFloatPoint& point_in_viewport) const; + gfx::PointF ViewportToRootFrame(const gfx::PointF& point_in_viewport) const; WebViewImpl* View() const; @@ -167,6 +270,11 @@ class CORE_EXPORT WebFrameWidgetBase virtual PageWidgetEventHandler* GetPageWidgetEventHandler() = 0; + // Return the LocalFrameView used for animation scrolling. This is overridden + // by WebViewFrameWidget and should eventually be removed once null does not + // need to be passed for the main frame. + virtual LocalFrameView* GetLocalFrameViewForAnimationScrolling() = 0; + // A copy of the web drop data object we received from the browser. Member<DataObject> current_drag_data_; @@ -180,6 +288,10 @@ class CORE_EXPORT WebFrameWidgetBase // current drop target in this WebView (the drop target can accept the drop). WebDragOperation drag_operation_ = kWebDragOperationNone; + // Base functionality all widgets have. This is a member as to avoid + // complicated inheritance structures. + std::unique_ptr<WidgetBase> widget_base_; + private: void CancelDrag(); void RequestAnimationAfterDelayTimerFired(TimerBase*); @@ -210,6 +322,9 @@ class CORE_EXPORT WebFrameWidgetBase std::unique_ptr<TaskRunnerTimer<WebFrameWidgetBase>> request_animation_after_delay_timer_; + mojo::AssociatedRemote<mojom::blink::FrameWidgetHost> frame_widget_host_; + mojo::AssociatedReceiver<mojom::blink::FrameWidget> receiver_; + friend class WebViewImpl; }; |