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

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

Issue 830433002: Navigation to relative fragments does not work correctly for OOP pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 11 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
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 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 13 matching lines...) Expand all
24 #include "ppapi/c/ppb_core.h" 24 #include "ppapi/c/ppb_core.h"
25 #include "ppapi/c/private/ppb_pdf.h" 25 #include "ppapi/c/private/ppb_pdf.h"
26 #include "ppapi/cpp/dev/memory_dev.h" 26 #include "ppapi/cpp/dev/memory_dev.h"
27 #include "ppapi/cpp/input_event.h" 27 #include "ppapi/cpp/input_event.h"
28 #include "ppapi/cpp/instance.h" 28 #include "ppapi/cpp/instance.h"
29 #include "ppapi/cpp/module.h" 29 #include "ppapi/cpp/module.h"
30 #include "ppapi/cpp/private/pdf.h" 30 #include "ppapi/cpp/private/pdf.h"
31 #include "ppapi/cpp/trusted/browser_font_trusted.h" 31 #include "ppapi/cpp/trusted/browser_font_trusted.h"
32 #include "ppapi/cpp/url_response_info.h" 32 #include "ppapi/cpp/url_response_info.h"
33 #include "ppapi/cpp/var.h" 33 #include "ppapi/cpp/var.h"
34 #include "ppapi/cpp/var_dictionary.h"
34 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h" 35 #include "third_party/pdfium/fpdfsdk/include/fpdf_ext.h"
35 #include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h" 36 #include "third_party/pdfium/fpdfsdk/include/fpdf_flatten.h"
36 #include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h" 37 #include "third_party/pdfium/fpdfsdk/include/fpdf_searchex.h"
37 #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h" 38 #include "third_party/pdfium/fpdfsdk/include/fpdf_sysfontinfo.h"
38 #include "third_party/pdfium/fpdfsdk/include/fpdf_transformpage.h" 39 #include "third_party/pdfium/fpdfsdk/include/fpdf_transformpage.h"
39 #include "third_party/pdfium/fpdfsdk/include/fpdfedit.h" 40 #include "third_party/pdfium/fpdfsdk/include/fpdfedit.h"
40 #include "third_party/pdfium/fpdfsdk/include/fpdfppo.h" 41 #include "third_party/pdfium/fpdfsdk/include/fpdfppo.h"
41 #include "third_party/pdfium/fpdfsdk/include/fpdfsave.h" 42 #include "third_party/pdfium/fpdfsdk/include/fpdfsave.h"
42 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PDFWindow.h" 43 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PDFWindow.h"
43 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PWL_FontMap.h" 44 #include "third_party/pdfium/fpdfsdk/include/pdfwindow/PWL_FontMap.h"
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 FPDF_WIDESTRING destination_pdf_wide = 2327 FPDF_WIDESTRING destination_pdf_wide =
2327 reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str()); 2328 reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str());
2328 FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc_, destination_pdf_wide); 2329 FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc_, destination_pdf_wide);
2329 if (!bookmark) 2330 if (!bookmark)
2330 return -1; 2331 return -1;
2331 dest = FPDFBookmark_GetDest(doc_, bookmark); 2332 dest = FPDFBookmark_GetDest(doc_, bookmark);
2332 } 2333 }
2333 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1; 2334 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1;
2334 } 2335 }
2335 2336
2337 pp::VarDictionary PDFiumEngine::GetNamedDestinations() {
2338 pp::VarDictionary named_destinations;
2339 for (unsigned long i = 0; i < FPDF_CountNamedDests(doc_); i++) {
2340 base::string16 name;
2341 unsigned long buffer_bytes;
2342 FPDF_GetNamedDest(doc_, i, NULL, buffer_bytes);
2343 unsigned long name_length =
2344 buffer_bytes / sizeof(base::string16::value_type);
2345 if (name_length > 0) {
2346 PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(
2347 &name, name_length, true);
2348 FPDF_DEST dest = FPDF_GetNamedDest(doc_, i, api_string_adapter.GetData(),
2349 buffer_bytes);
2350 api_string_adapter.Close(name_length);
2351 if (dest) {
2352 std::string named_dest = base::UTF16ToUTF8(name);
2353 int page_number = GetNamedDestinationPage(named_dest);
2354 if (page_number >= 0) {
2355 named_destinations.Set(pp::Var(named_dest.c_str()),
2356 pp::Var(page_number));
2357 }
2358 }
2359 }
2360 }
2361 return named_destinations;
2362 }
2363
2336 int PDFiumEngine::GetFirstVisiblePage() { 2364 int PDFiumEngine::GetFirstVisiblePage() {
2337 CalculateVisiblePages(); 2365 CalculateVisiblePages();
2338 return first_visible_page_; 2366 return first_visible_page_;
2339 } 2367 }
2340 2368
2341 int PDFiumEngine::GetMostVisiblePage() { 2369 int PDFiumEngine::GetMostVisiblePage() {
2342 CalculateVisiblePages(); 2370 CalculateVisiblePages();
2343 return most_visible_page_; 2371 return most_visible_page_;
2344 } 2372 }
2345 2373
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
3915 double* height) { 3943 double* height) {
3916 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3944 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3917 if (!doc) 3945 if (!doc)
3918 return false; 3946 return false;
3919 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3947 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3920 FPDF_CloseDocument(doc); 3948 FPDF_CloseDocument(doc);
3921 return success; 3949 return success;
3922 } 3950 }
3923 3951
3924 } // namespace chrome_pdf 3952 } // namespace chrome_pdf
OLDNEW
« chrome/browser/resources/pdf/pdf.js ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698