Commit f416741d authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Clean up WebView public API

Remove APIs that no longer are called.
Move APIs that are called by blink to be directly on WebViewImpl if
possible.

BUG=1097816

Change-Id: Ibab11949b7221774657acde3542590bb3b834294
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441964
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813292}
parent 33eaef93
......@@ -64,7 +64,6 @@ class WebFrame;
class WebFrameWidget;
class WebHitTestResult;
class WebLocalFrame;
class WebPageImportanceSignals;
class WebPagePopup;
class WebPrerendererClient;
class WebRemoteFrame;
......@@ -73,7 +72,6 @@ class WebString;
class WebViewClient;
class WebWidget;
struct DeviceEmulationParams;
struct WebRect;
struct WebWindowFeatures;
class WebView {
......@@ -138,11 +136,6 @@ class WebView {
// Initializes the various client interfaces.
virtual void SetPrerendererClient(WebPrerendererClient*) = 0;
// Called when some JS code has instructed the window associated to the main
// frame to close, which will result in a request to the browser to close the
// RenderWidget associated to it.
virtual void CloseWindowSoon() = 0;
// Options -------------------------------------------------------------
// The returned pointer is valid for the lifetime of the WebView.
......@@ -152,13 +145,8 @@ class WebView {
// encoding may cause the main frame to reload.
virtual WebString PageEncoding() const = 0;
// Controls whether pressing Tab key advances focus to links.
virtual bool TabsToLinks() const = 0;
virtual void SetTabsToLinks(bool) = 0;
// Method that controls whether pressing Tab key cycles through page
// elements or inserts a '\t' char in the focused text area.
virtual bool TabKeyCyclesThroughElements() const = 0;
virtual void SetTabKeyCyclesThroughElements(bool) = 0;
// Controls the WebView's active state, which may affect the rendering
......@@ -193,14 +181,6 @@ class WebView {
// previous element in the tab sequence (if reverse is true).
virtual void AdvanceFocus(bool reverse) {}
// Changes the zoom and scroll for zooming into an editable element
// with bounds |element_bounds_in_document| and caret bounds
// |caret_bounds_in_document|.
virtual void ZoomAndScrollToFocusedEditableElementRect(
const WebRect& element_bounds_in_document,
const WebRect& caret_bounds_in_document,
bool zoom_into_legible_scale) = 0;
// Zoom ----------------------------------------------------------------
// Returns the current zoom level. 0 is "original size", and each increment
......@@ -248,20 +228,9 @@ class WebView {
// page scale set in the page's viewport meta tag.
virtual void SetInitialPageScaleOverride(float) = 0;
// Sets the maximum page scale considered to be legible. Automatic zooms (e.g,
// double-tap or find in page) will have the page scale limited to this value
// times the font scale factor. Manual pinch zoom will not be affected by this
// limit.
virtual void SetMaximumLegibleScale(float) = 0;
// Reset any saved values for the scroll and scale state.
virtual void ResetScrollAndScaleState() = 0;
// Prevent the web page from setting min/max scale via the viewport meta
// tag. This is an accessibility feature that lets folks zoom in to web
// pages even if the web page tries to block scaling.
virtual void SetIgnoreViewportTagScaleLimits(bool) = 0;
// Returns the "preferred" contents size, defined as the preferred minimum
// width of the main document's contents and the minimum height required to
// display the main document without scrollbars. If the document is in quirks
......@@ -280,9 +249,6 @@ class WebView {
// Indicates that view's preferred size changes will be sent to the browser.
virtual void EnablePreferredSizeChangedMode() = 0;
// Asks the browser process to activate this web view.
virtual void Focus() = 0;
// Sets the ratio as computed by computePageScaleConstraints.
// TODO(oshima): Remove this once the device scale factor implementation is
// fully migrated to use zooming mechanism.
......@@ -304,13 +270,6 @@ class WebView {
float top_controls_height,
float bottom_controls_height,
bool browser_controls_shrink_layout) = 0;
// This method is used for testing.
// Resizes the unscaled (page scale = 1.0) visual viewport. Normally the
// unscaled visual viewport is the same size as the main frame. The passed
// size becomes the size of the viewport when page scale = 1. This
// is used to shrink the visible viewport to allow things like the ChromeOS
// virtual keyboard to overlay over content but allow scrolling it into view.
virtual void ResizeVisualViewport(const gfx::Size&) = 0;
// Same as ResizeWithBrowserControls(const gfx::Size&,float,float,bool), but
// includes all browser controls params such as the min heights.
......@@ -323,8 +282,6 @@ class WebView {
// settings.
virtual void Resize(const gfx::Size&) = 0;
virtual gfx::Size GetSize() = 0;
// Override the screen orientation override.
virtual void SetScreenOrientationOverrideForTesting(
base::Optional<blink::mojom::ScreenOrientation> orientation) = 0;
......@@ -356,12 +313,6 @@ class WebView {
virtual WebHitTestResult HitTestResultForTap(const gfx::Point& tap_point,
const gfx::Size& tap_area) = 0;
// Support for resource loading initiated by plugins -------------------
// Returns next unused request identifier which is unique within the
// parent Page.
virtual uint64_t CreateUniqueIdentifierForRequest() = 0;
// Developer tools -----------------------------------------------------
// Enables device emulation as specified in params.
......@@ -437,10 +388,6 @@ class WebView {
mojom::PageVisibilityState visibility,
mojom::PagehideDispatch pagehide_dispatch) = 0;
// Page Importance Signals ----------------------------------------------
virtual WebPageImportanceSignals* PageImportanceSignals() { return nullptr; }
// i18n -----------------------------------------------------------------
// Inform the WebView that the accept languages have changed.
......
......@@ -516,11 +516,6 @@ WebDevToolsAgentImpl* WebViewImpl::MainFrameDevToolsAgentImpl() {
return main_frame ? main_frame->DevToolsAgentImpl() : nullptr;
}
bool WebViewImpl::TabKeyCyclesThroughElements() const {
DCHECK(page_);
return page_->TabKeyCyclesThroughElements();
}
void WebViewImpl::SetTabKeyCyclesThroughElements(bool value) {
if (page_)
page_->SetTabKeyCyclesThroughElements(value);
......@@ -1646,10 +1641,6 @@ void WebViewImpl::Resize(const gfx::Size& new_size) {
GetBrowserControls().ShrinkViewport());
}
gfx::Size WebViewImpl::GetSize() {
return size_;
}
void WebViewImpl::SetScreenOrientationOverrideForTesting(
base::Optional<blink::mojom::ScreenOrientation> orientation) {
screen_orientation_override_ = orientation;
......@@ -1875,6 +1866,7 @@ void WebViewImpl::PaintContent(cc::PaintCanvas* canvas, const gfx::Rect& rect) {
// static
void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
WebView* web_view) {
WebViewImpl* web_view_impl = static_cast<WebViewImpl*>(web_view);
WebSettings* settings = web_view->GetSettings();
ApplyFontsFromMap(prefs.standard_font_family_map,
SetStandardFontFamilyWrapper, settings);
......@@ -1956,7 +1948,7 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
// Tabs to link is not part of the settings. WebCore calls
// ChromeClient::tabsToLinks which is part of the glue code.
web_view->SetTabsToLinks(prefs.tabs_to_links);
web_view_impl->SetTabsToLinks(prefs.tabs_to_links);
settings->SetAllowRunningOfInsecureContent(
prefs.allow_running_insecure_content);
......@@ -2066,7 +2058,7 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
settings->SetAllowCustomScrollbarInMainFrame(false);
settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor);
settings->SetDeviceScaleAdjustment(prefs.device_scale_adjustment);
web_view->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom);
web_view_impl->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom);
settings->SetAutoZoomFocusedNodeToLegibleScale(true);
settings->SetDefaultVideoPosterURL(
WebString::FromASCII(prefs.default_video_poster_url.spec()));
......@@ -2249,7 +2241,8 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
settings->SetTouchDragEndContextMenu(prefs.touch_dragend_context_menu);
#if defined(OS_MAC)
web_view->SetMaximumLegibleScale(prefs.default_maximum_page_scale_factor);
web_view_impl->SetMaximumLegibleScale(
prefs.default_maximum_page_scale_factor);
#endif
#if defined(OS_WIN)
......@@ -2719,8 +2712,8 @@ bool WebViewImpl::ShouldZoomToLegibleScale(const Element& element) {
}
void WebViewImpl::ZoomAndScrollToFocusedEditableElementRect(
const WebRect& element_bounds_in_document,
const WebRect& caret_bounds_in_document,
const IntRect& element_bounds_in_document,
const IntRect& caret_bounds_in_document,
bool zoom_into_legible_scale) {
float scale;
IntPoint scroll;
......@@ -3611,10 +3604,6 @@ void WebViewImpl::ConfigureAutoResizeMode() {
}
}
uint64_t WebViewImpl::CreateUniqueIdentifierForRequest() {
return CreateUniqueIdentifier();
}
void WebViewImpl::SetCompositorDeviceScaleFactorOverride(
float device_scale_factor) {
if (compositor_device_scale_factor_override_ == device_scale_factor)
......
......@@ -135,12 +135,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void DidAttachRemoteMainFrame() override;
void DidDetachRemoteMainFrame() override;
void SetPrerendererClient(WebPrerendererClient*) override;
void CloseWindowSoon() override;
WebSettings* GetSettings() override;
WebString PageEncoding() const override;
bool TabsToLinks() const override;
void SetTabsToLinks(bool value) override;
bool TabKeyCyclesThroughElements() const override;
void SetTabKeyCyclesThroughElements(bool value) override;
bool IsActive() const override;
void SetIsActive(bool value) override;
......@@ -160,10 +156,6 @@ class CORE_EXPORT WebViewImpl final : public WebView,
int target_y,
base::TimeDelta duration) override;
void AdvanceFocus(bool reverse) override;
void ZoomAndScrollToFocusedEditableElementRect(
const WebRect& element_bounds_in_document,
const WebRect& caret_bounds_in_document,
bool zoom_into_legible_scale) override;
double ZoomLevel() override;
double SetZoomLevel(double) override;
float PageScaleFactor() const override;
......@@ -171,25 +163,20 @@ class CORE_EXPORT WebViewImpl final : public WebView,
float MaximumPageScaleFactor() const override;
void SetDefaultPageScaleLimits(float min_scale, float max_scale) override;
void SetInitialPageScaleOverride(float) override;
void SetMaximumLegibleScale(float) override;
void SetPageScaleFactor(float) override;
void SetVisualViewportOffset(const gfx::PointF&) override;
gfx::PointF VisualViewportOffset() const override;
gfx::SizeF VisualViewportSize() const override;
void ResizeVisualViewport(const gfx::Size&) override;
void Resize(const gfx::Size&) override;
gfx::Size GetSize() override;
void SetScreenOrientationOverrideForTesting(
base::Optional<blink::mojom::ScreenOrientation> orientation) override;
void UseSynchronousResizeModeForTesting(bool enable) override;
void SetWindowRectSynchronouslyForTesting(
const gfx::Rect& new_window_rect) override;
void ResetScrollAndScaleState() override;
void SetIgnoreViewportTagScaleLimits(bool) override;
gfx::Size ContentsPreferredMinimumSize() override;
void UpdatePreferredSize() override;
void EnablePreferredSizeChangedMode() override;
void Focus() override;
void SetDeviceScaleFactor(float) override;
void SetZoomFactorForDeviceScaleFactor(float) override;
float ZoomFactorForDeviceScaleFactor() override {
......@@ -202,7 +189,6 @@ class CORE_EXPORT WebViewImpl final : public WebView,
WebHitTestResult HitTestResultAt(const gfx::PointF&);
WebHitTestResult HitTestResultForTap(const gfx::Point&,
const gfx::Size&) override;
uint64_t CreateUniqueIdentifierForRequest() override;
void EnableDeviceEmulation(const DeviceEmulationParams&) override;
void DisableDeviceEmulation() override;
void PerformCustomContextMenuAction(unsigned action) override;
......@@ -299,6 +285,14 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void MouseContextMenu(const WebMouseEvent&);
void MouseDoubleClick(const WebMouseEvent&);
// Changes the zoom and scroll for zooming into an editable element
// with bounds |element_bounds_in_document| and caret bounds
// |caret_bounds_in_document|.
void ZoomAndScrollToFocusedEditableElementRect(
const IntRect& element_bounds_in_document,
const IntRect& caret_bounds_in_document,
bool zoom_into_legible_scale);
bool StartPageScaleAnimation(const IntPoint& target_position,
bool use_anchor,
float new_scale,
......@@ -454,6 +448,26 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void DidEnterFullscreen();
void DidExitFullscreen();
// Called when some JS code has instructed the window associated to the main
// frame to close, which will result in a request to the browser to close the
// Widget associated to it.
void CloseWindowSoon();
// Controls whether pressing Tab key advances focus to links.
bool TabsToLinks() const;
void SetTabsToLinks(bool);
// Prevent the web page from setting min/max scale via the viewport meta
// tag. This is an accessibility feature that lets folks zoom in to web
// pages even if the web page tries to block scaling.
void SetIgnoreViewportTagScaleLimits(bool);
// Sets the maximum page scale considered to be legible. Automatic zooms (e.g,
// double-tap or find in page) will have the page scale limited to this value
// times the font scale factor. Manual pinch zoom will not be affected by this
// limit.
void SetMaximumLegibleScale(float);
void SetMainFrameViewWidget(WebViewFrameWidget* widget);
WebViewFrameWidget* MainFrameViewWidget();
......@@ -465,6 +479,17 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void RunPaintBenchmark(int repeat_count, cc::PaintBenchmarkResult& result);
// Asks the browser process to activate this web view.
void Focus();
// This method is used for testing.
// Resizes the unscaled (page scale = 1.0) visual viewport. Normally the
// unscaled visual viewport is the same size as the main frame. The passed
// size becomes the size of the viewport when page scale = 1. This
// is used to shrink the visible viewport to allow things like the ChromeOS
// virtual keyboard to overlay over content but allow scrolling it into view.
void ResizeVisualViewport(const gfx::Size&);
private:
FRIEND_TEST_ALL_PREFIXES(WebFrameTest, DivScrollIntoEditableTest);
FRIEND_TEST_ALL_PREFIXES(WebFrameTest,
......
......@@ -17,6 +17,7 @@
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy_manager.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
......@@ -619,7 +620,9 @@ void RemoteFrame::ScrollRectToVisible(
// This is due to something such as scroll focused editable element into
// view on Android which also requires an automatic zoom into legible scale.
// This is handled by main frame's WebView.
WebFrame::FromFrame(this)->View()->ZoomAndScrollToFocusedEditableElementRect(
WebViewImpl* web_view =
static_cast<WebViewImpl*>(WebFrame::FromFrame(this)->View());
web_view->ZoomAndScrollToFocusedEditableElementRect(
element_bounds_in_document, caret_bounds_in_document, true);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment