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

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

Issue 1552833003: Remove some dead PDF code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA, 520 mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA,
521 PDFiumPage::LinkTarget()), 521 PDFiumPage::LinkTarget()),
522 next_page_to_search_(-1), 522 next_page_to_search_(-1),
523 last_page_to_search_(-1), 523 last_page_to_search_(-1),
524 last_character_index_to_search_(-1), 524 last_character_index_to_search_(-1),
525 permissions_(0), 525 permissions_(0),
526 permissions_handler_revision_(-1), 526 permissions_handler_revision_(-1),
527 fpdf_availability_(NULL), 527 fpdf_availability_(NULL),
528 next_timer_id_(0), 528 next_timer_id_(0),
529 last_page_mouse_down_(-1), 529 last_page_mouse_down_(-1),
530 first_visible_page_(-1),
531 most_visible_page_(-1), 530 most_visible_page_(-1),
532 called_do_document_action_(false), 531 called_do_document_action_(false),
533 render_grayscale_(false), 532 render_grayscale_(false),
534 progressive_paint_timeout_(0), 533 progressive_paint_timeout_(0),
535 getting_password_(false) { 534 getting_password_(false) {
536 find_factory_.Initialize(this); 535 find_factory_.Initialize(this);
537 password_factory_.Initialize(this); 536 password_factory_.Initialize(this);
538 537
539 file_access_.m_FileLen = 0; 538 file_access_.m_FileLen = 0;
540 file_access_.m_GetBlock = &GetBlock; 539 file_access_.m_GetBlock = &GetBlock;
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 int page_index = -1; 2269 int page_index = -1;
2271 int form_type = FPDF_FORMFIELD_UNKNOWN; 2270 int form_type = FPDF_FORMFIELD_UNKNOWN;
2272 PDFiumPage::LinkTarget target; 2271 PDFiumPage::LinkTarget target;
2273 PDFiumPage::Area area = 2272 PDFiumPage::Area area =
2274 GetCharIndex(point, &page_index, &temp, &form_type, &target); 2273 GetCharIndex(point, &page_index, &temp, &form_type, &target);
2275 if (area == PDFiumPage::WEBLINK_AREA) 2274 if (area == PDFiumPage::WEBLINK_AREA)
2276 url = target.url; 2275 url = target.url;
2277 return url; 2276 return url;
2278 } 2277 }
2279 2278
2280 bool PDFiumEngine::IsSelecting() {
2281 return selecting_;
2282 }
2283
2284 bool PDFiumEngine::HasPermission(DocumentPermission permission) const { 2279 bool PDFiumEngine::HasPermission(DocumentPermission permission) const {
2285 // PDF 1.7 spec, section 3.5.2 says: "If the revision number is 2 or greater, 2280 // PDF 1.7 spec, section 3.5.2 says: "If the revision number is 2 or greater,
2286 // the operations to which user access can be controlled are as follows: ..." 2281 // the operations to which user access can be controlled are as follows: ..."
2287 // 2282 //
2288 // Thus for revision numbers less than 2, permissions are ignored and this 2283 // Thus for revision numbers less than 2, permissions are ignored and this
2289 // always returns true. 2284 // always returns true.
2290 if (permissions_handler_revision_ < 2) 2285 if (permissions_handler_revision_ < 2)
2291 return true; 2286 return true;
2292 2287
2293 // Handle high quality printing permission separately for security handler 2288 // Handle high quality printing permission separately for security handler
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 FPDF_WIDESTRING destination_pdf_wide = 2338 FPDF_WIDESTRING destination_pdf_wide =
2344 reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str()); 2339 reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str());
2345 FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc_, destination_pdf_wide); 2340 FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc_, destination_pdf_wide);
2346 if (!bookmark) 2341 if (!bookmark)
2347 return -1; 2342 return -1;
2348 dest = FPDFBookmark_GetDest(doc_, bookmark); 2343 dest = FPDFBookmark_GetDest(doc_, bookmark);
2349 } 2344 }
2350 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1; 2345 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1;
2351 } 2346 }
2352 2347
2353 int PDFiumEngine::GetFirstVisiblePage() {
2354 CalculateVisiblePages();
2355 return first_visible_page_;
2356 }
2357
2358 int PDFiumEngine::GetMostVisiblePage() { 2348 int PDFiumEngine::GetMostVisiblePage() {
2359 CalculateVisiblePages(); 2349 CalculateVisiblePages();
2360 return most_visible_page_; 2350 return most_visible_page_;
2361 } 2351 }
2362 2352
2363 pp::Rect PDFiumEngine::GetPageRect(int index) { 2353 pp::Rect PDFiumEngine::GetPageRect(int index) {
2364 pp::Rect rc(pages_[index]->rect()); 2354 pp::Rect rc(pages_[index]->rect());
2365 rc.Inset(-kPageShadowLeft, -kPageShadowTop, 2355 rc.Inset(-kPageShadowLeft, -kPageShadowTop,
2366 -kPageShadowRight, -kPageShadowBottom); 2356 -kPageShadowRight, -kPageShadowBottom);
2367 return rc; 2357 return rc;
2368 } 2358 }
2369 2359
2370 pp::Rect PDFiumEngine::GetPageContentsRect(int index) { 2360 pp::Rect PDFiumEngine::GetPageContentsRect(int index) {
2371 return GetScreenRect(pages_[index]->rect()); 2361 return GetScreenRect(pages_[index]->rect());
2372 } 2362 }
2373 2363
2374 void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) {
2375 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(
2376 image_data->size().width(), image_data->size().height(),
2377 FPDFBitmap_BGRx, image_data->data(), image_data->stride());
2378
2379 if (pages_[index]->available()) {
2380 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(),
2381 image_data->size().height(), 0xFFFFFFFF);
2382
2383 FPDF_RenderPageBitmap(
2384 bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(),
2385 image_data->size().height(), 0, GetRenderingFlags());
2386 } else {
2387 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(),
2388 image_data->size().height(), kPendingPageColor);
2389 }
2390
2391 FPDFBitmap_Destroy(bitmap);
2392 }
2393
2394 void PDFiumEngine::SetGrayscale(bool grayscale) { 2364 void PDFiumEngine::SetGrayscale(bool grayscale) {
2395 render_grayscale_ = grayscale; 2365 render_grayscale_ = grayscale;
2396 } 2366 }
2397 2367
2398 void PDFiumEngine::OnCallback(int id) { 2368 void PDFiumEngine::OnCallback(int id) {
2399 if (!timers_.count(id)) 2369 if (!timers_.count(id))
2400 return; 2370 return;
2401 2371
2402 timers_[id].second(id); 2372 timers_[id].second(id);
2403 if (timers_.count(id)) // The callback might delete the timer. 2373 if (timers_.count(id)) // The callback might delete the timer.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 // will be lost when the page is first closed anyways). 2682 // will be lost when the page is first closed anyways).
2713 if (static_cast<int>(i) == last_page_mouse_down_) 2683 if (static_cast<int>(i) == last_page_mouse_down_)
2714 last_page_mouse_down_ = -1; 2684 last_page_mouse_down_ = -1;
2715 } 2685 }
2716 } 2686 }
2717 2687
2718 // Any pending highlighting of form fields will be invalid since these are in 2688 // Any pending highlighting of form fields will be invalid since these are in
2719 // screen coordinates. 2689 // screen coordinates.
2720 form_highlights_.clear(); 2690 form_highlights_.clear();
2721 2691
2722 if (visible_pages_.size() == 0) 2692 int most_visible_page = visible_pages_.empty() ? 0 : visible_pages_.front();
2723 first_visible_page_ = -1;
2724 else
2725 first_visible_page_ = visible_pages_.front();
2726
2727 int most_visible_page = first_visible_page_;
2728 // Check if the next page is more visible than the first one. 2693 // Check if the next page is more visible than the first one.
2729 if (most_visible_page != -1 && 2694 if (most_visible_page != -1 && !pages_.empty() &&
raymes 2016/01/03 23:36:04 Can most_visible_page be -1 anymore?
Lei Zhang 2016/01/04 21:57:16 No. I added a DCHECK in its place.
2730 pages_.size() > 0 &&
2731 most_visible_page < static_cast<int>(pages_.size()) - 1) { 2695 most_visible_page < static_cast<int>(pages_.size()) - 1) {
2732 pp::Rect rc_first = 2696 pp::Rect rc_first =
2733 visible_rect.Intersect(GetPageScreenRect(most_visible_page)); 2697 visible_rect.Intersect(GetPageScreenRect(most_visible_page));
2734 pp::Rect rc_next = 2698 pp::Rect rc_next =
2735 visible_rect.Intersect(GetPageScreenRect(most_visible_page + 1)); 2699 visible_rect.Intersect(GetPageScreenRect(most_visible_page + 1));
2736 if (rc_next.height() > rc_first.height()) 2700 if (rc_next.height() > rc_first.height())
2737 most_visible_page++; 2701 most_visible_page++;
2738 } 2702 }
2739 2703
2740 SetCurrentPage(most_visible_page); 2704 SetCurrentPage(most_visible_page);
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 double* height) { 3972 double* height) {
4009 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3973 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
4010 if (!doc) 3974 if (!doc)
4011 return false; 3975 return false;
4012 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3976 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4013 FPDF_CloseDocument(doc); 3977 FPDF_CloseDocument(doc);
4014 return success; 3978 return success;
4015 } 3979 }
4016 3980
4017 } // namespace chrome_pdf 3981 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698