2 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WEB_FRAME_WIDGET_IMPL_H_
32 #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WEB_FRAME_WIDGET_IMPL_H_
34 #include "base/functional/function_ref.h"
35 #include "base/memory/weak_ptr.h"
36 #include "base/task/single_thread_task_runner.h"
37 #include "base/time/time.h"
38 #include "base/types/pass_key.h"
39 #include "base/unguessable_token.h"
40 #include "build/build_config.h"
41 #include "cc/input/event_listener_properties.h"
42 #include "cc/input/overscroll_behavior.h"
43 #include "cc/trees/layer_tree_host.h"
44 #include "cc/trees/paint_holding_reason.h"
45 #include "services/viz/public/mojom/hit_test/input_target_client.mojom-blink.h"
46 #include "third_party/blink/public/common/input/web_coalesced_input_event.h"
47 #include "third_party/blink/public/common/input/web_gesture_device.h"
48 #include "third_party/blink/public/mojom/drag/drag.mojom-blink.h"
49 #include "third_party/blink/public/mojom/input/input_handler.mojom-blink-forward.h"
50 #include "third_party/blink/public/mojom/input/stylus_writing_gesture.mojom-blink.h"
51 #include "third_party/blink/public/mojom/manifest/display_mode.mojom-blink.h"
52 #include "third_party/blink/public/mojom/page/widget.mojom-blink.h"
53 #include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink-forward.h"
54 #include "third_party/blink/public/platform/cross_variant_mojo_util.h"
55 #include "third_party/blink/public/platform/web_drag_data.h"
56 #include "third_party/blink/public/web/web_frame_widget.h"
57 #include "third_party/blink/public/web/web_meaningful_layout.h"
58 #include "third_party/blink/renderer/core/clipboard/data_object.h"
59 #include "third_party/blink/renderer/core/core_export.h"
60 #include "third_party/blink/renderer/core/exported/web_page_popup_impl.h"
61 #include "third_party/blink/renderer/core/frame/animation_frame_timing_monitor.h"
62 #include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
63 #include "third_party/blink/renderer/core/page/drag_controller.h"
64 #include "third_party/blink/renderer/core/page/event_with_hit_test_results.h"
65 #include "third_party/blink/renderer/core/page/viewport_description.h"
66 #include "third_party/blink/renderer/platform/graphics/apply_viewport_changes.h"
67 #include "third_party/blink/renderer/platform/graphics/paint/paint_image.h"
68 #include "third_party/blink/renderer/platform/heap/member.h"
69 #include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_receiver.h"
70 #include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_remote.h"
71 #include "third_party/blink/renderer/platform/mojo/heap_mojo_receiver.h"
72 #include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h"
73 #include "third_party/blink/renderer/platform/text/text_direction.h"
74 #include "third_party/blink/renderer/platform/widget/frame_widget.h"
75 #include "third_party/blink/renderer/platform/widget/input/widget_base_input_handler.h"
76 #include "third_party/blink/renderer/platform/widget/widget_base_client.h"
77 #include "third_party/blink/renderer/platform/wtf/casting.h"
78 #include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
79 #include "ui/base/ui_base_types.h"
80 #include "ui/gfx/ca_layer_result.h"
88 class AnimationWorkletMutatorDispatcherImpl;
90 class HTMLPlugInElement;
92 class PaintWorkletPaintDispatcher;
94 class WebLocalFrameImpl;
98 class WidgetEventHandler;
99 class ScreenMetricsEmulator;
101 // Implements WebFrameWidget for both main frames and child local root frame
103 class CORE_EXPORT WebFrameWidgetImpl
104 : public GarbageCollected<WebFrameWidgetImpl>,
105 public WebFrameWidget,
106 public WidgetBaseClient,
107 public mojom::blink::FrameWidget,
108 public viz::mojom::blink::InputTargetClient,
109 public mojom::blink::FrameWidgetInputHandler,
111 public AnimationFrameTimingMonitor::Client,
112 public WidgetEventHandler {
114 struct PromiseCallbacks {
115 base::OnceCallback<void(base::TimeTicks)> swap_time_callback;
116 base::OnceCallback<void(base::TimeTicks)> presentation_time_callback;
117 #if BUILDFLAG(IS_APPLE)
118 base::OnceCallback<void(gfx::CALayerResult)>
119 core_animation_error_code_callback;
122 return (!swap_time_callback &&
123 #if BUILDFLAG(IS_APPLE)
124 !core_animation_error_code_callback &&
126 !presentation_time_callback);
131 base::PassKey<WebLocalFrame>,
132 CrossVariantMojoAssociatedRemote<
133 mojom::blink::FrameWidgetHostInterfaceBase> frame_widget_host,
134 CrossVariantMojoAssociatedReceiver<mojom::blink::FrameWidgetInterfaceBase>
136 CrossVariantMojoAssociatedRemote<mojom::blink::WidgetHostInterfaceBase>
138 CrossVariantMojoAssociatedReceiver<mojom::blink::WidgetInterfaceBase>
140 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
141 const viz::FrameSinkId& frame_sink_id,
143 bool never_composited,
144 bool is_for_child_local_root,
145 bool is_for_nested_main_frame,
146 bool is_for_scalable_page);
147 ~WebFrameWidgetImpl() override;
149 virtual void Trace(Visitor*) const;
151 // Shutdown the widget.
154 // Returns the WebFrame that this widget is attached to. It will be a local
155 // root since only local roots have a widget attached.
156 WebLocalFrameImpl* LocalRootImpl() const { return local_root_.Get(); }
158 // Returns the bounding box of the block type node touched by the WebPoint.
159 gfx::Rect ComputeBlockBound(const gfx::Point& point_in_root_frame,
160 bool ignore_clipping) const;
162 virtual void BindLocalRoot(WebLocalFrame&);
164 // If this widget is for the top most main frame. This is different than
165 // |ForMainFrame| because |ForMainFrame| could return true but this method
166 // returns false. If this widget is a MainFrame widget embedded in another
167 // widget, for example embedding a portal.
168 bool ForTopMostMainFrame() const;
170 // Adjusts whether the widget is nested or not. This is called during portal
172 void SetIsNestedMainFrameWidget(bool is_nested);
174 // Returns true if this widget is for a local root that is a child frame,
176 bool ForSubframe() const { return is_for_child_local_root_; }
178 // Opposite of |ForSubframe|. If this widget is for the local main frame.
179 bool ForMainFrame() const { return !ForSubframe(); }
181 // Called when the intrinsic size of the owning container is changing its
182 // size. This should only be called when `ForSubframe` is true.
183 void IntrinsicSizingInfoChanged(mojom::blink::IntrinsicSizingInfoPtr);
185 void AutoscrollStart(const gfx::PointF& position);
186 void AutoscrollFling(const gfx::Vector2dF& position);
187 void AutoscrollEnd();
189 bool HandleCurrentKeyboardEvent();
191 // Creates or returns cached mutator dispatcher. This usually requires a
192 // round trip to the compositor. The returned WeakPtr must only be
193 // dereferenced on the output |mutator_task_runner|.
194 base::WeakPtr<AnimationWorkletMutatorDispatcherImpl>
195 EnsureCompositorMutatorDispatcher(
196 scoped_refptr<base::SingleThreadTaskRunner> mutator_task_runner);
198 // TODO: consider merge the input and return value to be one parameter.
199 // Creates or returns cached paint dispatcher. The returned WeakPtr must only
200 // be dereferenced on the output |paint_task_runner|.
201 base::WeakPtr<PaintWorkletPaintDispatcher> EnsureCompositorPaintDispatcher(
202 scoped_refptr<base::SingleThreadTaskRunner>* paint_task_runner);
204 HitTestResult CoreHitTestResultAt(const gfx::PointF&);
206 // Registers callbacks for the corresponding renderer frame: `swap_callback`
207 // is fired with the submission (aka swap) timestamp when the frame is
208 // submitted to Viz; `presentation_callback` is fired with the presentation
209 // timestamp after the frame is presented to the user.
210 void NotifySwapAndPresentationTimeForTesting(PromiseCallbacks callbacks);
212 // Process the input event, invoking the callback when complete. This
213 // method will call the callback synchronously.
214 void ProcessInputEventSynchronouslyForTesting(
215 const WebCoalescedInputEvent&,
216 WidgetBaseInputHandler::HandledEventCallback);
218 // FrameWidget overrides.
219 cc::AnimationHost* AnimationHost() const final;
220 cc::AnimationTimeline* ScrollAnimationTimeline() const final;
221 void SetOverscrollBehavior(
222 const cc::OverscrollBehavior& overscroll_behavior) final;
223 void RequestAnimationAfterDelay(const base::TimeDelta&) final;
224 void SetRootLayer(scoped_refptr<cc::Layer>) override;
225 void RequestDecode(const cc::PaintImage&,
226 base::OnceCallback<void(bool)>) override;
227 void NotifyPresentationTimeInBlink(
228 base::OnceCallback<void(base::TimeTicks)> presentation_callback) final;
229 void RequestBeginMainFrameNotExpected(bool request) final;
230 int GetLayerTreeId() final;
231 const cc::LayerTreeSettings* GetLayerTreeSettings() final;
232 void UpdateBrowserControlsState(cc::BrowserControlsState constraints,
233 cc::BrowserControlsState current,
235 void SetEventListenerProperties(cc::EventListenerClass,
236 cc::EventListenerProperties) final;
237 cc::EventListenerProperties EventListenerProperties(
238 cc::EventListenerClass) const final;
239 mojom::blink::DisplayMode DisplayMode() const override;
240 ui::WindowShowState WindowShowState() const override;
241 bool Resizable() const override;
242 const WebVector<gfx::Rect>& WindowSegments() const override;
243 void SetDelegatedInkMetadata(
244 std::unique_ptr<gfx::DelegatedInkMetadata> metadata) final;
245 void DidOverscroll(const gfx::Vector2dF& overscroll_delta,
246 const gfx::Vector2dF& accumulated_overscroll,
247 const gfx::PointF& position,
248 const gfx::Vector2dF& velocity) override;
249 void InjectScrollbarGestureScroll(const gfx::Vector2dF& delta,
250 ui::ScrollGranularity granularity,
251 cc::ElementId scrollable_area_element_id,
252 WebInputEvent::Type injected_type) override;
253 void DidChangeCursor(const ui::Cursor&) override;
254 void GetCompositionCharacterBoundsInWindow(
255 Vector<gfx::Rect>* bounds_in_dips) override;
256 // Return the last calculated line bounds.
257 Vector<gfx::Rect>& GetVisibleLineBoundsOnScreen() override;
258 void UpdateLineBounds() override;
259 gfx::Range CompositionRange() override;
260 WebTextInputInfo TextInputInfo() override;
261 ui::mojom::VirtualKeyboardVisibilityRequest
262 GetLastVirtualKeyboardVisibilityRequest() override;
263 bool ShouldSuppressKeyboardForFocusedElement() override;
264 void GetEditContextBoundsInWindow(
265 absl::optional<gfx::Rect>* control_bounds,
266 absl::optional<gfx::Rect>* selection_bounds) override;
267 int32_t ComputeWebTextInputNextPreviousFlags() override;
268 void ResetVirtualKeyboardVisibilityRequest() override;
269 bool GetSelectionBoundsInWindow(gfx::Rect* focus,
271 gfx::Rect* bounding_box,
272 base::i18n::TextDirection* focus_dir,
273 base::i18n::TextDirection* anchor_dir,
274 bool* is_anchor_first) override;
275 void ClearTextInputState() override;
277 bool SetComposition(const String& text,
278 const Vector<ui::ImeTextSpan>& ime_text_spans,
279 const gfx::Range& replacement_range,
281 int selection_end) override;
282 void CommitText(const String& text,
283 const Vector<ui::ImeTextSpan>& ime_text_spans,
284 const gfx::Range& replacement_range,
285 int relative_cursor_pos) override;
286 void FinishComposingText(bool keep_selection) override;
287 bool IsProvisional() override;
288 cc::ElementId GetScrollableContainerIdAt(const gfx::PointF& point) override;
289 bool ShouldHandleImeEvents() override;
290 void SetEditCommandsForNextKeyEvent(
291 Vector<mojom::blink::EditCommandPtr> edit_commands) override;
292 Vector<ui::mojom::blink::ImeTextSpanInfoPtr> GetImeTextSpansInfo(
293 const WebVector<ui::ImeTextSpan>& ime_text_spans) override;
294 void RequestMouseLock(
295 bool has_transient_user_activation,
296 bool request_unadjusted_movement,
297 mojom::blink::WidgetInputHandlerHost::RequestMouseLockCallback callback)
299 gfx::RectF BlinkSpaceToDIPs(const gfx::RectF& rect) override;
300 gfx::Rect BlinkSpaceToEnclosedDIPs(const gfx::Rect& rect) override;
301 gfx::Size BlinkSpaceToFlooredDIPs(const gfx::Size& size) override;
302 gfx::RectF DIPsToBlinkSpace(const gfx::RectF& rect) override;
303 gfx::PointF DIPsToBlinkSpace(const gfx::PointF& point) override;
304 gfx::Point DIPsToRoundedBlinkSpace(const gfx::Point& point) override;
305 float DIPsToBlinkSpace(float scalar) override;
306 void MouseCaptureLost() override;
307 bool CanComposeInline() override;
308 bool ShouldDispatchImeEventsToPlugin() override;
309 void ImeSetCompositionForPlugin(const String& text,
310 const Vector<ui::ImeTextSpan>& ime_text_spans,
311 const gfx::Range& replacement_range,
313 int selection_end) override;
314 void ImeCommitTextForPlugin(const String& text,
315 const Vector<ui::ImeTextSpan>& ime_text_spans,
316 const gfx::Range& replacement_range,
317 int relative_cursor_pos) override;
318 void ImeFinishComposingTextForPlugin(bool keep_selection) override;
319 float GetCompositingScaleFactor() override;
320 const cc::LayerTreeDebugState& GetLayerTreeDebugState() override;
321 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& state) override;
322 void SetMayThrottleIfUndrawnFrames(
323 bool may_throttle_if_undrawn_frames) override;
324 int GetVirtualKeyboardResizeHeight() const override;
326 void OnTaskCompletedForFrame(base::TimeTicks start_time,
327 base::TimeTicks end_time,
328 base::TimeTicks desired_execution_time,
329 LocalFrame*) override;
330 void SetVirtualKeyboardResizeHeightForTesting(int);
331 bool GetMayThrottleIfUndrawnFramesForTesting();
333 // AnimationFrameTimingMonitor::Client overrides
334 void ReportLongAnimationFrameTiming(AnimationFrameTimingInfo* info) override;
335 bool ShouldReportLongAnimationFrameTiming() const override;
336 void ReportLongTaskTiming(base::TimeTicks start_time,
338 ExecutionContext* task_context) override;
339 bool RequestedMainFramePending() override;
340 ukm::UkmRecorder* MainFrameUkmRecorder() override;
341 ukm::SourceId MainFrameUkmSourceId() override;
342 bool IsMainFrameFullyLoaded() const override;
344 // WebFrameWidget overrides.
345 void InitializeNonCompositing(WebNonCompositedWidgetClient* client) override;
346 WebLocalFrame* LocalRoot() const override;
347 void UpdateCompositorScrollState(
348 const cc::CompositorCommitData& commit_data) override;
349 WebInputMethodController* GetActiveWebInputMethodController() const override;
350 void DisableDragAndDrop() override;
351 WebLocalFrameImpl* FocusedWebLocalFrameInWidget() const override;
352 bool ScrollFocusedEditableElementIntoView() override;
353 void ApplyViewportChangesForTesting(
354 const ApplyViewportChangesArgs& args) override;
355 void ApplyViewportIntersectionForTesting(
356 mojom::blink::ViewportIntersectionStatePtr intersection_state);
357 void NotifyPresentationTime(
358 base::OnceCallback<void(base::TimeTicks)> callback) override;
359 #if BUILDFLAG(IS_APPLE)
360 void NotifyCoreAnimationErrorCode(
361 base::OnceCallback<void(gfx::CALayerResult)> callback) override;
363 void WaitForDebuggerWhenShown() override;
364 void SetTextZoomFactor(float text_zoom_factor) override;
365 float TextZoomFactor() override;
366 void SetMainFrameOverlayColor(SkColor) override;
367 void AddEditCommandForNextKeyEvent(const WebString& name,
368 const WebString& value) override;
369 void ClearEditCommands() override;
370 bool IsPasting() override;
371 bool HandlingSelectRange() override;
372 void ReleaseMouseLockAndPointerCaptureForTesting() override;
373 const viz::FrameSinkId& GetFrameSinkId() override;
374 WebHitTestResult HitTestResultAt(const gfx::PointF&) override;
375 void SetZoomLevelForTesting(double zoom_level) override;
376 void ResetZoomLevelForTesting() override;
377 void SetDeviceScaleFactorForTesting(float factor) override;
378 FrameWidgetTestHelper* GetFrameWidgetTestHelperForTesting() override;
379 void PrepareForFinalLifecyclUpdateForTesting() override;
381 // Called when a drag-n-drop operation should begin.
382 virtual void StartDragging(LocalFrame* source_frame,
385 const SkBitmap& drag_image,
386 const gfx::Vector2d& cursor_offset,
387 const gfx::Rect& drag_obj_rect);
389 bool DoingDragAndDrop() { return doing_drag_and_drop_; }
390 static void SetIgnoreInputEvents(
391 const base::UnguessableToken& browsing_context_group_token,
393 static bool IgnoreInputEvents(
394 const base::UnguessableToken& browsing_context_group_token);
396 // Resets the layout tracking steps for the main frame. When
397 // `UpdateLifecycle()` is called it generates `WebMeaningfulLayout` events
398 // only once. This resets the state back to the default so it will fire new
400 void ResetMeaningfulLayoutStateForMainFrame();
402 // WebWidget overrides.
403 void InitializeCompositing(const display::ScreenInfos& screen_infos,
404 const cc::LayerTreeSettings* settings) override;
405 void InitializeCompositingFromPreviousWidget(
406 const display::ScreenInfos& screen_infos,
407 const cc::LayerTreeSettings* settings,
408 WebFrameWidget& previous_widget) override;
409 void SetCompositorVisible(bool visible) override;
410 gfx::Size Size() override;
411 void Resize(const gfx::Size& size_with_dsf) override;
412 void SetCursor(const ui::Cursor& cursor) override;
413 bool HandlingInputEvent() override;
414 void SetHandlingInputEvent(bool handling) override;
415 void ProcessInputEventSynchronouslyForTesting(
416 const WebCoalescedInputEvent&) override;
417 WebInputEventResult DispatchBufferedTouchEvents() override;
418 WebInputEventResult HandleInputEvent(const WebCoalescedInputEvent&) override;
419 void UpdateTextInputState() override;
420 void UpdateSelectionBounds() override;
421 void ShowVirtualKeyboard() override;
422 bool HasFocus() override;
423 void SetFocus(bool focus) override;
424 void FlushInputProcessedCallback() override;
425 void CancelCompositionForPepper() override;
426 void ApplyVisualProperties(
427 const VisualProperties& visual_properties) override;
428 bool PinchGestureActiveInMainFrame() override;
429 float PageScaleInMainFrame() override;
430 const display::ScreenInfo& GetScreenInfo() override;
431 const display::ScreenInfos& GetScreenInfos() override;
432 const display::ScreenInfo& GetOriginalScreenInfo() override;
433 const display::ScreenInfos& GetOriginalScreenInfos() override;
434 gfx::Rect WindowRect() override;
435 gfx::Rect ViewRect() override;
436 void SetScreenRects(const gfx::Rect& widget_screen_rect,
437 const gfx::Rect& window_screen_rect) override;
438 gfx::Size VisibleViewportSizeInDIPs() override;
439 bool IsHidden() const override;
440 WebString GetLastToolTipTextForTesting() const override;
441 float GetEmulatorScale() override;
443 // WidgetBaseClient overrides:
444 void OnCommitRequested() override;
445 void BeginMainFrame(base::TimeTicks last_frame_time) override;
446 void UpdateLifecycle(WebLifecycleUpdate requested_update,
447 DocumentUpdateReason reason) override;
449 // mojom::blink::FrameWidget overrides:
450 void ShowContextMenu(ui::mojom::MenuSourceType source_type,
451 const gfx::Point& location) override;
452 void SetViewportIntersection(
453 mojom::blink::ViewportIntersectionStatePtr intersection_state,
454 const absl::optional<VisualProperties>& visual_properties) override;
455 void DragSourceEndedAt(const gfx::PointF& point_in_viewport,
456 const gfx::PointF& screen_point,
457 ui::mojom::blink::DragOperation,
458 base::OnceClosure callback) override;
460 // mojom::blink::FrameWidgetInputHandler overrides:
461 void HandleStylusWritingGestureAction(
462 mojom::blink::StylusWritingGestureDataPtr gesture_data,
463 HandleStylusWritingGestureActionCallback callback) override;
465 // Sets the display mode, which comes from the top-level browsing context and
466 // is applied to all widgets.
467 void SetDisplayMode(mojom::blink::DisplayMode);
469 // Sets the window show state.
470 void SetWindowShowState(ui::WindowShowState);
472 void SetResizable(bool);
474 absl::optional<gfx::Point> GetAndResetContextMenuLocation();
476 void BindWidgetCompositor(
477 mojo::PendingReceiver<mojom::blink::WidgetCompositor> receiver) override;
479 void BindInputTargetClient(
480 mojo::PendingReceiver<viz::mojom::blink::InputTargetClient> receiver)
483 // viz::mojom::blink::InputTargetClient:
484 void FrameSinkIdAt(const gfx::PointF& point,
485 const uint64_t trace_id,
486 FrameSinkIdAtCallback callback) override;
488 // Called when the FrameView for this Widget's local root is created.
489 void DidCreateLocalRootView();
491 void SetZoomLevel(double zoom_level);
493 // Called when the View has auto resized.
494 virtual void DidAutoResize(const gfx::Size& size);
496 // This method returns the focused frame belonging to this WebWidget, that
497 // is, a focused frame with the same local root as the one corresponding
498 // to this widget. It will return nullptr if no frame is focused or, the
499 // focused frame has a different local root.
500 LocalFrame* FocusedLocalFrameInWidget() const;
502 // For when the embedder itself change scales on the page (e.g. devtools)
503 // and wants all of the content at the new scale to be crisp
504 void SetNeedsRecalculateRasterScales();
506 // Sets the background color to be filled in as gutter behind/around the
507 // painted content. Non-composited WebViews need not implement this, as they
508 // paint into another widget which has a background color of its own.
509 void SetBackgroundColor(SkColor color);
511 // Sets whether the prefers-reduced-motion hint has been enabled.
512 void SetPrefersReducedMotion(bool prefers_reduced_motion);
514 // Starts an animation of the page scale to a target scale factor and scroll
516 // If use_anchor is true, destination is a point on the screen that will
517 // remain fixed for the duration of the animation.
518 // If use_anchor is false, destination is the final top-left scroll position.
519 void StartPageScaleAnimation(const gfx::Point& destination,
521 float new_page_scale,
522 base::TimeDelta duration);
524 // Called to update if scroll events should be sent.
525 void SetHaveScrollEventHandlers(bool);
527 // Start deferring commits to the compositor, allowing document lifecycle
528 // updates without committing the layer tree. Commits are deferred
529 // until at most the given |timeout| has passed. If multiple calls are made
530 // when deferral is active then the initial timeout applies.
531 bool StartDeferringCommits(base::TimeDelta timeout,
532 cc::PaintHoldingReason reason);
533 // Immediately stop deferring commits.
534 void StopDeferringCommits(cc::PaintHoldingCommitTrigger);
536 // Pause all rendering (main and compositor thread) in the compositor.
537 [[nodiscard]] std::unique_ptr<cc::ScopedPauseRendering> PauseRendering();
539 // Returns the maximum bounds for buffers allocated for rasterization and
540 // compositing. This is is max texture size for GPU compositing and a browser
541 // chosen limit in software mode.
542 // Returns null if the compositing stack has not been initialized yet.
543 absl::optional<int> GetMaxRenderBufferBounds() const;
545 // Prevents any updates to the input for the layer tree, and the layer tree
546 // itself, and the layer tree from becoming visible.
547 std::unique_ptr<cc::ScopedDeferMainFrameUpdate> DeferMainFrameUpdate();
549 // Sets the amount that the top and bottom browser controls are showing, from
550 // 0 (hidden) to 1 (fully shown).
551 void SetBrowserControlsShownRatio(float top_ratio, float bottom_ratio);
553 // Set browser controls params. These params consist of top and bottom
554 // heights, min-heights, browser_controls_shrink_blink_size, and
555 // animate_browser_controls_height_changes. If
556 // animate_browser_controls_height_changes is set to true, changes to the
557 // browser controls height will be animated. If
558 // browser_controls_shrink_blink_size is set to true, then Blink shrunk the
559 // viewport clip layers by the top and bottom browser controls height. Top
560 // controls will translate the web page down and do not immediately scroll
561 // when hiding. The bottom controls scroll immediately and never translate the
562 // content (only clip it).
563 void SetBrowserControlsParams(cc::BrowserControlsParams params);
565 // This function provides zooming for find in page results when browsing with
567 void ZoomToFindInPageRect(const gfx::Rect& rect_in_root_frame);
569 // Return the compositor LayerTreeHost.
570 cc::LayerTreeHost* LayerTreeHostForTesting() const;
571 // Ask compositor to composite a frame for testing. This will generate a
572 // BeginMainFrame, and update the document lifecycle.
573 void SynchronouslyCompositeForTesting(base::TimeTicks frame_time);
575 // Sets the device color space for testing.
576 void SetDeviceColorSpaceForTesting(const gfx::ColorSpace& color_space);
578 // Converts from DIPs to Blink coordinate space (ie. Viewport/Physical
580 gfx::Size DIPsToCeiledBlinkSpace(const gfx::Size& size);
582 void SetWindowRect(const gfx::Rect& requested_rect,
583 const gfx::Rect& adjusted_rect);
584 void SetWindowRectSynchronouslyForTesting(const gfx::Rect& new_window_rect);
586 void UpdateTooltipUnderCursor(const String& tooltip_text, TextDirection dir);
587 void UpdateTooltipFromKeyboard(const String& tooltip_text,
589 const gfx::Rect& bounds);
590 void ClearKeyboardTriggeredTooltip();
592 void ShowVirtualKeyboardOnElementFocus();
593 #if BUILDFLAG(IS_EFL)
594 void DidUpdateTextOfFocusedElementByNonUserInput();
596 void ProcessTouchAction(WebTouchAction touch_action);
597 void SetPanAction(mojom::blink::PanAction pan_action);
599 // Called to update whether low latency input mode is enabled or not.
600 void SetNeedsLowLatencyInput(bool);
602 // Requests unbuffered (ie. low latency) input until a pointerup
604 void RequestUnbufferedInputEvents();
606 // Requests unbuffered (ie. low latency) input due to debugger being
607 // attached. Debugger needs to paint when stopped in the event handler.
608 void SetNeedsUnbufferedInputForDebugger(bool);
610 // Called when the main frame navigates.
613 // Ensures all queued input in the widget has been processed and the queues
615 void FlushInputForTesting(base::OnceClosure done_callback);
617 // Called when the widget should get targeting input.
618 void SetMouseCapture(bool capture);
620 // Sets the current page scale factor and minimum / maximum limits. Both
621 // limits are initially 1 (no page scale allowed).
622 void SetPageScaleStateAndLimits(float page_scale_factor,
623 bool is_pinch_gesture_active,
626 void UpdateViewportDescription(
627 const ViewportDescription& viewport_description);
629 const viz::LocalSurfaceId& LocalSurfaceIdFromParent();
631 ScreenMetricsEmulator* DeviceEmulator();
633 // Calculates the selection bounds in the root frame. Returns bounds unchanged
634 // when there is no focused frame or no selection.
635 void CalculateSelectionBounds(
636 gfx::Rect& anchor_in_root_frame,
637 gfx::Rect& focus_in_root_frame,
638 gfx::Rect* bounding_box_in_root_frame = nullptr);
640 // Returns if auto resize mode is enabled.
641 bool AutoResizeMode();
643 void SetScreenMetricsEmulationParameters(
645 const blink::DeviceEmulationParams& params);
646 void SetScreenInfoAndSize(const display::ScreenInfos& screen_infos,
647 const gfx::Size& widget_size,
648 const gfx::Size& visible_viewport_size);
650 // Update the surface allocation information, compositor viewport rect and
651 // screen info on the widget.
652 void UpdateSurfaceAndScreenInfo(
653 const viz::LocalSurfaceId& new_local_surface_id,
654 const gfx::Rect& compositor_viewport_pixel_rect,
655 const display::ScreenInfos& screen_infos);
656 // Similar to UpdateSurfaceAndScreenInfo but the surface allocation
657 // and compositor viewport rect remains the same.
658 void UpdateScreenInfo(const display::ScreenInfos& screen_infos);
659 void UpdateSurfaceAndCompositorRect(
660 const viz::LocalSurfaceId& new_local_surface_id,
661 const gfx::Rect& compositor_viewport_pixel_rect);
662 void UpdateCompositorViewportRect(
663 const gfx::Rect& compositor_viewport_pixel_rect);
664 void SetWindowSegments(const std::vector<gfx::Rect>& window_segments);
665 viz::FrameSinkId GetFrameSinkIdAtPoint(const gfx::PointF& point,
666 gfx::PointF* local_point);
668 // Set the pending window rect. For every SetPendingWindowRect
669 // call there must be an AckPendingWindowRect call.
670 void SetPendingWindowRect(const gfx::Rect& window_screen_rect);
672 // Clear a previously set pending window rect. For every SetPendingWindowRect
673 // call there must be an AckPendingWindowRect call.
674 void AckPendingWindowRect();
676 // Return the focused WebPlugin if there is one.
677 WebPlugin* GetFocusedPluginContainer();
679 // Return if there is a pending scale animation.
680 bool HasPendingPageScaleAnimation();
682 // Set the source URL for the compositor.
683 void SetSourceURLForCompositor(ukm::SourceId source_id, const KURL& url);
685 // Ask compositor to create the shared memory for smoothness ukm region.
686 base::ReadOnlySharedMemoryRegion CreateSharedMemoryForSmoothnessUkm();
688 #if BUILDFLAG(IS_EFL)
689 void NotifyKeyEvent(WebInputEvent::Type type, bool processed) override;
692 #if BUILDFLAG(IS_TIZEN)
693 void SetMaxRefreshRate(uint32_t max_refresh_rate) override;
695 void SetDrawsTransparentBackground(
696 bool draws_transparent_background) override;
698 void SetBackgroundColor(int32_t red,
701 int32_t alpha) override;
704 #if BUILDFLAG(IS_TIZEN)
705 void DidChangeLoadState(bool is_loading) override;
708 // Calculate and cache the most up to date line bounding boxes in the document
710 Vector<gfx::Rect> CalculateVisibleLineBoundsOnScreen();
712 #if BUILDFLAG(IS_TIZEN_TV)
713 void NotifyTrackInfoToBrowser(int active_track_id,
714 const std::string& url,
715 const std::string& lang);
716 void MoveFocusToBrowser(int direction);
720 // WidgetBaseClient overrides:
721 void WillBeginMainFrame() override;
722 void ScheduleAnimation() override;
723 void DidBeginMainFrame() override;
724 std::unique_ptr<cc::LayerTreeFrameSink> AllocateNewLayerTreeFrameSink()
726 void WasShown(bool was_evicted) override;
728 // Whether compositing to LCD text should be auto determined. This can be
729 // overridden by tests to disable this.
730 virtual bool ShouldAutoDetermineCompositingToLCDTextSetting();
732 WidgetBase* widget_base_for_testing() const { return widget_base_.get(); }
734 // WebFrameWidget overrides.
735 cc::LayerTreeHost* LayerTreeHost() override;
737 // Determines whether the drag source is currently dragging.
738 bool doing_drag_and_drop_ = false;
741 friend class WebViewImpl;
742 friend class ReportTimeSwapPromise;
744 void NotifySwapAndPresentationTime(PromiseCallbacks callbacks);
746 // WidgetBaseClient overrides.
747 void BeginCommitCompositorFrame() override;
748 void EndCommitCompositorFrame(base::TimeTicks commit_start_time,
749 base::TimeTicks commit_finish_time) override;
750 void ApplyViewportChanges(const cc::ApplyViewportChangesArgs& args) override;
751 void RecordDispatchRafAlignedInputTime(
752 base::TimeTicks raf_aligned_input_start_time) override;
753 void SetSuppressFrameRequestsWorkaroundFor704763Only(bool) override;
754 void RecordStartOfFrameMetrics() override;
755 void RecordEndOfFrameMetrics(
757 cc::ActiveFrameSequenceTrackers trackers) override;
758 std::unique_ptr<cc::BeginMainFrameMetrics> GetBeginMainFrameMetrics()
760 std::unique_ptr<cc::WebVitalMetrics> GetWebVitalMetrics() override;
761 void BeginUpdateLayers() override;
762 void EndUpdateLayers() override;
763 void DidCommitAndDrawCompositorFrame() override;
764 void DidObserveFirstScrollDelay(
765 base::TimeDelta first_scroll_delay,
766 base::TimeTicks first_scroll_timestamp) override;
767 void DidCompletePageScaleAnimation() override;
768 void FocusChangeComplete() override;
769 void WillHandleGestureEvent(const WebGestureEvent& event,
770 bool* suppress) override;
771 void WillHandleMouseEvent(const WebMouseEvent& event) override;
772 void ObserveGestureEventAndResult(
773 const WebGestureEvent& gesture_event,
774 const gfx::Vector2dF& unused_delta,
775 const cc::OverscrollBehavior& overscroll_behavior,
776 bool event_processed) override;
777 bool SupportsBufferedTouchEvents() override { return true; }
778 void DidHandleKeyEvent() override;
779 WebTextInputType GetTextInputType() override;
780 void SetCursorVisibilityState(bool is_visible) override;
781 blink::FrameWidget* FrameWidget() override { return this; }
782 void FocusChanged(mojom::blink::FocusState focus_state) override;
783 bool ShouldAckSyntheticInputImmediately() override;
784 void UpdateVisualProperties(
785 const VisualProperties& visual_properties) override;
786 bool UpdateScreenRects(const gfx::Rect& widget_screen_rect,
787 const gfx::Rect& window_screen_rect) override;
788 #if BUILDFLAG(IS_EFL)
789 void GetContentSnapshot(const gfx::Rect& snapshot_rect,
790 float page_scale_factor,
791 SkBitmap* snapshot) override;
792 SkColor GetBackgroundColor() override;
793 gfx::RectF UpdateFocusedNodeBounds() override;
794 void SetLongPollingGlobalTimeout(uint64_t timeout) override;
795 void ResetLastInteractedElements() override;
796 void PrintToPdf(uint32_t width,
798 const base::FilePath& filename) override;
799 void SetMainFrameScrollbarVisible(bool visible) override;
800 bool RequestMainFrameScrollbarVisible(bool& visible) override;
801 bool QueryInputType() override;
802 void SelectClosestWord(uint32_t x, uint32_t y) override;
803 void SelectFocusedLink() override;
804 gfx::Rect RequestSelectionRect() override;
805 #if BUILDFLAG(IS_TIZEN_TV)
806 void SetFloatVideoWindowState(bool enabled) override;
807 void SuspendNetworkLoading() override;
808 void ResumeNetworkLoading() override;
812 #if BUILDFLAG(IS_TIZEN)
813 void PauseScheduledTasks() override;
814 void UnPauseScheduledTasks() override;
817 void OrientationChanged() override;
818 void DidUpdateSurfaceAndScreen(
819 const display::ScreenInfos& previous_original_screen_infos) override;
820 gfx::Rect ViewportVisibleRect() override;
821 absl::optional<display::mojom::blink::ScreenOrientation>
822 ScreenOrientationOverride() override;
823 void WasHidden() override;
824 void RunPaintBenchmark(int repeat_count,
825 cc::PaintBenchmarkResult& result) override;
826 KURL GetURLForDebugTrace() override;
827 float GetTestingDeviceScaleFactorOverride() override;
828 void CountDroppedPointerDownForEventTiming(unsigned count) override;
829 // mojom::blink::FrameWidget overrides.
830 void DragTargetDragEnter(const WebDragData&,
831 const gfx::PointF& point_in_viewport,
832 const gfx::PointF& screen_point,
833 DragOperationsMask operations_allowed,
834 uint32_t key_modifiers,
835 DragTargetDragEnterCallback callback) override;
836 void DragTargetDragOver(const gfx::PointF& point_in_viewport,
837 const gfx::PointF& screen_point,
838 DragOperationsMask operations_allowed,
839 uint32_t key_modifiers,
840 DragTargetDragOverCallback callback) override;
841 void DragTargetDragLeave(const gfx::PointF& point_in_viewport,
842 const gfx::PointF& screen_point) override;
843 void DragTargetDrop(const WebDragData&,
844 const gfx::PointF& point_in_viewport,
845 const gfx::PointF& screen_point,
846 uint32_t key_modifiers,
847 base::OnceClosure callback) override;
848 void DragSourceSystemDragEnded() override;
849 void OnStartStylusWriting(OnStartStylusWritingCallback callback) override;
850 void SetBackgroundOpaque(bool opaque) override;
851 void SetActive(bool active) override;
852 // For both mainframe and childframe change the text direction of the
853 // currently selected input field (if any).
854 void SetTextDirection(base::i18n::TextDirection direction) override;
855 // Sets the inherited effective touch action on an out-of-process iframe.
856 void SetInheritedEffectiveTouchActionForSubFrame(
857 WebTouchAction touch_action) override;
858 // Toggles render throttling for an out-of-process iframe. Local frames are
859 // throttled based on their visibility in the viewport, but remote frames
860 // have to have throttling information propagated from parent to child
862 void UpdateRenderThrottlingStatusForSubFrame(bool is_throttled,
863 bool subtree_throttled,
864 bool display_locked) override;
865 void EnableDeviceEmulation(const DeviceEmulationParams& parameters) override;
866 void DisableDeviceEmulation() override;
867 // Sets the inert bit on an out-of-process iframe, causing it to ignore
869 void SetIsInertForSubFrame(bool inert) override;
870 #if BUILDFLAG(IS_MAC)
871 void GetStringAtPoint(const gfx::Point& point_in_local_root,
872 GetStringAtPointCallback callback) override;
875 #if BUILDFLAG(IS_TIZEN_TV)
876 //Browser edge scroll
877 void EdgeScrollBy(const gfx::Point& offset, const gfx::Point& mouse_position) override;
878 // notify web browser video playing status
879 bool IsVideoPlaying() override;
880 void SetTranslatedURL(const WTF::String& url) override;
881 void SetParentalRatingResult(const WTF::String& url, bool is_pass) override;
882 void SetPreferSubtitleLang(const WTF::String lang_list) override;
885 // mojom::blink::FrameWidgetInputHandler overrides.
886 void AddImeTextSpansToExistingText(
889 const Vector<ui::ImeTextSpan>& ime_text_spans) override;
890 void ClearImeTextSpansByType(uint32_t start,
892 ui::ImeTextSpan::Type type) override;
893 void SetCompositionFromExistingText(
896 const Vector<ui::ImeTextSpan>& ime_text_spans) override;
897 void ExtendSelectionAndDelete(int32_t before, int32_t after) override;
898 void ExtendSelectionAndReplace(uint32_t before,
900 const String& replacement_text) override;
901 void DeleteSurroundingText(int32_t before, int32_t after) override;
902 void DeleteSurroundingTextInCodePoints(int32_t before,
903 int32_t after) override;
904 void SetEditableSelectionOffsets(int32_t start, int32_t end) override;
905 void ExecuteEditCommand(const String& command, const String& value) override;
906 void Undo() override;
907 void Redo() override;
909 void Copy() override;
910 void CopyToFindPboard() override;
911 void CenterSelection() override;
912 void Paste() override;
913 void PasteAndMatchStyle() override;
914 void Delete() override;
915 void SelectAll() override;
916 void CollapseSelection() override;
917 void Replace(const String& word) override;
918 void ReplaceMisspelling(const String& word) override;
919 void SelectRange(const gfx::Point& base_in_dips,
920 const gfx::Point& extent_in_dips) override;
921 void AdjustSelectionByCharacterOffset(
924 mojom::blink::SelectionMenuBehavior behavior) override;
925 void MoveRangeSelectionExtent(const gfx::Point& extent_in_dips) override;
926 void ScrollFocusedEditableNodeIntoView() override;
927 void WaitForPageScaleAnimationForTesting(
928 WaitForPageScaleAnimationForTestingCallback callback) override;
929 void MoveCaret(const gfx::Point& point_in_dips) override;
930 void SelectAroundCaret(mojom::blink::SelectionGranularity granularity,
931 bool should_show_handle,
932 bool should_show_context_menu,
933 SelectAroundCaretCallback callback) override;
935 // PageWidgetEventHandler overrides:
936 WebInputEventResult HandleKeyEvent(const WebKeyboardEvent&) override;
937 void HandleMouseDown(LocalFrame&, const WebMouseEvent&) override;
938 void HandleMouseLeave(LocalFrame&, const WebMouseEvent&) override;
939 WebInputEventResult HandleMouseUp(LocalFrame&, const WebMouseEvent&) override;
940 WebInputEventResult HandleGestureEvent(const WebGestureEvent&) override;
941 WebInputEventResult HandleMouseWheel(LocalFrame&,
942 const WebMouseWheelEvent&) override;
943 WebInputEventResult HandleCharEvent(const WebKeyboardEvent&) override;
945 WebInputEventResult HandleCapturedMouseEvent(const WebCoalescedInputEvent&);
946 void MouseContextMenu(const WebMouseEvent&);
948 void PresentationCallbackForMeaningfulLayout(base::TimeTicks);
950 void ForEachRemoteFrameControlledByWidget(
951 base::FunctionRef<void(RemoteFrame*)> callback);
953 void SetWindowRectSynchronously(const gfx::Rect& new_window_rect);
955 void SendOverscrollEventFromImplSide(const gfx::Vector2dF& overscroll_delta,
956 cc::ElementId scroll_latched_element_id);
957 void SendScrollEndEventFromImplSide(bool affects_outer_viewport,
958 cc::ElementId scroll_latched_element_id);
960 void RecordManipulationTypeCounts(cc::ManipulationInfo info);
962 enum DragAction { kDragEnter, kDragOver };
963 // Consolidate some common code between starting a drag over a target and
964 // updating a drag over a target. If we're starting a drag, |isEntering|
966 void DragTargetDragEnterOrOver(const gfx::PointF& point_in_viewport,
967 const gfx::PointF& screen_point,
969 uint32_t key_modifiers);
971 // Helper function to call VisualViewport::viewportToRootFrame().
972 gfx::PointF ViewportToRootFrame(const gfx::PointF& point_in_viewport) const;
974 WebViewImpl* View() const;
976 // Returns the page object associated with this widget. This may be null when
977 // the page is shutting down, but will be valid at all other times.
978 Page* GetPage() const;
980 mojom::blink::FrameWidgetHost* GetAssociatedFrameWidgetHost() const;
982 void InitializeCompositingInternal(const display::ScreenInfos& screen_infos,
983 const cc::LayerTreeSettings* settings,
984 WebFrameWidget* previous_widget);
986 // Notifies RenderWidgetHostImpl that the frame widget has painted something.
987 void DidMeaningfulLayout(WebMeaningfulLayout layout_type);
989 // Enable or disable auto-resize. This is part of
990 // UpdateVisualProperties though tests may call to it more directly.
991 void SetAutoResizeMode(bool auto_resize,
992 const gfx::Size& min_size_before_dsf,
993 const gfx::Size& max_size_before_dsf,
994 float device_scale_factor);
996 void ApplyViewportIntersection(
997 mojom::blink::ViewportIntersectionStatePtr intersection_state);
999 // Called when a gesture event has been processed.
1000 void DidHandleGestureEvent(const WebGestureEvent& event);
1002 // Called to update if pointerrawupdate events should be sent.
1003 void SetHasPointerRawUpdateEventHandlers(bool);
1005 // Helper function to process events while pointer locked.
1006 void PointerLockMouseEvent(const WebCoalescedInputEvent&);
1007 bool IsPointerLocked();
1009 // The fullscreen granted status from the most recent VisualProperties update.
1010 bool IsFullscreenGranted();
1012 // Set the compositing scale factor for this widget and notify remote frames
1013 // to update their compositing scale factor.
1014 void NotifyCompositingScaleFactorChanged(float compositing_scale_factor);
1016 void NotifyPageScaleFactorChanged(float page_scale_factor,
1017 bool is_pinch_gesture_active);
1019 // Helper for notifying frame-level objects that care about input events.
1020 // TODO: With some effort, this could be folded into a common implementation
1021 // of WebViewImpl::HandleInputEvent and WebFrameWidgetImpl::HandleInputEvent.
1022 void NotifyInputObservers(const WebCoalescedInputEvent& coalesced_event);
1024 Frame* FocusedCoreFrame() const;
1026 // Returns the currently focused `Element` in any `LocalFrame` owned by the
1027 // associated `WebView`.
1028 Element* FocusedElement() const;
1030 gfx::Rect GetAbsoluteCaretBounds();
1032 // Perform a hit test for a point relative to the root frame of the page.
1033 HitTestResult HitTestResultForRootFramePos(
1034 const gfx::PointF& pos_in_root_frame);
1036 // Called during |UpdateVisualProperties| to apply the new size to the widget.
1037 void ApplyVisualPropertiesSizing(const VisualProperties& visual_properties);
1039 // Returns true iff the visual property state contains an update that will
1040 // change the fullscreen state (e.g. on/off or current display).
1041 bool DidChangeFullscreenState(
1042 const VisualProperties& visual_properties) const;
1044 void NotifyZoomLevelChanged(LocalFrame* root);
1046 // Satisfy the render blocking condition for cross-document view transitions.
1047 void NotifyViewTransitionRenderingHasBegun();
1049 // True when `this` should ignore input events.
1050 bool ShouldIgnoreInputEvents();
1052 // Stores the current composition line bounds. These bounds are rectangles
1053 // which surround each line of text in a currently focused input or textarea
1055 Vector<gfx::Rect> input_visible_line_bounds_;
1057 // A copy of the web drop data object we received from the browser.
1058 Member<DataObject> current_drag_data_;
1060 // The available drag operations (copy, move link...) allowed by the source.
1061 DragOperationsMask operations_allowed_ = kDragOperationNone;
1063 // The current drag operation as negotiated by the source and destination.
1064 // When not equal to DragOperationNone, the drag data can be dropped onto the
1065 // current drop target in this WebView (the drop target can accept the drop).
1066 DragController::Operation drag_operation_;
1068 // This field stores drag/drop related info for the event that is currently
1069 // being handled. If the current event results in starting a drag/drop
1070 // session, this info is sent to the browser along with other drag/drop info.
1071 mojom::blink::DragEventSourceInfo possible_drag_event_info_;
1073 // Base functionality all widgets have. This is a member as to avoid
1074 // complicated inheritance structures.
1075 std::unique_ptr<WidgetBase> widget_base_;
1077 // Compositing scale factor for all frames attached to this widget sent from
1078 // the remote parent frame.
1079 float compositing_scale_factor_ = 1.f;
1081 // The last seen page scale state, which comes from the main frame if we're
1082 // in a child frame. This state is propagated through the RenderWidget tree
1083 // passed to any new child RenderWidget.
1084 float page_scale_factor_in_mainframe_ = 1.f;
1085 bool is_pinch_gesture_active_in_mainframe_ = false;
1087 // If set, the (plugin) element which has mouse capture.
1088 Member<HTMLPlugInElement> mouse_capture_element_;
1090 // The size of the widget in viewport coordinates. This is slightly different
1091 // than the WebViewImpl::size_ since isn't set in auto resize mode.
1092 absl::optional<gfx::Size> size_;
1094 // The amount the top-most widget has been resized by the virtual keyboard,
1095 // in physical pixels.
1096 int virtual_keyboard_resize_height_physical_px_ = 0;
1098 static bool ignore_input_events_;
1100 const viz::FrameSinkId frame_sink_id_;
1102 // WebFrameWidget is associated with a subtree of the frame tree,
1103 // corresponding to a maximal connected tree of LocalFrames. This member
1104 // points to the root of that subtree.
1105 Member<WebLocalFrameImpl> local_root_;
1107 mojom::blink::DisplayMode display_mode_;
1108 ui::WindowShowState window_show_state_;
1111 WebVector<gfx::Rect> window_segments_;
1113 // This is owned by the LayerTreeHostImpl, and should only be used on the
1114 // compositor thread, so we keep the TaskRunner where you post tasks to
1115 // make that happen.
1116 base::WeakPtr<AnimationWorkletMutatorDispatcherImpl> mutator_dispatcher_;
1117 scoped_refptr<base::SingleThreadTaskRunner> mutator_task_runner_;
1119 // The |paint_dispatcher_| should only be dereferenced on the
1120 // |paint_task_runner_| (in practice this is the compositor thread). We keep a
1121 // copy of it here to provide to new PaintWorkletProxyClient objects (which
1122 // run on the worklet thread) so that they can talk to the
1123 // PaintWorkletPaintDispatcher on the compositor thread.
1124 base::WeakPtr<PaintWorkletPaintDispatcher> paint_dispatcher_;
1125 scoped_refptr<base::SingleThreadTaskRunner> paint_task_runner_;
1127 // WebFrameWidgetImpl is not tied to ExecutionContext
1128 HeapMojoAssociatedRemote<mojom::blink::FrameWidgetHost> frame_widget_host_{
1130 // WebFrameWidgetImpl is not tied to ExecutionContext
1131 HeapMojoAssociatedReceiver<mojom::blink::FrameWidget, WebFrameWidgetImpl>
1132 receiver_{this, nullptr};
1133 HeapMojoReceiver<viz::mojom::blink::InputTargetClient, WebFrameWidgetImpl>
1134 input_target_receiver_{this, nullptr};
1136 // Different consumers in the browser process makes different assumptions, so
1137 // must always send the first IPC regardless of value.
1138 absl::optional<bool> has_touch_handlers_;
1140 Vector<mojom::blink::EditCommandPtr> edit_commands_;
1142 absl::optional<gfx::Point> host_context_menu_location_;
1143 uint32_t last_capture_sequence_number_ = 0u;
1145 // Indicates whether tab-initiated fullscreen was granted.
1146 bool is_fullscreen_granted_ = false;
1148 // Indicates whether we need to consume scroll gestures to move cursor.
1149 bool swipe_to_move_cursor_activated_ = false;
1151 // Set when a measurement begins, reset when the measurement is taken.
1152 absl::optional<base::TimeTicks> update_layers_start_time_;
1154 // Metrics for gathering time for commit of compositor frame.
1155 absl::optional<base::TimeTicks> commit_compositor_frame_start_time_;
1156 absl::optional<base::TimeTicks> next_commit_compositor_frame_start_time_;
1158 // Present when emulation is enabled, only on a main frame's WebFrameWidget.
1159 // Used to override values given from the browser such as ScreenInfo,
1160 // WidgetScreenRect, WindowScreenRect, and the widget's size.
1161 Member<ScreenMetricsEmulator> device_emulator_;
1163 Member<AnimationFrameTimingMonitor> animation_frame_timing_monitor_;
1165 // keyPress events to be suppressed if the associated keyDown event was
1167 bool suppress_next_keypress_event_ = false;
1169 // Whether drag and drop is supported by this widget. When disabled
1170 // any drag operation that is started will be canceled immediately.
1171 bool drag_and_drop_disabled_ = false;
1173 // A callback client for non-composited frame widgets.
1174 WebNonCompositedWidgetClient* non_composited_client_ = nullptr;
1176 // This struct contains data that is only valid for child local root widgets.
1177 // You should use `child_data()` to access it.
1178 struct ChildLocalRootData {
1179 gfx::Rect compositor_visible_rect;
1180 bool did_suspend_parsing = false;
1181 } child_local_root_data_;
1183 ChildLocalRootData& child_data() {
1184 DCHECK(ForSubframe());
1185 return child_local_root_data_;
1188 // Web tests override the zoom factor in the renderer with this. We store it
1189 // to keep the override if the browser passes along VisualProperties with the
1190 // real device scale factor. A value of -INFINITY means this is ignored.
1191 // It is always valid to read this variable but it can only be set for main
1193 double zoom_level_for_testing_ = -INFINITY;
1195 // Web tests override the device scale factor in the renderer with this. We
1196 // store it to keep the override if the browser passes along VisualProperties
1197 // with the real device scale factor. A value of 0.f means this is ignored.
1198 // It is always valid to read this variable but it can only be set for main
1200 float device_scale_factor_for_testing_ = 0;
1202 // This struct contains data that is only valid for main frame widgets.
1203 // You should use `main_data()` to access it.
1204 struct MainFrameData {
1205 // `UpdateLifecycle()` generates `WebMeaningfulLayout` events these
1206 // variables track what events should be generated. They are only applicable
1207 // for main frame widgets.
1208 bool should_dispatch_first_visually_non_empty_layout = false;
1209 bool should_dispatch_first_layout_after_finished_parsing = false;
1210 bool should_dispatch_first_layout_after_finished_loading = false;
1211 // Last background color sent to the browser. Only set for main frames.
1212 absl::optional<SkColor> last_background_color;
1213 // This bit is used to tell if this is a nested widget (an "inner web
1214 // contents") like a <webview> or <portal> widget. If false, the widget is
1215 // the top level widget.
1216 bool is_for_nested_main_frame = false;
1219 MainFrameData& main_data() {
1220 DCHECK(ForMainFrame());
1221 return main_frame_data_;
1224 const MainFrameData& main_data() const {
1225 DCHECK(ForMainFrame());
1226 return main_frame_data_;
1229 // Whether this widget is for a child local root, or otherwise a main frame.
1230 // Prefer using |ForSubframe()| for distinguishing subframes and
1231 // |widget_base_.is_embedded()| for subframes and embedded main frames (i.e.,
1232 // all embedded scenarios).
1233 const bool is_for_child_local_root_;
1235 // Whether this widget is for a portal, guest view, or top level frame.
1236 // These may have a page scale node, so it is important to plumb this
1237 // information through to avoid breaking assumptions.
1238 const bool is_for_scalable_page_;
1240 WaitForPageScaleAnimationForTestingCallback
1241 page_scale_animation_for_testing_callback_;
1243 // This stores the last hidden page popup. If a GestureTap attempts to open
1244 // the popup that is closed by its previous GestureTapDown, the popup remains
1246 scoped_refptr<WebPagePopupImpl> last_hidden_page_popup_;
1248 base::WeakPtrFactory<mojom::blink::FrameWidgetInputHandler>
1249 input_handler_weak_ptr_factory_{this};
1252 } // namespace blink
1254 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_WEB_FRAME_WIDGET_IMPL_H_