Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(995)

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2451143003: <webview>: Correctly shift focus between WebContents. (Closed)
Patch Set: Fix creis comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 9a76bae9c87376deaff6fca06f7b11c82ba19ecf..ac27c591d0f62f2d70775ddcc5f75595fd04e033 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -737,34 +737,43 @@ void RenderWidgetHostImpl::GotFocus() {
}
void RenderWidgetHostImpl::Focus() {
- is_focused_ = true;
+ RenderWidgetHostImpl* focused_widget =
+ delegate_ ? delegate_->GetRenderWidgetHostWithPageFocus() : nullptr;
- Send(new InputMsg_SetFocus(routing_id_, true));
-
- // Also send page-level focus state to other SiteInstances involved in
- // rendering the current FrameTree.
- if (RenderViewHost::From(this) && delegate_)
- delegate_->ReplicatePageFocus(true);
+ if (!focused_widget)
+ focused_widget = this;
+ focused_widget->SetPageFocus(true);
}
void RenderWidgetHostImpl::Blur() {
- is_focused_ = false;
+ RenderWidgetHostImpl* focused_widget =
+ delegate_ ? delegate_->GetRenderWidgetHostWithPageFocus() : nullptr;
- // If there is a pending mouse lock request, we don't want to reject it at
- // this point. The user can switch focus back to this view and approve the
- // request later.
- if (IsMouseLocked())
- view_->UnlockMouse();
+ if (!focused_widget)
+ focused_widget = this;
+ focused_widget->SetPageFocus(false);
+}
- if (touch_emulator_)
- touch_emulator_->CancelTouch();
+void RenderWidgetHostImpl::SetPageFocus(bool focused) {
+ is_focused_ = focused;
- Send(new InputMsg_SetFocus(routing_id_, false));
+ if (!focused) {
+ // If there is a pending mouse lock request, we don't want to reject it at
+ // this point. The user can switch focus back to this view and approve the
+ // request later.
+ if (IsMouseLocked())
+ view_->UnlockMouse();
+
+ if (touch_emulator_)
+ touch_emulator_->CancelTouch();
+ }
+
+ Send(new InputMsg_SetFocus(routing_id_, focused));
// Also send page-level focus state to other SiteInstances involved in
// rendering the current FrameTree.
if (RenderViewHost::From(this) && delegate_)
- delegate_->ReplicatePageFocus(false);
+ delegate_->ReplicatePageFocus(focused);
}
void RenderWidgetHostImpl::LostCapture() {
@@ -2076,11 +2085,17 @@ InputEventAckState RenderWidgetHostImpl::FilterInputEvent(
if (!process_->HasConnection())
return INPUT_EVENT_ACK_STATE_UNKNOWN;
- if (delegate_ && (event.type == WebInputEvent::MouseDown ||
- event.type == WebInputEvent::GestureScrollBegin ||
- event.type == WebInputEvent::TouchStart ||
- event.type == WebInputEvent::RawKeyDown)) {
- delegate_->OnUserInteraction(this, event.type);
+ if (delegate_) {
+ if (event.type == WebInputEvent::MouseDown ||
+ event.type == WebInputEvent::TouchStart) {
+ delegate_->FocusOwningWebContents(this);
+ }
+ if (event.type == WebInputEvent::MouseDown ||
+ event.type == WebInputEvent::GestureScrollBegin ||
+ event.type == WebInputEvent::TouchStart ||
+ event.type == WebInputEvent::RawKeyDown) {
+ delegate_->OnUserInteraction(this, event.type);
+ }
}
return view_ ? view_->FilterInputEvent(event)
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698