Commit 39d527dc authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Move methods no longer needed in WebViewClient into WebViewImpl

This is a follow-up CL for crrevc.com/c/2387801 to remove the methods
SetMouseOverURL() and SetKeyboardFocusURL() from WebViewClient, along
with their implementations in RenderViewImpl, and move the logic right
into WebViewImpl instead.

Additionally, this CL also removes a couple of leftover declarations
in render_view_impl.h for methods that were moved to WebViewImpl along
with crrev.com/c/2387801 already.

Bug: 993189, 1047464
Change-Id: I5e8b13b1db955272308490c82c97ff96e428a64e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2403260Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#805736}
parent 406820b3
......@@ -1432,16 +1432,6 @@ void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) {
this, &RenderViewImpl::SendFrameStateUpdates);
}
void RenderViewImpl::SetMouseOverURL(const WebURL& url) {
mouse_over_url_ = GURL(url);
GetWebView()->UpdateTargetURL(mouse_over_url_, focus_url_);
}
void RenderViewImpl::SetKeyboardFocusURL(const WebURL& url) {
focus_url_ = GURL(url);
GetWebView()->UpdateTargetURL(focus_url_, mouse_over_url_);
}
bool RenderViewImpl::AcceptsLoadDrops() {
return renderer_preferences_.can_accept_load_drops;
}
......
......@@ -218,8 +218,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
base::i18n::TextDirection main_text_hint,
base::string16* sub_text,
base::i18n::TextDirection sub_text_hint);
void SetMouseOverURL(const blink::WebURL& url) override;
void SetKeyboardFocusURL(const blink::WebURL& url) override;
bool AcceptsLoadDrops() override;
void FocusNext() override;
void FocusPrevious() override;
......@@ -381,7 +379,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
void OnSetRendererPrefs(
const blink::mojom::RendererPreferences& renderer_prefs);
void OnSuppressDialogsUntilSwapOut();
void OnUpdateTargetURLAck();
void OnUpdateWebPreferences(const WebPreferences& prefs);
// Page message handlers -----------------------------------------------------
......@@ -409,10 +406,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
// update to inform the browser process.
void SendFrameStateUpdates();
// Update the target url and tell the browser that the target URL has changed.
// If |url| is empty, show |fallback_url|.
void UpdateTargetURL(const GURL& url, const GURL& fallback_url);
// RenderFrameImpl accessible state ------------------------------------------
// The following section is the set of methods that RenderFrameImpl needs
// to access RenderViewImpl state. The set of state variables are page-level
......@@ -496,14 +489,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
// process.
int history_list_length_ = 0;
// UI state ------------------------------------------------------------------
// The URL the user's mouse is hovering over.
GURL mouse_over_url_;
// The URL that has keyboard focus.
GURL focus_url_;
// View ----------------------------------------------------------------------
// This class owns this member, and is responsible for calling
......
......@@ -282,10 +282,11 @@ class WebView {
// Asks the browser process to activate this web view.
virtual void Focus() = 0;
// Update the target url and tell the browser that the target URL has changed.
// If |url| is empty, show |fallback_url|.
virtual void UpdateTargetURL(const WebURL& url,
const WebURL& fallback_url) = 0;
// Called when hovering over an anchor with the given URL.
virtual void SetMouseOverURL(const WebURL&) {}
// Called when keyboard focus switches to an anchor with the given URL.
virtual void SetKeyboardFocusURL(const WebURL&) {}
// Sets the ratio as computed by computePageScaleConstraints.
// TODO(oshima): Remove this once the device scale factor implementation is
......
......@@ -44,7 +44,6 @@
namespace blink {
class WebPagePopup;
class WebURL;
class WebURLRequest;
class WebView;
struct WebRect;
......@@ -103,12 +102,6 @@ class WebViewClient {
// UI ------------------------------------------------------------------
// Called when hovering over an anchor with the given URL.
virtual void SetMouseOverURL(const WebURL&) {}
// Called when keyboard focus switches to an anchor with the given URL.
virtual void SetKeyboardFocusURL(const WebURL&) {}
// Called to determine if drag-n-drop operations may initiate a page
// navigation.
virtual bool AcceptsLoadDrops() { return true; }
......
......@@ -372,7 +372,7 @@ void WebViewImpl::SetTabKeyCyclesThroughElements(bool value) {
void WebViewImpl::HandleMouseLeave(LocalFrame& main_frame,
const WebMouseEvent& event) {
web_view_client_->SetMouseOverURL(WebURL());
SetMouseOverURL(WebURL());
PageWidgetEventHandler::HandleMouseLeave(main_frame, event);
}
......@@ -2939,6 +2939,16 @@ void WebViewImpl::Focus() {
}
}
void WebViewImpl::SetMouseOverURL(const WebURL& url) {
mouse_over_url_ = KURL(url);
UpdateTargetURL(mouse_over_url_, focus_url_);
}
void WebViewImpl::SetKeyboardFocusURL(const WebURL& url) {
focus_url_ = KURL(url);
UpdateTargetURL(focus_url_, mouse_over_url_);
}
void WebViewImpl::UpdateTargetURL(const WebURL& url,
const WebURL& fallback_url) {
KURL latest_url = KURL(url.IsEmpty() ? fallback_url : url);
......@@ -2958,30 +2968,30 @@ void WebViewImpl::UpdateTargetURL(const WebURL& url,
// see |ParamTraits<GURL>|.
if (latest_url.GetString().length() > url::kMaxURLChars)
latest_url = KURL();
UpdateTargetURLInBrowser(latest_url);
SendUpdatedTargetURLToBrowser(latest_url);
target_url_ = latest_url;
target_url_status_ = TARGET_INFLIGHT;
}
}
void WebViewImpl::UpdateTargetURLInBrowser(const KURL& target_url) {
void WebViewImpl::SendUpdatedTargetURLToBrowser(const KURL& target_url) {
if (GetPage()->MainFrame()->IsLocalFrame()) {
DCHECK(local_main_frame_host_remote_);
local_main_frame_host_remote_->UpdateTargetURL(
target_url, WTF::Bind(&WebViewImpl::TargetURLUpdated,
target_url, WTF::Bind(&WebViewImpl::TargetURLUpdatedInBrowser,
weak_ptr_factory_.GetWeakPtr()));
} else {
DCHECK(remote_main_frame_host_remote_);
remote_main_frame_host_remote_->UpdateTargetURL(
target_url, WTF::Bind(&WebViewImpl::TargetURLUpdated,
target_url, WTF::Bind(&WebViewImpl::TargetURLUpdatedInBrowser,
weak_ptr_factory_.GetWeakPtr()));
}
}
void WebViewImpl::TargetURLUpdated() {
void WebViewImpl::TargetURLUpdatedInBrowser() {
// Check if there is a targeturl waiting to be sent.
if (target_url_status_ == TARGET_PENDING)
UpdateTargetURLInBrowser(pending_target_url_);
SendUpdatedTargetURLToBrowser(pending_target_url_);
target_url_status_ = TARGET_NONE;
}
......
......@@ -189,7 +189,8 @@ class CORE_EXPORT WebViewImpl final : public WebView,
void UpdatePreferredSize() override;
void EnablePreferredSizeChangedMode() override;
void Focus() override;
void UpdateTargetURL(const WebURL& url, const WebURL& fallback_url) override;
void SetMouseOverURL(const WebURL& url) override;
void SetKeyboardFocusURL(const WebURL& url) override;
void SetDeviceScaleFactor(float) override;
void SetZoomFactorForDeviceScaleFactor(float) override;
float ZoomFactorForDeviceScaleFactor() override {
......@@ -498,8 +499,14 @@ class CORE_EXPORT WebViewImpl final : public WebView,
bool SelectionBounds(WebRect& anchor, WebRect& focus) const;
WebURL GetURLForDebugTrace();
void UpdateTargetURLInBrowser(const KURL& target_url);
void TargetURLUpdated();
// Update the target url locally and tell the browser that the target URL has
// changed. If |url| is empty, show |fallback_url|.
void UpdateTargetURL(const WebURL& url, const WebURL& fallback_url);
// Helper functions to send the updated target URL to the right render frame
// in the browser process, and to handle its associated reply message.
void SendUpdatedTargetURLToBrowser(const KURL& target_url);
void TargetURLUpdatedInBrowser();
void SetPageScaleFactorAndLocation(float scale,
bool is_pinch_gesture_active,
......@@ -645,6 +652,12 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// The next target URL we want to send to the browser.
KURL pending_target_url_;
// The URL the user's mouse is hovering over.
KURL mouse_over_url_;
// The URL that has keyboard focus.
KURL focus_url_;
// Keeps track of the current zoom level. 0 means no zoom, positive numbers
// mean zoom in, negative numbers mean zoom out.
double zoom_level_ = 0.;
......
......@@ -228,7 +228,7 @@ void ChromeClientImpl::SetKeyboardFocusURL(Element* new_focus_element) {
if (new_focus_element && new_focus_element->IsLiveLink() &&
new_focus_element->ShouldHaveFocusAppearance())
focus_url = new_focus_element->HrefURL();
web_view_->Client()->SetKeyboardFocusURL(focus_url);
web_view_->SetKeyboardFocusURL(focus_url);
}
void ChromeClientImpl::StartDragging(LocalFrame* frame,
......@@ -568,7 +568,7 @@ void ChromeClientImpl::ShowMouseOverURL(const HitTestResult& result) {
}
}
web_view_->Client()->SetMouseOverURL(url);
web_view_->SetMouseOverURL(url);
}
void ChromeClientImpl::SetToolTip(LocalFrame& frame,
......
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