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

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

Issue 553433002: PDF Viewer - Links should open on mouse up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 PDFiumEngine::PDFiumEngine(PDFEngine::Client* client) 523 PDFiumEngine::PDFiumEngine(PDFEngine::Client* client)
524 : client_(client), 524 : client_(client),
525 current_zoom_(1.0), 525 current_zoom_(1.0),
526 current_rotation_(0), 526 current_rotation_(0),
527 doc_loader_(this), 527 doc_loader_(this),
528 password_tries_remaining_(0), 528 password_tries_remaining_(0),
529 doc_(NULL), 529 doc_(NULL),
530 form_(NULL), 530 form_(NULL),
531 defer_page_unload_(false), 531 defer_page_unload_(false),
532 selecting_(false), 532 selecting_(false),
533 open_link_(false),
533 next_page_to_search_(-1), 534 next_page_to_search_(-1),
534 last_page_to_search_(-1), 535 last_page_to_search_(-1),
535 last_character_index_to_search_(-1), 536 last_character_index_to_search_(-1),
536 current_find_index_(-1), 537 current_find_index_(-1),
537 permissions_(0), 538 permissions_(0),
538 fpdf_availability_(NULL), 539 fpdf_availability_(NULL),
539 next_timer_id_(0), 540 next_timer_id_(0),
540 last_page_mouse_down_(-1), 541 last_page_mouse_down_(-1),
541 first_visible_page_(-1), 542 first_visible_page_(-1),
542 most_visible_page_(-1), 543 most_visible_page_(-1),
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 1282
1282 SelectionChangeInvalidator selection_invalidator(this); 1283 SelectionChangeInvalidator selection_invalidator(this);
1283 selection_.clear(); 1284 selection_.clear();
1284 1285
1285 int page_index = -1; 1286 int page_index = -1;
1286 int char_index = -1; 1287 int char_index = -1;
1287 PDFiumPage::LinkTarget target; 1288 PDFiumPage::LinkTarget target;
1288 PDFiumPage::Area area = GetCharIndex(event, &page_index, 1289 PDFiumPage::Area area = GetCharIndex(event, &page_index,
1289 &char_index, &target); 1290 &char_index, &target);
1290 if (area == PDFiumPage::WEBLINK_AREA) { 1291 if (area == PDFiumPage::WEBLINK_AREA) {
1291 bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier); 1292 open_link_ = true;
1292 client_->NavigateTo(target.url, open_in_new_tab);
1293 client_->FormTextFieldFocusChange(false);
raymes 2014/09/08 01:52:57 Would it be better to store the information relate
Nikhil 2014/09/08 09:44:53 Thanks for your suggestion, I agree that it could
1294 return true; 1293 return true;
1295 } 1294 }
1296 1295
1297 if (area == PDFiumPage::DOCLINK_AREA) { 1296 if (area == PDFiumPage::DOCLINK_AREA) {
1298 client_->ScrollToPage(target.page); 1297 client_->ScrollToPage(target.page);
1299 client_->FormTextFieldFocusChange(false); 1298 client_->FormTextFieldFocusChange(false);
1300 return true; 1299 return true;
1301 } 1300 }
1302 1301
1303 if (page_index != -1) { 1302 if (page_index != -1) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 selection_.push_back(PDFiumRange( 1362 selection_.push_back(PDFiumRange(
1364 pages_[page_index], start_index, end_index - start_index)); 1363 pages_[page_index], start_index, end_index - start_index));
1365 } 1364 }
1366 1365
1367 bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) { 1366 bool PDFiumEngine::OnMouseUp(const pp::MouseInputEvent& event) {
1368 if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT) 1367 if (event.GetButton() != PP_INPUTEVENT_MOUSEBUTTON_LEFT)
1369 return false; 1368 return false;
1370 1369
1371 int page_index = -1; 1370 int page_index = -1;
1372 int char_index = -1; 1371 int char_index = -1;
1373 GetCharIndex(event, &page_index, &char_index, NULL); 1372 PDFiumPage::LinkTarget target;
1373 PDFiumPage::Area area =
1374 GetCharIndex(event, &page_index, &char_index, &target);
1375
1376 if (open_link_ && area == PDFiumPage::WEBLINK_AREA) {
1377 bool open_in_new_tab = !!(event.GetModifiers() & kDefaultKeyModifier);
1378 client_->NavigateTo(target.url, open_in_new_tab);
1379 client_->FormTextFieldFocusChange(false);
1380 open_link_ = false;
1381 return true;
1382 }
1383
1374 if (page_index != -1) { 1384 if (page_index != -1) {
1375 double page_x, page_y; 1385 double page_x, page_y;
1376 pp::Point point = event.GetPosition(); 1386 pp::Point point = event.GetPosition();
1377 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y); 1387 DeviceToPage(page_index, point.x(), point.y(), &page_x, &page_y);
1378 FORM_OnLButtonUp( 1388 FORM_OnLButtonUp(
1379 form_, pages_[page_index]->GetPage(), 0, page_x, page_y); 1389 form_, pages_[page_index]->GetPage(), 0, page_x, page_y);
1380 } 1390 }
1381 1391
1382 if (!selecting_) 1392 if (!selecting_)
1383 return false; 1393 return false;
1384 1394
1385 selecting_ = false; 1395 selecting_ = false;
1386 return true; 1396 return true;
1387 } 1397 }
1388 1398
1389 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) { 1399 bool PDFiumEngine::OnMouseMove(const pp::MouseInputEvent& event) {
1390 int page_index = -1; 1400 int page_index = -1;
1391 int char_index = -1; 1401 int char_index = -1;
1392 PDFiumPage::Area area = GetCharIndex(event, &page_index, &char_index, NULL); 1402 PDFiumPage::Area area = GetCharIndex(event, &page_index, &char_index, NULL);
1403
1404 if (open_link_ && area != PDFiumPage::WEBLINK_AREA)
1405 open_link_ = false;
1406
1393 if (!selecting_) { 1407 if (!selecting_) {
1394 PP_CursorType_Dev cursor; 1408 PP_CursorType_Dev cursor;
1395 switch (area) { 1409 switch (area) {
1396 case PDFiumPage::TEXT_AREA: 1410 case PDFiumPage::TEXT_AREA:
1397 cursor = PP_CURSORTYPE_IBEAM; 1411 cursor = PP_CURSORTYPE_IBEAM;
1398 break; 1412 break;
1399 case PDFiumPage::WEBLINK_AREA: 1413 case PDFiumPage::WEBLINK_AREA:
1400 case PDFiumPage::DOCLINK_AREA: 1414 case PDFiumPage::DOCLINK_AREA:
1401 cursor = PP_CURSORTYPE_HAND; 1415 cursor = PP_CURSORTYPE_HAND;
1402 break; 1416 break;
(...skipping 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after
3422 double* height) { 3436 double* height) {
3423 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 3437 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
3424 if (!doc) 3438 if (!doc)
3425 return false; 3439 return false;
3426 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3440 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3427 FPDF_CloseDocument(doc); 3441 FPDF_CloseDocument(doc);
3428 return success; 3442 return success;
3429 } 3443 }
3430 3444
3431 } // namespace chrome_pdf 3445 } // 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