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

Side by Side Diff: fpdfsdk/fsdk_mgr.cpp

Issue 2179163004: Reland of Remove pageview from map immediately (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: FX_BOOL to bool Created 4 years, 4 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
« no previous file with comments | « fpdfsdk/fsdk_baseform.cpp ('k') | fpdfsdk/include/fsdk_mgr.h » ('j') | 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 "fpdfsdk/include/fsdk_mgr.h" 7 #include "fpdfsdk/include/fsdk_mgr.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 for (auto& it : m_pageMap) 256 for (auto& it : m_pageMap)
257 it.second->KillFocusAnnotIfNeeded(); 257 it.second->KillFocusAnnotIfNeeded();
258 258
259 for (auto& it : m_pageMap) 259 for (auto& it : m_pageMap)
260 delete it.second; 260 delete it.second;
261 m_pageMap.clear(); 261 m_pageMap.clear();
262 } 262 }
263 263
264 CPDFSDK_PageView* CPDFSDK_Document::GetPageView( 264 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(
265 UnderlyingPageType* pUnderlyingPage, 265 UnderlyingPageType* pUnderlyingPage,
266 FX_BOOL ReNew) { 266 bool ReNew) {
267 auto it = m_pageMap.find(pUnderlyingPage); 267 auto it = m_pageMap.find(pUnderlyingPage);
268 if (it != m_pageMap.end()) 268 if (it != m_pageMap.end())
269 return it->second; 269 return it->second;
270 270
271 if (!ReNew) 271 if (!ReNew)
272 return nullptr; 272 return nullptr;
273 273
274 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage); 274 CPDFSDK_PageView* pPageView = new CPDFSDK_PageView(this, pUnderlyingPage);
275 m_pageMap[pUnderlyingPage] = pPageView; 275 m_pageMap[pUnderlyingPage] = pPageView;
276 // Delay to load all the annotations, to avoid endless loop. 276 // Delay to load all the annotations, to avoid endless loop.
277 pPageView->LoadFXAnnots(); 277 pPageView->LoadFXAnnots();
278 return pPageView; 278 return pPageView;
279 } 279 }
280 280
281 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() { 281 CPDFSDK_PageView* CPDFSDK_Document::GetCurrentView() {
282 UnderlyingPageType* pPage = 282 UnderlyingPageType* pPage =
283 UnderlyingFromFPDFPage(m_pEnv->FFI_GetCurrentPage(m_pDoc)); 283 UnderlyingFromFPDFPage(m_pEnv->FFI_GetCurrentPage(m_pDoc));
284 return pPage ? GetPageView(pPage, TRUE) : nullptr; 284 return pPage ? GetPageView(pPage, true) : nullptr;
285 } 285 }
286 286
287 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) { 287 CPDFSDK_PageView* CPDFSDK_Document::GetPageView(int nIndex) {
288 UnderlyingPageType* pTempPage = 288 UnderlyingPageType* pTempPage =
289 UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); 289 UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex));
290 if (!pTempPage) 290 if (!pTempPage)
291 return nullptr; 291 return nullptr;
292 292
293 auto it = m_pageMap.find(pTempPage); 293 auto it = m_pageMap.find(pTempPage);
294 return it->second; 294 return it->second;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) { 347 void CPDFSDK_Document::RemovePageView(UnderlyingPageType* pUnderlyingPage) {
348 auto it = m_pageMap.find(pUnderlyingPage); 348 auto it = m_pageMap.find(pUnderlyingPage);
349 if (it == m_pageMap.end()) 349 if (it == m_pageMap.end())
350 return; 350 return;
351 351
352 CPDFSDK_PageView* pPageView = it->second; 352 CPDFSDK_PageView* pPageView = it->second;
353 if (pPageView->IsLocked()) 353 if (pPageView->IsLocked())
354 return; 354 return;
355 355
356 // Remove the page from the map to make sure we don't accidentally attempt
357 // to use the |pPageView| while we're cleaning it up.
358 m_pageMap.erase(it);
359
356 pPageView->KillFocusAnnotIfNeeded(); 360 pPageView->KillFocusAnnotIfNeeded();
357 delete pPageView; 361 delete pPageView;
358 m_pageMap.erase(it);
359 } 362 }
360 363
361 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) { 364 UnderlyingPageType* CPDFSDK_Document::GetPage(int nIndex) {
362 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex)); 365 return UnderlyingFromFPDFPage(m_pEnv->FFI_GetPage(m_pDoc, nIndex));
363 } 366 }
364 367
365 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() { 368 CPDFSDK_InterForm* CPDFSDK_Document::GetInterForm() {
366 if (!m_pInterForm) 369 if (!m_pInterForm)
367 m_pInterForm.reset(new CPDFSDK_InterForm(this)); 370 m_pInterForm.reset(new CPDFSDK_InterForm(this));
368 return m_pInterForm.get(); 371 return m_pInterForm.get();
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { 1046 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
1044 #ifdef PDF_ENABLE_XFA 1047 #ifdef PDF_ENABLE_XFA
1045 CPDF_Page* pPage = m_page->GetPDFPage(); 1048 CPDF_Page* pPage = m_page->GetPDFPage();
1046 #else // PDF_ENABLE_XFA 1049 #else // PDF_ENABLE_XFA
1047 CPDF_Page* pPage = m_page; 1050 CPDF_Page* pPage = m_page;
1048 #endif // PDF_ENABLE_XFA 1051 #endif // PDF_ENABLE_XFA
1049 CPDF_Dictionary* pDict = pPage->m_pFormDict; 1052 CPDF_Dictionary* pDict = pPage->m_pFormDict;
1050 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 1053 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
1051 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; 1054 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
1052 } 1055 }
OLDNEW
« no previous file with comments | « fpdfsdk/fsdk_baseform.cpp ('k') | fpdfsdk/include/fsdk_mgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698