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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 scroll_offset.y()); | 596 scroll_offset.y()); |
597 scroll_offset_float = BoundScrollOffsetToDocument(scroll_offset_float); | 597 scroll_offset_float = BoundScrollOffsetToDocument(scroll_offset_float); |
598 engine_->ScrolledToXPosition(scroll_offset_float.x() * device_scale_); | 598 engine_->ScrolledToXPosition(scroll_offset_float.x() * device_scale_); |
599 engine_->ScrolledToYPosition(scroll_offset_float.y() * device_scale_); | 599 engine_->ScrolledToYPosition(scroll_offset_float.y() * device_scale_); |
600 } | 600 } |
601 } | 601 } |
602 | 602 |
603 void OutOfProcessInstance::GetPrintPresetOptionsFromDocument( | 603 void OutOfProcessInstance::GetPrintPresetOptionsFromDocument( |
604 PP_PdfPrintPresetOptions_Dev* options) { | 604 PP_PdfPrintPresetOptions_Dev* options) { |
605 options->is_scaling_disabled = PP_FromBool(IsPrintScalingDisabled()); | 605 options->is_scaling_disabled = PP_FromBool(IsPrintScalingDisabled()); |
| 606 options->duplex = |
| 607 static_cast<PP_PrivateDuplexMode_Dev>(engine_->GetDuplexType()); |
606 options->copies = engine_->GetCopiesToPrint(); | 608 options->copies = engine_->GetCopiesToPrint(); |
607 } | 609 } |
608 | 610 |
609 pp::Var OutOfProcessInstance::GetLinkAtPosition( | 611 pp::Var OutOfProcessInstance::GetLinkAtPosition( |
610 const pp::Point& point) { | 612 const pp::Point& point) { |
611 pp::Point offset_point(point); | 613 pp::Point offset_point(point); |
612 ScalePoint(device_scale_, &offset_point); | 614 ScalePoint(device_scale_, &offset_point); |
613 offset_point.set_x(offset_point.x() - available_area_.x()); | 615 offset_point.set_x(offset_point.x() - available_area_.x()); |
614 return engine_->GetLinkAtPosition(offset_point); | 616 return engine_->GetLinkAtPosition(offset_point); |
615 } | 617 } |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 pp::PDF::DidStopLoading(this); | 1178 pp::PDF::DidStopLoading(this); |
1177 did_call_start_loading_ = false; | 1179 did_call_start_loading_ = false; |
1178 } | 1180 } |
1179 | 1181 |
1180 document_load_state_ = LOAD_STATE_FAILED; | 1182 document_load_state_ = LOAD_STATE_FAILED; |
1181 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1183 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
1182 | 1184 |
1183 // Send a progress value of -1 to indicate a failure. | 1185 // Send a progress value of -1 to indicate a failure. |
1184 pp::VarDictionary message; | 1186 pp::VarDictionary message; |
1185 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1187 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1186 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)) ; | 1188 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); |
1187 PostMessage(message); | 1189 PostMessage(message); |
1188 } | 1190 } |
1189 | 1191 |
1190 void OutOfProcessInstance::PreviewDocumentLoadFailed() { | 1192 void OutOfProcessInstance::PreviewDocumentLoadFailed() { |
1191 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); | 1193 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); |
1192 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1194 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
1193 preview_pages_info_.empty()) { | 1195 preview_pages_info_.empty()) { |
1194 return; | 1196 return; |
1195 } | 1197 } |
1196 | 1198 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 | 1245 |
1244 // We send 100% load progress in DocumentLoadComplete. | 1246 // We send 100% load progress in DocumentLoadComplete. |
1245 if (progress >= 100) | 1247 if (progress >= 100) |
1246 return; | 1248 return; |
1247 | 1249 |
1248 // Avoid sending too many progress messages over PostMessage. | 1250 // Avoid sending too many progress messages over PostMessage. |
1249 if (progress > last_progress_sent_ + 1) { | 1251 if (progress > last_progress_sent_ + 1) { |
1250 last_progress_sent_ = progress; | 1252 last_progress_sent_ = progress; |
1251 pp::VarDictionary message; | 1253 pp::VarDictionary message; |
1252 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1254 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1253 message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)) ; | 1255 message.Set(pp::Var(kJSProgressPercentage), pp::Var(progress)); |
1254 PostMessage(message); | 1256 PostMessage(message); |
1255 } | 1257 } |
1256 } | 1258 } |
1257 | 1259 |
1258 void OutOfProcessInstance::FormTextFieldFocusChange(bool in_focus) { | 1260 void OutOfProcessInstance::FormTextFieldFocusChange(bool in_focus) { |
1259 if (!text_input_.get()) | 1261 if (!text_input_.get()) |
1260 return; | 1262 return; |
1261 if (in_focus) | 1263 if (in_focus) |
1262 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_TEXT); | 1264 text_input_->SetTextInputType(PP_TEXTINPUT_TYPE_DEV_TEXT); |
1263 else | 1265 else |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1409 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1408 const pp::FloatPoint& scroll_offset) { | 1410 const pp::FloatPoint& scroll_offset) { |
1409 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1411 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1410 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1412 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1411 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1413 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1412 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1414 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1413 return pp::FloatPoint(x, y); | 1415 return pp::FloatPoint(x, y); |
1414 } | 1416 } |
1415 | 1417 |
1416 } // namespace chrome_pdf | 1418 } // namespace chrome_pdf |
OLD | NEW |