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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 2127383002: Open hyperlinks in PDF in a new tab when middle mouse clicking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Open hyperlinks in PDF in a new tab when middle mouse clicking. Created 4 years, 5 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/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> // for min/max() 10 #include <algorithm> // for min/max()
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const char kJSNamedDestinationPageNumber[] = "pageNumber"; 131 const char kJSNamedDestinationPageNumber[] = "pageNumber";
132 132
133 // Selecting text in document (Plugin -> Page) 133 // Selecting text in document (Plugin -> Page)
134 const char kJSSetIsSelectingType[] = "setIsSelecting"; 134 const char kJSSetIsSelectingType[] = "setIsSelecting";
135 const char kJSIsSelecting[] = "isSelecting"; 135 const char kJSIsSelecting[] = "isSelecting";
136 136
137 // Notify when a form field is focused (Plugin -> Page) 137 // Notify when a form field is focused (Plugin -> Page)
138 const char kJSFieldFocusType[] = "formFocusChange"; 138 const char kJSFieldFocusType[] = "formFocusChange";
139 const char kJSFieldFocus[] = "focused"; 139 const char kJSFieldFocus[] = "focused";
140 140
141 // Get link position in document (Page -> Plugin)
142 const char kJSGetLinkPositionType[] = "getLinkPosition";
Dan Beam 2016/07/11 21:03:09 please make this and all variants plural, i.e. get
143
144 // Reply with link position (Plugin -> Page)
145 const char kJSGetLinkPositionReplyType[] = "getLinkPositionReply";
146 const char kJSGetLinkPositionX[] = "x";
147 const char kJSGetLinkPositionY[] = "y";
148
141 const int kFindResultCooldownMs = 100; 149 const int kFindResultCooldownMs = 100;
142 150
143 // A delay to wait between each accessibility page to keep the system 151 // A delay to wait between each accessibility page to keep the system
144 // responsive. 152 // responsive.
145 const int kAccessibilityPageDelayMs = 100; 153 const int kAccessibilityPageDelayMs = 100;
146 154
147 const double kMinZoom = 0.01; 155 const double kMinZoom = 0.01;
148 156
149 namespace { 157 namespace {
150 158
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 PostMessage(reply); 468 PostMessage(reply);
461 } else if (type == KJSGetNamedDestinationType && 469 } else if (type == KJSGetNamedDestinationType &&
462 dict.Get(pp::Var(KJSGetNamedDestination)).is_string()) { 470 dict.Get(pp::Var(KJSGetNamedDestination)).is_string()) {
463 int page_number = engine_->GetNamedDestinationPage( 471 int page_number = engine_->GetNamedDestinationPage(
464 dict.Get(pp::Var(KJSGetNamedDestination)).AsString()); 472 dict.Get(pp::Var(KJSGetNamedDestination)).AsString());
465 pp::VarDictionary reply; 473 pp::VarDictionary reply;
466 reply.Set(pp::Var(kType), pp::Var(kJSGetNamedDestinationReplyType)); 474 reply.Set(pp::Var(kType), pp::Var(kJSGetNamedDestinationReplyType));
467 if (page_number >= 0) 475 if (page_number >= 0)
468 reply.Set(pp::Var(kJSNamedDestinationPageNumber), page_number); 476 reply.Set(pp::Var(kJSNamedDestinationPageNumber), page_number);
469 PostMessage(reply); 477 PostMessage(reply);
478 } else if (type == kJSGetLinkPositionType) {
479 std::vector<pp::Rect> rects = engine_->GetLinkRects();
480
481 pp::VarDictionary reply;
482 reply.Set(pp::Var(kType), pp::Var(kJSGetLinkPositionReplyType));
483 if (!rects.empty()) {
484 reply.Set(pp::Var(kJSGetLinkPositionX), pp::Var(rects[0].x()));
485 reply.Set(pp::Var(kJSGetLinkPositionY), pp::Var(rects[0].y()));
Dan Beam 2016/07/11 21:03:09 wait, how does this work with multiple links?
486 }
487 PostMessage(reply);
470 } else { 488 } else {
471 NOTREACHED(); 489 NOTREACHED();
472 } 490 }
473 } 491 }
474 492
475 bool OutOfProcessInstance::HandleInputEvent( 493 bool OutOfProcessInstance::HandleInputEvent(
476 const pp::InputEvent& event) { 494 const pp::InputEvent& event) {
477 // To simplify things, convert the event into device coordinates if it is 495 // To simplify things, convert the event into device coordinates if it is
478 // a mouse event. 496 // a mouse event.
479 pp::InputEvent event_device_res(event); 497 pp::InputEvent event_device_res(event);
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 const pp::FloatPoint& scroll_offset) { 1541 const pp::FloatPoint& scroll_offset) {
1524 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1542 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1525 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1543 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1526 float min_y = -top_toolbar_height_; 1544 float min_y = -top_toolbar_height_;
1527 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1545 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1528 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1546 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1529 return pp::FloatPoint(x, y); 1547 return pp::FloatPoint(x, y);
1530 } 1548 }
1531 1549
1532 } // namespace chrome_pdf 1550 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698