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 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 ignore_input_events_(false), | 177 ignore_input_events_(false), |
| 178 input_method_active_(false), | 178 input_method_active_(false), |
| 179 text_direction_updated_(false), | 179 text_direction_updated_(false), |
| 180 text_direction_(blink::WebTextDirectionLeftToRight), | 180 text_direction_(blink::WebTextDirectionLeftToRight), |
| 181 text_direction_canceled_(false), | 181 text_direction_canceled_(false), |
| 182 suppress_next_char_events_(false), | 182 suppress_next_char_events_(false), |
| 183 pending_mouse_lock_request_(false), | 183 pending_mouse_lock_request_(false), |
| 184 allow_privileged_mouse_lock_(false), | 184 allow_privileged_mouse_lock_(false), |
| 185 has_touch_handler_(false), | 185 has_touch_handler_(false), |
| 186 next_browser_snapshot_id_(1), | 186 next_browser_snapshot_id_(1), |
| 187 is_focused_(false), | |
| 187 weak_factory_(this) { | 188 weak_factory_(this) { |
| 188 CHECK(delegate_); | 189 CHECK(delegate_); |
| 189 if (routing_id_ == MSG_ROUTING_NONE) { | 190 if (routing_id_ == MSG_ROUTING_NONE) { |
| 190 routing_id_ = process_->GetNextRoutingID(); | 191 routing_id_ = process_->GetNextRoutingID(); |
| 191 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 192 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
| 192 process_->GetID(), | 193 process_->GetID(), |
| 193 routing_id_); | 194 routing_id_); |
| 194 } else { | 195 } else { |
| 195 // TODO(piman): This is a O(N) lookup, where we could forward the | 196 // TODO(piman): This is a O(N) lookup, where we could forward the |
| 196 // information from the RenderWidgetHelper. The problem is that doing so | 197 // information from the RenderWidgetHelper. The problem is that doing so |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); | 644 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); |
| 644 } | 645 } |
| 645 | 646 |
| 646 void RenderWidgetHostImpl::GotFocus() { | 647 void RenderWidgetHostImpl::GotFocus() { |
| 647 Focus(); | 648 Focus(); |
| 648 if (delegate_) | 649 if (delegate_) |
| 649 delegate_->RenderWidgetGotFocus(this); | 650 delegate_->RenderWidgetGotFocus(this); |
| 650 } | 651 } |
| 651 | 652 |
| 652 void RenderWidgetHostImpl::Focus() { | 653 void RenderWidgetHostImpl::Focus() { |
| 654 is_focused_ = true; | |
| 653 Send(new InputMsg_SetFocus(routing_id_, true)); | 655 Send(new InputMsg_SetFocus(routing_id_, true)); |
| 654 } | 656 } |
| 655 | 657 |
| 656 void RenderWidgetHostImpl::Blur() { | 658 void RenderWidgetHostImpl::Blur() { |
| 659 is_focused_ = false; | |
|
Charlie Reis
2015/01/21 17:55:33
Is this always called when another widget grabs fo
mlamouri (slow - plz ping)
2015/01/21 21:33:27
As far as I can tell, yes. I also did a couple of
| |
| 660 | |
| 657 // If there is a pending mouse lock request, we don't want to reject it at | 661 // If there is a pending mouse lock request, we don't want to reject it at |
| 658 // this point. The user can switch focus back to this view and approve the | 662 // this point. The user can switch focus back to this view and approve the |
| 659 // request later. | 663 // request later. |
| 660 if (IsMouseLocked()) | 664 if (IsMouseLocked()) |
| 661 view_->UnlockMouse(); | 665 view_->UnlockMouse(); |
| 662 | 666 |
| 663 if (touch_emulator_) | 667 if (touch_emulator_) |
| 664 touch_emulator_->CancelTouch(); | 668 touch_emulator_->CancelTouch(); |
| 665 | 669 |
| 666 Send(new InputMsg_SetFocus(routing_id_, false)); | 670 Send(new InputMsg_SetFocus(routing_id_, false)); |
| 667 } | 671 } |
| 668 | 672 |
| 673 bool RenderWidgetHostImpl::IsFocused() const { | |
| 674 return is_focused_; | |
| 675 } | |
| 676 | |
| 669 void RenderWidgetHostImpl::LostCapture() { | 677 void RenderWidgetHostImpl::LostCapture() { |
| 670 if (touch_emulator_) | 678 if (touch_emulator_) |
| 671 touch_emulator_->CancelTouch(); | 679 touch_emulator_->CancelTouch(); |
| 672 | 680 |
| 673 Send(new InputMsg_MouseCaptureLost(routing_id_)); | 681 Send(new InputMsg_MouseCaptureLost(routing_id_)); |
| 674 } | 682 } |
| 675 | 683 |
| 676 void RenderWidgetHostImpl::SetActive(bool active) { | 684 void RenderWidgetHostImpl::SetActive(bool active) { |
| 677 Send(new ViewMsg_SetActive(routing_id_, active)); | 685 Send(new ViewMsg_SetActive(routing_id_, active)); |
| 678 } | 686 } |
| (...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2160 } | 2168 } |
| 2161 #endif | 2169 #endif |
| 2162 | 2170 |
| 2163 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2171 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2164 if (view_) | 2172 if (view_) |
| 2165 return view_->PreferredReadbackFormat(); | 2173 return view_->PreferredReadbackFormat(); |
| 2166 return kN32_SkColorType; | 2174 return kN32_SkColorType; |
| 2167 } | 2175 } |
| 2168 | 2176 |
| 2169 } // namespace content | 2177 } // namespace content |
| OLD | NEW |