| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Get the selected text in the document (Page -> Plugin) | 133 // Get the selected text in the document (Page -> Plugin) |
| 134 const char kJSGetSelectedTextType[] = "getSelectedText"; | 134 const char kJSGetSelectedTextType[] = "getSelectedText"; |
| 135 // Reply with selected text (Plugin -> Page) | 135 // Reply with selected text (Plugin -> Page) |
| 136 const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply"; | 136 const char kJSGetSelectedTextReplyType[] = "getSelectedTextReply"; |
| 137 const char kJSSelectedText[] = "selectedText"; | 137 const char kJSSelectedText[] = "selectedText"; |
| 138 | 138 |
| 139 // List of named destinations (Plugin -> Page) | 139 // List of named destinations (Plugin -> Page) |
| 140 const char kJSSetNamedDestinationsType[] = "setNamedDestinations"; | 140 const char kJSSetNamedDestinationsType[] = "setNamedDestinations"; |
| 141 const char kJSNamedDestinations[] = "namedDestinations"; | 141 const char kJSNamedDestinations[] = "namedDestinations"; |
| 142 | 142 |
| 143 // Selecting text in document (Plugin -> Page) |
| 144 const char kJSSetIsSelectingType[] = "setIsSelecting"; |
| 145 const char kJSIsSelecting[] = "isSelecting"; |
| 146 |
| 143 const int kFindResultCooldownMs = 100; | 147 const int kFindResultCooldownMs = 100; |
| 144 | 148 |
| 145 const double kMinZoom = 0.01; | 149 const double kMinZoom = 0.01; |
| 146 | 150 |
| 147 namespace { | 151 namespace { |
| 148 | 152 |
| 149 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 153 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 150 | 154 |
| 151 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 155 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| 152 pp::Var var; | 156 pp::Var var; |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 return; | 1331 return; |
| 1328 engine_->AppendBlankPages(print_preview_page_count_); | 1332 engine_->AppendBlankPages(print_preview_page_count_); |
| 1329 if (preview_pages_info_.size() > 0) | 1333 if (preview_pages_info_.size() > 0) |
| 1330 LoadAvailablePreviewPage(); | 1334 LoadAvailablePreviewPage(); |
| 1331 } | 1335 } |
| 1332 | 1336 |
| 1333 bool OutOfProcessInstance::IsPrintPreview() { | 1337 bool OutOfProcessInstance::IsPrintPreview() { |
| 1334 return IsPrintPreviewUrl(url_); | 1338 return IsPrintPreviewUrl(url_); |
| 1335 } | 1339 } |
| 1336 | 1340 |
| 1341 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { |
| 1342 pp::VarDictionary message; |
| 1343 message.Set(kType, kJSSetIsSelectingType); |
| 1344 message.Set(kJSIsSelecting, pp::Var(is_selecting)); |
| 1345 PostMessage(message); |
| 1346 } |
| 1347 |
| 1337 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, | 1348 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, |
| 1338 int dst_page_index) { | 1349 int dst_page_index) { |
| 1339 if (!IsPrintPreview()) | 1350 if (!IsPrintPreview()) |
| 1340 return; | 1351 return; |
| 1341 | 1352 |
| 1342 int src_page_index = ExtractPrintPreviewPageIndex(url); | 1353 int src_page_index = ExtractPrintPreviewPageIndex(url); |
| 1343 if (src_page_index < 1) | 1354 if (src_page_index < 1) |
| 1344 return; | 1355 return; |
| 1345 | 1356 |
| 1346 preview_pages_info_.push(std::make_pair(url, dst_page_index)); | 1357 preview_pages_info_.push(std::make_pair(url, dst_page_index)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1375 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1386 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1376 const pp::FloatPoint& scroll_offset) { | 1387 const pp::FloatPoint& scroll_offset) { |
| 1377 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1388 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1378 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1389 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1379 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1390 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1380 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1391 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
| 1381 return pp::FloatPoint(x, y); | 1392 return pp::FloatPoint(x, y); |
| 1382 } | 1393 } |
| 1383 | 1394 |
| 1384 } // namespace chrome_pdf | 1395 } // namespace chrome_pdf |
| OLD | NEW |