OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/cfwl_notedriver.h" | 7 #include "xfa/fwl/core/cfwl_notedriver.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 return; | 39 return; |
40 | 40 |
41 for (const auto& pair : m_eventTargets) { | 41 for (const auto& pair : m_eventTargets) { |
42 CFWL_EventTarget* pEventTarget = pair.second; | 42 CFWL_EventTarget* pEventTarget = pair.second; |
43 if (pEventTarget && !pEventTarget->IsInvalid()) | 43 if (pEventTarget && !pEventTarget->IsInvalid()) |
44 pEventTarget->ProcessEvent(pNote); | 44 pEventTarget->ProcessEvent(pNote); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, | 48 void CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, |
49 IFWL_Widget* pEventSource, | 49 IFWL_Widget* pEventSource) { |
50 uint32_t dwFilter) { | |
51 uint32_t key = pListener->GetEventKey(); | 50 uint32_t key = pListener->GetEventKey(); |
52 if (key == 0) { | 51 if (key == 0) { |
53 do { | 52 do { |
54 key = rand(); | 53 key = rand(); |
55 } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key)); | 54 } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key)); |
56 pListener->SetEventKey(key); | 55 pListener->SetEventKey(key); |
57 } | 56 } |
58 if (!m_eventTargets[key]) | 57 if (!m_eventTargets[key]) |
59 m_eventTargets[key] = new CFWL_EventTarget(pListener); | 58 m_eventTargets[key] = new CFWL_EventTarget(pListener); |
60 | 59 |
61 m_eventTargets[key]->SetEventSource(pEventSource, dwFilter); | 60 m_eventTargets[key]->SetEventSource(pEventSource); |
62 } | 61 } |
63 | 62 |
64 void CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { | 63 void CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { |
65 uint32_t key = pListener->GetEventKey(); | 64 uint32_t key = pListener->GetEventKey(); |
66 if (key == 0) | 65 if (key == 0) |
67 return; | 66 return; |
68 | 67 |
69 auto it = m_eventTargets.find(key); | 68 auto it = m_eventTargets.find(key); |
70 if (it != m_eventTargets.end()) | 69 if (it != m_eventTargets.end()) |
71 it->second->FlagInvalid(); | 70 it->second->FlagInvalid(); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { | 479 void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { |
481 auto it = m_eventTargets.begin(); | 480 auto it = m_eventTargets.begin(); |
482 while (it != m_eventTargets.end()) { | 481 while (it != m_eventTargets.end()) { |
483 auto old = it++; | 482 auto old = it++; |
484 if (old->second && (bRemoveAll || old->second->IsInvalid())) { | 483 if (old->second && (bRemoveAll || old->second->IsInvalid())) { |
485 delete old->second; | 484 delete old->second; |
486 m_eventTargets.erase(old); | 485 m_eventTargets.erase(old); |
487 } | 486 } |
488 } | 487 } |
489 } | 488 } |
OLD | NEW |