Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2915613004: [PointerLock] Move "silent mouse lock" logic from renderer to RWHI (Closed)
Patch Set: Don't pass bool to RejectMouseLockOrUnlockIfNecessary Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 is_unresponsive_(false), 279 is_unresponsive_(false),
280 in_flight_event_count_(0), 280 in_flight_event_count_(0),
281 in_get_backing_store_(false), 281 in_get_backing_store_(false),
282 ignore_input_events_(false), 282 ignore_input_events_(false),
283 text_direction_updated_(false), 283 text_direction_updated_(false),
284 text_direction_(blink::kWebTextDirectionLeftToRight), 284 text_direction_(blink::kWebTextDirectionLeftToRight),
285 text_direction_canceled_(false), 285 text_direction_canceled_(false),
286 suppress_events_until_keydown_(false), 286 suppress_events_until_keydown_(false),
287 pending_mouse_lock_request_(false), 287 pending_mouse_lock_request_(false),
288 allow_privileged_mouse_lock_(false), 288 allow_privileged_mouse_lock_(false),
289 is_last_unlocked_by_target_(false),
289 has_touch_handler_(false), 290 has_touch_handler_(false),
290 is_in_touchpad_gesture_fling_(false), 291 is_in_touchpad_gesture_fling_(false),
291 latency_tracker_(), 292 latency_tracker_(),
292 next_browser_snapshot_id_(1), 293 next_browser_snapshot_id_(1),
293 owned_by_render_frame_host_(false), 294 owned_by_render_frame_host_(false),
294 is_focused_(false), 295 is_focused_(false),
295 hung_renderer_delay_( 296 hung_renderer_delay_(
296 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), 297 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
297 hang_monitor_event_type_(blink::WebInputEvent::kUndefined), 298 hang_monitor_event_type_(blink::WebInputEvent::kUndefined),
298 last_event_type_(blink::WebInputEvent::kUndefined), 299 last_event_type_(blink::WebInputEvent::kUndefined),
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 if (view_) 2062 if (view_)
2062 view_->ImeCompositionRangeChanged(range, character_bounds); 2063 view_->ImeCompositionRangeChanged(range, character_bounds);
2063 } 2064 }
2064 2065
2065 void RenderWidgetHostImpl::OnImeCancelComposition() { 2066 void RenderWidgetHostImpl::OnImeCancelComposition() {
2066 if (view_) 2067 if (view_)
2067 view_->ImeCancelComposition(); 2068 view_->ImeCancelComposition();
2068 } 2069 }
2069 2070
2070 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture, 2071 void RenderWidgetHostImpl::OnLockMouse(bool user_gesture,
2071 bool last_unlocked_by_target,
2072 bool privileged) { 2072 bool privileged) {
2073 if (pending_mouse_lock_request_) { 2073 if (pending_mouse_lock_request_) {
2074 Send(new ViewMsg_LockMouse_ACK(routing_id_, false)); 2074 Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
2075 return; 2075 return;
2076 } 2076 }
2077 2077
2078 pending_mouse_lock_request_ = true; 2078 pending_mouse_lock_request_ = true;
2079 if (delegate_) { 2079 if (delegate_) {
2080 delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target, 2080 delegate_->RequestToLockMouse(this, user_gesture,
2081 is_last_unlocked_by_target_,
2081 privileged && allow_privileged_mouse_lock_); 2082 privileged && allow_privileged_mouse_lock_);
2083 // We need to reset |is_last_unlocked_by_target_| here as we don't know
2084 // request source in |LostMouseLock()|.
2085 is_last_unlocked_by_target_ = false;
2082 return; 2086 return;
2083 } 2087 }
2084 2088
2085 if (privileged && allow_privileged_mouse_lock_) { 2089 if (privileged && allow_privileged_mouse_lock_) {
2086 // Directly approve to lock the mouse. 2090 // Directly approve to lock the mouse.
2087 GotResponseToLockMouseRequest(true); 2091 GotResponseToLockMouseRequest(true);
2088 } else { 2092 } else {
2089 // Otherwise, just reject it. 2093 // Otherwise, just reject it.
2090 GotResponseToLockMouseRequest(false); 2094 GotResponseToLockMouseRequest(false);
2091 } 2095 }
2092 } 2096 }
2093 2097
2094 void RenderWidgetHostImpl::OnUnlockMouse() { 2098 void RenderWidgetHostImpl::OnUnlockMouse() {
2095 RejectMouseLockOrUnlockIfNecessary(); 2099 if (!pending_mouse_lock_request_ && IsMouseLocked()) {
2100 // Got unlock request from renderer. Otherwise we only got |LostMouseLock()|
2101 // if user unlocked mouse by pressing ESC.
2102 is_last_unlocked_by_target_ = true;
2103 view_->UnlockMouse();
2104 }
chongz 2017/06/01 14:58:20 Actually I don't think we should use |RejectMouseL
dtapuska 2017/06/05 14:49:49 This pending_mouse_lock_request boolean is a littl
chongz 2017/06/05 15:33:57 Added back |RejectMouseLockOrUnlockIfNecessary()|
2096 } 2105 }
2097 2106
2098 void RenderWidgetHostImpl::OnShowDisambiguationPopup( 2107 void RenderWidgetHostImpl::OnShowDisambiguationPopup(
2099 const gfx::Rect& rect_pixels, 2108 const gfx::Rect& rect_pixels,
2100 const gfx::Size& size, 2109 const gfx::Size& size,
2101 const cc::SharedBitmapId& id) { 2110 const cc::SharedBitmapId& id) {
2102 DCHECK(!rect_pixels.IsEmpty()); 2111 DCHECK(!rect_pixels.IsEmpty());
2103 DCHECK(!size.IsEmpty()); 2112 DCHECK(!size.IsEmpty());
2104 2113
2105 std::unique_ptr<cc::SharedBitmap> bitmap = 2114 std::unique_ptr<cc::SharedBitmap> bitmap =
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 device::mojom::WakeLockType::PreventDisplaySleep, 2669 device::mojom::WakeLockType::PreventDisplaySleep,
2661 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", 2670 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot",
2662 std::move(request)); 2671 std::move(request));
2663 } 2672 }
2664 } 2673 }
2665 return wake_lock_.get(); 2674 return wake_lock_.get();
2666 } 2675 }
2667 #endif 2676 #endif
2668 2677
2669 } // namespace content 2678 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698