OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/page/PointerLockController.h" | 26 #include "core/page/PointerLockController.h" |
27 | 27 |
28 #include "core/dom/Element.h" | 28 #include "core/dom/Element.h" |
29 #include "core/events/Event.h" | 29 #include "core/events/Event.h" |
30 #include "core/frame/LocalDOMWindow.h" | 30 #include "core/frame/LocalDOMWindow.h" |
| 31 #include "core/inspector/ConsoleMessage.h" |
31 #include "core/page/Chrome.h" | 32 #include "core/page/Chrome.h" |
32 #include "core/page/ChromeClient.h" | 33 #include "core/page/ChromeClient.h" |
33 #include "core/page/Page.h" | 34 #include "core/page/Page.h" |
34 #include "platform/PlatformMouseEvent.h" | 35 #include "platform/PlatformMouseEvent.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 | 38 |
38 PointerLockController::PointerLockController(Page* page) | 39 PointerLockController::PointerLockController(Page* page) |
39 : m_page(page) | 40 : m_page(page) |
40 , m_lockPending(false) | 41 , m_lockPending(false) |
41 { | 42 { |
42 } | 43 } |
43 | 44 |
44 PassOwnPtrWillBeRawPtr<PointerLockController> PointerLockController::create(Page
* page) | 45 PassOwnPtrWillBeRawPtr<PointerLockController> PointerLockController::create(Page
* page) |
45 { | 46 { |
46 return adoptPtrWillBeNoop(new PointerLockController(page)); | 47 return adoptPtrWillBeNoop(new PointerLockController(page)); |
47 } | 48 } |
48 | 49 |
49 void PointerLockController::requestPointerLock(Element* target) | 50 void PointerLockController::requestPointerLock(Element* target) |
50 { | 51 { |
51 if (!target || !target->inDocument() || m_documentOfRemovedElementWhileWaiti
ngForUnlock) { | 52 if (!target || !target->inDocument() || m_documentOfRemovedElementWhileWaiti
ngForUnlock) { |
52 enqueueEvent(EventTypeNames::pointerlockerror, target); | 53 enqueueEvent(EventTypeNames::pointerlockerror, target); |
53 return; | 54 return; |
54 } | 55 } |
55 | 56 |
56 if (target->document().isSandboxed(SandboxPointerLock)) { | 57 if (target->document().isSandboxed(SandboxPointerLock)) { |
57 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 58 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
58 target->document().addConsoleMessage(SecurityMessageSource, ErrorMessage
Level, "Blocked pointer lock on an element because the element's frame is sandbo
xed and the 'allow-pointer-lock' permission is not set."); | 59 target->document().addConsoleMessage(ConsoleMessage::create(SecurityMess
ageSource, ErrorMessageLevel, "Blocked pointer lock on an element because the el
ement's frame is sandboxed and the 'allow-pointer-lock' permission is not set.")
); |
59 enqueueEvent(EventTypeNames::pointerlockerror, target); | 60 enqueueEvent(EventTypeNames::pointerlockerror, target); |
60 return; | 61 return; |
61 } | 62 } |
62 | 63 |
63 if (m_element) { | 64 if (m_element) { |
64 if (m_element->document() != target->document()) { | 65 if (m_element->document() != target->document()) { |
65 enqueueEvent(EventTypeNames::pointerlockerror, target); | 66 enqueueEvent(EventTypeNames::pointerlockerror, target); |
66 return; | 67 return; |
67 } | 68 } |
68 enqueueEvent(EventTypeNames::pointerlockchange, target); | 69 enqueueEvent(EventTypeNames::pointerlockchange, target); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 160 } |
160 | 161 |
161 void PointerLockController::trace(Visitor* visitor) | 162 void PointerLockController::trace(Visitor* visitor) |
162 { | 163 { |
163 visitor->trace(m_page); | 164 visitor->trace(m_page); |
164 visitor->trace(m_element); | 165 visitor->trace(m_element); |
165 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock); | 166 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock); |
166 } | 167 } |
167 | 168 |
168 } // namespace blink | 169 } // namespace blink |
OLD | NEW |