Next round of master changes to match XFA
authorTom Sepez <tsepez@chromium.org>
Wed, 14 Oct 2015 20:54:22 +0000 (13:54 -0700)
committerTom Sepez <tsepez@chromium.org>
Wed, 14 Oct 2015 20:54:22 +0000 (13:54 -0700)
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1401423004 .

fpdfsdk/include/fsdk_define.h
fpdfsdk/include/fsdk_mgr.h
fpdfsdk/src/fpdf_dataavail.cpp
fpdfsdk/src/fpdf_transformpage.cpp
fpdfsdk/src/fpdfformfill.cpp
fpdfsdk/src/fpdfview.cpp
fpdfsdk/src/fsdk_baseform.cpp
fpdfsdk/src/fsdk_mgr.cpp
fpdfsdk/src/javascript/JS_Define.h
fpdfsdk/src/javascript/PublicMethods.cpp
fpdfsdk/src/javascript/app.cpp

index d2af1e1..12e3f27 100644 (file)
@@ -10,7 +10,6 @@
 #include "../../core/include/fpdfapi/fpdf_module.h"
 #include "../../core/include/fpdfapi/fpdf_pageobj.h"
 #include "../../core/include/fpdfapi/fpdf_parser.h"
-#include "../../core/include/fpdfapi/fpdf_parser.h"
 #include "../../core/include/fpdfapi/fpdf_render.h"
 #include "../../core/include/fpdfapi/fpdf_serial.h"
 #include "../../core/include/fpdfapi/fpdfapi.h"
@@ -48,10 +47,9 @@ class CPDF_CustomAccess final : public IFX_FileRead {
   CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
   ~CPDF_CustomAccess() override {}
 
+  // IFX_FileRead
   FX_FILESIZE GetSize() override { return m_FileAccess.m_FileLen; }
-
   void Release() override { delete this; }
-
   FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
 
  private:
index ca9a8cc..5ddc8e6 100644 (file)
@@ -325,7 +325,6 @@ class CPDFSDK_PageView final {
 
   int GetPageIndex();
   void LoadFXAnnots();
-
   void SetValid(FX_BOOL bValid) { m_bValid = bValid; }
   FX_BOOL IsValid() { return m_bValid; }
   void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; }
index 9ce298d..5343723 100644 (file)
@@ -5,6 +5,7 @@
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "../../public/fpdf_dataavail.h"
+#include "../../public/fpdf_formfill.h"
 #include "../include/fsdk_define.h"
 
 class CFPDF_FileAvailWrap : public IFX_FileAvail {
index d0dee59..4a892f1 100644 (file)
@@ -138,7 +138,6 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
     CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
     pContentArray->InsertAt(0, pRef);
     pContentArray->AddReference(pDoc, pEndStream);
-
   } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) {
     CPDF_Reference* pReference = (CPDF_Reference*)pContentObj;
     CPDF_Object* pDirectObj = pReference->GetDirect();
index cca4834..37af1fb 100644 (file)
@@ -9,7 +9,6 @@
 #include "../../third_party/base/nonstd_unique_ptr.h"
 #include "../include/fsdk_define.h"
 #include "../include/fsdk_mgr.h"
-#include "../include/javascript/IJavaScript.h"
 
 namespace {
 
index dfa91d1..84dabe6 100644 (file)
@@ -64,30 +64,6 @@ FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) {
 
 CCodec_ModuleMgr* g_pCodecModule = nullptr;
 
-#if _FX_OS_ == _FX_LINUX_EMBEDDED_
-class CFontMapper : public IPDF_FontMapper {
- public:
-  CFontMapper();
-  ~CFontMapper() override;
-
-  // IPDF_FontMapper
-  FT_Face FindSubstFont(
-      CPDF_Document* pDoc,              // [IN] The PDF document
-      const CFX_ByteString& face_name,  // [IN] Original name
-      FX_BOOL bTrueType,                // [IN] TrueType or Type1
-      FX_DWORD flags,   // [IN] PDF font flags (see PDF Reference section 5.7.1)
-      int font_weight,  // [IN] original font weight. 0 for not specified
-      int CharsetCP,    // [IN] code page for charset (see Win32 GetACP())
-      FX_BOOL bVertical,
-      CPDF_SubstFont* pSubstFont  // [OUT] Subst font data
-      ) override;
-
-  FT_Face m_SysFace;
-};
-
-CFontMapper* g_pFontMapper = NULL;
-#endif  // #if _FX_OS_ == _FX_LINUX_EMBEDDED_
-
 DLLEXPORT void STDCALL FPDF_InitLibrary() {
   FPDF_InitLibraryWithConfig(nullptr);
 }
@@ -115,10 +91,6 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
 }
 
 DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
-#if _FX_OS_ == _FX_LINUX_EMBEDDED_
-  delete g_pFontMapper;
-  g_pFontMapper = nullptr;
-#endif
   CPDF_ModuleMgr::Destroy();
   CFX_GEModule::Destroy();
 
@@ -203,7 +175,7 @@ class CMemFile final : public IFX_FileRead {
   }
 
  private:
-  ~CMemFile() {}
+  ~CMemFile() override {}
 
   uint8_t* m_pBuf;
   FX_FILESIZE m_size;
index f6b6b14..7d0346c 100644 (file)
@@ -38,7 +38,7 @@ CPDFSDK_Widget::~CPDFSDK_Widget() {}
 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
     CPDF_Annot::AppearanceMode mode) {
   CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
-  if (pAP == NULL)
+  if (!pAP)
     return FALSE;
 
   // Choose the right sub-ap
@@ -52,7 +52,7 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
 
   // Get the AP stream or subdirectory
   CPDF_Object* psub = pAP->GetElementValue(ap_entry);
-  if (psub == NULL)
+  if (!psub)
     return FALSE;
 
   int nFieldType = GetFieldType();
@@ -71,7 +71,6 @@ FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(
       }
       return FALSE;
   }
