summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-10 18:38:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-10 18:38:03 +0000
commit461acb276e1c38c9ebb3546c5b3254fa5cf9c585 (patch)
tree1680a982413c0fc199af16392772e261fec97a71 /fpdfsdk
parent8d8d3bc54593d2d86054d59669b86a959ec0b602 (diff)
downloadpdfium-461acb276e1c38c9ebb3546c5b3254fa5cf9c585.tar.xz
Remove impossible nullptr checks in CPDFSDK_InterForm.
Also remove dead code and move initialization to headers in CPDFSDK_InterForm. Change-Id: Ib75864ccfd3f1d0d255d9c7942cc610edce822a3 Reviewed-on: https://pdfium-review.googlesource.com/c/43599 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp23
-rw-r--r--fpdfsdk/cpdfsdk_interform.h22
-rw-r--r--fpdfsdk/cpdfsdk_widgethandler.cpp2
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp1
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp10
5 files changed, 16 insertions, 42 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index bd3c7fa1a3..549caafb51 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -122,15 +122,9 @@ bool FDFToURLEncodedData(std::vector<uint8_t>* pBuffer) {
CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv)
: m_pFormFillEnv(pFormFillEnv),
- m_pInterForm(
- pdfium::MakeUnique<CPDF_InterForm>(m_pFormFillEnv->GetPDFDocument())),
-#ifdef PDF_ENABLE_XFA
- m_bXfaCalculate(true),
- m_bXfaValidationsEnabled(true),
-#endif // PDF_ENABLE_XFA
- m_bCalculate(true),
- m_bBusy(false),
- m_HighlightAlpha(0) {
+ m_pInterForm(pdfium::MakeUnique<CPDF_InterForm>(
+ m_pFormFillEnv->GetPDFDocument())) {
+ ASSERT(m_pFormFillEnv);
m_pInterForm->SetFormNotify(this);
RemoveAllHighLights();
}
@@ -142,10 +136,6 @@ CPDFSDK_InterForm::~CPDFSDK_InterForm() {
#endif // PDF_ENABLE_XFA
}
-bool CPDFSDK_InterForm::HighlightWidgets() {
- return false;
-}
-
CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget,
bool bNext) const {
auto pIterator = pdfium::MakeUnique<CPDFSDK_AnnotIterator>(
@@ -156,7 +146,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget,
}
CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const {
- if (!pControl || !m_pInterForm)
+ if (!pControl)
return nullptr;
CPDFSDK_Widget* pWidget = nullptr;
@@ -527,9 +517,6 @@ bool CPDFSDK_InterForm::SubmitForm(const WideString& sDestination,
if (sDestination.IsEmpty())
return false;
- if (!m_pFormFillEnv || !m_pInterForm)
- return false;
-
std::unique_ptr<CFDF_Document> pFDFDoc =
m_pInterForm->ExportToFDF(m_pFormFillEnv->JS_docGetFilePath(), false);
if (!pFDFDoc)
@@ -642,7 +629,7 @@ void CPDFSDK_InterForm::AfterFormReset(CPDF_InterForm* pForm) {
OnCalculate(nullptr);
}
-bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) {
+bool CPDFSDK_InterForm::IsNeedHighLight(FormFieldType fieldType) const {
if (fieldType == FormFieldType::kUnknown)
return false;
diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h
index bd1a76087e..1862fdbe2c 100644
--- a/fpdfsdk/cpdfsdk_interform.h
+++ b/fpdfsdk/cpdfsdk_interform.h
@@ -39,8 +39,6 @@ class CPDFSDK_InterForm final : public IPDF_FormNotify {
return m_pFormFillEnv.Get();
}
- bool HighlightWidgets();
-
CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, bool bNext) const;
CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl) const;
void GetWidgets(const WideString& sFieldName,
@@ -92,7 +90,7 @@ class CPDFSDK_InterForm final : public IPDF_FormNotify {
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude);
- bool IsNeedHighLight(FormFieldType fieldType);
+ bool IsNeedHighLight(FormFieldType fieldType) const;
void RemoveAllHighLights();
void SetHighlightAlpha(uint8_t alpha) { m_HighlightAlpha = alpha; }
uint8_t GetHighlightAlpha() { return m_HighlightAlpha; }
@@ -114,20 +112,18 @@ class CPDFSDK_InterForm final : public IPDF_FormNotify {
int GetPageIndexByAnnotDict(CPDF_Document* pDocument,
CPDF_Dictionary* pAnnotDict) const;
- using CPDFSDK_WidgetMap = std::map<CPDF_FormControl*, CPDFSDK_Widget*>;
-
- UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
- std::unique_ptr<CPDF_InterForm> m_pInterForm;
- CPDFSDK_WidgetMap m_Map;
+ UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
+ std::unique_ptr<CPDF_InterForm> const m_pInterForm;
+ std::map<CPDF_FormControl*, CPDFSDK_Widget*> m_Map;
#ifdef PDF_ENABLE_XFA
std::map<CXFA_FFWidget*, CPDFSDK_XFAWidget*> m_XFAMap;
- bool m_bXfaCalculate;
- bool m_bXfaValidationsEnabled;
+ bool m_bXfaCalculate = true;
+ bool m_bXfaValidationsEnabled = true;
#endif // PDF_ENABLE_XFA
- bool m_bCalculate;
- bool m_bBusy;
+ bool m_bCalculate = true;
+ bool m_bBusy = false;
- uint8_t m_HighlightAlpha;
+ uint8_t m_HighlightAlpha = 0;
FX_COLORREF m_HighlightColor[kFormFieldTypeCount];
bool m_NeedsHighlight[kFormFieldTypeCount];
};
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 70d0397b3c..b67a92d29f 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -62,7 +62,7 @@ CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot,
CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm);
pInterForm->AddMap(pCtrl, pWidget);
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- if (pPDFInterForm && pPDFInterForm->NeedConstructAP())
+ if (pPDFInterForm->NeedConstructAP())
pWidget->ResetAppearance(nullptr, false);
return pWidget;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 2e1abb859f..40ccbdc1ef 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -12,7 +12,6 @@
#include "core/fpdfapi/parser/cpdf_document.h"
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
-#include "fpdfsdk/cpdfsdk_interform.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
#include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h"
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index db58c8724a..6b617eaef0 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -380,12 +380,7 @@ void CPDFXFA_DocEnvironment::SetCurrentPage(CXFA_FFDoc* hDoc,
bool CPDFXFA_DocEnvironment::IsCalculationsEnabled(CXFA_FFDoc* hDoc) {
if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetFormFillEnv())
return false;
- if (m_pContext->GetFormFillEnv()->GetInterForm()) {
- return m_pContext->GetFormFillEnv()
- ->GetInterForm()
- ->IsXfaCalculateEnabled();
- }
- return false;
+ return m_pContext->GetFormFillEnv()->GetInterForm()->IsXfaCalculateEnabled();
}
void CPDFXFA_DocEnvironment::SetCalculationsEnabled(CXFA_FFDoc* hDoc,
@@ -602,9 +597,6 @@ FX_ARGB CPDFXFA_DocEnvironment::GetHighlightColor(CXFA_FFDoc* hDoc) {
return 0;
CPDFSDK_InterForm* pInterForm = m_pContext->GetFormFillEnv()->GetInterForm();
- if (!pInterForm)
- return 0;
-
return AlphaAndColorRefToArgb(
pInterForm->GetHighlightAlpha(),
pInterForm->GetHighlightColor(FormFieldType::kXFA));