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

Side by Side Diff: third_party/WebKit/Source/core/page/PointerLockController.cpp

Issue 1980133002: Implement pointer lock API for out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return; 61 return;
62 } 62 }
63 63
64 if (m_element) { 64 if (m_element) {
65 if (m_element->document() != target->document()) { 65 if (m_element->document() != target->document()) {
66 enqueueEvent(EventTypeNames::pointerlockerror, target); 66 enqueueEvent(EventTypeNames::pointerlockerror, target);
67 return; 67 return;
68 } 68 }
69 enqueueEvent(EventTypeNames::pointerlockchange, target); 69 enqueueEvent(EventTypeNames::pointerlockchange, target);
70 m_element = target; 70 m_element = target;
71 } else if (m_page->chromeClient().requestPointerLock()) { 71 } else if (m_page->chromeClient().requestPointerLock(target->document().fram e())) {
72 m_lockPending = true; 72 m_lockPending = true;
73 m_element = target; 73 m_element = target;
74 } else { 74 } else {
75 enqueueEvent(EventTypeNames::pointerlockerror, target); 75 enqueueEvent(EventTypeNames::pointerlockerror, target);
76 } 76 }
77 } 77 }
78 78
79 void PointerLockController::requestPointerUnlock() 79 void PointerLockController::requestPointerUnlock()
80 { 80 {
81 return m_page->chromeClient().requestPointerUnlock(); 81 return m_page->chromeClient().requestPointerUnlock(m_element->document().fra me());
82 } 82 }
83 83
84 void PointerLockController::elementRemoved(Element* element) 84 void PointerLockController::elementRemoved(Element* element)
85 { 85 {
86 if (m_element == element) { 86 if (m_element == element) {
87 m_documentOfRemovedElementWhileWaitingForUnlock = &m_element->document() ; 87 m_documentOfRemovedElementWhileWaitingForUnlock = &m_element->document() ;
88 requestPointerUnlock();
88 // Set element null immediately to block any future interaction with it 89 // Set element null immediately to block any future interaction with it
89 // including mouse events received before the unlock completes. 90 // including mouse events received before the unlock completes.
90 clearElement(); 91 clearElement();
91 requestPointerUnlock();
92 } 92 }
93 } 93 }
94 94
95 void PointerLockController::documentDetached(Document* document) 95 void PointerLockController::documentDetached(Document* document)
96 { 96 {
97 if (m_element && m_element->document() == document) { 97 if (m_element && m_element->document() == document) {
98 requestPointerUnlock();
98 clearElement(); 99 clearElement();
99 requestPointerUnlock();
100 } 100 }
101 } 101 }
102 102
103 bool PointerLockController::lockPending() const 103 bool PointerLockController::lockPending() const
104 { 104 {
105 return m_lockPending; 105 return m_lockPending;
106 } 106 }
107 107
108 Element* PointerLockController::element() const 108 Element* PointerLockController::element() const
109 { 109 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 DEFINE_TRACE(PointerLockController) 162 DEFINE_TRACE(PointerLockController)
163 { 163 {
164 visitor->trace(m_page); 164 visitor->trace(m_page);
165 visitor->trace(m_element); 165 visitor->trace(m_element);
166 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock); 166 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock);
167 } 167 }
168 168
169 } // namespace blink 169 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/ChromeClient.h ('k') | third_party/WebKit/Source/web/ChromeClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698