Skip to content

Commit

Permalink
Move didFocus from WebWidgetClient to WebViewClient.
Browse files Browse the repository at this point in the history
This method is used to bring the window to focus, and only makes sense
when called on the main frame.

This is part of a refactor to split WebView/WebWidget.

BUG=419087

Review-Url: https://codereview.chromium.org/2157113002
Cr-Commit-Position: refs/heads/master@{#406609}
  • Loading branch information
lucasgadani authored and Commit bot committed Jul 20, 2016
1 parent 0f92cee commit 09e6b3b
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion components/test_runner/web_test_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class WebTestProxy : public Base, public WebTestProxyBase {
return widget_test_client()->isPointerLocked();
}
void didFocus() override {
widget_test_client()->didFocus();
view_test_client()->didFocus();
Base::didFocus();
}
void setToolTipText(const blink::WebString& text,
Expand Down
4 changes: 4 additions & 0 deletions components/test_runner/web_view_test_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,8 @@ WebTestDelegate* WebViewTestClient::delegate() {
return web_test_proxy_base_->delegate();
}

void WebViewTestClient::didFocus() {
test_runner_->SetFocus(web_test_proxy_base_->web_view(), true);
}

} // namespace test_runner
1 change: 1 addition & 0 deletions components/test_runner/web_view_test_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class WebViewTestClient : public blink::WebViewClient {
void printPage(blink::WebLocalFrame* frame) override;
blink::WebSpeechRecognizer* speechRecognizer() override;
blink::WebString acceptLanguages() override;
void didFocus() override;

private:
WebTestDelegate* delegate();
Expand Down
4 changes: 0 additions & 4 deletions components/test_runner/web_widget_test_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ bool WebWidgetTestClient::isPointerLocked() {
return web_test_proxy_base_->view_test_runner()->isPointerLocked();
}

void WebWidgetTestClient::didFocus() {
test_runner_->SetFocus(web_test_proxy_base_->web_view(), true);
}

void WebWidgetTestClient::setToolTipText(const blink::WebString& text,
blink::WebTextDirection direction) {
test_runner_->setToolTipText(text);
Expand Down
1 change: 0 additions & 1 deletion components/test_runner/web_widget_test_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class WebWidgetTestClient : public blink::WebWidgetClient {
bool requestPointerLock() override;
void requestPointerUnlock() override;
bool isPointerLocked() override;
void didFocus() override;
void setToolTipText(const blink::WebString& text,
blink::WebTextDirection direction) override;
void resetInputMethod() override;
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/render_view_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ class CONTENT_EXPORT RenderViewImpl
// blink::WebWidgetClient implementation ------------------------------------

// Most methods are handled by RenderWidget.
void didFocus() override;
void show(blink::WebNavigationPolicy policy) override;
void didHandleGestureEvent(const blink::WebGestureEvent& event,
bool event_cancelled) override;
Expand Down Expand Up @@ -384,6 +383,7 @@ class CONTENT_EXPORT RenderViewImpl
void pageImportanceSignalsChanged() override;
void didAutoResize(const blink::WebSize& newSize) override;
blink::WebRect rootWindowRect() override;
void didFocus() override;

#if defined(OS_ANDROID)
void scheduleContentIntent(const blink::WebURL& intent,
Expand Down
3 changes: 0 additions & 3 deletions content/renderer/render_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1220,9 +1220,6 @@ void RenderWidget::show(WebNavigationPolicy) {
SetPendingWindowRect(initial_rect_);
}

void RenderWidget::didFocus() {
}

void RenderWidget::DoDeferredClose() {
WillCloseLayerTreeView();
Send(new ViewHostMsg_Close(routing_id_));
Expand Down
1 change: 0 additions & 1 deletion content/renderer/render_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ class CONTENT_EXPORT RenderWidget
void initializeLayerTreeView() override;
blink::WebLayerTreeView* layerTreeView() override;
void didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
void didFocus() override;
void didChangeCursor(const blink::WebCursorInfo&) override;
void closeWidgetSoon() override;
void show(blink::WebNavigationPolicy) override;
Expand Down
3 changes: 2 additions & 1 deletion third_party/WebKit/public/web/WebViewClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ class WebViewClient : protected WebWidgetClient {
// Called when the View has changed size as a result of an auto-resize.
virtual void didAutoResize(const WebSize& newSize) {}

// Called when the View acquires focus.
virtual void didFocus() {}

// Session history -----------------------------------------------------

Expand Down Expand Up @@ -260,7 +262,6 @@ class WebViewClient : protected WebWidgetClient {
void closeWidgetSoon() override {}
void convertViewportToWindow(WebRect* rect) override {}
void convertWindowToViewport(WebFloatRect* rect) override {}
void didFocus() override {}
void didHandleGestureEvent(const WebGestureEvent& event, bool eventCancelled) override {}
void didInvalidateRect(const WebRect&) override {}
void didOverscroll(const WebFloatSize& overscrollDelta, const WebFloatSize& accumulatedOverscroll, const WebFloatPoint& positionInViewport, const WebFloatSize& velocityInViewport) override {}
Expand Down
4 changes: 0 additions & 4 deletions third_party/WebKit/public/web/WebWidgetClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class WebWidgetClient {

virtual void didFirstLayoutAfterFinishedParsing() { }

// Called when the widget acquires or loses focus, respectively.
virtual void didFocus() { }
virtual void didBlur() { }

// Called when the cursor for the widget changes.
virtual void didChangeCursor(const WebCursorInfo&) { }

Expand Down

0 comments on commit 09e6b3b

Please sign in to comment.