Delete dead code for deleting pages and icons.
authorLei Zhang <thestig@chromium.org>
Mon, 22 Jun 2015 22:10:28 +0000 (15:10 -0700)
committerLei Zhang <thestig@chromium.org>
Mon, 22 Jun 2015 22:10:28 +0000 (15:10 -0700)
1) Document::deletePages()
2) CPDFSDK_Document::DeletePages()
3) Document::removeIcon()
4) IconTree::DeleteIconElement()

Originally (1) called (2), but only when FOXIT_CHROME_BUILD was not
defined. Since it was always defined for PDFium, this was effectively
dead code the whole time. Ditto for (3) and (4). The functions were
deemed unsafe in https://crbug.com/67100

R=jam@chromium.org

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

fpdfsdk/include/fsdk_mgr.h
fpdfsdk/include/javascript/Document.h
fpdfsdk/src/fsdk_mgr.cpp
fpdfsdk/src/javascript/Document.cpp

index 43f6bf0..4f2a87d 100644 (file)
@@ -389,7 +389,6 @@ public:
 
        FX_BOOL                                 ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc);
        FX_BOOL                                 InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
-       FX_BOOL                                 DeletePages(int nStart, int nCount);
        FX_BOOL                                 ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages);
 
        void                                    OnCloseDocument();
index b3725e7..6b40069 100644 (file)
@@ -64,7 +64,6 @@ public:
 
 public:
        void                    InsertIconElement(IconElement* pNewIcon);
-       void                    DeleteIconElement(CFX_WideString swIconName);
        void                    DeleteIconTree();
        int                             GetLength();
        IconElement*    operator[](int iIndex);
index 0037532..ad27aeb 100644 (file)
@@ -517,25 +517,6 @@ FX_BOOL CPDFSDK_Document::KillFocusAnnot(FX_UINT nFlag)
        return FALSE;
 }
 
-FX_BOOL        CPDFSDK_Document::DeletePages(int nStart, int  nCount)
-{
-       if ( nStart < 0 || nStart >= GetPageCount() || nCount <= 0 )
-       {
-               return FALSE;
-       }
-
-       CPDF_Page * pTempPage = NULL;
-       for ( int i = nCount-1; i >= 0; i-- )
-       {
-               pTempPage = GetPage(nStart+i);
-               if ( pTempPage != NULL )
-               {
-                       ReMovePageView(pTempPage);
-               }
-       }
-       return TRUE;
-}
-
 void CPDFSDK_Document::OnCloseDocument()
 {
        KillFocusAnnot();
index 7c77e82..1d2dca5 100644 (file)
@@ -1420,47 +1420,6 @@ IconElement* IconTree::operator [](int iIndex)
                return NULL;
 }
 
-void IconTree::DeleteIconElement(CFX_WideString swIconName)
-{
-       IconElement* pTemp = m_pHead;
-       int iLoopCount = m_iLength;
-       for (int i = 0; i < iLoopCount - 1; i++)
-       {
-               if (pTemp == m_pEnd)
-                       break;
-
-               if (m_pHead->IconName == swIconName)
-               {
-                       m_pHead = m_pHead->NextIcon;
-                       delete pTemp;
-                       m_iLength--;
-                       pTemp = m_pHead;
-               }
-               if (pTemp->NextIcon->IconName == swIconName)
-               {
-                       if (pTemp->NextIcon == m_pEnd)
-                       {
-                               m_pEnd = pTemp;
-                               delete pTemp->NextIcon;
-                               m_iLength--;
-                               pTemp->NextIcon = NULL;
-                       }
-                       else
-                       {
-                               IconElement* pElement = pTemp->NextIcon;
-                               pTemp->NextIcon = pTemp->NextIcon->NextIcon;
-                               delete pElement;
-                               m_iLength--;
-                               pElement = NULL;
-                       }
-
-                       continue;
-               }
-
-               pTemp = pTemp->NextIcon;
-       }
-}
-
 FX_BOOL Document::addIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
        CJS_Context* pContext = (CJS_Context*)cc;
@@ -1581,16 +1540,8 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_V
 
 FX_BOOL Document::removeIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
-       CJS_Context* pContext = (CJS_Context *)cc;
-       if (params.size() != 1) {
-               sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
-               return FALSE;
-       }
-
-       if(!m_pIconTree)
-               return FALSE;
-       CFX_WideString swIconName = params[0].ToCFXWideString();
-       return TRUE;
+  // Unsafe, no supported.
+  return FALSE;
 }
 
 FX_BOOL Document::createDataObject(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
@@ -1854,55 +1805,8 @@ FX_BOOL Document::zoomType(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString&
 
 FX_BOOL Document::deletePages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
 {
-       v8::Isolate* isolate = GetIsolate(cc);
-       ASSERT(m_pDocument != NULL);
-
-       if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
-               m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE;
-
-       int iSize = params.size();
-
-       int nStart = 0;
-       int nEnd = 0;
-
-       if (iSize < 1)
-       {
-       }
-       else if (iSize == 1)
-       {
-               if (params[0].GetType() == VT_object)
-               {
-                       JSObject pObj = params[0].ToV8Object();
-                       v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"nStart");
-            nStart = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt();
-
-                       pValue = JS_GetObjectElement(isolate, pObj, L"nEnd");
-                       nEnd = CJS_Value(m_isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt();
-               }
-               else
-               {
-                       nStart = params[0].ToInt();
-               }
-       }
-       else
-       {
-               nStart = params[0].ToInt();
-               nEnd = params[1].ToInt();
-       }
-
-       int nTotal = m_pDocument->GetPageCount();
-
-       if (nStart < 0) nStart = 0;
-       if (nStart >= nTotal) nStart = nTotal - 1;
-
-       if (nEnd < 0) nEnd = 0;
-       if (nEnd >= nTotal) nEnd = nTotal - 1;
-
-       if (nEnd < nStart) nEnd = nStart;
-
-
-
-       return TRUE;
+  // Unsafe, no supported.
+  return FALSE;
 }
 
 FX_BOOL Document::extractPages(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)