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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2418533002: [pdf] Defer page unloading in JS callback. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #include "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 return -1; 2280 return -1;
2281 dest = FPDFBookmark_GetDest(doc_, bookmark); 2281 dest = FPDFBookmark_GetDest(doc_, bookmark);
2282 } 2282 }
2283 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1; 2283 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1;
2284 } 2284 }
2285 2285
2286 int PDFiumEngine::GetMostVisiblePage() { 2286 int PDFiumEngine::GetMostVisiblePage() {
2287 if (in_flight_visible_page_) 2287 if (in_flight_visible_page_)
2288 return *in_flight_visible_page_; 2288 return *in_flight_visible_page_;
2289 2289
2290 // We can call GetMostVisiblePage through a callback from PDFium. We have
2291 // to defer the page deletion otherwise we could potentially delete the page
2292 // that originated the calling JS request and destroy the objects that are
2293 // currently being used.
2294 defer_page_unload_ = true;
2290 CalculateVisiblePages(); 2295 CalculateVisiblePages();
2296 defer_page_unload_ = false;
2291 return most_visible_page_; 2297 return most_visible_page_;
2292 } 2298 }
2293 2299
2294 pp::Rect PDFiumEngine::GetPageRect(int index) { 2300 pp::Rect PDFiumEngine::GetPageRect(int index) {
2295 pp::Rect rc(pages_[index]->rect()); 2301 pp::Rect rc(pages_[index]->rect());
2296 rc.Inset(-kPageShadowLeft, -kPageShadowTop, 2302 rc.Inset(-kPageShadowLeft, -kPageShadowTop,
2297 -kPageShadowRight, -kPageShadowBottom); 2303 -kPageShadowRight, -kPageShadowBottom);
2298 return rc; 2304 return rc;
2299 } 2305 }
2300 2306
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 FPDF_DOCUMENT doc = 3981 FPDF_DOCUMENT doc =
3976 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3982 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3977 if (!doc) 3983 if (!doc)
3978 return false; 3984 return false;
3979 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3985 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3980 FPDF_CloseDocument(doc); 3986 FPDF_CloseDocument(doc);
3981 return success; 3987 return success;
3982 } 3988 }
3983 3989
3984 } // namespace chrome_pdf 3990 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698