From f4dc38bbc52501b322e1c39115f5ce4231773eab Mon Sep 17 00:00:00 2001 From: tonikitoo Date: Tue, 9 Aug 2016 17:07:54 -0700 Subject: The benefits of having a CPDFSDK_FormActionHandler instance in CPDFSDK_ActionHandler are unclear. It does not add encapsulation, nor simplicity to the logic. CL is a driven-by clean up that merges CPDFSDK_FormActionHandler into CPDFSDK_ActionHandler. It takes the opportunity to delete CPDFSDK_ActionHandler (now) empty constructor and destructor, in favor of compiler-generated ones. No behavior change is expected, so no new tests are being added. Review-Url: https://codereview.chromium.org/2227173002 --- fpdfsdk/fsdk_actionhandler.cpp | 34 ++++++++++------------------------ fpdfsdk/include/fsdk_actionhandler.h | 22 +++++++--------------- 2 files changed, 17 insertions(+), 39 deletions(-) diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp index 27f0d34066..be61ba4f08 100644 --- a/fpdfsdk/fsdk_actionhandler.cpp +++ b/fpdfsdk/fsdk_actionhandler.cpp @@ -17,11 +17,6 @@ #include "fpdfsdk/javascript/ijs_runtime.h" #include "third_party/base/stl_util.h" -CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() - : m_pFormActionHandler(new CPDFSDK_FormActionHandler) {} - -CPDFSDK_ActionHandler::~CPDFSDK_ActionHandler() {} - FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument) { std::set visited; @@ -383,27 +378,19 @@ void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action, case CPDF_Action::Movie: break; case CPDF_Action::Hide: - if (m_pFormActionHandler) { - m_pFormActionHandler->DoAction_Hide(action, pDocument); - } + DoAction_Hide(action, pDocument); break; case CPDF_Action::Named: DoAction_Named(pDocument, action); break; case CPDF_Action::SubmitForm: - if (m_pFormActionHandler) { - m_pFormActionHandler->DoAction_SubmitForm(action, pDocument); - } + DoAction_SubmitForm(action, pDocument); break; case CPDF_Action::ResetForm: - if (m_pFormActionHandler) { - m_pFormActionHandler->DoAction_ResetForm(action, pDocument); - } + DoAction_ResetForm(action, pDocument); break; case CPDF_Action::ImportData: - if (m_pFormActionHandler) { - m_pFormActionHandler->DoAction_ImportData(action, pDocument); - } + DoAction_ImportData(action, pDocument); break; case CPDF_Action::JavaScript: ASSERT(FALSE); @@ -606,8 +593,8 @@ void CPDFSDK_ActionHandler::RunDocumentPageJavaScript( pRuntime->ReleaseContext(pContext); } -FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, - CPDFSDK_Document* pDocument) { +FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide(const CPDF_Action& action, + CPDFSDK_Document* pDocument) { CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); if (pInterForm->DoAction_Hide(action)) { pDocument->SetChangeMark(); @@ -617,21 +604,20 @@ FX_BOOL CPDFSDK_FormActionHandler::DoAction_Hide(const CPDF_Action& action, return FALSE; } -FX_BOOL CPDFSDK_FormActionHandler::DoAction_SubmitForm( +FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm( const CPDF_Action& action, CPDFSDK_Document* pDocument) { CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); return pInterForm->DoAction_SubmitForm(action); } -FX_BOOL CPDFSDK_FormActionHandler::DoAction_ResetForm( - const CPDF_Action& action, - CPDFSDK_Document* pDocument) { +FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm(const CPDF_Action& action, + CPDFSDK_Document* pDocument) { CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); return pInterForm->DoAction_ResetForm(action); } -FX_BOOL CPDFSDK_FormActionHandler::DoAction_ImportData( +FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData( const CPDF_Action& action, CPDFSDK_Document* pDocument) { CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm(); diff --git a/fpdfsdk/include/fsdk_actionhandler.h b/fpdfsdk/include/fsdk_actionhandler.h index e8f1a0deb9..66ec69e06a 100644 --- a/fpdfsdk/include/fsdk_actionhandler.h +++ b/fpdfsdk/include/fsdk_actionhandler.h @@ -18,22 +18,8 @@ class CPDFSDK_Document; class CPDF_Bookmark; class CPDF_Dictionary; -class CPDFSDK_FormActionHandler { - public: - FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_SubmitForm(const CPDF_Action& action, - CPDFSDK_Document* pDocument); - FX_BOOL DoAction_ResetForm(const CPDF_Action& action, - CPDFSDK_Document* pDocument); - FX_BOOL DoAction_ImportData(const CPDF_Action& action, - CPDFSDK_Document* pDocument); -}; - class CPDFSDK_ActionHandler { public: - CPDFSDK_ActionHandler(); - ~CPDFSDK_ActionHandler(); - FX_BOOL DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument); FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction, @@ -117,7 +103,13 @@ class CPDFSDK_ActionHandler { void DoAction_SetOCGState(CPDFSDK_Document* pDocument, const CPDF_Action& action); - std::unique_ptr m_pFormActionHandler; + FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument); + FX_BOOL DoAction_SubmitForm(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_ResetForm(const CPDF_Action& action, + CPDFSDK_Document* pDocument); + FX_BOOL DoAction_ImportData(const CPDF_Action& action, + CPDFSDK_Document* pDocument); }; #endif // FPDFSDK_INCLUDE_FSDK_ACTIONHANDLER_H_ -- cgit v1.2.3