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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 // Don't trust PDFium to handle circular bookmarks. | 446 // Don't trust PDFium to handle circular bookmarks. |
447 const unsigned int kMaxDepth = 128; | 447 const unsigned int kMaxDepth = 128; |
448 if (depth < kMaxDepth) { | 448 if (depth < kMaxDepth) { |
449 int child_index = 0; | 449 int child_index = 0; |
450 std::set<FPDF_BOOKMARK> seen_bookmarks; | 450 std::set<FPDF_BOOKMARK> seen_bookmarks; |
451 for (FPDF_BOOKMARK child_bookmark = | 451 for (FPDF_BOOKMARK child_bookmark = |
452 FPDFBookmark_GetFirstChild(doc, bookmark); | 452 FPDFBookmark_GetFirstChild(doc, bookmark); |
453 child_bookmark; | 453 child_bookmark; |
454 child_bookmark = FPDFBookmark_GetNextSibling(doc, child_bookmark)) { | 454 child_bookmark = FPDFBookmark_GetNextSibling(doc, child_bookmark)) { |
455 if (ContainsKey(seen_bookmarks, child_bookmark)) | 455 if (base::ContainsKey(seen_bookmarks, child_bookmark)) |
456 break; | 456 break; |
457 | 457 |
458 seen_bookmarks.insert(child_bookmark); | 458 seen_bookmarks.insert(child_bookmark); |
459 children.Set(child_index, | 459 children.Set(child_index, |
460 TraverseBookmarks(doc, child_bookmark, depth + 1)); | 460 TraverseBookmarks(doc, child_bookmark, depth + 1)); |
461 child_index++; | 461 child_index++; |
462 } | 462 } |
463 } | 463 } |
464 dict.Set(pp::Var("children"), children); | 464 dict.Set(pp::Var("children"), children); |
465 return dict; | 465 return dict; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 FPDF_CloseDocument(doc_); | 640 FPDF_CloseDocument(doc_); |
641 FPDFDOC_ExitFormFillEnvironment(form_); | 641 FPDFDOC_ExitFormFillEnvironment(form_); |
642 #else | 642 #else |
643 // Normally |doc_| should outlive |form_|. | 643 // Normally |doc_| should outlive |form_|. |
644 FPDFDOC_ExitFormFillEnvironment(form_); | 644 FPDFDOC_ExitFormFillEnvironment(form_); |
645 FPDF_CloseDocument(doc_); | 645 FPDF_CloseDocument(doc_); |
646 #endif | 646 #endif |
647 } | 647 } |
648 FPDFAvail_Destroy(fpdf_availability_); | 648 FPDFAvail_Destroy(fpdf_availability_); |
649 | 649 |
650 STLDeleteElements(&pages_); | 650 base::STLDeleteElements(&pages_); |
651 } | 651 } |
652 | 652 |
653 #ifdef PDF_USE_XFA | 653 #ifdef PDF_USE_XFA |
654 | 654 |
655 void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* param, | 655 void PDFiumEngine::Form_EmailTo(FPDF_FORMFILLINFO* param, |
656 FPDF_FILEHANDLER* file_handler, | 656 FPDF_FILEHANDLER* file_handler, |
657 FPDF_WIDESTRING to, | 657 FPDF_WIDESTRING to, |
658 FPDF_WIDESTRING subject, | 658 FPDF_WIDESTRING subject, |
659 FPDF_WIDESTRING cc, | 659 FPDF_WIDESTRING cc, |
660 FPDF_WIDESTRING bcc, | 660 FPDF_WIDESTRING bcc, |
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 pp::Rect rc_next = | 2664 pp::Rect rc_next = |
2665 visible_rect.Intersect(GetPageScreenRect(most_visible_page + 1)); | 2665 visible_rect.Intersect(GetPageScreenRect(most_visible_page + 1)); |
2666 if (rc_next.height() > rc_first.height()) | 2666 if (rc_next.height() > rc_first.height()) |
2667 most_visible_page++; | 2667 most_visible_page++; |
2668 } | 2668 } |
2669 | 2669 |
2670 SetCurrentPage(most_visible_page); | 2670 SetCurrentPage(most_visible_page); |
2671 } | 2671 } |
2672 | 2672 |
2673 bool PDFiumEngine::IsPageVisible(int index) const { | 2673 bool PDFiumEngine::IsPageVisible(int index) const { |
2674 return ContainsValue(visible_pages_, index); | 2674 return base::ContainsValue(visible_pages_, index); |
2675 } | 2675 } |
2676 | 2676 |
2677 bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { | 2677 bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { |
2678 if (!doc_ || !form_) | 2678 if (!doc_ || !form_) |
2679 return false; | 2679 return false; |
2680 | 2680 |
2681 const int num_pages = static_cast<int>(pages_.size()); | 2681 const int num_pages = static_cast<int>(pages_.size()); |
2682 if (index < num_pages && pages_[index]->available()) | 2682 if (index < num_pages && pages_[index]->available()) |
2683 return true; | 2683 return true; |
2684 | 2684 |
2685 if (!FPDFAvail_IsPageAvail(fpdf_availability_, index, &download_hints_)) { | 2685 if (!FPDFAvail_IsPageAvail(fpdf_availability_, index, &download_hints_)) { |
2686 if (!ContainsValue(*pending, index)) | 2686 if (!base::ContainsValue(*pending, index)) |
2687 pending->push_back(index); | 2687 pending->push_back(index); |
2688 return false; | 2688 return false; |
2689 } | 2689 } |
2690 | 2690 |
2691 if (index < num_pages) | 2691 if (index < num_pages) |
2692 pages_[index]->set_available(true); | 2692 pages_[index]->set_available(true); |
2693 if (default_page_size_.IsEmpty()) | 2693 if (default_page_size_.IsEmpty()) |
2694 default_page_size_ = GetPageSize(index); | 2694 default_page_size_ = GetPageSize(index); |
2695 return true; | 2695 return true; |
2696 } | 2696 } |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3918 FPDF_DOCUMENT doc = | 3918 FPDF_DOCUMENT doc = |
3919 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); | 3919 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); |
3920 if (!doc) | 3920 if (!doc) |
3921 return false; | 3921 return false; |
3922 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; | 3922 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; |
3923 FPDF_CloseDocument(doc); | 3923 FPDF_CloseDocument(doc); |
3924 return success; | 3924 return success; |
3925 } | 3925 } |
3926 | 3926 |
3927 } // namespace chrome_pdf | 3927 } // namespace chrome_pdf |
OLD | NEW |