OLD | NEW |
---|---|
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 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2463 } | 2463 } |
2464 | 2464 |
2465 int PDFiumEngine::GetMostVisiblePage() { | 2465 int PDFiumEngine::GetMostVisiblePage() { |
2466 if (in_flight_visible_page_) | 2466 if (in_flight_visible_page_) |
2467 return *in_flight_visible_page_; | 2467 return *in_flight_visible_page_; |
2468 | 2468 |
2469 // We can call GetMostVisiblePage through a callback from PDFium. We have | 2469 // We can call GetMostVisiblePage through a callback from PDFium. We have |
2470 // to defer the page deletion otherwise we could potentially delete the page | 2470 // to defer the page deletion otherwise we could potentially delete the page |
2471 // that originated the calling JS request and destroy the objects that are | 2471 // that originated the calling JS request and destroy the objects that are |
2472 // currently being used. | 2472 // currently being used. |
2473 bool old_defer_page_unload = defer_page_unload_; | |
Tom Sepez
2016/12/05 17:54:05
base::AutoReset maybe?
dsinclair
2016/12/05 20:07:48
Done.
| |
2473 defer_page_unload_ = true; | 2474 defer_page_unload_ = true; |
2474 CalculateVisiblePages(); | 2475 CalculateVisiblePages(); |
2475 defer_page_unload_ = false; | 2476 defer_page_unload_ = old_defer_page_unload; |
2476 return most_visible_page_; | 2477 return most_visible_page_; |
2477 } | 2478 } |
2478 | 2479 |
2479 pp::Rect PDFiumEngine::GetPageRect(int index) { | 2480 pp::Rect PDFiumEngine::GetPageRect(int index) { |
2480 pp::Rect rc(pages_[index]->rect()); | 2481 pp::Rect rc(pages_[index]->rect()); |
2481 rc.Inset(-kPageShadowLeft, -kPageShadowTop, | 2482 rc.Inset(-kPageShadowLeft, -kPageShadowTop, |
2482 -kPageShadowRight, -kPageShadowBottom); | 2483 -kPageShadowRight, -kPageShadowBottom); |
2483 return rc; | 2484 return rc; |
2484 } | 2485 } |
2485 | 2486 |
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4153 | 4154 |
4154 bool PDFiumEngineExports::GetPDFPageSizeByIndex(void* pdf_handle, | 4155 bool PDFiumEngineExports::GetPDFPageSizeByIndex(void* pdf_handle, |
4155 int page_number, | 4156 int page_number, |
4156 double* width, | 4157 double* width, |
4157 double* height) { | 4158 double* height) { |
4158 FPDF_DOCUMENT doc = pdf_handle; | 4159 FPDF_DOCUMENT doc = pdf_handle; |
4159 return doc && FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 4160 return doc && FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
4160 } | 4161 } |
4161 | 4162 |
4162 } // namespace chrome_pdf | 4163 } // namespace chrome_pdf |
OLD | NEW |