Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: fpdfsdk/src/fsdk_mgr.cpp

Issue 594403003: Lock page in LoadFXAnnot to prevent unintended page closing (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« fpdfsdk/include/fsdk_mgr.h ('K') | « fpdfsdk/src/fpdfview.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fpdf_ext.h" 9 #include "../include/fpdf_ext.h"
10 #include "../include/formfiller/FFL_FormFiller.h" 10 #include "../include/formfiller/FFL_FormFiller.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 326
327 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv ):m_pDoc(pDoc), 327 CPDFSDK_Document::CPDFSDK_Document(CPDF_Document* pDoc,CPDFDoc_Environment* pEnv ):m_pDoc(pDoc),
328 m_pInterForm(NULL),m_pEnv(pEnv), m_pOccontent(NULL),m_bChangeMask(FALSE) 328 m_pInterForm(NULL),m_pEnv(pEnv), m_pOccontent(NULL),m_bChangeMask(FALSE)
329 { 329 {
330 m_pFocusAnnot = NULL; 330 m_pFocusAnnot = NULL;
331 } 331 }
332 332
333 CPDFSDK_Document::~CPDFSDK_Document() 333 CPDFSDK_Document::~CPDFSDK_Document()
334 { 334 {
335 » m_pageMap.RemoveAll(); 335 » FX_POSITION pos = m_pageMap.GetStartPosition();
336 » while (pos) {
337 CPDF_Page* pPage = NULL;
338 CPDFSDK_PageView* pPageView = NULL;
339 m_pageMap.GetNextAssoc(pos, pPage, pPageView);
340 delete pPageView;
341 }
342 m_pageMap.RemoveAll();
336 if(m_pInterForm) 343 if(m_pInterForm)
337 { 344 {
338 m_pInterForm->Destroy(); 345 m_pInterForm->Destroy();
339 m_pInterForm = NULL; 346 m_pInterForm = NULL;
340 } 347 }
341 if(m_pOccontent) 348 if(m_pOccontent)
342 { 349 {
343 delete m_pOccontent; 350 delete m_pOccontent;
344 m_pOccontent = NULL; 351 m_pOccontent = NULL;
345 } 352 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 CPDF_OCContext* CPDFSDK_Document::GetOCContext() 453 CPDF_OCContext* CPDFSDK_Document::GetOCContext()
447 { 454 {
448 if(!m_pOccontent) 455 if(!m_pOccontent)
449 m_pOccontent = new CPDF_OCContext(m_pDoc); 456 m_pOccontent = new CPDF_OCContext(m_pDoc);
450 return m_pOccontent; 457 return m_pOccontent;
451 } 458 }
452 459
453 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage) 460 void CPDFSDK_Document::ReMovePageView(CPDF_Page* pPDFPage)
454 { 461 {
455 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pP DFPage); 462 CPDFSDK_PageView* pPageView = (CPDFSDK_PageView*)m_pageMap.GetValueAt(pP DFPage);
456 » if(pPageView) 463 » if(pPageView && !pPageView->IsLocked())
457 { 464 {
458 delete pPageView; 465 delete pPageView;
459 m_pageMap.RemoveKey(pPDFPage); 466 m_pageMap.RemoveKey(pPDFPage);
460 } 467 }
461 } 468 }
462 469
463 CPDF_Page * CPDFSDK_Document::GetPage(int nIndex) 470 CPDF_Page * CPDFSDK_Document::GetPage(int nIndex)
464 { 471 {
465 CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex); 472 CPDF_Page * pTempPage = (CPDF_Page*)m_pEnv->FFI_GetPage(m_pDoc,nIndex);
466 if(!pTempPage) 473 if(!pTempPage)
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 608
602 609
603 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_ page(page),m_pSDKDoc(pSDKDoc) 610 CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page):m_ page(page),m_pSDKDoc(pSDKDoc)
604 { 611 {
605 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); 612 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm();
606 if(pInterForm) 613 if(pInterForm)
607 { 614 {
608 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); 615 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
609 pPDFInterForm->FixPageFields(page); 616 pPDFInterForm->FixPageFields(page);
610 } 617 }
611 618 m_page->SetPrivateData((FX_LPVOID)m_page, (FX_LPVOID)this, NULL);
612 m_fxAnnotArray.RemoveAll(); 619 m_fxAnnotArray.RemoveAll();
613 620
614 m_bEnterWidget = FALSE; 621 m_bEnterWidget = FALSE;
615 m_bExitWidget = FALSE; 622 m_bExitWidget = FALSE;
616 m_bOnWidget = FALSE; 623 m_bOnWidget = FALSE;
617 m_CaptureWidget = NULL; 624 m_CaptureWidget = NULL;
618 m_bValid = FALSE; 625 m_bValid = FALSE;
626 m_bLocked = FALSE;
627 m_bTakeOverPage = FALSE;
619 } 628 }
620 629
621 CPDFSDK_PageView::~CPDFSDK_PageView() 630 CPDFSDK_PageView::~CPDFSDK_PageView()
622 { 631 {
623 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 632 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
624 int nAnnotCount = m_fxAnnotArray.GetSize(); 633 int nAnnotCount = m_fxAnnotArray.GetSize();
634
625 for (int i=0; i<nAnnotCount; i++) 635 for (int i=0; i<nAnnotCount; i++)
626 { 636 {
627 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); 637 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
628 //if there is a focused annot on the page, we should kill the fo cus first. 638 //if there is a focused annot on the page, we should kill the fo cus first.
629 if(pAnnot == m_pSDKDoc->GetFocusAnnot()) 639 if(pAnnot == m_pSDKDoc->GetFocusAnnot())
630 KillFocusAnnot(); 640 KillFocusAnnot();
631 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 641 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr();
632 ASSERT(pAnnotHandlerMgr); 642 ASSERT(pAnnotHandlerMgr);
633 pAnnotHandlerMgr->ReleaseAnnot(pAnnot); 643 pAnnotHandlerMgr->ReleaseAnnot(pAnnot);
634 } 644 }
635 m_fxAnnotArray.RemoveAll(); 645 m_fxAnnotArray.RemoveAll();
636 if(m_pAnnotList) 646 if(m_pAnnotList)
637 { 647 {
638 delete m_pAnnotList; 648 delete m_pAnnotList;
639 m_pAnnotList = NULL; 649 m_pAnnotList = NULL;
640 } 650 }
651 m_page->RemovePrivateData((FX_LPVOID)m_page);
652 if(m_bTakeOverPage) {
653 delete m_page;
654 }
641 } 655 }
642 656
643 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device,CPDF_RenderOptions* pOptions) 657 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* p User2Device,CPDF_RenderOptions* pOptions)
644 { 658 {
645 m_curMatrix = *pUser2Device; 659 m_curMatrix = *pUser2Device;
646 660
647 // m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE , pOptions); 661 // m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE , pOptions);
648 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 662 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
649 CPDFSDK_AnnotIterator annotIterator(this, TRUE); 663 CPDFSDK_AnnotIterator annotIterator(this, TRUE);
650 CPDFSDK_Annot * pSDKAnnot=NULL; 664 CPDFSDK_Annot * pSDKAnnot=NULL;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 976
963 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot); 977 extern void CheckUnSupportAnnot(CPDF_Document * pDoc, CPDF_Annot* pPDFAnnot);
964 978
965 void CPDFSDK_PageView::LoadFXAnnots() 979 void CPDFSDK_PageView::LoadFXAnnots()
966 { 980 {
967 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 981 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
968 982
969 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled(); 983 FX_BOOL enableAPUpdate = CPDF_InterForm::UpdatingAPEnabled();
970 //Disable the default AP construction. 984 //Disable the default AP construction.
971 CPDF_InterForm::EnableUpdateAP(FALSE); 985 CPDF_InterForm::EnableUpdateAP(FALSE);
972 m_pAnnotList = new CPDF_AnnotList(m_page); 986 m_pAnnotList = new CPDF_AnnotList(m_page);
Tom Sepez 2014/09/24 17:02:11 I saw this function getting re-entered during some
973 CPDF_InterForm::EnableUpdateAP(enableAPUpdate); 987 CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
974 int nCount = m_pAnnotList->Count(); 988 int nCount = m_pAnnotList->Count();
989 SetLock(TRUE);
975 for(int i=0; i<nCount; i++) 990 for(int i=0; i<nCount; i++)
Tom Sepez 2014/09/24 17:02:11 if re-entered, nCount is from the old m_pAnnotList
976 { 991 {
977 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); 992 CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
Tom Sepez 2014/09/24 17:02:11 ... but this is retrieved from the new m_pAnnotLis
978 CPDF_Document * pDoc = this->GetPDFDocument(); 993 CPDF_Document * pDoc = this->GetPDFDocument();
979 994
980 CheckUnSupportAnnot(pDoc, pPDFAnnot); 995 CheckUnSupportAnnot(pDoc, pPDFAnnot);
981 996
982 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr(); 997 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandle rMgr();
983 ASSERT(pAnnotHandlerMgr != NULL); 998 ASSERT(pAnnotHandlerMgr != NULL);
999
984 if(pAnnotHandlerMgr) 1000 if(pAnnotHandlerMgr)
985 { 1001 {
986 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFA nnot, this); 1002 CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFA nnot, this);
987 if(!pAnnot) 1003 if(!pAnnot)
988 continue; 1004 continue;
989 m_fxAnnotArray.Add(pAnnot); 1005 m_fxAnnotArray.Add(pAnnot);
990 1006
991 pAnnotHandlerMgr->Annot_OnLoad(pAnnot); 1007 pAnnotHandlerMgr->Annot_OnLoad(pAnnot);
Tom Sepez 2014/09/24 17:02:11 (re-entrancy obseved above ...OnLoad() in this loo
992 } 1008 }
993 1009
994 } 1010 }
1011 SetLock(FALSE);
995 } 1012 }
996 1013
997 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects) 1014 void CPDFSDK_PageView::UpdateRects(CFX_RectArray& rects)
998 { 1015 {
999 for(int i=0; i<rects.GetSize(); i++) 1016 for(int i=0; i<rects.GetSize(); i++)
1000 { 1017 {
1001 CPDF_Rect rc = rects.GetAt(i); 1018 CPDF_Rect rc = rects.GetAt(i);
1002 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 1019 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
1003 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.botto m); 1020 pEnv->FFI_Invalidate(m_page, rc.left, rc.top, rc.right, rc.botto m);
1004 } 1021 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 1068
1052 for(int i=0; i<m_fxAnnotArray.GetSize(); i++) 1069 for(int i=0; i<m_fxAnnotArray.GetSize(); i++)
1053 { 1070 {
1054 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); 1071 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i);
1055 if(pAnnot == pFocusAnnot) 1072 if(pAnnot == pFocusAnnot)
1056 return pAnnot; 1073 return pAnnot;
1057 } 1074 }
1058 return NULL; 1075 return NULL;
1059 } 1076 }
1060 1077
OLDNEW
« fpdfsdk/include/fsdk_mgr.h ('K') | « fpdfsdk/src/fpdfview.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698