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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 | 134 |
135 void PointerLockController::DispatchLockedMouseEvent( | 135 void PointerLockController::DispatchLockedMouseEvent( |
136 const WebMouseEvent& event, | 136 const WebMouseEvent& event, |
137 const AtomicString& event_type) { | 137 const AtomicString& event_type) { |
138 if (!element_ || !element_->GetDocument().GetFrame()) | 138 if (!element_ || !element_->GetDocument().GetFrame()) |
139 return; | 139 return; |
140 | 140 |
141 element_->DispatchMouseEvent(event, event_type, event.click_count); | 141 element_->DispatchMouseEvent(event, event_type, event.click_count); |
142 | 142 |
| 143 // Event handlers may remove element. |
| 144 if (!element_) |
| 145 return; |
| 146 |
143 // Create click events | 147 // Create click events |
144 if (event_type == EventTypeNames::mouseup) { | 148 if (event_type == EventTypeNames::mouseup) { |
145 element_->DispatchMouseEvent(event, EventTypeNames::click, | 149 element_->DispatchMouseEvent(event, EventTypeNames::click, |
146 event.click_count); | 150 event.click_count); |
147 } | 151 } |
148 } | 152 } |
149 | 153 |
150 void PointerLockController::ClearElement() { | 154 void PointerLockController::ClearElement() { |
151 lock_pending_ = false; | 155 lock_pending_ = false; |
152 element_ = nullptr; | 156 element_ = nullptr; |
(...skipping 11 matching lines...) Expand all Loading... |
164 document->domWindow()->EnqueueDocumentEvent(Event::Create(type)); | 168 document->domWindow()->EnqueueDocumentEvent(Event::Create(type)); |
165 } | 169 } |
166 | 170 |
167 DEFINE_TRACE(PointerLockController) { | 171 DEFINE_TRACE(PointerLockController) { |
168 visitor->Trace(page_); | 172 visitor->Trace(page_); |
169 visitor->Trace(element_); | 173 visitor->Trace(element_); |
170 visitor->Trace(document_of_removed_element_while_waiting_for_unlock_); | 174 visitor->Trace(document_of_removed_element_while_waiting_for_unlock_); |
171 } | 175 } |
172 | 176 |
173 } // namespace blink | 177 } // namespace blink |
OLD | NEW |