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

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

Issue 1564453002: Remove some dead PDF code. (try 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try 2 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA, 527 mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA,
528 PDFiumPage::LinkTarget()), 528 PDFiumPage::LinkTarget()),
529 next_page_to_search_(-1), 529 next_page_to_search_(-1),
530 last_page_to_search_(-1), 530 last_page_to_search_(-1),
531 last_character_index_to_search_(-1), 531 last_character_index_to_search_(-1),
532 permissions_(0), 532 permissions_(0),
533 permissions_handler_revision_(-1), 533 permissions_handler_revision_(-1),
534 fpdf_availability_(NULL), 534 fpdf_availability_(NULL),
535 next_timer_id_(0), 535 next_timer_id_(0),
536 last_page_mouse_down_(-1), 536 last_page_mouse_down_(-1),
537 first_visible_page_(-1),
538 most_visible_page_(-1), 537 most_visible_page_(-1),
539 called_do_document_action_(false), 538 called_do_document_action_(false),
540 render_grayscale_(false), 539 render_grayscale_(false),
541 progressive_paint_timeout_(0), 540 progressive_paint_timeout_(0),
542 getting_password_(false) { 541 getting_password_(false) {
543 find_factory_.Initialize(this); 542 find_factory_.Initialize(this);
544 password_factory_.Initialize(this); 543 password_factory_.Initialize(this);
545 544
546 file_access_.m_FileLen = 0; 545 file_access_.m_FileLen = 0;
547 file_access_.m_GetBlock = &GetBlock; 546 file_access_.m_GetBlock = &GetBlock;
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 int page_index = -1; 2259 int page_index = -1;
2261 int form_type = FPDF_FORMFIELD_UNKNOWN; 2260 int form_type = FPDF_FORMFIELD_UNKNOWN;
2262 PDFiumPage::LinkTarget target; 2261 PDFiumPage::LinkTarget target;
2263 PDFiumPage::Area area = 2262 PDFiumPage::Area area =
2264 GetCharIndex(point, &page_index, &temp, &form_type, &target); 2263 GetCharIndex(point, &page_index, &temp, &form_type, &target);
2265 if (area == PDFiumPage::WEBLINK_AREA) 2264 if (area == PDFiumPage::WEBLINK_AREA)
2266 url = target.url; 2265 url = target.url;
2267 return url; 2266 return url;
2268 } 2267 }
2269 2268
2270 bool PDFiumEngine::IsSelecting() {
2271 return selecting_;
2272 }
2273
2274 bool PDFiumEngine::HasPermission(DocumentPermission permission) const { 2269 bool PDFiumEngine::HasPermission(DocumentPermission permission) const {
2275 // PDF 1.7 spec, section 3.5.2 says: "If the revision number is 2 or greater, 2270 // PDF 1.7 spec, section 3.5.2 says: "If the revision number is 2 or greater,
2276 // the operations to which user access can be controlled are as follows: ..." 2271 // the operations to which user access can be controlled are as follows: ..."
2277 // 2272 //
2278 // Thus for revision numbers less than 2, permissions are ignored and this 2273 // Thus for revision numbers less than 2, permissions are ignored and this
2279 // always returns true. 2274 // always returns true.
2280 if (permissions_handler_revision_ < 2) 2275 if (permissions_handler_revision_ < 2)
2281 return true; 2276 return true;
2282 2277
2283 // Handle high quality printing permission separately for security handler 2278 // Handle high quality printing permission separately for security handler
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 FPDF_WIDESTRING destination_pdf_wide = 2327 FPDF_WIDESTRING destination_pdf_wide =
2333 reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str()); 2328 reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str());
2334 FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc_, destination_pdf_wide); 2329 FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc_, destination_pdf_wide);
2335 if (!bookmark) 2330 if (!bookmark)
2336 return -1; 2331 return -1;
2337 dest = FPDFBookmark_GetDest(doc_, bookmark); 2332 dest = FPDFBookmark_GetDest(doc_, bookmark);
2338 } 2333 }
2339 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1; 2334 return dest ? FPDFDest_GetPageIndex(doc_, dest) : -1;
2340 } 2335 }
2341 2336
2342 int PDFiumEngine::GetFirstVisiblePage() {
2343 CalculateVisiblePages();
2344 return first_visible_page_;
2345 }
2346
2347 int PDFiumEngine::GetMostVisiblePage() { 2337 int PDFiumEngine::GetMostVisiblePage() {
2348 CalculateVisiblePages(); 2338 CalculateVisiblePages();
2349 return most_visible_page_; 2339 return most_visible_page_;
2350 } 2340 }
2351 2341
2352 pp::Rect PDFiumEngine::GetPageRect(int index) { 2342 pp::Rect PDFiumEngine::GetPageRect(int index) {
2353 pp::Rect rc(pages_[index]->rect()); 2343 pp::Rect rc(pages_[index]->rect());
2354 rc.Inset(-kPageShadowLeft, -kPageShadowTop, 2344 rc.Inset(-kPageShadowLeft, -kPageShadowTop,
2355 -kPageShadowRight, -kPageShadowBottom); 2345 -kPageShadowRight, -kPageShadowBottom);
2356 return rc; 2346 return rc;
2357 } 2347 }
2358 2348
2359 pp::Rect PDFiumEngine::GetPageContentsRect(int index) { 2349 pp::Rect PDFiumEngine::GetPageContentsRect(int index) {
2360 return GetScreenRect(pages_[index]->rect()); 2350 return GetScreenRect(pages_[index]->rect());
2361 } 2351 }
2362 2352
2363 void PDFiumEngine::PaintThumbnail(pp::ImageData* image_data, int index) {
2364 FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(
2365 image_data->size().width(), image_data->size().height(),
2366 FPDFBitmap_BGRx, image_data->data(), image_data->stride());
2367
2368 if (pages_[index]->available()) {
2369 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(),
2370 image_data->size().height(), 0xFFFFFFFF);
2371
2372 FPDF_RenderPageBitmap(
2373 bitmap, pages_[index]->GetPage(), 0, 0, image_data->size().width(),
2374 image_data->size().height(), 0, GetRenderingFlags());
2375 } else {
2376 FPDFBitmap_FillRect(bitmap, 0, 0, image_data->size().width(),
2377 image_data->size().height(), kPendingPageColor);
2378 }
2379
2380 FPDFBitmap_Destroy(bitmap);
2381 }
2382
2383 void PDFiumEngine::SetGrayscale(bool grayscale) { 2353 void PDFiumEngine::SetGrayscale(bool grayscale) {
2384 render_grayscale_ = grayscale; 2354 render_grayscale_ = grayscale;
2385 } 2355 }
2386 2356
2387 void PDFiumEngine::OnCallback(int id) { 2357 void PDFiumEngine::OnCallback(int id) {
2388 if (!timers_.count(id)) 2358 if (!timers_.count(id))
2389 return; 2359 return;
2390 2360
2391 timers_[id].second(id); 2361 timers_[id].second(id);
2392 if (timers_.count(id)) // The callback might delete the timer. 2362 if (timers_.count(id)) // The callback might delete the timer.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2701 // will be lost when the page is first closed anyways). 2671 // will be lost when the page is first closed anyways).
2702 if (static_cast<int>(i) == last_page_mouse_down_) 2672 if (static_cast<int>(i) == last_page_mouse_down_)
2703 last_page_mouse_down_ = -1; 2673 last_page_mouse_down_ = -1;
2704 } 2674 }
2705 } 2675 }
2706 2676
2707 // Any pending highlighting of form fields will be invalid since these are in 2677 // Any pending highlighting of form fields will be invalid since these are in
2708 // screen coordinates. 2678 // screen coordinates.
2709 form_highlights_.clear(); 2679 form_highlights_.clear();
2710 2680
2711 if (visible_pages_.size() == 0) 2681 int most_visible_page = visible_pages_.empty() ? -1 : visible_pages_.front();
2712 first_visible_page_ = -1;
2713 else
2714 first_visible_page_ = visible_pages_.front();
2715
2716 int most_visible_page = first_visible_page_;
2717 // Check if the next page is more visible than the first one. 2682 // Check if the next page is more visible than the first one.
2718 if (most_visible_page != -1 && 2683 if (most_visible_page != -1 && !pages_.empty() &&
2719 pages_.size() > 0 &&
2720 most_visible_page < static_cast<int>(pages_.size()) - 1) { 2684 most_visible_page < static_cast<int>(pages_.size()) - 1) {
2721 pp::Rect rc_first = 2685 pp::Rect rc_first =
2722 visible_rect.Intersect(GetPageScreenRect(most_visible_page)); 2686 visible_rect.Intersect(GetPageScreenRect(most_visible_page));
2723 pp::Rect rc_next = 2687 pp::Rect rc_next =
2724 visible_rect.Intersect(GetPageScreenRect(most_visible_page + 1)); 2688 visible_rect.Intersect(GetPageScreenRect(most_visible_page + 1));
2725 if (rc_next.height() > rc_first.height()) 2689 if (rc_next.height() > rc_first.height())
2726 most_visible_page++; 2690 most_visible_page++;
2727 } 2691 }
2728 2692
2729 SetCurrentPage(most_visible_page); 2693 SetCurrentPage(most_visible_page);
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 double* height) { 3944 double* height) {
3981 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3945 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3982 if (!doc) 3946 if (!doc)
3983 return false; 3947 return false;
3984 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3948 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3985 FPDF_CloseDocument(doc); 3949 FPDF_CloseDocument(doc);
3986 return success; 3950 return success;
3987 } 3951 }
3988 3952
3989 } // namespace chrome_pdf 3953 } // 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