| OLD | NEW |
| 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 <algorithm> // for min/max() | 7 #include <algorithm> // for min/max() |
| 8 #define _USE_MATH_DEFINES // for M_PI | 8 #define _USE_MATH_DEFINES // for M_PI |
| 9 #include <cmath> // for log() and pow() | 9 #include <cmath> // for log() and pow() |
| 10 #include <math.h> | 10 #include <math.h> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const char kJSEmailTo[] = "to"; | 120 const char kJSEmailTo[] = "to"; |
| 121 const char kJSEmailCc[] = "cc"; | 121 const char kJSEmailCc[] = "cc"; |
| 122 const char kJSEmailBcc[] = "bcc"; | 122 const char kJSEmailBcc[] = "bcc"; |
| 123 const char kJSEmailSubject[] = "subject"; | 123 const char kJSEmailSubject[] = "subject"; |
| 124 const char kJSEmailBody[] = "body"; | 124 const char kJSEmailBody[] = "body"; |
| 125 // Rotation (Page -> Plugin) | 125 // Rotation (Page -> Plugin) |
| 126 const char kJSRotateClockwiseType[] = "rotateClockwise"; | 126 const char kJSRotateClockwiseType[] = "rotateClockwise"; |
| 127 const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise"; | 127 const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise"; |
| 128 // Select all text in the document (Page -> Plugin) | 128 // Select all text in the document (Page -> Plugin) |
| 129 const char kJSSelectAllType[] = "selectAll"; | 129 const char kJSSelectAllType[] = "selectAll"; |
| 130 // Get the selected text in the document (Page -> Plugin) | |
| 131 const char kJSGetSelectedTextType[] = "getSelectedText"; | |
| 132 // Reply with selected text (Plugin -> Page) | |
| 133 const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply"; | |
| 134 const char kJSSelectedText[] = "selectedText"; | |
| 135 | 130 |
| 136 const int kFindResultCooldownMs = 100; | 131 const int kFindResultCooldownMs = 100; |
| 137 | 132 |
| 138 const double kMinZoom = 0.01; | 133 const double kMinZoom = 0.01; |
| 139 | 134 |
| 140 namespace { | 135 namespace { |
| 141 | 136 |
| 142 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 137 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 143 | 138 |
| 144 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 139 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 engine_->HasPermission(PDFEngine::PERMISSION_COPY) || | 437 engine_->HasPermission(PDFEngine::PERMISSION_COPY) || |
| 443 engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE); | 438 engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE); |
| 444 node.SetBoolean(kAccessibleCopyable, has_permissions); | 439 node.SetBoolean(kAccessibleCopyable, has_permissions); |
| 445 std::string json; | 440 std::string json; |
| 446 base::JSONWriter::Write(&node, &json); | 441 base::JSONWriter::Write(&node, &json); |
| 447 reply.Set(pp::Var(kJSAccessibilityJSON), pp::Var(json)); | 442 reply.Set(pp::Var(kJSAccessibilityJSON), pp::Var(json)); |
| 448 } | 443 } |
| 449 PostMessage(reply); | 444 PostMessage(reply); |
| 450 } else if (type == kJSStopScrollingType) { | 445 } else if (type == kJSStopScrollingType) { |
| 451 stop_scrolling_ = true; | 446 stop_scrolling_ = true; |
| 452 } else if (type == kJSGetSelectedTextType) { | |
| 453 pp::VarDictionary reply; | |
| 454 reply.Set(pp::Var(kType), pp::Var(kJSGetSelectedTextReplyType)); | |
| 455 reply.Set(pp::Var(kJSSelectedText), engine_->GetSelectedText()); | |
| 456 PostMessage(reply); | |
| 457 } else { | 447 } else { |
| 458 NOTREACHED(); | 448 NOTREACHED(); |
| 459 } | 449 } |
| 460 } | 450 } |
| 461 | 451 |
| 462 bool OutOfProcessInstance::HandleInputEvent( | 452 bool OutOfProcessInstance::HandleInputEvent( |
| 463 const pp::InputEvent& event) { | 453 const pp::InputEvent& event) { |
| 464 // To simplify things, convert the event into device coordinates if it is | 454 // To simplify things, convert the event into device coordinates if it is |
| 465 // a mouse event. | 455 // a mouse event. |
| 466 pp::InputEvent event_device_res(event); | 456 pp::InputEvent event_device_res(event); |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1382 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1393 const pp::FloatPoint& scroll_offset) { | 1383 const pp::FloatPoint& scroll_offset) { |
| 1394 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1384 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1395 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1385 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1396 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1386 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1397 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1387 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
| 1398 return pp::FloatPoint(x, y); | 1388 return pp::FloatPoint(x, y); |
| 1399 } | 1389 } |
| 1400 | 1390 |
| 1401 } // namespace chrome_pdf | 1391 } // namespace chrome_pdf |
| OLD | NEW |