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 loader_factory_.Initialize(this); | 295 loader_factory_.Initialize(this); |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 | 1191 |
1194 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { | 1192 void OutOfProcessInstance::DocumentLoadComplete(int page_count) { |
1195 // Clear focus state for OSK. | 1193 // Clear focus state for OSK. |
1196 FormTextFieldFocusChange(false); | 1194 FormTextFieldFocusChange(false); |
1197 | 1195 |
1198 DCHECK(document_load_state_ == LOAD_STATE_LOADING); | 1196 DCHECK(document_load_state_ == LOAD_STATE_LOADING); |
1199 document_load_state_ = LOAD_STATE_COMPLETE; | 1197 document_load_state_ = LOAD_STATE_COMPLETE; |
1200 UserMetricsRecordAction("PDF.LoadSuccess"); | 1198 UserMetricsRecordAction("PDF.LoadSuccess"); |
1201 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, | 1199 uma_.HistogramEnumeration("PDF.DocumentFeature", LOADED_DOCUMENT, |
1202 FEATURES_COUNT); | 1200 FEATURES_COUNT); |
1203 #if defined(OS_LINUX) | |
1204 if (!font_substitution_reported_) | 1201 if (!font_substitution_reported_) |
1205 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); | 1202 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 0, 2); |
1206 #endif | |
1207 | 1203 |
1208 // Note: If we are in print preview mode the scroll location is retained | 1204 // Note: If we are in print preview mode the scroll location is retained |
1209 // across document loads so we don't want to scroll again and override it. | 1205 // across document loads so we don't want to scroll again and override it. |
1210 if (IsPrintPreview()) { | 1206 if (IsPrintPreview()) { |
1211 AppendBlankPrintPreviewPages(); | 1207 AppendBlankPrintPreviewPages(); |
1212 OnGeometryChanged(0, 0); | 1208 OnGeometryChanged(0, 0); |
1213 } | 1209 } |
1214 | 1210 |
1215 pp::VarDictionary metadata_message; | 1211 pp::VarDictionary metadata_message; |
1216 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1212 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); | 1300 paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); |
1305 | 1301 |
1306 // Send a progress value of -1 to indicate a failure. | 1302 // Send a progress value of -1 to indicate a failure. |
1307 pp::VarDictionary message; | 1303 pp::VarDictionary message; |
1308 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1304 message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1309 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); | 1305 message.Set(pp::Var(kJSProgressPercentage), pp::Var(-1)); |
1310 PostMessage(message); | 1306 PostMessage(message); |
1311 } | 1307 } |
1312 | 1308 |
1313 void OutOfProcessInstance::FontSubstituted() { | 1309 void OutOfProcessInstance::FontSubstituted() { |
1314 #if defined(OS_LINUX) | |
1315 if (font_substitution_reported_) | 1310 if (font_substitution_reported_) |
1316 return; | 1311 return; |
1317 font_substitution_reported_ = true; | 1312 font_substitution_reported_ = true; |
1318 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 1, 2); | 1313 uma_.HistogramEnumeration("PDF.IsFontSubstituted", 1, 2); |
1319 #endif | |
1320 } | 1314 } |
1321 | 1315 |
1322 void OutOfProcessInstance::PreviewDocumentLoadFailed() { | 1316 void OutOfProcessInstance::PreviewDocumentLoadFailed() { |
1323 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); | 1317 UserMetricsRecordAction("PDF.PreviewDocumentLoadFailure"); |
1324 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1318 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
1325 preview_pages_info_.empty()) { | 1319 preview_pages_info_.empty()) { |
1326 return; | 1320 return; |
1327 } | 1321 } |
1328 | 1322 |
1329 preview_document_load_state_ = LOAD_STATE_FAILED; | 1323 preview_document_load_state_ = LOAD_STATE_FAILED; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 const pp::FloatPoint& scroll_offset) { | 1541 const pp::FloatPoint& scroll_offset) { |
1548 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1542 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1549 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1543 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1550 float min_y = -top_toolbar_height_; | 1544 float min_y = -top_toolbar_height_; |
1551 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1545 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1552 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1546 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1553 return pp::FloatPoint(x, y); | 1547 return pp::FloatPoint(x, y); |
1554 } | 1548 } |
1555 | 1549 |
1556 } // namespace chrome_pdf | 1550 } // namespace chrome_pdf |
OLD | NEW |