[M120 Migration] Fix show IME
[platform/framework/web/chromium-efl.git] / third_party / blink / renderer / core / exported / web_view_impl.h
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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
13  * distribution.
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.
17  *
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.
29  */
30
31 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_VIEW_IMPL_H_
32 #define THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_VIEW_IMPL_H_
33
34 #include <memory>
35
36 #include "base/gtest_prod_util.h"
37 #include "base/memory/scoped_refptr.h"
38 #include "base/observer_list.h"
39 #include "build/build_config.h"
40 #include "mojo/public/cpp/bindings/associated_receiver.h"
41 #include "mojo/public/cpp/bindings/associated_remote.h"
42 #include "mojo/public/cpp/bindings/remote_set.h"
43 #include "third_party/blink/public/common/input/web_gesture_event.h"
44 #include "third_party/blink/public/common/input/web_input_event.h"
45 #include "third_party/blink/public/common/page/browsing_context_group_info.h"
46 #include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
47 #include "third_party/blink/public/common/tokens/tokens.h"
48 #include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
49 #include "third_party/blink/public/mojom/frame/remote_frame.mojom-blink.h"
50 #include "third_party/blink/public/mojom/input/focus_type.mojom-blink-forward.h"
51 #include "third_party/blink/public/mojom/page/page.mojom-blink.h"
52 #include "third_party/blink/public/mojom/page/page_visibility_state.mojom-blink.h"
53 #include "third_party/blink/public/mojom/renderer_preference_watcher.mojom-blink.h"
54 #include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
55 #include "third_party/blink/public/platform/web_input_event_result.h"
56 #include "third_party/blink/public/platform/web_string.h"
57 #include "third_party/blink/public/platform/web_vector.h"
58 #include "third_party/blink/public/web/web_frame_widget.h"
59 #include "third_party/blink/public/web/web_navigation_policy.h"
60 #include "third_party/blink/public/web/web_view.h"
61 #include "third_party/blink/public/web/web_view_observer.h"
62 #include "third_party/blink/renderer/core/core_export.h"
63 #include "third_party/blink/renderer/core/exported/web_page_popup_impl.h"
64 #include "third_party/blink/renderer/core/frame/resize_viewport_anchor.h"
65 #include "third_party/blink/renderer/core/loader/navigation_policy.h"
66 #include "third_party/blink/renderer/core/page/chrome_client.h"
67 #include "third_party/blink/renderer/core/page/context_menu_provider.h"
68 #include "third_party/blink/renderer/core/page/event_with_hit_test_results.h"
69 #include "third_party/blink/renderer/core/page/scoped_page_pauser.h"
70 #include "third_party/blink/renderer/platform/graphics/apply_viewport_changes.h"
71 #include "third_party/blink/renderer/platform/graphics/touch_action.h"
72 #include "third_party/blink/renderer/platform/heap/member.h"
73 #include "third_party/blink/renderer/platform/weborigin/kurl.h"
74 #include "third_party/blink/renderer/platform/wtf/hash_set.h"
75 #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
76 #include "third_party/blink/renderer/platform/wtf/vector.h"
77 #include "ui/base/ime/mojom/virtual_keyboard_types.mojom-blink.h"
78 #include "ui/gfx/geometry/point.h"
79 #include "ui/gfx/geometry/rect.h"
80 #include "ui/gfx/geometry/vector2d_f.h"
81
82 namespace cc {
83 class ScopedDeferMainFrameUpdate;
84 }
85
86 namespace blink {
87
88 namespace frame_test_helpers {
89 class WebViewHelper;
90 }
91
92 class BrowserControls;
93 class DevToolsEmulator;
94 class Frame;
95 class FullscreenController;
96 class PageScaleConstraintsSet;
97 class WebDevToolsAgentImpl;
98 class WebLocalFrame;
99 class WebLocalFrameImpl;
100 class WebSettingsImpl;
101 class WebViewClient;
102 class WebFrameWidgetImpl;
103
104 enum class FullscreenRequestType;
105
106 namespace mojom {
107 namespace blink {
108 class TextAutosizerPageInfo;
109 }
110 }  // namespace mojom
111
112 using PaintHoldingCommitTrigger = cc::PaintHoldingCommitTrigger;
113
114 class CORE_EXPORT WebViewImpl final : public WebView,
115                                       public RefCounted<WebViewImpl>,
116                                       public mojom::blink::PageBroadcast {
117  public:
118   static WebViewImpl* Create(
119       WebViewClient*,
120       mojom::blink::PageVisibilityState visibility,
121       bool is_prerendering,
122       bool is_inside_portal,
123       absl::optional<blink::FencedFrame::DeprecatedFencedFrameMode>
124           fenced_frame_mode,
125       bool compositing_enabled,
126       bool widgets_never_composited,
127       WebViewImpl* opener,
128       mojo::PendingAssociatedReceiver<mojom::blink::PageBroadcast> page_handle,
129       scheduler::WebAgentGroupScheduler& agent_group_scheduler,
130       const SessionStorageNamespaceId& session_storage_namespace_id,
131       absl::optional<SkColor> page_base_background_color,
132       const BrowsingContextGroupInfo& browsing_context_group_info);
133
134   // All calls to Create() should be balanced with a call to Close(). This
135   // synchronously destroys the WebViewImpl.
136   void Close() override;
137   static HashSet<WebViewImpl*>& AllInstances();
138   // Returns true if popup menus should be rendered by the browser, false if
139   // they should be rendered by WebKit (which is the default).
140   static bool UseExternalPopupMenus();
141
142   // Returns whether frames under this WebView are backed by a compositor.
143   bool does_composite() const { return does_composite_; }
144
145   // WebView methods:
146   void DidAttachLocalMainFrame() override;
147   void DidDetachLocalMainFrame() override;
148   void DidAttachRemoteMainFrame(
149       CrossVariantMojoAssociatedRemote<
150           mojom::blink::RemoteMainFrameHostInterfaceBase>,
151       CrossVariantMojoAssociatedReceiver<
152           mojom::blink::RemoteMainFrameInterfaceBase>) override;
153   void DidDetachRemoteMainFrame() override;
154   void SetNoStatePrefetchClient(WebNoStatePrefetchClient*) override;
155   WebSettings* GetSettings() override;
156   WebString PageEncoding() const override;
157 #if BUILDFLAG(IS_EFL)
158   bool MoveFocusToNext(
159       TraverseFocusThrough =
160           TraverseFocusThrough::EditableAndSelectElements) override;
161   bool MoveFocusToPrevious(
162       TraverseFocusThrough =
163           TraverseFocusThrough::EditableAndSelectElements) override;
164 #endif
165   void SetTabKeyCyclesThroughElements(bool value) override;
166   bool IsActive() const override;
167   void SetIsActive(bool value) override;
168   void SetWindowFeatures(const WebWindowFeatures&) override;
169   void SetOpenedByDOM() override;
170   WebFrame* MainFrame() override;
171   const WebFrame* MainFrame() const override;
172   WebLocalFrame* FocusedFrame() override;
173   void SetFocusedFrame(WebFrame*) override;
174   void SmoothScroll(int target_x,
175                     int target_y,
176                     base::TimeDelta duration) override;
177   void AdvanceFocus(bool reverse) override;
178   double ZoomLevel() override;
179   double SetZoomLevel(double) override;
180   float PageScaleFactor() const override;
181   float MinimumPageScaleFactor() const override;
182   float MaximumPageScaleFactor() const override;
183   void SetDefaultPageScaleLimits(float min_scale, float max_scale) override;
184   void SetInitialPageScaleOverride(float) override;
185   void SetPageScaleFactor(float) override;
186   void SetVisualViewportOffset(const gfx::PointF&) override;
187   gfx::PointF VisualViewportOffset() const override;
188   gfx::SizeF VisualViewportSize() const override;
189   void SetScreenOrientationOverrideForTesting(
190       absl::optional<display::mojom::blink::ScreenOrientation> orientation)
191       override;
192   void SetWindowRectSynchronouslyForTesting(
193       const gfx::Rect& new_window_rect) override;
194   void ResetScrollAndScaleState() override;
195   gfx::Size ContentsPreferredMinimumSize() override;
196   void UpdatePreferredSize() override;
197   void EnablePreferredSizeChangedMode() override;
198   void SetZoomFactorForDeviceScaleFactor(float) override;
199   float ZoomFactorForViewportLayout() override {
200     // This returns the zoom factor to use when determining the layout width
201     // while processing the viewport meta tag. We use only the device scale
202     // factor, rather than the full zoom factor which includes browser zoom,
203     // since changing browser zoom should cause a page to reflow into a static
204     // initial containing block. i.e. The device's (potentially simulated by the
205     // meta tag) screen size, as measured in physical pixels, does not change
206     // with browser zoom.
207     //
208     // compositor_device_scale_factor_override_ is set by dev tools emulation to
209     // simulate a device scale factor of a particular device. If this is set we
210     // should use it rather than the host's device scale factor.
211     return compositor_device_scale_factor_override_
212                ? compositor_device_scale_factor_override_
213                : zoom_factor_for_device_scale_factor_;
214   }
215   bool AutoResizeMode() override;
216   void EnableAutoResizeForTesting(const gfx::Size& min_window_size,
217                                   const gfx::Size& max_window_size) override;
218   void DisableAutoResizeForTesting(const gfx::Size& new_window_size) override;
219   WebHitTestResult HitTestResultForTap(const gfx::Point&,
220                                        const gfx::Size&) override;
221   void EnableDeviceEmulation(const DeviceEmulationParams&) override;
222   void DisableDeviceEmulation() override;
223   void PerformCustomContextMenuAction(unsigned action) override;
224   void DidCloseContextMenu() override;
225   void CancelPagePopup() override;
226   WebPagePopupImpl* GetPagePopup() const override { return page_popup_.get(); }
227   void SetPageFrozen(bool frozen) override;
228   WebFrameWidget* MainFrameWidget() override;
229   void SetDeviceColorSpaceForTesting(
230       const gfx::ColorSpace& color_space) override;
231   void PaintContent(cc::PaintCanvas*, const gfx::Rect&) override;
232   void RegisterRendererPreferenceWatcher(
233       CrossVariantMojoRemote<mojom::RendererPreferenceWatcherInterfaceBase>
234           watcher) override;
235   void SetRendererPreferences(const RendererPreferences& preferences) override;
236   const RendererPreferences& GetRendererPreferences() const override;
237   void SetWebPreferences(const web_pref::WebPreferences& preferences) override;
238   const web_pref::WebPreferences& GetWebPreferences() override;
239   void SetHistoryListFromNavigation(
240       int32_t history_offset,
241       absl::optional<int32_t> history_length) override;
242   void IncreaseHistoryListFromNavigation() override;
243   int32_t HistoryBackListCount() const override;
244   int32_t HistoryForwardListCount() const override;
245   int32_t HistoryListLength() const { return history_list_length_; }
246   const SessionStorageNamespaceId& GetSessionStorageNamespaceId() override;
247   bool IsFencedFrameRoot() const override;
248
249 #if BUILDFLAG(IS_TIZEN_TV)
250   bool IsHitScrollbar() override;
251   bool IsMouseDownEventSwallowed() override;
252 #endif
253
254 #if BUILDFLAG(IS_EFL)
255   bool PaintSoftBitmap(SkCanvas*, const gfx::Rect&) override;
256   bool HasAcceleratedCanvasWithinViewport() const override;
257   void SetLongPollingGlobalTimeout(uint64_t timeout) override;
258   void ScrollFocusedNodeIntoView() override;
259   void SetScrollOffset(float x, float y) override;
260   gfx::Rect CurrentSelectionRect() const override;
261
262 #if BUILDFLAG(IS_TIZEN_TV)
263   void SuspendNetworkLoading() override;
264   void ResumeNetworkLoading() override;
265 #endif  // IS_TIZEN_TV
266 #endif  // IS_EFL
267
268   // Functions to add and remove observers for this object.
269   void AddObserver(WebViewObserver* observer);
270   void RemoveObserver(WebViewObserver* observer);
271
272 #if defined(OS_TIZEN_TV_PRODUCT)
273   void SetFloatVideoWindowState(bool) override;
274 #endif // OS_TIZEN_TV_PRODUCT
275
276   // `BaseBackgroundColor()` affects how the document is rendered.
277   // `BackgroundColor()` is what the document computes as its background color
278   // (with `BaseBackgroundColor()` as an input), or `BaseBackgroundColor()` if
279   // there is no local main frame; it's used as the background color of the
280   // compositor.
281   //
282   // These methods override `BaseBackgroundColor()` or `BackgroundColor()` for
283   // specific use cases. You can use this to set a transparent background,
284   // which is useful if you want to have some custom background rendered behind
285   // the widget.
286   //
287   // These settings only have an effect for composited WebViews
288   // These overrides are listed in order of precedence.
289   // - Overriding the background color for fullscreen ignores all other inputs,
290   //   including `BaseBackgroundColor()`. Note, however, that
291   //   `BaseBackgroundColor()` is passed directly into
292   //   `LocalFrameView::SetBaseBackgroundColor`.
293   // - Overriding base background color transparency takes precedences over
294   //   any base background color that might be specified for inspector--the
295   //   transparency specified in the inspector base background color is
296   //   ignored.
297   //
298   // Add new methods with clear precedence for new use cases.
299   void SetBackgroundColorOverrideForFullscreenController(
300       absl::optional<SkColor>);
301   void SetBaseBackgroundColorOverrideTransparent(bool override_to_transparent);
302   void SetBaseBackgroundColorOverrideForInspector(absl::optional<SkColor>);
303
304   // Resize the WebView. You likely should be using
305   // MainFrameWidget()->Resize instead.
306   void Resize(const gfx::Size&);
307
308   // This method is used for testing.
309   // Resize the view at the same time as changing the state of the top
310   // controls. If |browser_controls_shrink_layout| is true, the embedder shrunk
311   // the WebView size by the browser controls height.
312   void ResizeWithBrowserControls(const gfx::Size& main_frame_widget_size,
313                                  float top_controls_height,
314                                  float bottom_controls_height,
315                                  bool browser_controls_shrink_layout);
316   // Same as ResizeWithBrowserControls(const gfx::Size&,float,float,bool), but
317   // includes all browser controls params such as the min heights.
318   void ResizeWithBrowserControls(const gfx::Size& main_frame_widget_size,
319                                  const gfx::Size& visible_viewport_size,
320                                  cc::BrowserControlsParams);
321
322   // Requests a page-scale animation based on the specified point/rect.
323   void AnimateDoubleTapZoom(const gfx::Point&, const gfx::Rect& block_bounds);
324
325   // mojom::blink::PageBroadcast method:
326   void SetPageLifecycleState(
327       mojom::blink::PageLifecycleStatePtr state,
328       mojom::blink::PageRestoreParamsPtr page_restore_params,
329       SetPageLifecycleStateCallback callback) override;
330   void AudioStateChanged(bool is_audio_playing) override;
331   void ActivatePrerenderedPage(
332       mojom::blink::PrerenderPageActivationParamsPtr
333           prerender_page_activation_params,
334       ActivatePrerenderedPageCallback callback) override;
335   void SetInsidePortal(bool is_inside_portal) override;
336   void UpdateWebPreferences(
337       const blink::web_pref::WebPreferences& preferences) override;
338   void UpdateRendererPreferences(
339       const RendererPreferences& preferences) override;
340   void SetHistoryOffsetAndLength(int32_t history_offset,
341                                  int32_t history_length) override;
342 #if BUILDFLAG(IS_TIZEN)
343   void EnterDragState() override;
344 #endif
345   void SetPageBaseBackgroundColor(absl::optional<SkColor> color) override;
346   void CreateRemoteMainFrame(
347       const RemoteFrameToken& frame_token,
348       const absl::optional<FrameToken>& opener_frame_token,
349       mojom::blink::FrameReplicationStatePtr replicated_state,
350       bool is_loading,
351       const base::UnguessableToken& devtools_frame_token,
352       mojom::blink::RemoteFrameInterfacesFromBrowserPtr remote_frame_interfaces,
353       mojom::blink::RemoteMainFrameInterfacesPtr remote_main_frame_interfaces)
354       override;
355   void UpdatePageBrowsingContextGroup(
356       const BrowsingContextGroupInfo& browsing_context_group_info) override;
357   void SetPageAttributionSupport(
358       network::mojom::AttributionSupport support) override;
359
360   void DispatchPersistedPageshow(base::TimeTicks navigation_start);
361   void DispatchPagehide(mojom::blink::PagehideDispatch pagehide_dispatch);
362   void HookBackForwardCacheEviction(bool hook);
363
364   float DefaultMinimumPageScaleFactor() const;
365   float DefaultMaximumPageScaleFactor() const;
366   float ClampPageScaleFactorToLimits(float) const;
367   void ResetScaleStateImmediately();
368   absl::optional<display::mojom::blink::ScreenOrientation>
369   ScreenOrientationOverride();
370
371   // This is only for non-composited WebViewPlugin.
372   void InvalidateContainer();
373
374   void SetZoomFactorOverride(float);
375   void SetCompositorDeviceScaleFactorOverride(float);
376   gfx::Transform GetDeviceEmulationTransform() const;
377   void EnableAutoResizeMode(const gfx::Size& min_viewport_size,
378                             const gfx::Size& max_viewport_size);
379   void DisableAutoResizeMode();
380   void ActivateDevToolsTransform(const DeviceEmulationParams&);
381   void DeactivateDevToolsTransform();
382
383 #if BUILDFLAG(IS_EFL)
384   SkColor BackgroundColor() const override;
385 #else
386   SkColor BackgroundColor() const;
387 #endif
388   Color BaseBackgroundColor() const;
389
390   Frame* FocusedCoreFrame() const;
391
392   // Returns the currently focused Element or null if no element has focus.
393   Element* FocusedElement() const;
394
395   // Returns the page object associated with this view. This may be null when
396   // the page is shutting down, but will be valid at all other times.
397   Page* GetPage() const { return page_.Get(); }
398
399   WebViewClient* Client() { return web_view_client_; }
400
401   WebDevToolsAgentImpl* MainFrameDevToolsAgentImpl();
402
403   DevToolsEmulator* GetDevToolsEmulator() const {
404     return dev_tools_emulator_.Get();
405   }
406
407   // When true, a hint to all WebWidgets that they will never be
408   // user-visible and thus never need to produce pixels for display. This is
409   // separate from page visibility, as background pages can be marked visible in
410   // blink even though they are not user-visible. Page visibility controls blink
411   // behaviour for javascript, timers, and such to inform blink it is in the
412   // foreground or background. Whereas this bit refers to user-visibility and
413   // whether the tab needs to produce pixels to put on the screen at some point
414   // or not.
415   bool widgets_never_composited() const { return widgets_never_composited_; }
416
417   // Returns the main frame associated with this view. This will be null when
418   // the main frame is remote.
419   // Internally during startup/shutdown this can be null when no main frame
420   // (local or remote) is attached, but this should not generally matter to code
421   // outside this class.
422   WebLocalFrameImpl* MainFrameImpl() const;
423
424   // TODO(https://crbug.com/1139104): Remove this.
425   std::string GetNullFrameReasonForBug1139104() const;
426
427   // Finishes a ScrollIntoView for a focused editable element by performing a
428   // view-level reveal. That is, when an embedder requests to reveal a focused
429   // editable, the editable is first ScrollIntoView'ed in the layout tree to
430   // ensure it's visible in the outermost document but stops short of scrolling
431   // the outermost frame. This method will then perform a platform-specific
432   // reveal of the editable, e.g. by animating a scroll and zoom in to a
433   // legible scale. This should only be called in a WebView where the main
434   // frame is local and outermost.
435   void FinishScrollFocusedEditableIntoView(
436       const gfx::RectF& caret_rect_in_root_frame,
437       mojom::blink::ScrollIntoViewParamsPtr params);
438
439   // Handles context menu events orignated via the the keyboard. These
440   // include the VK_APPS virtual key and the Shift+F10 combine. Code is
441   // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
442   // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
443   // significant change in this function is the code to convert from a
444   // Keyboard event to the Right Mouse button down event.
445   WebInputEventResult SendContextMenuEvent();
446
447   // Notifies the WebView that a load has been committed. isNewNavigation
448   // will be true if a new session history item should be created for that
449   // load. isNavigationWithinPage will be true if the navigation does
450   // not take the user away from the current page.
451   void DidCommitLoad(bool is_new_navigation, bool is_navigation_within_page);
452
453   // Indicates two things:
454   //   1) This view may have a new layout now.
455   //   2) Layout is up-to-date.
456   // After calling WebWidget::updateAllLifecyclePhases(), expect to get this
457   // notification unless the view did not need a layout.
458   void MainFrameLayoutUpdated();
459   void ResizeAfterLayout();
460   void DidCommitCompositorFrameForLocalMainFrame();
461 #if BUILDFLAG(IS_EFL)
462   bool FiltersInSelectElement(WebView::TraverseFocusThrough filter);
463   bool FiltersInEditableElement(WebView::TraverseFocusThrough filter);
464 #endif
465   void DidChangeContentsSize();
466   void PageScaleFactorChanged();
467   void OutermostMainFrameScrollOffsetChanged();
468   void TextAutosizerPageInfoChanged(
469       const mojom::blink::TextAutosizerPageInfo& page_info);
470
471   bool ShouldAutoResize() const { return should_auto_resize_; }
472
473   gfx::Size MinAutoSize() const { return min_auto_size_; }
474
475   gfx::Size MaxAutoSize() const { return max_auto_size_; }
476
477   void UpdateMainFrameLayoutSize();
478   void UpdatePageDefinedViewportConstraints(const ViewportDescription&);
479
480   WebPagePopupImpl* OpenPagePopup(PagePopupClient*);
481   bool HasOpenedPopup() const { return page_popup_.get(); }
482   void ClosePagePopup(PagePopup*);
483   // Callback from PagePopup when it is closed, which it can be done directly
484   // without coming through WebViewImpl.
485   void CleanupPagePopup();
486   // Ensure popup's size and position is correct based on its owner element's
487   // dimensions.
488   void UpdatePagePopup();
489   LocalDOMWindow* PagePopupWindow() const;
490
491   PageScheduler* Scheduler() const override;
492   void SetVisibilityState(mojom::blink::PageVisibilityState visibility_state,
493                           bool is_initial_state) override;
494   mojom::blink::PageVisibilityState GetVisibilityState() override;
495
496   void SetPageLifecycleStateFromNewPageCommit(
497       mojom::blink::PageVisibilityState visibility,
498       mojom::blink::PagehideDispatch pagehide_dispatch) override;
499
500   // Called by a full frame plugin inside this view to inform it that its
501   // zoom level has been updated.  The plugin should only call this function
502   // if the zoom change was triggered by the browser, it's only needed in case
503   // a plugin can update its own zoom, say because of its own UI.
504   void FullFramePluginZoomLevelChanged(double zoom_level);
505
506   // Requests a page-scale animation based on the specified rect.
507   void ZoomToFindInPageRect(const gfx::Rect&);
508
509   void ComputeScaleAndScrollForBlockRect(
510       const gfx::Point& hit_point,
511       const gfx::Rect& block_rect,
512       float padding,
513       float default_scale_when_already_legible,
514       float& scale,
515       gfx::Point& scroll);
516   Node* BestTapNode(const GestureEventWithHitTestResults& targeted_tap_event);
517   void EnableTapHighlightAtPoint(
518       const GestureEventWithHitTestResults& targeted_tap_event);
519
520   void EnableFakePageScaleAnimationForTesting(bool);
521   bool FakeDoubleTapAnimationPendingForTesting() const {
522     return double_tap_zoom_pending_;
523   }
524   gfx::Point FakePageScaleAnimationTargetPositionForTesting() const {
525     return fake_page_scale_animation_target_position_;
526   }
527   float FakePageScaleAnimationPageScaleForTesting() const {
528     return fake_page_scale_animation_page_scale_factor_;
529   }
530   bool FakePageScaleAnimationUseAnchorForTesting() const {
531     return fake_page_scale_animation_use_anchor_;
532   }
533   ui::mojom::blink::VirtualKeyboardMode VirtualKeyboardModeForTesting() {
534     return virtual_keyboard_mode_;
535   }
536
537   void EnterFullscreen(LocalFrame&,
538                        const FullscreenOptions*,
539                        FullscreenRequestType);
540   void ExitFullscreen(LocalFrame&);
541   void FullscreenElementChanged(Element* old_element,
542                                 Element* new_element,
543                                 const FullscreenOptions* options,
544                                 FullscreenRequestType);
545
546   // Sends a request to the main frame's view to resize, and updates the page
547   // scale limits if needed.
548   void SendResizeEventForMainFrame();
549
550   // Exposed for testing purposes.
551   bool HasHorizontalScrollbar();
552   bool HasVerticalScrollbar();
553
554   WebSettingsImpl* SettingsImpl();
555
556 #if BUILDFLAG(IS_TIZEN)
557   // WebView
558   void PauseScheduledTasks() override;
559   void UnpauseScheduledTasks() override;
560 #endif
561
562   BrowserControls& GetBrowserControls();
563   // Called anytime browser controls layout height or content offset have
564   // changed.
565   void DidUpdateBrowserControls();
566
567   void AddAutoplayFlags(int32_t) override;
568   void ClearAutoplayFlags() override;
569   int32_t AutoplayFlagsForTest() override;
570   gfx::Size GetPreferredSizeForTest() override;
571
572   gfx::Size Size();
573   gfx::Size MainFrameSize();
574
575 #if BUILDFLAG(IS_TIZEN_TV)
576   bool IsVideoPlaying() const override;
577   void SetParentalRatingResult(const WebString&, bool) override;
578   void SetPreferTextLang(const WebString&) override;
579 #endif
580
581   PageScaleConstraintsSet& GetPageScaleConstraintsSet() const;
582
583   gfx::Vector2dF ElasticOverscroll() const { return elastic_overscroll_; }
584
585   class ChromeClient& GetChromeClient() const { return *chrome_client_.Get(); }
586
587   // Allows main frame updates to occur if they were previously blocked. They
588   // are blocked during loading a navigation, to allow Blink to proceed without
589   // being interrupted by useless work until enough progress is made that it
590   // desires composited output to be generated.
591   void StopDeferringMainFrameUpdate();
592
593   // This function checks the element ids of ScrollableAreas only and returns
594   // the equivalent DOM Node if such exists.
595   Node* FindNodeFromScrollableCompositorElementId(
596       cc::ElementId element_id) const;
597
598   void DidEnterFullscreen();
599   void DidExitFullscreen();
600
601   // Called when some JS code has instructed the window associated to the main
602   // frame to close, which will result in a request to the browser to close the
603   // Widget associated to it.
604   void CloseWindowSoon();
605
606   // Controls whether pressing Tab key advances focus to links.
607   bool TabsToLinks() const;
608   void SetTabsToLinks(bool);
609
610   // Prevent the web page from setting min/max scale via the viewport meta
611   // tag. This is an accessibility feature that lets folks zoom in to web
612   // pages even if the web page tries to block scaling.
613   void SetIgnoreViewportTagScaleLimits(bool);
614
615   // Sets the maximum page scale considered to be legible. Automatic zooms (e.g,
616   // double-tap or find in page) will have the page scale limited to this value
617   // times the font scale factor. Manual pinch zoom will not be affected by this
618   // limit.
619   void SetMaximumLegibleScale(float);
620
621   void SetMainFrameViewWidget(WebFrameWidgetImpl* widget);
622   WebFrameWidgetImpl* MainFrameViewWidget();
623
624   // Called when hovering over an anchor with the given URL.
625   void SetMouseOverURL(const KURL&);
626
627   // Called when keyboard focus switches to an anchor with the given URL.
628   void SetKeyboardFocusURL(const KURL&);
629
630   // Asks the browser process to activate this web view.
631   void Focus();
632
633   // Asks the browser process to take focus away from the WebView by focusing an
634   // adjacent UI element in the containing window.
635   void TakeFocus(bool reverse);
636
637   // Shows a previously created WebView (via window.open()).
638   void Show(const LocalFrameToken& opener_frame_token,
639             NavigationPolicy policy,
640             const gfx::Rect& requested_rect,
641             const gfx::Rect& adjusted_rect,
642             bool opened_by_user_gesture);
643
644   // Send the window rect to the browser and call `ack_callback` when the
645   // browser has processed it.
646   void SendWindowRectToMainFrameHost(const gfx::Rect& bounds,
647                                      base::OnceClosure ack_callback);
648
649   // Tells the browser that another page has accessed the DOM of the initial
650   // empty document of a main frame.
651   void DidAccessInitialMainDocument();
652
653   // Sends window.setResizable() requests to the browser window.
654   void SetResizable(bool resizable);
655
656   // TODO(crbug.com/1149992): This is called from the associated widget and this
657   // code should eventually move out of WebView into somewhere else.
658   void ApplyViewportChanges(const ApplyViewportChangesArgs& args);
659
660   // Indication that the root layer for the main frame widget has changed.
661   void DidChangeRootLayer(bool root_layer_exists);
662
663   // Sets the page focus.
664   void SetPageFocus(bool enable);
665
666   // This method is used for testing.
667   // Resizes the unscaled (page scale = 1.0) visual viewport. Normally the
668   // unscaled visual viewport is the same size as the main frame. The passed
669   // size becomes the size of the viewport when page scale = 1. This
670   // is used to shrink the visible viewport to allow things like the ChromeOS
671   // virtual keyboard to overlay over content but allow scrolling it into view.
672   void ResizeVisualViewport(const gfx::Size&);
673
674   // Called once a paint happens after the first non empty layout. In other
675   // words, after the frame has painted something.
676   void DidFirstVisuallyNonEmptyPaint();
677
678   scheduler::WebAgentGroupScheduler& GetWebAgentGroupScheduler();
679
680 #if defined(TIZEN_VIDEO_HOLE)
681   bool IsVideoHoleForRender() const override;
682 #endif
683
684 #if BUILDFLAG(IS_TIZEN_TV)
685   //Browser edge scroll
686   bool EdgeScrollBy(const ScrollOffset&, const gfx::Point&) override;
687   void SetTranslatedURL(const WebString) override;
688 #endif
689
690  private:
691   FRIEND_TEST_ALL_PREFIXES(WebFrameTest, DivScrollIntoEditableTest);
692   FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
693                            DivScrollIntoEditablePreservePageScaleTest);
694   FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
695                            DivScrollIntoEditableTestZoomToLegibleScaleDisabled);
696   FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
697                            DivScrollIntoEditableTestWithDeviceScaleFactor);
698   FRIEND_TEST_ALL_PREFIXES(WebViewTest, SetBaseBackgroundColorBeforeMainFrame);
699   FRIEND_TEST_ALL_PREFIXES(WebViewTest, LongPressImage);
700   FRIEND_TEST_ALL_PREFIXES(WebViewTest, LongPressImageAndThenLongTapImage);
701   FRIEND_TEST_ALL_PREFIXES(WebViewTest, UpdateTargetURLWithInvalidURL);
702   FRIEND_TEST_ALL_PREFIXES(WebViewTest, TouchDragContextMenu);
703   FRIEND_TEST_ALL_PREFIXES(WebViewTest, ContextMenuAndDrag);
704
705   friend class frame_test_helpers::WebViewHelper;
706   friend class SimCompositor;
707   friend class WebView;  // So WebView::Create can call our constructor
708   friend class WTF::RefCounted<WebViewImpl>;
709
710   void AcceptLanguagesChanged();
711   void ThemeChanged();
712
713   // Update the target url locally and tell the browser that the target URL has
714   // changed. If |url| is empty, show |fallback_url|.
715   void UpdateTargetURL(const WebURL& url, const WebURL& fallback_url);
716
717   // Helper functions to send the updated target URL to the right render frame
718   // in the browser process, and to handle its associated reply message.
719   void SendUpdatedTargetURLToBrowser(const KURL& target_url);
720   void TargetURLUpdatedInBrowser();
721
722   void SetPageScaleFactorAndLocation(float scale,
723                                      bool is_pinch_gesture_active,
724                                      const gfx::PointF&);
725   void PropagateZoomFactorToLocalFrameRoots(Frame*, float);
726
727   void SetPageLifecycleStateInternal(
728       mojom::blink::PageLifecycleStatePtr new_state,
729       mojom::blink::PageRestoreParamsPtr page_restore_params);
730
731   // Updates the main frame's view transition state.
732   void UpdateViewTransitionState(
733       bool restoring_from_bfcache,
734       bool storing_in_bfcache,
735       const mojom::blink::PageRestoreParamsPtr& page_restore_params);
736
737   float MaximumLegiblePageScale() const;
738   void RefreshPageScaleFactor();
739   gfx::Size ContentsSize() const;
740
741   void UpdateBrowserControlsConstraint(cc::BrowserControlsState constraint);
742   void UpdateICBAndResizeViewport(const gfx::Size& visible_viewport_size);
743   void ResizeViewWhileAnchored(cc::BrowserControlsParams params,
744                                const gfx::Size& visible_viewport_size);
745
746   void UpdateBaseBackgroundColor();
747   void UpdateFontRenderingFromRendererPrefs();
748
749   // Request the window to close from the renderer by sending the request to the
750   // browser.
751   void DoDeferredCloseWindowSoon();
752
753   WebViewImpl(
754       WebViewClient*,
755       mojom::blink::PageVisibilityState visibility,
756       bool is_prerendering,
757       bool is_inside_portal,
758       absl::optional<blink::FencedFrame::DeprecatedFencedFrameMode>
759           fenced_frame_mode,
760       bool does_composite,
761       bool widgets_never_composite,
762       WebViewImpl* opener,
763       mojo::PendingAssociatedReceiver<mojom::blink::PageBroadcast> page_handle,
764       scheduler::WebAgentGroupScheduler& agent_group_scheduler,
765       const SessionStorageNamespaceId& session_storage_namespace_id,
766       absl::optional<SkColor> page_base_background_color,
767       const BrowsingContextGroupInfo& browsing_context_group_info);
768
769 #if BUILDFLAG(IS_EFL)
770   enum FormInputAction {
771     FormInputNone = 0x00,
772     FormInputPrevText = 0x01,
773     FormInputPrevSelect = 0x02,
774     FormInputNextText = 0x04,
775     FormInputNextSelect = 0x08,
776   };
777 #endif
778
779   ~WebViewImpl() override;
780
781   void ConfigureAutoResizeMode();
782
783   void DoComposite();
784   void ReallocateRenderer();
785
786   void SetDeviceEmulationTransform(const gfx::Transform&);
787   void UpdateDeviceEmulationTransform();
788
789   // Helper function: Widens the width of |source| by the specified margins
790   // while keeping it smaller than page width.
791   //
792   // This method can only be called if the main frame is local.
793   gfx::Rect WidenRectWithinPageBounds(const gfx::Rect& source,
794                                       int target_margin,
795                                       int minimum_margin);
796
797   void EnablePopupMouseWheelEventListener(WebLocalFrameImpl* local_root);
798   void DisablePopupMouseWheelEventListener();
799
800   LocalFrame* FocusedLocalFrameInWidget() const;
801
802   // Clear focus and text input state of the page. If there was a focused
803   // element, this will trigger updates to observers and send focus, selection,
804   // and text input-related events.
805   void RemoveFocusAndTextInputState();
806
807   // Finds the zoom and scroll parameters for zooming into an editable element
808   // with bounds |element_bounds_in_root_frame| and caret bounds
809   // |caret_bounds_in_root_frame|.
810   void ComputeScaleAndScrollForEditableElementRects(
811       const gfx::Rect& element_bounds_in_root_frame,
812       const gfx::Rect& caret_bounds_in_root_frame,
813       bool zoom_into_legible_scale,
814       float& new_scale,
815       gfx::Point& new_scroll_position,
816       bool& need_animation);
817
818   // Starts a page scale (and scroll!) animation on the compositor thread that
819   // will smoothly animate the viewport position and zoom. Returns true if an
820   // animation was queued, false if an animation was not needed.
821   //
822   // * target_position - A position in root document coordinates ("position"
823   // meaning it's relative to the top-left of the document).  This is the
824   // location that scroll will animate to.
825   // * use_anchor: If true, the animation `target_position` is used as an
826   // "anchor". `target_position` must already be visible in the viewport and
827   // scroll/zoom will be animated such that the anchor will be kept fixed in
828   // the viewport (if possible).
829   // * new_scale: The target page scale factor to animate to.
830   // * duration: The animation's duration.
831   bool StartPageScaleAnimation(const gfx::Point& target_position,
832                                bool use_anchor,
833                                float new_scale,
834                                base::TimeDelta duration);
835
836   // Sends any outstanding TrackedFeaturesUpdate messages to the browser.
837   void ReportActiveSchedulerTrackedFeatures();
838
839   // Callback when this widget window has been displayed by the browser.
840   // Corresponds to a Show method call.
841   void DidShowCreatedWindow();
842
843   // Called when mojo is disconnected.
844   void MojoDisconnected();
845
846   // A value provided by the browser to state that all Widgets in this
847   // WebView's frame tree will never be user-visible and thus never need to
848   // produce pixels for display. This is separate from Page visibility, as
849   // non-user-visible pages can still be marked visible for blink. Page
850   // visibility controls blink behaviour for javascript, timers, and such to
851   // inform blink it is in the foreground or background. Whereas this bit refers
852   // to user-visibility and whether the tab needs to produce pixels to put on
853   // the screen at some point or not.
854   const bool widgets_never_composited_;
855
856   // Can be null (e.g. unittests, shared workers, etc).
857   WebViewClient* web_view_client_;
858   Persistent<ChromeClient> chrome_client_;
859   Persistent<Page> page_;
860
861   // This is the size of the page that the web contents will render into. This
862   // is usually, but not necessarily the same as the VisualViewport size. The
863   // VisualViewport is the 'inner' viewport, and can be smaller than the size of
864   // the page. This allows the browser to shrink the size of the displayed
865   // contents [e.g. to accomodate a keyboard] without forcing the web page to
866   // relayout. For more details, see the header for the VisualViewport class.
867   gfx::Size size_;
868   // If true, automatically resize the layout view around its content.
869   bool should_auto_resize_ = false;
870   // The lower bound on the size when auto-resizing.
871   gfx::Size min_auto_size_;
872   // The upper bound on the size when auto-resizing.
873   gfx::Size max_auto_size_;
874
875   // An object that can be used to manipulate m_page->settings() without linking
876   // against WebCore. This is lazily allocated the first time GetWebSettings()
877   // is called.
878   std::unique_ptr<WebSettingsImpl> web_settings_;
879
880   // The state of our target_url transmissions. When we receive a request to
881   // send a URL to the browser, we set this to TARGET_INFLIGHT until an ACK
882   // comes back - if a new request comes in before the ACK, we store the new
883   // URL in pending_target_url_ and set the status to TARGET_PENDING. If an
884   // ACK comes back and we are in TARGET_PENDING, we send the stored URL and
885   // revert to TARGET_INFLIGHT.
886   //
887   // We don't need a queue of URLs to send, as only the latest is useful.
888   enum {
889     TARGET_NONE,
890     TARGET_INFLIGHT,  // We have a request in-flight, waiting for an ACK
891     TARGET_PENDING    // INFLIGHT + we have a URL waiting to be sent
892   } target_url_status_ = TARGET_NONE;
893
894   // The URL we show the user in the status bar. We use this to determine if we
895   // want to send a new one (we do not need to send duplicates). It will be
896   // equal to either |mouse_over_url_| or |focus_url_|, depending on which was
897   // updated last.
898   KURL target_url_;
899
900   // The next target URL we want to send to the browser.
901   KURL pending_target_url_;
902
903   // The URL the user's mouse is hovering over.
904   KURL mouse_over_url_;
905
906   // The URL that has keyboard focus.
907   KURL focus_url_;
908
909   // Keeps track of the current zoom level. 0 means no zoom, positive numbers
910   // mean zoom in, negative numbers mean zoom out.
911   double zoom_level_ = 0.;
912
913   const double minimum_zoom_level_;
914   const double maximum_zoom_level_;
915
916   // Additional zoom factor used to scale the content by device scale factor.
917   double zoom_factor_for_device_scale_factor_ = 0.;
918
919   // This value, when multiplied by the font scale factor, gives the maximum
920   // page scale that can result from automatic zooms.
921   float maximum_legible_scale_ = 1.f;
922
923   // The scale moved to by the latest double tap zoom, if any.
924   float double_tap_zoom_page_scale_factor_ = 0.f;
925   // Have we sent a double-tap zoom and not yet heard back the scale?
926   bool double_tap_zoom_pending_ = false;
927
928   // Used for testing purposes.
929   bool enable_fake_page_scale_animation_for_testing_ = false;
930   gfx::Point fake_page_scale_animation_target_position_;
931   float fake_page_scale_animation_page_scale_factor_ = 0.f;
932   bool fake_page_scale_animation_use_anchor_ = false;
933
934   float compositor_device_scale_factor_override_ = 0.f;
935   gfx::Transform device_emulation_transform_;
936
937   // The offset of the current item in the history list.
938   // The initial value is -1 since the offset should be lower than
939   // |history_list_length_| to count the back/forward history list.
940   int32_t history_list_offset_ = -1;
941
942   // The RenderView's current impression of the history length.  This includes
943   // any items that have committed in this process, but because of cross-process
944   // navigations, the history may have some entries that were committed in other
945   // processes.  We won't know about them until the next navigation in this
946   // process.
947   int32_t history_list_length_ = 0;
948
949   // The popup associated with an input/select element. The popup is owned via
950   // closership (self-owned-but-deleted-via-close) by RenderWidget. We also hold
951   // a reference here because we can extend the lifetime of the popup while
952   // handling input events in order to compare its popup client after it was
953   // closed.
954   scoped_refptr<WebPagePopupImpl> page_popup_;
955
956   Persistent<DevToolsEmulator> dev_tools_emulator_;
957
958   // Whether the user can press tab to focus links.
959   bool tabs_to_links_ = false;
960
961   // WebViews, and WebWidgets, are used to host a Page. The WidgetClient()
962   // provides compositing support for the WebView.
963   // In some cases, a WidgetClient() is not provided, or it informs us that
964   // it won't be presenting content via a compositor.
965   //
966   // TODO(dcheng): All WebViewImpls should have an associated LayerTreeView,
967   // but for various reasons, that's not the case... WebView plugin, printing,
968   // workers, and tests don't use a compositor in their WebViews. Sometimes
969   // they avoid the compositor by using a null client, and sometimes by having
970   // the client return a null compositor. We should make things more consistent
971   // and clear.
972   const bool does_composite_;
973
974   bool matches_heuristics_for_gpu_rasterization_ = false;
975
976   std::unique_ptr<FullscreenController> fullscreen_controller_;
977
978   absl::optional<SkColor> background_color_override_for_fullscreen_controller_;
979   bool override_base_background_color_to_transparent_ = false;
980   absl::optional<SkColor> base_background_color_override_for_inspector_;
981   SkColor page_base_background_color_;  // Only applies to main frame.
982
983   float zoom_factor_override_ = 0.f;
984
985   gfx::Vector2dF elastic_overscroll_;
986
987   // If true, we send IPC messages when |preferred_size_| changes.
988   bool send_preferred_size_changes_ = false;
989
990   // Whether the preferred size may have changed and |UpdatePreferredSize| needs
991   // to be called.
992   bool needs_preferred_size_update_ = true;
993
994   // Cache the preferred size of the page in order to prevent sending the IPC
995   // when layout() recomputes but doesn't actually change sizes.
996   gfx::Size preferred_size_in_dips_;
997
998   Persistent<EventListener> popup_mouse_wheel_event_listener_;
999
1000   web_pref::WebPreferences web_preferences_;
1001
1002   blink::RendererPreferences renderer_preferences_;
1003 #if BUILDFLAG(IS_EFL)
1004   bool IsFormNavigationTextInput(Element&) const;
1005   bool IsSelectElement(const Element&) const;
1006   bool PerformClickOnElement(Element&);
1007   Element* NextTextOrSelectElement(
1008       Element*,
1009       TraverseFocusThrough = TraverseFocusThrough::EditableAndSelectElements);
1010   Element* PreviousTextOrSelectElement(
1011       Element*,
1012       TraverseFocusThrough = TraverseFocusThrough::EditableAndSelectElements);
1013   gfx::Rect GetElementBounds(const Element&) const;
1014 #endif
1015
1016   // The local root whose document has |popup_mouse_wheel_event_listener_|
1017   // registered.
1018   WeakPersistent<WebLocalFrameImpl> local_root_with_empty_mouse_wheel_listener_;
1019
1020   // The WebWidget for the main frame. This is expected to be unset when the
1021   // WebWidget destroys itself. This will be null if the main frame is remote.
1022   WeakPersistent<WebFrameWidgetImpl> web_widget_;
1023
1024   // We defer commits when transitioning to a new page. ChromeClientImpl calls
1025   // StopDeferringCommits() to release this when a new page is loaded.
1026   std::unique_ptr<cc::ScopedDeferMainFrameUpdate>
1027       scoped_defer_main_frame_update_;
1028
1029   Persistent<ResizeViewportAnchor> resize_viewport_anchor_;
1030
1031   // Handle to the local main frame host. Only valid when the MainFrame is
1032   // local. It is ok to use WTF::Unretained(this) for callbacks made on this
1033   // interface because the callbacks will be associated with the lifecycle
1034   // of this AssociatedRemote and the lifetiime of the main LocalFrame.
1035   mojo::AssociatedRemote<mojom::blink::LocalMainFrameHost>
1036       local_main_frame_host_remote_;
1037
1038   // Handle to the remote main frame host. Only valid when the MainFrame is
1039   // remote.  It is ok to use WTF::Unretained(this) for callbacks made on this
1040   // interface because the callbacks will be associated with the lifecycle
1041   // of this AssociatedRemote and the lifetime of the main RemoteFrame.
1042   mojo::AssociatedRemote<mojom::blink::RemoteMainFrameHost>
1043       remote_main_frame_host_remote_;
1044
1045   absl::optional<display::mojom::blink::ScreenOrientation>
1046       screen_orientation_override_;
1047
1048   mojo::AssociatedReceiver<mojom::blink::PageBroadcast> receiver_;
1049
1050   // These are observing changes in |renderer_preferences_|. This is used for
1051   // keeping WorkerFetchContext in sync.
1052   mojo::RemoteSet<mojom::blink::RendererPreferenceWatcher>
1053       renderer_preference_watchers_;
1054
1055   // The SessionStorage namespace that we're assigned to has an ID, and that ID
1056   // is passed to us upon creation.  WebKit asks for this ID upon first use and
1057   // uses it whenever asking the browser process to allocate new storage areas.
1058   SessionStorageNamespaceId session_storage_namespace_id_;
1059
1060   // The mode that the virtual keyboard is in, with respect to how it will
1061   // affect the Blink viewport and layout. This can be set by the page using
1062   // the viewport meta tag.
1063   ui::mojom::blink::VirtualKeyboardMode virtual_keyboard_mode_ =
1064       ui::mojom::blink::VirtualKeyboardMode::kUnset;
1065
1066   scheduler::WebAgentGroupScheduler& web_agent_group_scheduler_;
1067
1068   // All the registered observers.
1069   base::ObserverList<WebViewObserver> observers_;
1070
1071   base::WeakPtrFactory<WebViewImpl> weak_ptr_factory_{this};
1072 };
1073
1074 // WebView is always implemented by WebViewImpl, so explicitly allow the
1075 // downcast.
1076 template <>
1077 struct DowncastTraits<WebViewImpl> {
1078   static bool AllowFrom(const WebView& web_view) { return true; }
1079 };
1080
1081 }  // namespace blink
1082
1083 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_VIEW_IMPL_H_