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/cba_annotiterator.cpp b/fpdfsdk/cba_annotiterator.cpp
index 773fe61..b99fabf 100644
--- a/fpdfsdk/cba_annotiterator.cpp
+++ b/fpdfsdk/cba_annotiterator.cpp
@@ -23,10 +23,10 @@
 }
 
 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView,
-                                     const CFX_ByteString& sAnnotSubtype)
+                                     CPDF_Annot::Subtype nAnnotSubtype)
     : m_eTabOrder(STRUCTURE),
       m_pPageView(pPageView),
-      m_sAnnotSubtype(sAnnotSubtype) {
+      m_nAnnotSubtype(nAnnotSubtype) {
   CPDF_Page* pPDFPage = m_pPageView->GetPDFPage();
   CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetStringBy("Tabs");
   if (sTabs == "R")
@@ -71,7 +71,7 @@
     case STRUCTURE: {
       for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) {
         CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
-        if (pAnnot->GetAnnotSubtype() == m_sAnnotSubtype &&
+        if (pAnnot->GetAnnotSubtype() == m_nAnnotSubtype &&
             !pAnnot->IsSignatureWidget())
           m_Annots.push_back(pAnnot);
       }
@@ -81,7 +81,7 @@
       std::vector<CPDFSDK_Annot*> sa;
       for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) {
         CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
-        if (pAnnot->GetAnnotSubtype() == m_sAnnotSubtype &&
+        if (pAnnot->GetAnnotSubtype() == m_nAnnotSubtype &&
             !pAnnot->IsSignatureWidget())
           sa.push_back(pAnnot);
       }
@@ -123,7 +123,7 @@
       std::vector<CPDFSDK_Annot*> sa;
       for (size_t i = 0; i < m_pPageView->CountAnnots(); ++i) {
         CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i);
-        if (pAnnot->GetAnnotSubtype() == m_sAnnotSubtype &&
+        if (pAnnot->GetAnnotSubtype() == m_nAnnotSubtype &&
             !pAnnot->IsSignatureWidget())
           sa.push_back(pAnnot);
       }
diff --git a/fpdfsdk/cpdfsdk_annot.cpp b/fpdfsdk/cpdfsdk_annot.cpp
index 5ca439d..59d8f24 100644
--- a/fpdfsdk/cpdfsdk_annot.cpp
+++ b/fpdfsdk/cpdfsdk_annot.cpp
@@ -58,8 +58,8 @@
   return nullptr;
 }
 
-CFX_ByteString CPDFSDK_Annot::GetAnnotSubtype() const {
-  return "";
+CPDF_Annot::Subtype CPDFSDK_Annot::GetAnnotSubtype() const {
+  return CPDF_Annot::Subtype::UNKNOWN;
 }
 
 bool CPDFSDK_Annot::IsSignatureWidget() const {
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
 }
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 5e3e145..a2fd7c7 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -42,7 +42,7 @@
   return m_pAnnot->GetRect();
 }
 
-CFX_ByteString CPDFSDK_BAAnnot::GetAnnotSubtype() const {
+CPDF_Annot::Subtype CPDFSDK_BAAnnot::GetAnnotSubtype() const {
   return m_pAnnot->GetSubtype();
 }
 
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index 2fe3623..4422dc4 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -37,10 +37,6 @@
 
 CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() {}
 
-CFX_ByteString CPDFSDK_BAAnnotHandler::GetType() {
-  return CFX_ByteString("");
-}
-
 FX_BOOL CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
   return FALSE;
 }
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 1346deb..345487a 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -71,8 +71,8 @@
 
 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget,
                                               FX_BOOL bNext) const {
-  std::unique_ptr<CBA_AnnotIterator> pIterator(
-      new CBA_AnnotIterator(pWidget->GetPageView(), "Widget"));
+  std::unique_ptr<CBA_AnnotIterator> pIterator(new CBA_AnnotIterator(
+      pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET));
 
   if (bNext)
     return static_cast<CPDFSDK_Widget*>(pIterator->GetNextAnnot(pWidget));
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 0fb64df..77e14f0 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -27,12 +27,8 @@
 
 CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() {}
 
-CFX_ByteString CPDFSDK_WidgetHandler::GetType() {
-  return CFX_ByteString("Widget");
-}
-
 FX_BOOL CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
-  ASSERT(pAnnot->GetAnnotSubtype() == "Widget");
+  ASSERT(pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET);
   if (pAnnot->IsSignatureWidget())
     return FALSE;
 
diff --git a/fpdfsdk/cpdfsdk_xfawidget.cpp b/fpdfsdk/cpdfsdk_xfawidget.cpp
index 445abc5..b5e26d6 100644
--- a/fpdfsdk/cpdfsdk_xfawidget.cpp
+++ b/fpdfsdk/cpdfsdk_xfawidget.cpp
@@ -24,8 +24,8 @@
   return m_hXFAWidget;
 }
 
-CFX_ByteString CPDFSDK_XFAWidget::GetAnnotSubtype() const {
-  return FSDK_XFAWIDGET_TYPENAME;
+CPDF_Annot::Subtype CPDFSDK_XFAWidget::GetAnnotSubtype() const {
+  return CPDF_Annot::Subtype::XFAWIDGET;
 }
 
 CFX_FloatRect CPDFSDK_XFAWidget::GetRect() const {
diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
index 9a9a7a8..59fa5c7 100644
--- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp
@@ -25,10 +25,6 @@
 
 CPDFSDK_XFAWidgetHandler::~CPDFSDK_XFAWidgetHandler() {}
 
-CFX_ByteString CPDFSDK_XFAWidgetHandler::GetType() {
-  return FSDK_XFAWIDGET_TYPENAME;
-}
-
 FX_BOOL CPDFSDK_XFAWidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
   return !!pAnnot->GetXFAWidget();
 }
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 90b83d6..6a8ec5d 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -85,7 +85,7 @@
                              CFX_RenderDevice* pDevice,
                              CFX_Matrix* pUser2Device,
                              uint32_t dwFlags) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
     CFX_Matrix mt = GetCurMatrix();
diff --git a/fpdfsdk/formfiller/cffl_iformfiller.cpp b/fpdfsdk/formfiller/cffl_iformfiller.cpp
index 0f5ed89..1112947 100644
--- a/fpdfsdk/formfiller/cffl_iformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_iformfiller.cpp
@@ -124,7 +124,7 @@
 void CFFL_IFormFiller::OnMouseEnter(CPDFSDK_PageView* pPageView,
                                     CPDFSDK_Annot* pAnnot,
                                     FX_UINT nFlag) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
@@ -160,7 +160,7 @@
 void CFFL_IFormFiller::OnMouseExit(CPDFSDK_PageView* pPageView,
                                    CPDFSDK_Annot* pAnnot,
                                    FX_UINT nFlag) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
@@ -197,7 +197,7 @@
                                         CPDFSDK_Annot* pAnnot,
                                         FX_UINT nFlags,
                                         const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
@@ -239,7 +239,7 @@
                                       CPDFSDK_Annot* pAnnot,
                                       FX_UINT nFlags,
                                       const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
   CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
   CPDFSDK_Document* pDocument = m_pApp->GetSDKDocument();
 
@@ -319,7 +319,7 @@
                                           CPDFSDK_Annot* pAnnot,
                                           FX_UINT nFlags,
                                           const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
     return pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
@@ -332,7 +332,7 @@
                                       CPDFSDK_Annot* pAnnot,
                                       FX_UINT nFlags,
                                       const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   // change cursor
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, TRUE)) {
@@ -347,7 +347,7 @@
                                        FX_UINT nFlags,
                                        short zDelta,
                                        const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
     return pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, point);
