Chromium Code Reviews| 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 0ce169540b3cae2c0e67d865f585d0d48d8763a3..24fdb73baac47aafaf8162e021d33d85483c8ec6 100644 |
| --- a/content/browser/renderer_host/render_widget_host_impl.cc |
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc |
| @@ -692,6 +692,26 @@ void RenderWidgetHostImpl::GotFocus() { |
| } |
| void RenderWidgetHostImpl::Focus() { |
| + RenderWidgetHostImpl* focused_widget = |
| + delegate_ ? delegate_->GetFocusedRenderWidgetHost(this) : nullptr; |
|
alexmos
2016/10/28 06:36:39
I think in the case where GetFocusedRenderWidgetHo
avallee
2016/10/28 19:19:56
The main place where Focus() is called is from the
alexmos
2016/10/31 18:57:57
It might not always be safe: a malicious embedder
avallee
2016/11/16 05:38:09
Would crashing the renderer lead a focus change? C
alexmos
2016/11/16 23:29:02
I'm not sure -- that's why I was curious if you co
|
| + |
| + if (focused_widget) |
| + focused_widget->FocusDirect(); |
|
alexmos
2016/10/28 06:36:39
I'm trying to understand the implication of this c
avallee
2016/10/28 19:19:56
I believe that GetFocusedWebContents()->GetMainFra
alexmos
2016/10/31 18:57:57
Yes, that looks better. However, are we sure that
alexmos
2016/11/09 02:47:54
Still curious about this. Might be worth trying p
avallee
2016/11/16 05:38:09
This DCHECK would fail if a webview is focused. On
alexmos
2016/11/16 23:29:02
Sorry, the DCHECK I had in mind was assuming a sin
|
| + else |
| + FocusDirect(); |
| +} |
| + |
| +void RenderWidgetHostImpl::Blur() { |
| + RenderWidgetHostImpl* focused_widget = |
| + delegate_ ? delegate_->GetFocusedRenderWidgetHost(this) : nullptr; |
| + |
| + if (focused_widget) |
| + focused_widget->BlurDirect(); |
| + else |
| + BlurDirect(); |
| +} |
| + |
| +void RenderWidgetHostImpl::FocusDirect() { |
|
alexmos
2016/10/28 06:36:39
I find these names a bit hard to interpret. Since
avallee
2016/10/28 19:19:56
Done.
|
| is_focused_ = true; |
| Send(new InputMsg_SetFocus(routing_id_, true)); |
| @@ -702,7 +722,7 @@ void RenderWidgetHostImpl::Focus() { |
| delegate_->ReplicatePageFocus(true); |
| } |
| -void RenderWidgetHostImpl::Blur() { |
| +void RenderWidgetHostImpl::BlurDirect() { |
| is_focused_ = false; |
| // If there is a pending mouse lock request, we don't want to reject it at |
| @@ -1886,11 +1906,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_->EnsureOwningContentsIsFocused(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) |