Browser Plugin: Make aware of focus direction.
In order to fix focus ordering into and out of GuestViews, this CL makes focus
aware of tab direction.
This CL is the content side change for this Blink change:
https://codereview.chromium.org/852083002
BUG=448716, 147644
[email protected] for trivial browser_plugin_messages.h change (added focus type to existing IPC).
Review URL: https://codereview.chromium.org/853333002
Cr-Commit-Position: refs/heads/master@{#312126}
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 16a4473df..5309523 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -132,11 +132,18 @@
return weak_ptr_factory_.GetWeakPtr();
}
-void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh, bool focused) {
+void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh,
+ bool focused,
+ blink::WebFocusType focus_type) {
focused_ = focused;
if (!rwh)
return;
+ if ((focus_type == blink::WebFocusTypeForward) ||
+ (focus_type == blink::WebFocusTypeBackward)) {
+ static_cast<RenderViewHostImpl*>(RenderViewHost::From(rwh))->
+ SetInitialFocus(focus_type == blink::WebFocusTypeBackward);
+ }
rwh->Send(new InputMsg_SetFocus(rwh->GetRoutingID(), focused));
if (!focused && mouse_locked_)
OnUnlockMouse();
@@ -220,7 +227,9 @@
const BrowserPluginHostMsg_Attach_Params& params,
WebContentsImpl* owner_web_contents) {
focused_ = params.focused;
- OnSetFocus(browser_plugin::kInstanceIDNone, focused_);
+ OnSetFocus(browser_plugin::kInstanceIDNone,
+ focused_,
+ blink::WebFocusTypeNone);
guest_visible_ = params.visible;
UpdateVisibility();
@@ -748,10 +757,11 @@
}
void BrowserPluginGuest::OnSetFocus(int browser_plugin_instance_id,
- bool focused) {
+ bool focused,
+ blink::WebFocusType focus_type) {
RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView();
RenderWidgetHost* rwh = rwhv ? rwhv->GetRenderWidgetHost() : NULL;
- SetFocus(rwh, focused);
+ SetFocus(rwh, focused, focus_type);
}
void BrowserPluginGuest::OnSetEditCommandsForNextKeyEvent(