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 = nullptr; | |
| 696 if (delegate_) | |
| 697 focused_widget = delegate_->GetFocusedRenderWidgetHost(this); | |
|
wjmaclean
2016/10/27 18:41:01
Minor suggestion:
RenderWidgetHostImpl* focused_w
avallee
2016/10/27 19:00:57
Done. How do we feel about auto*?
avallee
2016/11/16 21:18:10
csreis asked for this to be reverted in https://co
Charlie Reis
2016/11/16 21:51:19
Maybe there's a misunderstanding? I'm fine with w
| |
| 698 | |
| 699 if (focused_widget) | |
| 700 focused_widget->FocusDirect(); | |
| 701 else | |
| 702 FocusDirect(); | |
| 703 } | |
| 704 | |
| 705 void RenderWidgetHostImpl::Blur() { | |
| 706 RenderWidgetHostImpl* focused_widget = nullptr; | |
| 707 if (delegate_) | |
| 708 focused_widget = delegate_->GetFocusedRenderWidgetHost(this); | |
| 709 | |
| 710 if (focused_widget) | |
| 711 focused_widget->BlurDirect(); | |
| 712 else | |
| 713 BlurDirect(); | |
| 714 } | |
| 715 | |
| 716 void RenderWidgetHostImpl::FocusDirect() { | |
| 695 is_focused_ = true; | 717 is_focused_ = true; |
| 696 | 718 |
| 697 Send(new InputMsg_SetFocus(routing_id_, true)); | 719 Send(new InputMsg_SetFocus(routing_id_, true)); |
| 698 | 720 |
| 699 // Also send page-level focus state to other SiteInstances involved in | 721 // Also send page-level focus state to other SiteInstances involved in |
| 700 // rendering the current FrameTree. | 722 // rendering the current FrameTree. |
| 701 if (RenderViewHost::From(this) && delegate_) | 723 if (RenderViewHost::From(this) && delegate_) |
| 702 delegate_->ReplicatePageFocus(true); | 724 delegate_->ReplicatePageFocus(true); |
| 703 } | 725 } |
| 704 | 726 |
| 705 void RenderWidgetHostImpl::Blur() { | 727 void RenderWidgetHostImpl::BlurDirect() { |
| 706 is_focused_ = false; | 728 is_focused_ = false; |
| 707 | 729 |
| 708 // If there is a pending mouse lock request, we don't want to reject it at | 730 // 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 | 731 // this point. The user can switch focus back to this view and approve the |
| 710 // request later. | 732 // request later. |
| 711 if (IsMouseLocked()) | 733 if (IsMouseLocked()) |
| 712 view_->UnlockMouse(); | 734 view_->UnlockMouse(); |
| 713 | 735 |
| 714 if (touch_emulator_) | 736 if (touch_emulator_) |
| 715 touch_emulator_->CancelTouch(); | 737 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) { | 1901 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { |
| 1880 // Don't ignore touch cancel events, since they may be sent while input | 1902 // 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 | 1903 // events are being ignored in order to keep the renderer from getting |
| 1882 // confused about how many touches are active. | 1904 // confused about how many touches are active. |
| 1883 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) | 1905 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) |
| 1884 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 1906 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 1885 | 1907 |
| 1886 if (!process_->HasConnection()) | 1908 if (!process_->HasConnection()) |
| 1887 return INPUT_EVENT_ACK_STATE_UNKNOWN; | 1909 return INPUT_EVENT_ACK_STATE_UNKNOWN; |
| 1888 | 1910 |
| 1889 if (delegate_ && (event.type == WebInputEvent::MouseDown || | 1911 if (delegate_) { |
| 1890 event.type == WebInputEvent::GestureScrollBegin || | 1912 if (event.type == WebInputEvent::MouseDown || |
| 1891 event.type == WebInputEvent::TouchStart || | 1913 event.type == WebInputEvent::TouchStart) { |
| 1892 event.type == WebInputEvent::RawKeyDown)) { | 1914 delegate_->EnsureOwningContentsIsFocused(this); |
| 1893 delegate_->OnUserInteraction(this, event.type); | 1915 } |
| 1916 if (event.type == WebInputEvent::MouseDown || | |
| 1917 event.type == WebInputEvent::GestureScrollBegin || | |
| 1918 event.type == WebInputEvent::TouchStart || | |
| 1919 event.type == WebInputEvent::RawKeyDown) { | |
| 1920 delegate_->OnUserInteraction(this, event.type); | |
| 1921 } | |
| 1894 } | 1922 } |
| 1895 | 1923 |
| 1896 return view_ ? view_->FilterInputEvent(event) | 1924 return view_ ? view_->FilterInputEvent(event) |
| 1897 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1925 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1898 } | 1926 } |
| 1899 | 1927 |
| 1900 void RenderWidgetHostImpl::IncrementInFlightEventCount( | 1928 void RenderWidgetHostImpl::IncrementInFlightEventCount( |
| 1901 blink::WebInputEvent::Type event_type) { | 1929 blink::WebInputEvent::Type event_type) { |
| 1902 increment_in_flight_event_count(); | 1930 increment_in_flight_event_count(); |
| 1903 if (!is_hidden_) { | 1931 if (!is_hidden_) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2222 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2250 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2223 } | 2251 } |
| 2224 | 2252 |
| 2225 BrowserAccessibilityManager* | 2253 BrowserAccessibilityManager* |
| 2226 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2254 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2227 return delegate_ ? | 2255 return delegate_ ? |
| 2228 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2256 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| 2229 } | 2257 } |
| 2230 | 2258 |
| 2231 } // namespace content | 2259 } // namespace content |
| OLD | NEW |