Chromium Code Reviews| 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 font_substitution_reported_(false), | |
| 285 print_preview_page_count_(0), | 286 print_preview_page_count_(0), |
| 286 last_progress_sent_(0), | 287 last_progress_sent_(0), |
| 287 recently_sent_find_update_(false), | 288 recently_sent_find_update_(false), |
| 288 received_viewport_message_(false), | 289 received_viewport_message_(false), |
| 289 did_call_start_loading_(false), | 290 did_call_start_loading_(false), |
| 290 stop_scrolling_(false), | 291 stop_scrolling_(false), |
| 291 background_color_(0), | 292 background_color_(0), |
| 292 top_toolbar_height_(0), | 293 top_toolbar_height_(0), |
| 293 accessibility_state_(ACCESSIBILITY_STATE_OFF) { | 294 accessibility_state_(ACCESSIBILITY_STATE_OFF) { |
| 294 loader_factory_.Initialize(this); | 295 loader_factory_.Initialize(this); |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 | 1200 |
| 1200 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { | 1201 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
| 1201 // Clear focus state for OSK. | 1202 // Clear focus state for OSK. |
| 1202 FormTextFieldFocusChange(false); | 1203 FormTextFieldFocusChange(false); |
| 1203 | 1204 |
| 1204 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1205 DCHECK(document_load_state_ == LOAD_STATE_LOADING); |
| 1205 document_load_state_ = LOAD_STATE_COMPLETE; | 1206 document_load_state_ = LOAD_STATE_COMPLETE; |
| 1206 UserMetricsRecordAction("PDF.LoadSuccess"); | 1207 UserMetricsRecordAction("PDF.LoadSuccess"); |
| 1207 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, | 1208 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, |
| 1208 FEATURES_COUNT); | 1209 FEATURES_COUNT); |
| 1210 #if defined(OS_LINUX) | |
| 1211 if (!font_substitution_reported_) | |
| 1212 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); | |
| 1213 #endif | |
| 1209 | 1214 |
| 1210 // Note: If we are in print preview mode the scroll location is retained | 1215 // Note: If we are in print preview mode the scroll location is retained |
| 1211 // across document loads so we don't want to scroll again and override it. | 1216 // across document loads so we don't want to scroll again and override it. |
| 1212 if (IsPrintPreview()) { | 1217 if (IsPrintPreview()) { |
| 1213 AppendBlankPrintPreviewPages(); | 1218 AppendBlankPrintPreviewPages(); |
| 1214 OnGeometryChanged(0, 0); | 1219 OnGeometryChanged(0, 0); |
| 1215 } | 1220 } |
| 1216 | 1221 |
| 1217 pp::VarDictionary metadata_message; | 1222 pp::VarDictionary metadata_message; |
| 1218 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1223 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1305 document_load_state_ = LOAD_STATE_FAILED; | 1310 document_load_state_ = LOAD_STATE_FAILED; |
| 1306 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1311 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
| 1307 | 1312 |
| 1308 // Send a progress value of -1 to indicate a failure. | 1313 // Send a progress value of -1 to indicate a failure. |
| 1309 pp::VarDictionary message; | 1314 pp::VarDictionary message; |
| 1310 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1315 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
| 1311 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); | 1316 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); |
| 1312 PostMessage(message); | 1317 PostMessage(message); |
| 1313 } | 1318 } |
| 1314 | 1319 |
| 1320 void OutOfProcessInstance::FontSubstituted() { | |
| 1321 if (font_substitution_reported_) | |
|
Lei Zhang
2016/10/12 18:56:38
Can we have a matching #if defined() here? Also fo
| |
| 1322 return; | |
| 1323 font_substitution_reported_ = true; | |
| 1324 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 1, 2); | |
| 1325 } | |
| 1326 | |
| 1315 void OutOfProcessInstance::PreviewDocumentLoadFailed() { | 1327 void OutOfProcessInstance::PreviewDocumentLoadFailed() { |
| 1316 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); | 1328 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); |
| 1317 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1329 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
| 1318 preview_pages_info_.empty()) { | 1330 preview_pages_info_.empty()) { |
| 1319 return; | 1331 return; |
| 1320 } | 1332 } |
| 1321 | 1333 |
| 1322 preview_document_load_state_ = LOAD_STATE_FAILED; | 1334 preview_document_load_state_ = LOAD_STATE_FAILED; |
| 1323 preview_pages_info_.pop(); | 1335 preview_pages_info_.pop(); |
| 1324 | 1336 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1534 const pp::FloatPoint& scroll_offset) { | 1546 const pp::FloatPoint& scroll_offset) { |
| 1535 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1547 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1536 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1548 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1537 float min_y = -top_toolbar_height_; | 1549 float min_y = -top_toolbar_height_; |
| 1538 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1550 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1539 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1551 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1540 return pp::FloatPoint(x, y); | 1552 return pp::FloatPoint(x, y); |
| 1541 } | 1553 } |
| 1542 | 1554 |
| 1543 } // namespace chrome_pdf | 1555 } // namespace chrome_pdf |
| OLD | NEW |