| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const char KJSGetNamedDestinationType[] = "getNamedDestination"; | 137 const char KJSGetNamedDestinationType[] = "getNamedDestination"; |
| 138 const char KJSGetNamedDestination[] = "namedDestination"; | 138 const char KJSGetNamedDestination[] = "namedDestination"; |
| 139 // Reply with the page number of the named destination (Plugin -> Page) | 139 // Reply with the page number of the named destination (Plugin -> Page) |
| 140 const char kJSGetNamedDestinationReplyType[] = "getNamedDestinationReply"; | 140 const char kJSGetNamedDestinationReplyType[] = "getNamedDestinationReply"; |
| 141 const char kJSNamedDestinationPageNumber[] = "pageNumber"; | 141 const char kJSNamedDestinationPageNumber[] = "pageNumber"; |
| 142 | 142 |
| 143 // Selecting text in document (Plugin -> Page) | 143 // Selecting text in document (Plugin -> Page) |
| 144 const char kJSSetIsSelectingType[] = "setIsSelecting"; | 144 const char kJSSetIsSelectingType[] = "setIsSelecting"; |
| 145 const char kJSIsSelecting[] = "isSelecting"; | 145 const char kJSIsSelecting[] = "isSelecting"; |
| 146 | 146 |
| 147 // Notify when a form field is focused (Plugin -> Page) |
| 148 const char kJSFieldFocusType[] = "formFocusChange"; |
| 149 const char kJSFieldFocus[] = "focused"; |
| 150 |
| 147 const int kFindResultCooldownMs = 100; | 151 const int kFindResultCooldownMs = 100; |
| 148 | 152 |
| 149 const double kMinZoom = 0.01; | 153 const double kMinZoom = 0.01; |
| 150 | 154 |
| 151 namespace { | 155 namespace { |
| 152 | 156 |
| 153 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; | 157 static const char kPPPPdfInterface[] = PPP_PDF_INTERFACE_1; |
| 154 | 158 |
| 155 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { | 159 PP_Var GetLinkAtPosition(PP_Instance instance, PP_Point point) { |
| 156 pp::Var var; | 160 pp::Var var; |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 pp::VarDictionary message; | 1261 pp::VarDictionary message; |
| 1258 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1262 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1259 message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)); | 1263 message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)); |
| 1260 PostMessage(message); | 1264 PostMessage(message); |
| 1261 } | 1265 } |
| 1262 } | 1266 } |
| 1263 | 1267 |
| 1264 void OutOfProcessInstance::FormTextFieldFocusChange(bool in_focus) { | 1268 void OutOfProcessInstance::FormTextFieldFocusChange(bool in_focus) { |
| 1265 if (!text_input_.get()) | 1269 if (!text_input_.get()) |
| 1266 return; | 1270 return; |
| 1271 |
| 1272 pp::VarDictionary message; |
| 1273 message.Set(pp::Var(kType), pp::Var(kJSFieldFocusType)); |
| 1274 message.Set(pp::Var(kJSFieldFocus), pp::Var(in_focus)); |
| 1275 PostMessage(message); |
| 1276 |
| 1267 if (in_focus) | 1277 if (in_focus) |
| 1268 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_TEXT); | 1278 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_TEXT); |
| 1269 else | 1279 else |
| 1270 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_NONE); | 1280 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_NONE); |
| 1271 } | 1281 } |
| 1272 | 1282 |
| 1273 void OutOfProcessInstance::ResetRecentlySentFindUpdate(int32_t /* unused */) { | 1283 void OutOfProcessInstance::ResetRecentlySentFindUpdate(int32_t /* unused */) { |
| 1274 recently_sent_find_update_ = false; | 1284 recently_sent_find_update_ = false; |
| 1275 } | 1285 } |
| 1276 | 1286 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 const pp::FloatPoint& scroll_offset) { | 1416 const pp::FloatPoint& scroll_offset) { |
| 1407 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1417 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1408 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1418 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1409 float min_y = -top_toolbar_height_; | 1419 float min_y = -top_toolbar_height_; |
| 1410 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1420 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1411 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1421 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1412 return pp::FloatPoint(x, y); | 1422 return pp::FloatPoint(x, y); |
| 1413 } | 1423 } |
| 1414 | 1424 |
| 1415 } // namespace chrome_pdf | 1425 } // namespace chrome_pdf |
| OLD | NEW |