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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2807433003: No pointer captured when the pointer lock is applied (Closed)
Patch Set: pointer lock Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 2184
2185 bool is_pointer_locked = false; 2185 bool is_pointer_locked = false;
2186 if (WebFrameWidgetBase* widget = MainFrameImpl()->FrameWidget()) { 2186 if (WebFrameWidgetBase* widget = MainFrameImpl()->FrameWidget()) {
2187 if (WebWidgetClient* client = widget->Client()) 2187 if (WebWidgetClient* client = widget->Client())
2188 is_pointer_locked = client->IsPointerLocked(); 2188 is_pointer_locked = client->IsPointerLocked();
2189 } 2189 }
2190 2190
2191 if (is_pointer_locked && 2191 if (is_pointer_locked &&
2192 WebInputEvent::IsMouseEventType(input_event.GetType())) { 2192 WebInputEvent::IsMouseEventType(input_event.GetType())) {
2193 MainFrameImpl()->FrameWidget()->PointerLockMouseEvent(input_event); 2193 MainFrameImpl()->FrameWidget()->PointerLockMouseEvent(input_event);
2194 LocalFrame* focusedFrame = FocusedLocalFrameInWidget();
2195
2196 if (focusedFrame) {
2197 WebMouseEvent transformed_event = TransformWebMouseEvent(
2198 MainFrameImpl()->GetFrameView(),
2199 static_cast<const WebMouseEvent&>(input_event));
2200 Vector<WebMouseEvent> transformed_coalesced_events =
2201 TransformWebMouseEventVector(
2202 MainFrameImpl()->GetFrameView(),
2203 coalesced_event.GetCoalescedEventsPointers());
2204 focusedFrame->GetEventHandler().DispatchLostPointerCaptureEvent(
Navid Zolghadr 2017/05/17 16:30:11 This doesn't seem correct. We should have called P
2205 transformed_event, transformed_coalesced_events);
2206 }
2194 return WebInputEventResult::kHandledSystem; 2207 return WebInputEventResult::kHandledSystem;
2195 } 2208 }
2196 2209
2197 if (mouse_capture_node_ && 2210 if (mouse_capture_node_ &&
2198 WebInputEvent::IsMouseEventType(input_event.GetType())) { 2211 WebInputEvent::IsMouseEventType(input_event.GetType())) {
2199 TRACE_EVENT1("input", "captured mouse event", "type", 2212 TRACE_EVENT1("input", "captured mouse event", "type",
2200 input_event.GetType()); 2213 input_event.GetType());
2201 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. 2214 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
2202 Node* node = mouse_capture_node_; 2215 Node* node = mouse_capture_node_;
2203 2216
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 } 2285 }
2273 2286
2274 void WebViewImpl::SetCursorVisibilityState(bool is_visible) { 2287 void WebViewImpl::SetCursorVisibilityState(bool is_visible) {
2275 if (page_) 2288 if (page_)
2276 page_->SetIsCursorVisible(is_visible); 2289 page_->SetIsCursorVisible(is_visible);
2277 } 2290 }
2278 2291
2279 void WebViewImpl::MouseCaptureLost() { 2292 void WebViewImpl::MouseCaptureLost() {
2280 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this); 2293 TRACE_EVENT_ASYNC_END0("input", "capturing mouse", this);
2281 mouse_capture_node_ = nullptr; 2294 mouse_capture_node_ = nullptr;
2295
2296 LocalFrame* focusedFrame = FocusedLocalFrameInWidget();
2297
2298 if (focusedFrame)
2299 focusedFrame->GetEventHandler().ReleaseMousePointerCapture();
Navid Zolghadr 2017/05/17 16:30:11 Why do we need to release mouse capture when captu
lanwei 2017/05/19 15:05:00 This is for the case that we call the setPointerCa
2282 } 2300 }
2283 2301
2284 void WebViewImpl::SetFocus(bool enable) { 2302 void WebViewImpl::SetFocus(bool enable) {
2285 page_->GetFocusController().SetFocused(enable); 2303 page_->GetFocusController().SetFocused(enable);
2286 if (enable) { 2304 if (enable) {
2287 page_->GetFocusController().SetActive(true); 2305 page_->GetFocusController().SetActive(true);
2288 LocalFrame* focused_frame = page_->GetFocusController().FocusedFrame(); 2306 LocalFrame* focused_frame = page_->GetFocusController().FocusedFrame();
2289 if (focused_frame) { 2307 if (focused_frame) {
2290 Element* element = focused_frame->GetDocument()->FocusedElement(); 2308 Element* element = focused_frame->GetDocument()->FocusedElement();
2291 if (element && focused_frame->Selection() 2309 if (element && focused_frame->Selection()
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame()) 4187 if (focused_frame->LocalFrameRoot() != MainFrameImpl()->GetFrame())
4170 return nullptr; 4188 return nullptr;
4171 return focused_frame; 4189 return focused_frame;
4172 } 4190 }
4173 4191
4174 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const { 4192 LocalFrame* WebViewImpl::FocusedLocalFrameAvailableForIme() const {
4175 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr; 4193 return ime_accept_events_ ? FocusedLocalFrameInWidget() : nullptr;
4176 } 4194 }
4177 4195
4178 } // namespace blink 4196 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698