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

Unified Diff: xfa/fwl/core/fwl_noteimp.cpp

Issue 2012143003: Remove one (of several) usages of SetPrivateData from IFWL_Widget (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Remove casts Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | xfa/fwl/core/fwl_widgetimp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fwl/core/fwl_noteimp.cpp
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index 41201e6b6b9c552dab950b8df65b687b47e2fd72..9518a08f005d482a98d3feafd638d4099fe189e7 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -7,6 +7,7 @@
#include "xfa/fwl/core/fwl_noteimp.h"
#include "core/fxcrt/include/fx_ext.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h"
#include "xfa/fwl/basewidget/ifwl_tooltip.h"
#include "xfa/fwl/core/cfwl_message.h"
@@ -101,18 +102,15 @@ void CFWL_NoteDriver::SendEvent(CFWL_Event* pNote) {
}
}
-#define FWL_NoteDriver_EventKey 1100
FWL_Error CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
IFWL_Widget* pEventSource,
uint32_t dwFilter) {
- uint32_t key = (uint32_t)(uintptr_t)pListener->GetPrivateData(
- (void*)(uintptr_t)FWL_NoteDriver_EventKey);
+ uint32_t key = pListener->GetEventKey();
if (key == 0) {
- void* random = FX_Random_MT_Start(0);
- key = rand();
- FX_Random_MT_Close(random);
- pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey,
- (void*)(uintptr_t)key, NULL);
+ do {
+ key = rand();
+ } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key));
+ pListener->SetEventKey(key);
}
if (!m_eventTargets[key])
m_eventTargets[key] = new CFWL_EventTarget(this, pListener);
@@ -122,8 +120,7 @@ FWL_Error CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener,
}
FWL_Error CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) {
- uint32_t key = (uint32_t)(uintptr_t)pListener->GetPrivateData(
- (void*)(uintptr_t)FWL_NoteDriver_EventKey);
+ uint32_t key = pListener->GetEventKey();
if (key == 0)
return FWL_Error::Indefinite;
« no previous file with comments | « no previous file | xfa/fwl/core/fwl_widgetimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698