| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 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/inspector/ConsoleMessage.h" |
| 32 #include "core/page/ChromeClient.h" | 32 #include "core/page/ChromeClient.h" |
| 33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
| 34 #include "platform/PlatformMouseEvent.h" | 34 #include "public/platform/WebMouseEvent.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 PointerLockController::PointerLockController(Page* page) | 38 PointerLockController::PointerLockController(Page* page) |
| 39 : m_page(page), m_lockPending(false) {} | 39 : m_page(page), m_lockPending(false) {} |
| 40 | 40 |
| 41 PointerLockController* PointerLockController::create(Page* page) { | 41 PointerLockController* PointerLockController::create(Page* page) { |
| 42 return new PointerLockController(page); | 42 return new PointerLockController(page); |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void PointerLockController::didLosePointerLock() { | 125 void PointerLockController::didLosePointerLock() { |
| 126 enqueueEvent(EventTypeNames::pointerlockchange, | 126 enqueueEvent(EventTypeNames::pointerlockchange, |
| 127 m_element | 127 m_element |
| 128 ? &m_element->document() | 128 ? &m_element->document() |
| 129 : m_documentOfRemovedElementWhileWaitingForUnlock.get()); | 129 : m_documentOfRemovedElementWhileWaitingForUnlock.get()); |
| 130 clearElement(); | 130 clearElement(); |
| 131 m_documentOfRemovedElementWhileWaitingForUnlock = nullptr; | 131 m_documentOfRemovedElementWhileWaitingForUnlock = nullptr; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void PointerLockController::dispatchLockedMouseEvent( | 134 void PointerLockController::dispatchLockedMouseEvent( |
| 135 const PlatformMouseEvent& event, | 135 const WebMouseEvent& event, |
| 136 const AtomicString& eventType) { | 136 const AtomicString& eventType) { |
| 137 if (!m_element || !m_element->document().frame()) | 137 if (!m_element || !m_element->document().frame()) |
| 138 return; | 138 return; |
| 139 | 139 |
| 140 m_element->dispatchMouseEvent(event, eventType, event.clickCount()); | 140 m_element->dispatchMouseEvent(event, eventType, event.clickCount); |
| 141 | 141 |
| 142 // Create click events | 142 // Create click events |
| 143 if (eventType == EventTypeNames::mouseup) | 143 if (eventType == EventTypeNames::mouseup) { |
| 144 m_element->dispatchMouseEvent(event, EventTypeNames::click, | 144 m_element->dispatchMouseEvent(event, EventTypeNames::click, |
| 145 event.clickCount()); | 145 event.clickCount); |
| 146 } |
| 146 } | 147 } |
| 147 | 148 |
| 148 void PointerLockController::clearElement() { | 149 void PointerLockController::clearElement() { |
| 149 m_lockPending = false; | 150 m_lockPending = false; |
| 150 m_element = nullptr; | 151 m_element = nullptr; |
| 151 } | 152 } |
| 152 | 153 |
| 153 void PointerLockController::enqueueEvent(const AtomicString& type, | 154 void PointerLockController::enqueueEvent(const AtomicString& type, |
| 154 Element* element) { | 155 Element* element) { |
| 155 if (element) | 156 if (element) |
| 156 enqueueEvent(type, &element->document()); | 157 enqueueEvent(type, &element->document()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void PointerLockController::enqueueEvent(const AtomicString& type, | 160 void PointerLockController::enqueueEvent(const AtomicString& type, |
| 160 Document* document) { | 161 Document* document) { |
| 161 if (document && document->domWindow()) | 162 if (document && document->domWindow()) |
| 162 document->domWindow()->enqueueDocumentEvent(Event::create(type)); | 163 document->domWindow()->enqueueDocumentEvent(Event::create(type)); |
| 163 } | 164 } |
| 164 | 165 |
| 165 DEFINE_TRACE(PointerLockController) { | 166 DEFINE_TRACE(PointerLockController) { |
| 166 visitor->trace(m_page); | 167 visitor->trace(m_page); |
| 167 visitor->trace(m_element); | 168 visitor->trace(m_element); |
| 168 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock); | 169 visitor->trace(m_documentOfRemovedElementWhileWaitingForUnlock); |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |