Remove implicit conversions and some cleanup

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/1751753002 .
diff --git a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
index 21a4bb6..2cad12b 100644
--- a/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
+++ b/fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
@@ -128,7 +128,7 @@
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-    if (pWidget->GetAAction(CPDF_AAction::CursorEnter)) {
+    if (pWidget->GetAAction(CPDF_AAction::CursorEnter).GetDict()) {
       m_bNotifying = TRUE;
 
       int nValueAge = pWidget->GetValueAge();
@@ -164,7 +164,7 @@
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-    if (pWidget->GetAAction(CPDF_AAction::CursorExit)) {
+    if (pWidget->GetAAction(CPDF_AAction::CursorExit).GetDict()) {
       m_bNotifying = TRUE;
       pWidget->GetAppearanceAge();
       int nValueAge = pWidget->GetValueAge();
@@ -202,7 +202,7 @@
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
     if (Annot_HitTest(pPageView, pAnnot, point) &&
-        pWidget->GetAAction(CPDF_AAction::ButtonDown)) {
+        pWidget->GetAAction(CPDF_AAction::ButtonDown).GetDict()) {
       m_bNotifying = TRUE;
       pWidget->GetAppearanceAge();
       int nValueAge = pWidget->GetValueAge();
@@ -284,7 +284,7 @@
   ASSERT(pWidget);
 
   if (!m_bNotifying) {
-    if (pWidget->GetAAction(CPDF_AAction::ButtonUp)) {
+    if (pWidget->GetAAction(CPDF_AAction::ButtonUp).GetDict()) {
       m_bNotifying = TRUE;
       int nAge = pWidget->GetAppearanceAge();
       int nValueAge = pWidget->GetValueAge();
@@ -415,7 +415,7 @@
 
   if (!m_bNotifying) {
     CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-    if (pWidget->GetAAction(CPDF_AAction::GetFocus)) {
+    if (pWidget->GetAAction(CPDF_AAction::GetFocus).GetDict()) {
       m_bNotifying = TRUE;
       pWidget->GetAppearanceAge();
 
@@ -461,7 +461,7 @@
 
     if (!m_bNotifying) {
       CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
-      if (pWidget->GetAAction(CPDF_AAction::LoseFocus)) {
+      if (pWidget->GetAAction(CPDF_AAction::LoseFocus).GetDict()) {
         m_bNotifying = TRUE;
         pWidget->ClearAppModified();
 
@@ -642,7 +642,7 @@
                                          FX_BOOL& bExit,
                                          FX_DWORD nFlag) {
   if (!m_bNotifying) {
-    if (pWidget->GetAAction(CPDF_AAction::KeyStroke)) {
+    if (pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
       m_bNotifying = TRUE;
       pWidget->ClearAppModified();
 
@@ -674,7 +674,7 @@
                                   FX_BOOL& bExit,
                                   FX_DWORD nFlag) {
   if (!m_bNotifying) {
-    if (pWidget->GetAAction(CPDF_AAction::Validate)) {
+    if (pWidget->GetAAction(CPDF_AAction::Validate).GetDict()) {
       m_bNotifying = TRUE;
       pWidget->ClearAppModified();
 
@@ -951,7 +951,7 @@
 #endif  // PDF_ENABLE_XFA
 
   if (!m_bNotifying) {
-    if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) {
+    if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) {
       m_bNotifying = TRUE;
       int nAge = pData->pWidget->GetAppearanceAge();
       int nValueAge = pData->pWidget->GetValueAge();
diff --git a/fpdfsdk/src/fpdfdoc.cpp b/fpdfsdk/src/fpdfdoc.cpp
index c88dccd..50f3e2c 100644
--- a/fpdfsdk/src/fpdfdoc.cpp
+++ b/fpdfsdk/src/fpdfdoc.cpp
@@ -15,16 +15,17 @@
 CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
                            CPDF_Bookmark bookmark,
                            const CFX_WideString& title) {
-  if (bookmark && bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
+  if (bookmark.GetDict() &&
+      bookmark.GetTitle().CompareNoCase(title.c_str()) == 0) {
     // First check this item
     return bookmark;
   }
   // go into children items
   CPDF_Bookmark child = tree.GetFirstChild(bookmark);
-  while (child) {
+  while (child.GetDict()) {
     // check if this item
     CPDF_Bookmark found = FindBookmark(tree, child, title);
-    if (found)
+    if (found.GetDict())
       return found;
     child = tree.GetNextSibling(child);
   }
@@ -112,12 +113,12 @@
     return nullptr;
   CPDF_Bookmark bookmark(ToDictionary(static_cast<CPDF_Object*>(pDict)));
   CPDF_Dest dest = bookmark.GetDest(pDoc);
-  if (dest)
+  if (dest.GetObject())
     return dest.GetObject();
   // If this bookmark is not directly associated with a dest, we try to get
   // action
   CPDF_Action action = bookmark.GetAction();
-  if (!action)
+  if (!action.GetDict())
     return nullptr;
   return action.GetDest(pDoc).GetObject();
 }
@@ -244,7 +245,7 @@
     return dest;
   // If this link is not directly associated with a dest, we try to get action
   CPDF_Action action = link.GetAction();
-  if (!action)
+  if (!action.GetDict())
     return nullptr;
   return action.GetDest(pDoc).GetObject();
 }
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index c2e75c3..874082e 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -691,7 +691,7 @@
   if (!pDic)
     return;
 
-  CPDF_AAction aa = pDic->GetDictBy("AA");
+  CPDF_AAction aa(pDic->GetDictBy("AA"));
   if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) {
     CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
     CPDFSDK_ActionHandler* pActionHandler =
@@ -715,7 +715,7 @@
     CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
     CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
     CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict;
-    CPDF_AAction aa = pPageDict->GetDictBy("AA");
+    CPDF_AAction aa(pPageDict->GetDictBy("AA"));
     if (FPDFPAGE_AACTION_OPEN == aaType) {
       if (aa.ActionExist(CPDF_AAction::OpenPage)) {
         CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
diff --git a/fpdfsdk/src/fsdk_actionhandler.cpp b/fpdfsdk/src/fsdk_actionhandler.cpp
index c429373..496e113 100644
--- a/fpdfsdk/src/fsdk_actionhandler.cpp
+++ b/fpdfsdk/src/fsdk_actionhandler.cpp
@@ -421,7 +421,7 @@
 
 void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
                                           const CPDF_Action& action) {
-  ASSERT(action);
+  ASSERT(action.GetDict());
 
   CPDF_Document* pPDFDocument = pDocument->GetPDFDocument();
   ASSERT(pPDFDocument);
@@ -454,7 +454,7 @@
 
 void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument,
                                          const CPDF_Action& action) {
-  ASSERT(action);
+  ASSERT(action.GetDict());
 
   CPDFDoc_Environment* pApp = pDocument->GetEnv();
   CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument());
@@ -463,7 +463,7 @@
 
 void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
                                            const CPDF_Action& action) {
-  ASSERT(action);
+  ASSERT(action.GetDict());
 
   CFX_ByteString csName = action.GetNamedAction();
   pDocument->GetEnv()->FFI_ExecuteNamedAction(csName);
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 132d30b..bd73ee3 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -892,9 +892,8 @@
 }
 
 void CPDFSDK_BAAnnot::SetAction(const CPDF_Action& action) {
-  ASSERT(action);
-  if ((CPDF_Action&)action !=
-      CPDF_Action(m_pAnnot->GetAnnotDict()->GetDictBy("A"))) {
+  ASSERT(action.GetDict());
+  if (action.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("A")) {
     CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
     CPDF_Dictionary* pDict = action.GetDict();
     if (pDict && pDict->GetObjNum() == 0) {
@@ -909,12 +908,12 @@
 }
 
 CPDF_AAction CPDFSDK_BAAnnot::GetAAction() const {
-  return m_pAnnot->GetAnnotDict()->GetDictBy("AA");
+  return CPDF_AAction(m_pAnnot->GetAnnotDict()->GetDictBy("AA"));
 }
 
 void CPDFSDK_BAAnnot::SetAAction(const CPDF_AAction& aa) {
-  if ((CPDF_AAction&)aa != m_pAnnot->GetAnnotDict()->GetDictBy("AA"))
-    m_pAnnot->GetAnnotDict()->SetAt("AA", (CPDF_AAction&)aa);
+  if (aa.GetDict() != m_pAnnot->GetAnnotDict()->GetDictBy("AA"))
+    m_pAnnot->GetAnnotDict()->SetAt("AA", aa.GetDict());
 }
 
 void CPDFSDK_BAAnnot::RemoveAAction() {
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 8245980..8d8b95f 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -1912,7 +1912,7 @@
 #endif  // PDF_ENABLE_XFA
 
   CPDF_Action action = GetAAction(type);
-  if (action && action.GetType() != CPDF_Action::Unknown) {
+  if (action.GetDict() && action.GetType() != CPDF_Action::Unknown) {
     CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
     return pActionHandler->DoAction_Field(action, type, pDocument,
                                           GetFormField(), data);
@@ -1939,8 +1939,8 @@
     case CPDF_AAction::Validate:
     case CPDF_AAction::Calculate: {
       CPDF_FormField* pField = GetFormField();
-      if (CPDF_AAction aa = pField->GetAdditionalAction())
-        return aa.GetAction(eAAT);
+      if (pField->GetAdditionalAction().GetDict())
+        return pField->GetAdditionalAction().GetAction(eAAT);
       return CPDFSDK_BAAnnot::GetAAction(eAAT);
     }
     default:
@@ -2200,9 +2200,10 @@
         int nType = pField->GetFieldType();
         if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) {
           CPDF_AAction aAction = pField->GetAdditionalAction();
-          if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) {
+          if (aAction.GetDict() &&
+              aAction.ActionExist(CPDF_AAction::Calculate)) {
             CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate);
-            if (action) {
+            if (action.GetDict()) {
               CFX_WideString csJS = action.GetJavaScript();
               if (!csJS.IsEmpty()) {
                 IJS_Context* pContext = pRuntime->NewContext();
@@ -2256,9 +2257,9 @@
   bFormated = FALSE;
 
   CPDF_AAction aAction = pFormField->GetAdditionalAction();
-  if (aAction && aAction.ActionExist(CPDF_AAction::Format)) {
+  if (aAction.GetDict() && aAction.ActionExist(CPDF_AAction::Format)) {
     CPDF_Action action = aAction.GetAction(CPDF_AAction::Format);
-    if (action) {
+    if (action.GetDict()) {
       CFX_WideString script = action.GetJavaScript();
       if (!script.IsEmpty()) {
         CFX_WideString Value = sValue;
@@ -2313,11 +2314,11 @@
 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
                                              const CFX_WideString& csValue) {
   CPDF_AAction aAction = pFormField->GetAdditionalAction();
-  if (!aAction || !aAction.ActionExist(CPDF_AAction::KeyStroke))
+  if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke))
     return TRUE;
 
   CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke);
-  if (!action)
+  if (!action.GetDict())
     return TRUE;
 
   CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
@@ -2334,11 +2335,11 @@
 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
                                       const CFX_WideString& csValue) {
   CPDF_AAction aAction = pFormField->GetAdditionalAction();
-  if (!aAction || !aAction.ActionExist(CPDF_AAction::Validate))
+  if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate))
     return TRUE;
 
   CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate);
-  if (!action)
+  if (!action.GetDict())
     return TRUE;
 
   CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
@@ -2353,9 +2354,9 @@
 }
 
 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
-  ASSERT(action);
+  ASSERT(action.GetDict());
 
-  CPDF_ActionFields af = action.GetWidgets();
+  CPDF_ActionFields af(&action);
   std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
   std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
 
@@ -2392,7 +2393,7 @@
 
   CPDF_Dictionary* pActionDict = action.GetDict();
   if (pActionDict->KeyExist("Fields")) {
-    CPDF_ActionFields af = action.GetWidgets();
+    CPDF_ActionFields af(&action);
     FX_DWORD dwFlags = action.GetFlags();
     std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
     std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
@@ -2559,13 +2560,13 @@
 }
 
 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) {
-  ASSERT(action);
+  ASSERT(action.GetDict());
 
   CPDF_Dictionary* pActionDict = action.GetDict();
   if (!pActionDict->KeyExist("Fields"))
     return m_pInterForm->ResetForm(true);
 
-  CPDF_ActionFields af = action.GetWidgets();
+  CPDF_ActionFields af(&action);
   FX_DWORD dwFlags = action.GetFlags();
 
   std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
diff --git a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
index 1bfa1a6..d8e11c2 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Icon.cpp
@@ -128,7 +128,7 @@
     fLeft = 0.0f;
     fBottom = 0.0f;
     CPDF_Array* pA =
-        m_pIconFit->m_pDict ? m_pIconFit->m_pDict->GetArrayBy("A") : NULL;
+        m_pIconFit->GetDict() ? m_pIconFit->GetDict()->GetArrayBy("A") : NULL;
     if (pA) {
       FX_DWORD dwCount = pA->GetCount();
       if (dwCount > 0)