| 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 | 730 |
| 731 void RenderWidgetHostImpl::GotFocus() { | 731 void RenderWidgetHostImpl::GotFocus() { |
| 732 Focus(); | 732 Focus(); |
| 733 if (owner_delegate_) | 733 if (owner_delegate_) |
| 734 owner_delegate_->RenderWidgetGotFocus(); | 734 owner_delegate_->RenderWidgetGotFocus(); |
| 735 if (delegate_) | 735 if (delegate_) |
| 736 delegate_->RenderWidgetGotFocus(this); | 736 delegate_->RenderWidgetGotFocus(this); |
| 737 } | 737 } |
| 738 | 738 |
| 739 void RenderWidgetHostImpl::Focus() { | 739 void RenderWidgetHostImpl::Focus() { |
| 740 is_focused_ = true; | 740 RenderWidgetHostImpl* focused_widget = |
| 741 delegate_ ? delegate_->GetRenderWidgetHostWithPageFocus() : nullptr; |
| 741 | 742 |
| 742 Send(new InputMsg_SetFocus(routing_id_, true)); | 743 if (!focused_widget) |
| 744 focused_widget = this; |
| 745 focused_widget->SetPageFocus(true); |
| 746 } |
| 747 |
| 748 void RenderWidgetHostImpl::Blur() { |
| 749 RenderWidgetHostImpl* focused_widget = |
| 750 delegate_ ? delegate_->GetRenderWidgetHostWithPageFocus() : nullptr; |
| 751 |
| 752 if (!focused_widget) |
| 753 focused_widget = this; |
| 754 focused_widget->SetPageFocus(false); |
| 755 } |
| 756 |
| 757 void RenderWidgetHostImpl::SetPageFocus(bool focused) { |
| 758 is_focused_ = focused; |
| 759 |
| 760 if (!focused) { |
| 761 // If there is a pending mouse lock request, we don't want to reject it at |
| 762 // this point. The user can switch focus back to this view and approve the |
| 763 // request later. |
| 764 if (IsMouseLocked()) |
| 765 view_->UnlockMouse(); |
| 766 |
| 767 if (touch_emulator_) |
| 768 touch_emulator_->CancelTouch(); |
| 769 } |
| 770 |
| 771 Send(new InputMsg_SetFocus(routing_id_, focused)); |
| 743 | 772 |
| 744 // Also send page-level focus state to other SiteInstances involved in | 773 // Also send page-level focus state to other SiteInstances involved in |
| 745 // rendering the current FrameTree. | 774 // rendering the current FrameTree. |
| 746 if (RenderViewHost::From(this) && delegate_) | 775 if (RenderViewHost::From(this) && delegate_) |
| 747 delegate_->ReplicatePageFocus(true); | 776 delegate_->ReplicatePageFocus(focused); |
| 748 } | |
| 749 | |
| 750 void RenderWidgetHostImpl::Blur() { | |
| 751 is_focused_ = false; | |
| 752 | |
| 753 // If there is a pending mouse lock request, we don't want to reject it at | |
| 754 // this point. The user can switch focus back to this view and approve the | |
| 755 // request later. | |
| 756 if (IsMouseLocked()) | |
| 757 view_->UnlockMouse(); | |
| 758 | |
| 759 if (touch_emulator_) | |
| 760 touch_emulator_->CancelTouch(); | |
| 761 | |
| 762 Send(new InputMsg_SetFocus(routing_id_, false)); | |
| 763 | |
| 764 // Also send page-level focus state to other SiteInstances involved in | |
| 765 // rendering the current FrameTree. | |
| 766 if (RenderViewHost::From(this) && delegate_) | |
| 767 delegate_->ReplicatePageFocus(false); | |
| 768 } | 777 } |
| 769 | 778 |
| 770 void RenderWidgetHostImpl::LostCapture() { | 779 void RenderWidgetHostImpl::LostCapture() { |
| 771 if (touch_emulator_) | 780 if (touch_emulator_) |
| 772 touch_emulator_->CancelTouch(); | 781 touch_emulator_->CancelTouch(); |
| 773 | 782 |
| 774 Send(new InputMsg_MouseCaptureLost(routing_id_)); | 783 Send(new InputMsg_MouseCaptureLost(routing_id_)); |
| 775 | 784 |
| 776 if (delegate_) | 785 if (delegate_) |
| 777 delegate_->LostCapture(this); | 786 delegate_->LostCapture(this); |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { | 2078 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { |
| 2070 // Don't ignore touch cancel events, since they may be sent while input | 2079 // Don't ignore touch cancel events, since they may be sent while input |
| 2071 // events are being ignored in order to keep the renderer from getting | 2080 // events are being ignored in order to keep the renderer from getting |
| 2072 // confused about how many touches are active. | 2081 // confused about how many touches are active. |
| 2073 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) | 2082 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) |
| 2074 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 2083 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 2075 | 2084 |
| 2076 if (!process_->HasConnection()) | 2085 if (!process_->HasConnection()) |
| 2077 return INPUT_EVENT_ACK_STATE_UNKNOWN; | 2086 return INPUT_EVENT_ACK_STATE_UNKNOWN; |
| 2078 | 2087 |
| 2079 if (delegate_ && (event.type == WebInputEvent::MouseDown || | 2088 if (delegate_) { |
| 2080 event.type == WebInputEvent::GestureScrollBegin || | 2089 if (event.type == WebInputEvent::MouseDown || |
| 2081 event.type == WebInputEvent::TouchStart || | 2090 event.type == WebInputEvent::TouchStart) { |
| 2082 event.type == WebInputEvent::RawKeyDown)) { | 2091 delegate_->FocusOwningWebContents(this); |
| 2083 delegate_->OnUserInteraction(this, event.type); | 2092 } |
| 2093 if (event.type == WebInputEvent::MouseDown || |
| 2094 event.type == WebInputEvent::GestureScrollBegin || |
| 2095 event.type == WebInputEvent::TouchStart || |
| 2096 event.type == WebInputEvent::RawKeyDown) { |
| 2097 delegate_->OnUserInteraction(this, event.type); |
| 2098 } |
| 2084 } | 2099 } |
| 2085 | 2100 |
| 2086 return view_ ? view_->FilterInputEvent(event) | 2101 return view_ ? view_->FilterInputEvent(event) |
| 2087 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 2102 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 2088 } | 2103 } |
| 2089 | 2104 |
| 2090 void RenderWidgetHostImpl::IncrementInFlightEventCount( | 2105 void RenderWidgetHostImpl::IncrementInFlightEventCount( |
| 2091 blink::WebInputEvent::Type event_type) { | 2106 blink::WebInputEvent::Type event_type) { |
| 2092 increment_in_flight_event_count(); | 2107 increment_in_flight_event_count(); |
| 2093 if (!is_hidden_) { | 2108 if (!is_hidden_) { |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2492 // Note: We are using the origin URL provided by the sender here. It may be | 2507 // Note: We are using the origin URL provided by the sender here. It may be |
| 2493 // different from the receiver's. | 2508 // different from the receiver's. |
| 2494 file_system_file.url = | 2509 file_system_file.url = |
| 2495 GURL(storage::GetIsolatedFileSystemRootURIString( | 2510 GURL(storage::GetIsolatedFileSystemRootURIString( |
| 2496 file_system_url.origin(), filesystem_id, std::string()) | 2511 file_system_url.origin(), filesystem_id, std::string()) |
| 2497 .append(register_name)); | 2512 .append(register_name)); |
| 2498 } | 2513 } |
| 2499 } | 2514 } |
| 2500 | 2515 |
| 2501 } // namespace content | 2516 } // namespace content |
| OLD | NEW |