-
   return TRUE;
 }
 
@@ -186,15 +185,11 @@ FX_FLOAT CPDFSDK_Widget::GetFontSize() const {
 
 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const {
   CPDF_FormField* pFormField = GetFormField();
-  ASSERT(pFormField != NULL);
-
   return pFormField->GetSelectedIndex(nIndex);
 }
 
 CFX_WideString CPDFSDK_Widget::GetValue() const {
   CPDF_FormField* pFormField = GetFormField();
-  ASSERT(pFormField != NULL);
-
   return pFormField->GetValue();
 }
 
@@ -221,8 +216,6 @@ int CPDFSDK_Widget::CountOptions() const {
 
 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const {
   CPDF_FormField* pFormField = GetFormField();
-  ASSERT(pFormField != NULL);
-
   return pFormField->IsItemSelected(nIndex);
 }
 
@@ -1464,19 +1457,11 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
 
   if (action && action.GetType() != CPDF_Action::Unknown) {
     CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
-    ASSERT(pDocument != NULL);
-
     CPDFDoc_Environment* pEnv = pDocument->GetEnv();
-    ASSERT(pEnv != NULL);
-
-    CPDFSDK_ActionHandler* pActionHandler =
-        pEnv->GetActionHander(); /*(CPDFSDK_ActionHandler*)pApp->GetActionHandler();*/
-    ASSERT(pActionHandler != NULL);
-
+    CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
     return pActionHandler->DoAction_Field(action, type, pDocument,
                                           GetFormField(), data);
   }
-
   return FALSE;
 }
 
index b7962d5..883ad60 100644 (file)
@@ -6,9 +6,9 @@
 
 #include "../../public/fpdf_ext.h"
 #include "../../third_party/base/nonstd_unique_ptr.h"
+#include "../include/formfiller/FFL_FormFiller.h"
 #include "../include/fsdk_define.h"
 #include "../include/fsdk_mgr.h"
-#include "../include/formfiller/FFL_FormFiller.h"
 #include "../include/javascript/IJavaScript.h"
 
 #if _FX_OS_ == _FX_ANDROID_
@@ -660,11 +660,9 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
 
   CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
   CPDFSDK_AnnotIterator annotIterator(this, TRUE);
-  CPDFSDK_Annot* pSDKAnnot = nullptr;
   int index = -1;
-  while ((pSDKAnnot = annotIterator.Next(index))) {
+  while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) {
     CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr();
-    ASSERT(pAnnotHandlerMgr);
     pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0);
   }
 }
