summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-01 19:51:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-01 19:51:11 +0000
commit1c88166e517d294141e08a45c81ce3c2d9fddaab (patch)
treeca1f61890138aba1da03ecbe5d31690b7209b270 /fpdfsdk
parentce342184e625493b826f6318cf104001c5c4d859 (diff)
downloadpdfium-1c88166e517d294141e08a45c81ce3c2d9fddaab.tar.xz
Remove checks for impossible situation in CPDFXFA_Context.
CPDFXFA_Context should always have a valid doc. Change-Id: Ifb547281f1e4f2741e2d741438b9a3ece71f9e99 Reviewed-on: https://pdfium-review.googlesource.com/43212 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp28
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.h2
2 files changed, 8 insertions, 22 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index f2bfff6fa6..2e1abb859f 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -19,7 +19,6 @@
#include "fxjs/cjs_runtime.h"
#include "fxjs/ijs_runtime.h"
#include "public/fpdf_formfill.h"
-#include "third_party/base/compiler_specific.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fgas/font/cfgas_defaultfontmanager.h"
@@ -31,11 +30,6 @@
#include "xfa/fxfa/cxfa_ffwidgethandler.h"
#include "xfa/fxfa/cxfa_fontmgr.h"
-#ifndef _WIN32
-extern void SetLastError(int err);
-extern int GetLastError();
-#endif
-
namespace {
bool IsValidAlertButton(int type) {
@@ -58,7 +52,9 @@ bool IsValidAlertIcon(int type) {
CPDFXFA_Context::CPDFXFA_Context(CPDF_Document* pPDFDoc)
: m_pPDFDoc(pPDFDoc),
m_pXFAApp(pdfium::MakeUnique<CXFA_FFApp>(this)),
- m_DocEnv(this) {}
+ m_DocEnv(this) {
+ ASSERT(m_pPDFDoc);
+}
CPDFXFA_Context::~CPDFXFA_Context() {
m_nLoadStatus = FXFA_LOADSTATUS_CLOSING;
@@ -109,9 +105,6 @@ bool CPDFXFA_Context::LoadXFADoc() {
m_nLoadStatus = FXFA_LOADSTATUS_LOADING;
m_XFAPageList.clear();
- if (!m_pPDFDoc)
- return false;
-
CXFA_FFApp* pApp = GetXFAApp();
if (!pApp)
return false;
@@ -148,21 +141,15 @@ bool CPDFXFA_Context::LoadXFADoc() {
}
int CPDFXFA_Context::GetPageCount() const {
- if (!m_pPDFDoc && !m_pXFADoc)
- return 0;
-
switch (m_FormType) {
case FormType::kNone:
case FormType::kAcroForm:
case FormType::kXFAForeground:
- if (m_pPDFDoc)
- return m_pPDFDoc->GetPageCount();
- FALLTHROUGH;
+ return m_pPDFDoc->GetPageCount();
case FormType::kXFAFull:
- if (m_pXFADoc)
- return m_pXFADocView->CountPageViews();
- break;
+ return m_pXFADoc ? m_pXFADocView->CountPageViews() : 0;
}
+ NOTREACHED();
return 0;
}
@@ -214,8 +201,7 @@ void CPDFXFA_Context::DeletePage(int page_index) {
// Delete from the document first because, if GetPage was never called for
// this |page_index| then |m_XFAPageList| may have size < |page_index| even
// if it's a valid page in the document.
- if (m_pPDFDoc)
- m_pPDFDoc->DeletePage(page_index);
+ m_pPDFDoc->DeletePage(page_index);
if (pdfium::IndexInBounds(m_XFAPageList, page_index))
m_XFAPageList[page_index].Reset();
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
index 1315375b58..92592a208e 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
@@ -111,7 +111,7 @@ class CPDFXFA_Context final : public CPDF_Document::Extension,
void CloseXFADoc();
FormType m_FormType = FormType::kNone;
- UnownedPtr<CPDF_Document> m_pPDFDoc;
+ UnownedPtr<CPDF_Document> const m_pPDFDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
Observable<CPDFSDK_FormFillEnvironment>::ObservedPtr m_pFormFillEnv;
UnownedPtr<CXFA_FFDocView> m_pXFADocView;