Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 | 685 |
| 686 void RenderWidgetHostImpl::GotFocus() { | 686 void RenderWidgetHostImpl::GotFocus() { |
| 687 Focus(); | 687 Focus(); |
| 688 if (owner_delegate_) | 688 if (owner_delegate_) |
| 689 owner_delegate_->RenderWidgetGotFocus(); | 689 owner_delegate_->RenderWidgetGotFocus(); |
| 690 if (delegate_) | 690 if (delegate_) |
| 691 delegate_->RenderWidgetGotFocus(this); | 691 delegate_->RenderWidgetGotFocus(this); |
| 692 } | 692 } |
| 693 | 693 |
| 694 void RenderWidgetHostImpl::Focus() { | 694 void RenderWidgetHostImpl::Focus() { |
| 695 RenderWidgetHostImpl* focused_widget = | |
| 696 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
| |
| 697 | |
| 698 if (focused_widget) | |
| 699 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
| |
| 700 else | |
| 701 FocusDirect(); | |
| 702 } | |
| 703 | |
| 704 void RenderWidgetHostImpl::Blur() { | |
| 705 RenderWidgetHostImpl* focused_widget = | |
| 706 delegate_ ? delegate_->GetFocusedRenderWidgetHost(this) : nullptr; | |
| 707 | |
| 708 if (focused_widget) | |
| 709 focused_widget->BlurDirect(); | |
| 710 else | |
| 711 BlurDirect(); | |
| 712 } | |
| 713 | |
| 714 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.
| |
| 695 is_focused_ = true; | 715 is_focused_ = true; |
| 696 | 716 |
| 697 Send(new InputMsg_SetFocus(routing_id_, true)); | 717 Send(new InputMsg_SetFocus(routing_id_, true)); |
| 698 | 718 |
| 699 // Also send page-level focus state to other SiteInstances involved in | 719 // Also send page-level focus state to other SiteInstances involved in |
| 700 // rendering the current FrameTree. | 720 // rendering the current FrameTree. |
| 701 if (RenderViewHost::From(this) && delegate_) | 721 if (RenderViewHost::From(this) && delegate_) |
| 702 delegate_->ReplicatePageFocus(true); | 722 delegate_->ReplicatePageFocus(true); |
| 703 } | 723 } |
| 704 | 724 |
| 705 void RenderWidgetHostImpl::Blur() { | 725 void RenderWidgetHostImpl::BlurDirect() { |
| 706 is_focused_ = false; | 726 is_focused_ = false; |
| 707 | 727 |
| 708 // If there is a pending mouse lock request, we don't want to reject it at | 728 // If there is a pending mouse lock request, we don't want to reject it at |
| 709 // this point. The user can switch focus back to this view and approve the | 729 // this point. The user can switch focus back to this view and approve the |
| 710 // request later. | 730 // request later. |
| 711 if (IsMouseLocked()) | 731 if (IsMouseLocked()) |
| 712 view_->UnlockMouse(); | 732 view_->UnlockMouse(); |
| 713 | 733 |
| 714 if (touch_emulator_) | 734 if (touch_emulator_) |
| 715 touch_emulator_->CancelTouch(); | 735 touch_emulator_->CancelTouch(); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1879 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { | 1899 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { |
| 1880 // Don't ignore touch cancel events, since they may be sent while input | 1900 // Don't ignore touch cancel events, since they may be sent while input |
| 1881 // events are being ignored in order to keep the renderer from getting | 1901 // events are being ignored in order to keep the renderer from getting |
| 1882 // confused about how many touches are active. | 1902 // confused about how many touches are active. |
| 1883 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) | 1903 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) |
| 1884 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 1904 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 1885 | 1905 |
| 1886 if (!process_->HasConnection()) | 1906 if (!process_->HasConnection()) |
| 1887 return INPUT_EVENT_ACK_STATE_UNKNOWN; | 1907 return INPUT_EVENT_ACK_STATE_UNKNOWN; |
| 1888 | 1908 |
| 1889 if (delegate_ && (event.type == WebInputEvent::MouseDown || | 1909 if (delegate_) { |
| 1890 event.type == WebInputEvent::GestureScrollBegin || | 1910 if (event.type == WebInputEvent::MouseDown || |
| 1891 event.type == WebInputEvent::TouchStart || | 1911 event.type == WebInputEvent::TouchStart) { |
| 1892 event.type == WebInputEvent::RawKeyDown)) { | 1912 delegate_->EnsureOwningContentsIsFocused(this); |
| 1893 delegate_->OnUserInteraction(this, event.type); | 1913 } |
| 1914 if (event.type == WebInputEvent::MouseDown || | |
| 1915 event.type == WebInputEvent::GestureScrollBegin || | |
| 1916 event.type == WebInputEvent::TouchStart || | |
| 1917 event.type == WebInputEvent::RawKeyDown) { | |
| 1918 delegate_->OnUserInteraction(this, event.type); | |
| 1919 } | |
| 1894 } | 1920 } |
| 1895 | 1921 |
| 1896 return view_ ? view_->FilterInputEvent(event) | 1922 return view_ ? view_->FilterInputEvent(event) |
| 1897 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1923 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1898 } | 1924 } |
| 1899 | 1925 |
| 1900 void RenderWidgetHostImpl::IncrementInFlightEventCount( | 1926 void RenderWidgetHostImpl::IncrementInFlightEventCount( |
| 1901 blink::WebInputEvent::Type event_type) { | 1927 blink::WebInputEvent::Type event_type) { |
| 1902 increment_in_flight_event_count(); | 1928 increment_in_flight_event_count(); |
| 1903 if (!is_hidden_) { | 1929 if (!is_hidden_) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2222 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2248 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2223 } | 2249 } |
| 2224 | 2250 |
| 2225 BrowserAccessibilityManager* | 2251 BrowserAccessibilityManager* |
| 2226 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2252 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2227 return delegate_ ? | 2253 return delegate_ ? |
| 2228 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2254 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| 2229 } | 2255 } |
| 2230 | 2256 |
| 2231 } // namespace content | 2257 } // namespace content |
| OLD | NEW |