index 3e5b797..b21f894 100644 (file)
@@ -71,9 +71,8 @@ struct JSMethodSpec {
   }                            \
   ;
 
-template <
-    class C,
-    FX_BOOL (C::*M)(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)>
+template <class C,
+          FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
 void JSPropGetter(const char* prop_name_string,
                   const char* class_name_string,
                   v8::Local<v8::String> property,
@@ -97,9 +96,8 @@ void JSPropGetter(const char* prop_name_string,
   info.GetReturnValue().Set((v8::Local<v8::Value>)value);
 }
 
-template <
-    class C,
-    FX_BOOL (C::*M)(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)>
+template <class C,
+          FX_BOOL (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
 void JSPropSetter(const char* prop_name_string,
                   const char* class_name_string,
                   v8::Local<v8::String> property,
@@ -137,10 +135,10 @@ void JSPropSetter(const char* prop_name_string,
   }
 
 template <class C,
-          FX_BOOL (C::*M)(IJS_Context* cc,
-                          const CJS_Parameters& params,
-                          CJS_Value& vRet,
-                          CFX_WideString& sError)>
+          FX_BOOL (C::*M)(IJS_Context*,
+                          const CJS_Parameters&,
+                          CJS_Value&,
+                          CFX_WideString&)>
 void JSMethod(const char* method_name_string,
               const char* class_name_string,
               const v8::FunctionCallbackInfo<v8::Value>& info) {
index 4743d3d..e898214 100644 (file)
@@ -48,14 +48,31 @@ END_JS_STATIC_GLOBAL_FUN()
 
 IMPLEMENT_JS_STATIC_GLOBAL_FUN(CJS_PublicMethods)
 
-static const FX_WCHAR* months[] = {L"Jan", L"Feb", L"Mar", L"Apr",
-                                   L"May", L"Jun", L"Jul", L"Aug",
-                                   L"Sep", L"Oct", L"Nov", L"Dec"};
-
-static const FX_WCHAR* fullmonths[] = {L"January", L"February", L"March",
-                                       L"April",   L"May",      L"June",
-                                       L"July",    L"August",   L"September",
-                                       L"October", L"November", L"December"};
+static const FX_WCHAR* const months[] = {L"Jan",
+                                         L"Feb",
+                                         L"Mar",
+                                         L"Apr",
+                                         L"May",
+                                         L"Jun",
+                                         L"Jul",
+                                         L"Aug",
+                                         L"Sep",
+                                         L"Oct",
+                                         L"Nov",
+                                         L"Dec"};
+
+static const FX_WCHAR* const fullmonths[] = {L"January",
+                                             L"February",
+                                             L"March",
+                                             L"April",
+                                             L"May",
+                                             L"June",
+                                             L"July",
+                                             L"August",
+                                             L"September",
+                                             L"October",
+                                             L"November",
+                                             L"December"};
 
 FX_BOOL CJS_PublicMethods::IsNumber(const FX_WCHAR* string) {
   CFX_WideString sTrim = StrTrim(string);
@@ -984,10 +1001,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
     else
       cSeperator = '.';
 
-    int iDecPositive;
-    iDecPositive = iDec2;
-
-    for (iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
+    for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
       strValue.Insert(iDecPositive, cSeperator);
       iMax++;
     }
@@ -1273,10 +1287,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(IJS_Context* cc,
     else
       cSeperator = '.';
 
-    int iDecPositive;
-    iDecPositive = iDec2;
-
-    for (iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
+    for (int iDecPositive = iDec2 - 3; iDecPositive > 0; iDecPositive -= 3) {
       strValue.Insert(iDecPositive, cSeperator);
       iMax++;
     }
index 3db1e5b..1bd089a 100644 (file)
@@ -194,12 +194,11 @@ FX_BOOL app::viewerVariation(IJS_Context* cc,
 FX_BOOL app::viewerVersion(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
-  if (vp.IsGetting()) {
-    vp << JS_NUM_VIEWERVERSION;
-    return TRUE;
-  }
+  if (!vp.IsGetting())
+    return FALSE;
 
-  return FALSE;
+  vp << JS_NUM_VIEWERVERSION;
+  return TRUE;
 }
 
 FX_BOOL app::platform(IJS_Context* cc,