Use enum class for subtypes of CPDF_Annot.
Comparing CFX_ByteString for annotation subtypes is inefficient and
error-prone. This CL uses enum class to compare annotation subtypes.
Also, remove unused IPDFSDK_AnnotHandler::GetType() and
FSDK_XFAWIDGET_TYPENAME.
Review-Url: https://codereview.chromium.org/2295953002
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 9f5a545..d909f5b 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -46,7 +46,8 @@
ASSERT(pAnnot);
ASSERT(pPageView);
- return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)->NewAnnot(pAnnot, pPageView);
+ return GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET)
+ ->NewAnnot(pAnnot, pPageView);
}
#endif // PDF_ENABLE_XFA
@@ -77,12 +78,12 @@
}
IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
- const CFX_ByteString& sType) const {
- if (sType == "Widget")
+ CPDF_Annot::Subtype nAnnotSubtype) const {
+ if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET)
return m_pWidgetHandler.get();
#ifdef PDF_ENABLE_XFA
- if (sType == FSDK_XFAWIDGET_TYPENAME)
+ if (nAnnotSubtype == CPDF_Annot::Subtype::XFAWIDGET)
return m_pXFAWidgetHandler.get();
#endif // PDF_ENABLE_XFA
@@ -242,7 +243,7 @@
if (bXFA) {
if (IPDFSDK_AnnotHandler* pXFAAnnotHandler =
- GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME))
+ GetAnnotHandler(CPDF_Annot::Subtype::XFAWIDGET))
return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot);
}
@@ -299,7 +300,7 @@
return pPageView->GetAnnotByXFAWidget(hNextFocus);
#else // PDF_ENABLE_XFA
- CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget");
+ CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), CPDF_Annot::Subtype::WIDGET);
return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot);
#endif // PDF_ENABLE_XFA
}