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

Unified Diff: fpdfsdk/fsdk_annothandler.cpp

Issue 2166953005: Remove the use of handler array in CPDFSDK_AnnotHandlerMgr (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 5 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 | fpdfsdk/include/fsdk_annothandler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fsdk_annothandler.cpp
diff --git a/fpdfsdk/fsdk_annothandler.cpp b/fpdfsdk/fsdk_annothandler.cpp
index 2185562668b6f42b404e01f7d95a7fdb8aafa687..f7dd531f35601d57af2fa3c07214d9d20f98d04d 100644
--- a/fpdfsdk/fsdk_annothandler.cpp
+++ b/fpdfsdk/fsdk_annothandler.cpp
@@ -40,32 +40,18 @@ CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) {
#endif // PDF_ENABLE_XFA
}
-CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {
- for (int i = 0; i < m_Handlers.GetSize(); i++) {
- IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i);
- delete pHandler;
- }
- m_Handlers.RemoveAll();
- m_mapType2Handler.clear();
-}
+CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {}
void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler(
IPDFSDK_AnnotHandler* pAnnotHandler) {
ASSERT(!GetAnnotHandler(pAnnotHandler->GetType()));
- m_Handlers.Add(pAnnotHandler);
- m_mapType2Handler[pAnnotHandler->GetType()] = pAnnotHandler;
+ m_mapType2Handler[pAnnotHandler->GetType()].reset(pAnnotHandler);
}
void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler(
IPDFSDK_AnnotHandler* pAnnotHandler) {
m_mapType2Handler.erase(pAnnotHandler->GetType());
- for (int i = 0, sz = m_Handlers.GetSize(); i < sz; i++) {
- if (m_Handlers.GetAt(i) == pAnnotHandler) {
- m_Handlers.RemoveAt(i);
- break;
- }
- }
}
CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot,
@@ -139,7 +125,7 @@ IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
const CFX_ByteString& sType) const {
auto it = m_mapType2Handler.find(sType);
- return it != m_mapType2Handler.end() ? it->second : nullptr;
+ return it != m_mapType2Handler.end() ? it->second.get() : nullptr;
}
void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
« no previous file with comments | « no previous file | fpdfsdk/include/fsdk_annothandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698