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

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

Issue 424213007: Revert of Remove prefixed Pointer Lock API. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/events/EventTypeNames.in ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 PassOwnPtrWillBeRawPtr<PointerLockController> PointerLockController::create(Page * page) 44 PassOwnPtrWillBeRawPtr<PointerLockController> PointerLockController::create(Page * page)
45 { 45 {
46 return adoptPtrWillBeNoop(new PointerLockController(page)); 46 return adoptPtrWillBeNoop(new PointerLockController(page));
47 } 47 }
48 48
49 void PointerLockController::requestPointerLock(Element* target) 49 void PointerLockController::requestPointerLock(Element* target)
50 { 50 {
51 if (!target || !target->inDocument() || m_documentOfRemovedElementWhileWaiti ngForUnlock) { 51 if (!target || !target->inDocument() || m_documentOfRemovedElementWhileWaiti ngForUnlock) {
52 enqueueEvent(EventTypeNames::pointerlockerror, target); 52 enqueueEvent(EventTypeNames::pointerlockerror, target);
53 enqueueEvent(EventTypeNames::webkitpointerlockerror, 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(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 enqueueEvent(EventTypeNames::pointerlockerror, target); 60 enqueueEvent(EventTypeNames::pointerlockerror, target);
61 enqueueEvent(EventTypeNames::webkitpointerlockerror, target);
60 return; 62 return;
61 } 63 }
62 64
63 if (m_element) { 65 if (m_element) {
64 if (m_element->document() != target->document()) { 66 if (m_element->document() != target->document()) {
65 enqueueEvent(EventTypeNames::pointerlockerror, target); 67 enqueueEvent(EventTypeNames::pointerlockerror, target);
68 enqueueEvent(EventTypeNames::webkitpointerlockerror, target);
66 return; 69 return;
67 } 70 }
68 enqueueEvent(EventTypeNames::pointerlockchange, target); 71 enqueueEvent(EventTypeNames::pointerlockchange, target);
72 enqueueEvent(EventTypeNames::webkitpointerlockchange, target);
69 m_element = target; 73 m_element = target;
70 } else if (m_page->chrome().client().requestPointerLock()) { 74 } else if (m_page->chrome().client().requestPointerLock()) {
71 m_lockPending = true; 75 m_lockPending = true;
72 m_element = target; 76 m_element = target;
73 } else { 77 } else {
74 enqueueEvent(EventTypeNames::pointerlockerror, target); 78 enqueueEvent(EventTypeNames::pointerlockerror, target);
79 enqueueEvent(EventTypeNames::webkitpointerlockerror, target);
75 } 80 }
76 } 81 }
77 82
78 void PointerLockController::requestPointerUnlock() 83 void PointerLockController::requestPointerUnlock()
79 { 84 {
80 return m_page->chrome().client().requestPointerUnlock(); 85 return m_page->chrome().client().requestPointerUnlock();
81 } 86 }
82 87
83 void PointerLockController::elementRemoved(Element* element) 88 void PointerLockController::elementRemoved(Element* element)
84 { 89 {
(...skipping 20 matching lines...) Expand all
105 } 110 }
106 111
107 Element* PointerLockController::element() const 112 Element* PointerLockController::element() const
108 { 113 {
109 return m_element.get(); 114 return m_element.get();
110 } 115 }
111 116
112 void PointerLockController::didAcquirePointerLock() 117 void PointerLockController::didAcquirePointerLock()
113 { 118 {
114 enqueueEvent(EventTypeNames::pointerlockchange, m_element.get()); 119 enqueueEvent(EventTypeNames::pointerlockchange, m_element.get());
120 enqueueEvent(EventTypeNames::webkitpointerlockchange, m_element.get());
115 m_lockPending = false; 121 m_lockPending = false;
116 } 122 }
117 123
118 void PointerLockController::didNotAcquirePointerLock() 124 void PointerLockController::didNotAcquirePointerLock()
119 { 125 {
120 enqueueEvent(EventTypeNames::pointerlockerror, m_element.get()); 126 enqueueEvent(EventTypeNames::pointerlockerror, m_element.get());
127 enqueueEvent(EventTypeNames::webkitpointerlockerror, m_element.get());
121 clearElement(); 128 clearElement();
122 } 129 }
123 130
124 void PointerLockController::didLosePointerLock() 131 void PointerLockController::didLosePointerLock()
125 { 132 {
126 enqueueEvent(EventTypeNames::pointerlockchange, m_element ? &m_element->docu ment() : m_documentOfRemovedElementWhileWaitingForUnlock.get()); 133 enqueueEvent(EventTypeNames::pointerlockchange, m_element ? &m_element->docu ment() : m_documentOfRemovedElementWhileWaitingForUnlock.get());
134 enqueueEvent(EventTypeNames::webkitpointerlockchange, m_element ? &m_element ->document() : m_documentOfRemovedElementWhileWaitingForUnlock.get());
127 clearElement(); 135 clearElement();
128 m_documentOfRemovedElementWhileWaitingForUnlock = nullptr; 136 m_documentOfRemovedElementWhileWaitingForUnlock = nullptr;
129 } 137 }
130 138
131 void PointerLockController::dispatchLockedMouseEvent(const PlatformMouseEvent& e vent, const AtomicString& eventType) 139 void PointerLockController::dispatchLockedMouseEvent(const PlatformMouseEvent& e vent, const AtomicString& eventType)
132 { 140 {
133 if (!m_element || !m_element->document().frame()) 141 if (!m_element || !m_element->document().frame())
134 return; 142 return;
135 143
136 m_element->dispatchMouseEvent(event, eventType, event.clickCount()); 144 m_element->dispatchMouseEvent(event, eventType, event.clickCount());
(...skipping 22 matching lines...) Expand all
159 } 167 }
160 168
161 void PointerLockController::trace(Visitor* visitor) 169 void PointerLockController::trace(Visitor* visitor)
162 { 170 {
163 visitor->trace(m_page); 171 visitor->trace(m_page);
164 visitor->trace(m_element); 172 visitor->trace(m_element);
165 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock); 173 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock);
166 } 174 }
167 175
168 } // namespace blink 176 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/events/EventTypeNames.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698