@@ -360,7 +360,7 @@
                                         CPDFSDK_Annot* pAnnot,
                                         FX_UINT nFlags,
                                         const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
     return pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point);
@@ -373,7 +373,7 @@
                                       CPDFSDK_Annot* pAnnot,
                                       FX_UINT nFlags,
                                       const CFX_FloatPoint& point) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
     return pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point);
@@ -385,7 +385,7 @@
 FX_BOOL CFFL_IFormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot,
                                     FX_UINT nKeyCode,
                                     FX_UINT nFlags) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
     return pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlags);
@@ -397,7 +397,7 @@
 FX_BOOL CFFL_IFormFiller::OnChar(CPDFSDK_Annot* pAnnot,
                                  FX_UINT nChar,
                                  FX_UINT nFlags) {
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
   if (nChar == FWL_VKEY_Tab)
     return TRUE;
 
@@ -411,7 +411,7 @@
   if (!pAnnot)
     return FALSE;
 
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
@@ -454,7 +454,7 @@
 FX_BOOL CFFL_IFormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) {
   if (!pAnnot)
     return FALSE;
-  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == "Widget");
+  ASSERT(pAnnot->GetPDFAnnot()->GetSubtype() == CPDF_Annot::Subtype::WIDGET);
 
   if (CFFL_FormFiller* pFormFiller = GetFormFiller(pAnnot, FALSE)) {
     pFormFiller->KillFocusForAnnot(pAnnot, nFlag);
diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp
index d03b438..46bc7e5 100644
--- a/fpdfsdk/fpdf_ext.cpp
+++ b/fpdfsdk/fpdf_ext.cpp
@@ -46,33 +46,31 @@
 }
 
 void CheckUnSupportAnnot(CPDF_Document* pDoc, const CPDF_Annot* pPDFAnnot) {
-  CFX_ByteString cbSubType = pPDFAnnot->GetSubtype();
-  if (cbSubType.Compare("3D") == 0) {
+  CPDF_Annot::Subtype nAnnotSubtype = pPDFAnnot->GetSubtype();
+  if (nAnnotSubtype == CPDF_Annot::Subtype::THREED) {
     FPDF_UnSupportError(FPDF_UNSP_ANNOT_3DANNOT);
-  } else if (cbSubType.Compare("Screen") == 0) {
+  } else if (nAnnotSubtype == CPDF_Annot::Subtype::SCREEN) {
     const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
     CFX_ByteString cbString;
     if (pAnnotDict->KeyExist("IT"))
       cbString = pAnnotDict->GetStringBy("IT");
     if (cbString.Compare("Img") != 0)
       FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_MEDIA);
-  } else if (cbSubType.Compare("Movie") == 0) {
+  } else if (nAnnotSubtype == CPDF_Annot::Subtype::MOVIE) {
     FPDF_UnSupportError(FPDF_UNSP_ANNOT_MOVIE);
-  } else if (cbSubType.Compare("Sound") == 0) {
+  } else if (nAnnotSubtype == CPDF_Annot::Subtype::SOUND) {
     FPDF_UnSupportError(FPDF_UNSP_ANNOT_SOUND);
-  } else if (cbSubType.Compare("RichMedia") == 0) {
+  } else if (nAnnotSubtype == CPDF_Annot::Subtype::RICHMEDIA) {
     FPDF_UnSupportError(FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA);
-  } else if (cbSubType.Compare("FileAttachment") == 0) {
+  } else if (nAnnotSubtype == CPDF_Annot::Subtype::FILEATTACHMENT) {
     FPDF_UnSupportError(FPDF_UNSP_ANNOT_ATTACHMENT);
-  } else if (cbSubType.Compare("Widget") == 0) {
+  } else if (nAnnotSubtype == CPDF_Annot::Subtype::WIDGET) {
     const CPDF_Dictionary* pAnnotDict = pPDFAnnot->GetAnnotDict();
     CFX_ByteString cbString;
-    if (pAnnotDict->KeyExist("FT")) {
+    if (pAnnotDict->KeyExist("FT"))
       cbString = pAnnotDict->GetStringBy("FT");
-    }
-    if (cbString.Compare("Sig") == 0) {
+    if (cbString.Compare("Sig") == 0)
       FPDF_UnSupportError(FPDF_UNSP_ANNOT_SIG);
-    }
   }
 }
 
