| 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"; |
| 130 | 135 |
| 131 const int kFindResultCooldownMs = 100; | 136 const int kFindResultCooldownMs = 100; |
| 132 | 137 |
| 133 const double kMinZoom = 0.01; | 138 const double kMinZoom = 0.01; |
| 134 | 139 |
| 135 namespace { | 140 namespace { |
| 136 | 141 |
| 137 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 142 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 138 | 143 |
| 139 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 144 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 engine_->HasPermission(PDFEngine::PERMISSION_COPY) || | 442 engine_->HasPermission(PDFEngine::PERMISSION_COPY) || |
| 438 engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE); | 443 engine_->HasPermission(PDFEngine::PERMISSION_COPY_ACCESSIBLE); |
| 439 node.SetBoolean(kAccessibleCopyable, has_permissions); | 444 node.SetBoolean(kAccessibleCopyable, has_permissions); |
| 440 std::string json; | 445 std::string json; |
| 441 base::JSONWriter::Write(&node, &json); | 446 base::JSONWriter::Write(&node, &json); |
| 442 reply.Set(pp::Var(kJSAccessibilityJSON), pp::Var(json)); | 447 reply.Set(pp::Var(kJSAccessibilityJSON), pp::Var(json)); |
| 443 } | 448 } |
| 444 PostMessage(reply); | 449 PostMessage(reply); |
| 445 } else if (type == kJSStopScrollingType) { | 450 } else if (type == kJSStopScrollingType) { |
| 446 stop_scrolling_ = true; | 451 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); |
| 447 } else { | 457 } else { |
| 448 NOTREACHED(); | 458 NOTREACHED(); |
| 449 } | 459 } |
| 450 } | 460 } |
| 451 | 461 |
| 452 bool OutOfProcessInstance::HandleInputEvent( | 462 bool OutOfProcessInstance::HandleInputEvent( |
| 453 const pp::InputEvent& event) { | 463 const pp::InputEvent& event) { |
| 454 // To simplify things, convert the event into device coordinates if it is | 464 // To simplify things, convert the event into device coordinates if it is |
| 455 // a mouse event. | 465 // a mouse event. |
| 456 pp::InputEvent event_device_res(event); | 466 pp::InputEvent event_device_res(event); |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1392 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1383 const pp::FloatPoint& scroll_offset) { | 1393 const pp::FloatPoint& scroll_offset) { |
| 1384 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1394 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1385 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1395 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1386 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1396 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1387 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1397 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
| 1388 return pp::FloatPoint(x, y); | 1398 return pp::FloatPoint(x, y); |
| 1389 } | 1399 } |
| 1390 | 1400 |
| 1391 } // namespace chrome_pdf | 1401 } // namespace chrome_pdf |
| OLD | NEW |