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

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

Issue 266533004: Create unprefixed versions of pointerlockchange & pointerlockerror events. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 PassOwnPtr<PointerLockController> PointerLockController::create(Page* page) 44 PassOwnPtr<PointerLockController> PointerLockController::create(Page* page)
45 { 45 {
46 return adoptPtr(new PointerLockController(page)); 46 return adoptPtr(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::webkitpointerlockerror, 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.");
60 enqueueEvent(EventTypeNames::pointerlockerror, target);
59 enqueueEvent(EventTypeNames::webkitpointerlockerror, 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()) {
67 enqueueEvent(EventTypeNames::pointerlockerror, target);
65 enqueueEvent(EventTypeNames::webkitpointerlockerror, target); 68 enqueueEvent(EventTypeNames::webkitpointerlockerror, target);
66 return; 69 return;
67 } 70 }
71 enqueueEvent(EventTypeNames::pointerlockchange, target);
68 enqueueEvent(EventTypeNames::webkitpointerlockchange, 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 {
78 enqueueEvent(EventTypeNames::pointerlockerror, target);
74 enqueueEvent(EventTypeNames::webkitpointerlockerror, 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)
(...skipping 20 matching lines...) Expand all
104 return m_lockPending; 109 return m_lockPending;
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 {
119 enqueueEvent(EventTypeNames::pointerlockchange, m_element.get());
114 enqueueEvent(EventTypeNames::webkitpointerlockchange, 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 {
126 enqueueEvent(EventTypeNames::pointerlockerror, m_element.get());
120 enqueueEvent(EventTypeNames::webkitpointerlockerror, 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 {
133 enqueueEvent(EventTypeNames::pointerlockchange, m_element ? &m_element->docu ment() : m_documentOfRemovedElementWhileWaitingForUnlock.get());
126 enqueueEvent(EventTypeNames::webkitpointerlockchange, m_element ? &m_element ->document() : 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
(...skipping 16 matching lines...) Expand all
152 enqueueEvent(type, &element->document()); 160 enqueueEvent(type, &element->document());
153 } 161 }
154 162
155 void PointerLockController::enqueueEvent(const AtomicString& type, Document* doc ument) 163 void PointerLockController::enqueueEvent(const AtomicString& type, Document* doc ument)
156 { 164 {
157 if (document && document->domWindow()) 165 if (document && document->domWindow())
158 document->domWindow()->enqueueDocumentEvent(Event::create(type)); 166 document->domWindow()->enqueueDocumentEvent(Event::create(type));
159 } 167 }
160 168
161 } // namespace WebCore 169 } // namespace WebCore
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