diff --git a/fpdfsdk/fsdk_baseform_embeddertest.cpp b/fpdfsdk/fsdk_baseform_embeddertest.cpp
index c87073d..53611ae 100644
--- a/fpdfsdk/fsdk_baseform_embeddertest.cpp
+++ b/fpdfsdk/fsdk_baseform_embeddertest.cpp
@@ -42,7 +42,8 @@
       CPDFSDK_Document::FromFPDFFormHandle(form_handle());
   {
     // Page 0 specifies "row order".
-    CBA_AnnotIterator iter(pSDKDoc->GetPageView(0), "Widget");
+    CBA_AnnotIterator iter(pSDKDoc->GetPageView(0),
+                           CPDF_Annot::Subtype::WIDGET);
     CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot();
     CheckRect(pAnnot->GetRect(), RightTop);
     pAnnot = iter.GetNextAnnot(pAnnot);
@@ -67,7 +68,8 @@
   }
   {
     // Page 1 specifies "column order"
-    CBA_AnnotIterator iter(pSDKDoc->GetPageView(1), "Widget");
+    CBA_AnnotIterator iter(pSDKDoc->GetPageView(1),
+                           CPDF_Annot::Subtype::WIDGET);
     CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot();
     CheckRect(pAnnot->GetRect(), RightTop);
     pAnnot = iter.GetNextAnnot(pAnnot);
@@ -92,7 +94,8 @@
   }
   {
     // Page 2 specifies "struct order"
-    CBA_AnnotIterator iter(pSDKDoc->GetPageView(2), "Widget");
+    CBA_AnnotIterator iter(pSDKDoc->GetPageView(2),
+                           CPDF_Annot::Subtype::WIDGET);
     CPDFSDK_Annot* pAnnot = iter.GetFirstAnnot();
     CheckRect(pAnnot->GetRect(), LeftBottom);
     pAnnot = iter.GetNextAnnot(pAnnot);
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp
index fda00e0..4ca2e6c 100644
--- a/fpdfsdk/fsdk_mgr.cpp
+++ b/fpdfsdk/fsdk_mgr.cpp
@@ -442,7 +442,7 @@
 #endif  // PDF_ENABLE_XFA
 
     if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) {
-      if (pFocusAnnot->GetAnnotSubtype() == "Widget") {
+      if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) {
         CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
         int nFieldType = pWidget->GetFieldType();
         if (FIELDTYPE_TEXTFIELD == nFieldType ||
@@ -586,7 +586,7 @@
 const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
                                                         FX_FLOAT pageY) {
   for (const auto& pAnnot : m_pAnnotList->All()) {
-    if (pAnnot->GetSubtype() == "Widget") {
+    if (pAnnot->GetSubtype() == CPDF_Annot::Subtype::WIDGET) {
       CFX_FloatRect annotRect = pAnnot->GetRect();
       if (annotRect.Contains(pageX, pageY))
         return pAnnot.get();
@@ -602,7 +602,7 @@
   CPDFSDK_AnnotIterator annotIterator(this, false);
   while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
     CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
-    if (pSDKAnnot->GetAnnotSubtype() == "Popup")
+    if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP)
       continue;
     if (rc.Contains(pageX, pageY))
       return pSDKAnnot;
@@ -617,10 +617,10 @@
   CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
   CPDFSDK_AnnotIterator annotIterator(this, false);
   while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
-    bool bHitTest = pSDKAnnot->GetAnnotSubtype() == "Widget";
+    bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET;
 #ifdef PDF_ENABLE_XFA
-    bHitTest =
-        bHitTest || pSDKAnnot->GetAnnotSubtype() == FSDK_XFAWIDGET_TYPENAME;
+    bHitTest = bHitTest ||
+               pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET;
 #endif  // PDF_ENABLE_XFA
     if (bHitTest) {
       pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
diff --git a/fpdfsdk/include/cba_annotiterator.h b/fpdfsdk/include/cba_annotiterator.h
index 0cf6e6a..aa0ad2d 100644
--- a/fpdfsdk/include/cba_annotiterator.h
+++ b/fpdfsdk/include/cba_annotiterator.h
@@ -9,6 +9,7 @@
 
 #include <vector>
 
+#include "core/fpdfdoc/include/cpdf_annot.h"
 #include "core/fxcrt/include/fx_coordinates.h"
 #include "core/fxcrt/include/fx_string.h"
 
@@ -20,7 +21,7 @@
   enum TabOrder { STRUCTURE = 0, ROW, COLUMN };
 
   CBA_AnnotIterator(CPDFSDK_PageView* pPageView,
-                    const CFX_ByteString& sAnnotSubtype);
+                    CPDF_Annot::Subtype nAnnotSubtype);
   ~CBA_AnnotIterator();
 
   CPDFSDK_Annot* GetFirstAnnot();
@@ -40,7 +41,7 @@
 
   TabOrder m_eTabOrder;
   CPDFSDK_PageView* m_pPageView;
-  CFX_ByteString m_sAnnotSubtype;
+  CPDF_Annot::Subtype m_nAnnotSubtype;
   std::vector<CPDFSDK_Annot*> m_Annots;
 };
 
diff --git a/fpdfsdk/include/cpdfsdk_annot.h b/fpdfsdk/include/cpdfsdk_annot.h
index 9501037..967226e 100644
--- a/fpdfsdk/include/cpdfsdk_annot.h
+++ b/fpdfsdk/include/cpdfsdk_annot.h
@@ -35,7 +35,7 @@
   virtual FX_FLOAT GetMinHeight() const;
   virtual int GetLayoutOrder() const;
   virtual CPDF_Annot* GetPDFAnnot() const;
-  virtual CFX_ByteString GetAnnotSubtype() const;
+  virtual CPDF_Annot::Subtype GetAnnotSubtype() const;
   virtual bool IsSignatureWidget() const;
   virtual CFX_FloatRect GetRect() const;
 
diff --git a/fpdfsdk/include/cpdfsdk_annothandlermgr.h b/fpdfsdk/include/cpdfsdk_annothandlermgr.h
index 016135c..3c36692 100644
--- a/fpdfsdk/include/cpdfsdk_annothandlermgr.h
+++ b/fpdfsdk/include/cpdfsdk_annothandlermgr.h
@@ -10,12 +10,12 @@
 #include <map>
 #include <memory>
 
+#include "core/fpdfdoc/include/cpdf_annot.h"
 #include "core/fxcrt/include/fx_basic.h"
 #include "core/fxcrt/include/fx_coordinates.h"
 
 class CFX_Matrix;
 class CFX_RenderDevice;
-class CPDF_Annot;
 class CPDFDoc_Environment;
 class CPDFSDK_Annot;
 class CPDFSDK_BAAnnotHandler;
@@ -109,7 +109,7 @@
                                   const CFX_FloatPoint& point);
 
  private:
-  IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const;
+  IPDFSDK_AnnotHandler* GetAnnotHandler(CPDF_Annot::Subtype nSubtype) const;
   CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, FX_BOOL bNext);
 
   std::unique_ptr<CPDFSDK_BAAnnotHandler> m_pBAAnnotHandler;
diff --git a/fpdfsdk/include/cpdfsdk_baannot.h b/fpdfsdk/include/cpdfsdk_baannot.h
index 0f41738..4575bfe 100644
--- a/fpdfsdk/include/cpdfsdk_baannot.h
+++ b/fpdfsdk/include/cpdfsdk_baannot.h
@@ -28,7 +28,7 @@
   ~CPDFSDK_BAAnnot() override;
 
   // CPDFSDK_Annot
-  CFX_ByteString GetAnnotSubtype() const override;
+  CPDF_Annot::Subtype GetAnnotSubtype() const override;
   void SetRect(const CFX_FloatRect& rect) override;
   CFX_FloatRect GetRect() const override;
   CPDF_Annot* GetPDFAnnot() const override;
diff --git a/fpdfsdk/include/cpdfsdk_baannothandler.h b/fpdfsdk/include/cpdfsdk_baannothandler.h
index c1936a7..ac93a59 100644
--- a/fpdfsdk/include/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/include/cpdfsdk_baannothandler.h
@@ -28,7 +28,6 @@
   CPDFSDK_BAAnnotHandler();
   ~CPDFSDK_BAAnnotHandler() override;
 
-  CFX_ByteString GetType() override;
   FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override;
   CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override;
 #ifdef PDF_ENABLE_XFA
diff --git a/fpdfsdk/include/cpdfsdk_widgethandler.h b/fpdfsdk/include/cpdfsdk_widgethandler.h
index 0155967..042fc2b 100644
--- a/fpdfsdk/include/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/include/cpdfsdk_widgethandler.h
@@ -28,7 +28,6 @@
   explicit CPDFSDK_WidgetHandler(CPDFDoc_Environment* pApp);
   ~CPDFSDK_WidgetHandler() override;
 
-  CFX_ByteString GetType() override;
   FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override;
   CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override;
 #ifdef PDF_ENABLE_XFA
diff --git a/fpdfsdk/include/cpdfsdk_xfawidget.h b/fpdfsdk/include/cpdfsdk_xfawidget.h
index 00cc012..311c225 100644
--- a/fpdfsdk/include/cpdfsdk_xfawidget.h
+++ b/fpdfsdk/include/cpdfsdk_xfawidget.h
@@ -24,7 +24,7 @@
 
   FX_BOOL IsXFAField() override;
   CXFA_FFWidget* GetXFAWidget() const override;
-  CFX_ByteString GetAnnotSubtype() const override;
+  CPDF_Annot::Subtype GetAnnotSubtype() const override;
   CFX_FloatRect GetRect() const override;
 
   CPDFSDK_InterForm* GetInterForm() { return m_pInterForm; }
diff --git a/fpdfsdk/include/cpdfsdk_xfawidgethandler.h b/fpdfsdk/include/cpdfsdk_xfawidgethandler.h
index 84e74b4..269b416 100644
--- a/fpdfsdk/include/cpdfsdk_xfawidgethandler.h
+++ b/fpdfsdk/include/cpdfsdk_xfawidgethandler.h
@@ -25,7 +25,6 @@
   explicit CPDFSDK_XFAWidgetHandler(CPDFDoc_Environment* pApp);
   ~CPDFSDK_XFAWidgetHandler() override;
 
-  CFX_ByteString GetType() override;
   FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) override;
   CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) override;
   CPDFSDK_Annot* NewAnnot(CXFA_FFWidget* pAnnot,
diff --git a/fpdfsdk/include/ipdfsdk_annothandler.h b/fpdfsdk/include/ipdfsdk_annothandler.h
index 0dd1a93..1a6ba86 100644
--- a/fpdfsdk/include/ipdfsdk_annothandler.h
+++ b/fpdfsdk/include/ipdfsdk_annothandler.h
@@ -10,10 +10,6 @@
 #include "core/fxcrt/include/fx_basic.h"
 #include "core/fxcrt/include/fx_coordinates.h"
 
-#ifdef PDF_ENABLE_XFA
-#define FSDK_XFAWIDGET_TYPENAME "XFAWidget"
-#endif  // PDF_ENABLE_XFA
-
 class CFX_Matrix;
 class CFX_RenderDevice;
 class CPDF_Annot;
@@ -28,7 +24,6 @@
  public:
   virtual ~IPDFSDK_AnnotHandler() {}
 
-  virtual CFX_ByteString GetType() = 0;
   virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0;
   virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot,
                                   CPDFSDK_PageView* pPage) = 0;
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp
index 9945217..a23d42f 100644
--- a/fpdfsdk/javascript/Annot.cpp
+++ b/fpdfsdk/javascript/Annot.cpp
@@ -80,7 +80,7 @@
     return FALSE;
   }
 
-  vp << m_BAAnnot->GetAnnotSubtype();
+  vp << CPDF_Annot::AnnotSubtypeToString(m_BAAnnot->GetAnnotSubtype());
   return TRUE;
 }