| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> // for min/max() | 10 #include <algorithm> // for min/max() |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 cursor_(PP_CURSORTYPE_POINTER), | 275 cursor_(PP_CURSORTYPE_POINTER), |
| 276 zoom_(1.0), | 276 zoom_(1.0), |
| 277 device_scale_(1.0), | 277 device_scale_(1.0), |
| 278 full_(false), | 278 full_(false), |
| 279 paint_manager_(this, this, true), | 279 paint_manager_(this, this, true), |
| 280 first_paint_(true), | 280 first_paint_(true), |
| 281 document_load_state_(LOAD_STATE_LOADING), | 281 document_load_state_(LOAD_STATE_LOADING), |
| 282 preview_document_load_state_(LOAD_STATE_COMPLETE), | 282 preview_document_load_state_(LOAD_STATE_COMPLETE), |
| 283 uma_(this), | 283 uma_(this), |
| 284 told_browser_about_unsupported_feature_(false), | 284 told_browser_about_unsupported_feature_(false), |
| 285 #if defined(OS_LINUX) | |
| 286 font_substitution_reported_(false), | 285 font_substitution_reported_(false), |
| 287 #endif | |
| 288 print_preview_page_count_(0), | 286 print_preview_page_count_(0), |
| 289 last_progress_sent_(0), | 287 last_progress_sent_(0), |
| 290 recently_sent_find_update_(false), | 288 recently_sent_find_update_(false), |
| 291 received_viewport_message_(false), | 289 received_viewport_message_(false), |
| 292 did_call_start_loading_(false), | 290 did_call_start_loading_(false), |
| 293 stop_scrolling_(false), | 291 stop_scrolling_(false), |
| 294 background_color_(0), | 292 background_color_(0), |
| 295 top_toolbar_height_(0), | 293 top_toolbar_height_(0), |
| 296 accessibility_state_(ACCESSIBILITY_STATE_OFF), | 294 accessibility_state_(ACCESSIBILITY_STATE_OFF), |
| 297 is_print_preview_(false) { | 295 is_print_preview_(false) { |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 | 1203 |
| 1206 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { | 1204 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
| 1207 // Clear focus state for OSK. | 1205 // Clear focus state for OSK. |
| 1208 FormTextFieldFocusChange(false); | 1206 FormTextFieldFocusChange(false); |
| 1209 | 1207 |
| 1210 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1208 DCHECK(document_load_state_ == LOAD_STATE_LOADING); |
| 1211 document_load_state_ = LOAD_STATE_COMPLETE; | 1209 document_load_state_ = LOAD_STATE_COMPLETE; |
| 1212 UserMetricsRecordAction("PDF.LoadSuccess"); | 1210 UserMetricsRecordAction("PDF.LoadSuccess"); |
| 1213 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, | 1211 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, |
| 1214 FEATURES_COUNT); | 1212 FEATURES_COUNT); |
| 1215 #if defined(OS_LINUX) | |
| 1216 if (!font_substitution_reported_) | 1213 if (!font_substitution_reported_) |
| 1217 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); | 1214 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); |
| 1218 #endif | |
| 1219 | 1215 |
| 1220 // Note: If we are in print preview mode the scroll location is retained | 1216 // Note: If we are in print preview mode the scroll location is retained |
| 1221 // across document loads so we don't want to scroll again and override it. | 1217 // across document loads so we don't want to scroll again and override it. |
| 1222 if (IsPrintPreview()) { | 1218 if (IsPrintPreview()) { |
| 1223 AppendBlankPrintPreviewPages(); | 1219 AppendBlankPrintPreviewPages(); |
| 1224 OnGeometryChanged(0, 0); | 1220 OnGeometryChanged(0, 0); |
| 1225 } | 1221 } |
| 1226 | 1222 |
| 1227 pp::VarDictionary metadata_message; | 1223 pp::VarDictionary metadata_message; |
| 1228 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1224 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1316 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1312 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
| 1317 | 1313 |
| 1318 // Send a progress value of -1 to indicate a failure. | 1314 // Send a progress value of -1 to indicate a failure. |
| 1319 pp::VarDictionary message; | 1315 pp::VarDictionary message; |
| 1320 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1316 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1321 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); | 1317 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); |
| 1322 PostMessage(message); | 1318 PostMessage(message); |
| 1323 } | 1319 } |
| 1324 | 1320 |
| 1325 void OutOfProcessInstance::FontSubstituted() { | 1321 void OutOfProcessInstance::FontSubstituted() { |
| 1326 #if defined(OS_LINUX) | |
| 1327 if (font_substitution_reported_) | 1322 if (font_substitution_reported_) |
| 1328 return; | 1323 return; |
| 1329 font_substitution_reported_ = true; | 1324 font_substitution_reported_ = true; |
| 1330 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 1, 2); | 1325 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 1, 2); |
| 1331 #endif | |
| 1332 } | 1326 } |
| 1333 | 1327 |
| 1334 void OutOfProcessInstance::PreviewDocumentLoadFailed() { | 1328 void OutOfProcessInstance::PreviewDocumentLoadFailed() { |
| 1335 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); | 1329 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); |
| 1336 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1330 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
| 1337 preview_pages_info_.empty()) { | 1331 preview_pages_info_.empty()) { |
| 1338 return; | 1332 return; |
| 1339 } | 1333 } |
| 1340 | 1334 |
| 1341 preview_document_load_state_ = LOAD_STATE_FAILED; | 1335 preview_document_load_state_ = LOAD_STATE_FAILED; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 const pp::FloatPoint& scroll_offset) { | 1552 const pp::FloatPoint& scroll_offset) { |
| 1559 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1553 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1560 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1554 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1561 float min_y = -top_toolbar_height_; | 1555 float min_y = -top_toolbar_height_; |
| 1562 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1556 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1563 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1557 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1564 return pp::FloatPoint(x, y); | 1558 return pp::FloatPoint(x, y); |
| 1565 } | 1559 } |
| 1566 | 1560 |
| 1567 } // namespace chrome_pdf | 1561 } // namespace chrome_pdf |
| OLD | NEW |