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 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 // Note: If we are in print preview mode the scroll location is retained | 1105 // Note: If we are in print preview mode the scroll location is retained |
1106 // across document loads so we don't want to scroll again and override it. | 1106 // across document loads so we don't want to scroll again and override it. |
1107 if (IsPrintPreview()) { | 1107 if (IsPrintPreview()) { |
1108 AppendBlankPrintPreviewPages(); | 1108 AppendBlankPrintPreviewPages(); |
1109 OnGeometryChanged(0, 0); | 1109 OnGeometryChanged(0, 0); |
1110 } | 1110 } |
1111 | 1111 |
1112 pp::VarDictionary metadata_message; | 1112 pp::VarDictionary metadata_message; |
1113 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); | 1113 metadata_message.Set(pp::Var(kType), pp::Var(kJSMetadataType)); |
1114 std::string title = engine_->GetMetadata("Title"); | 1114 std::string title = engine_->GetMetadata("Title"); |
1115 if (!base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty()) | 1115 bool has_title = |
1116 !base::TrimWhitespace(base::UTF8ToUTF16(title), base::TRIM_ALL).empty(); | |
1117 if (has_title) { | |
raymes
2015/10/14 02:39:08
nit: don't need {
| |
1116 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); | 1118 metadata_message.Set(pp::Var(kJSTitle), pp::Var(title)); |
1119 } | |
1120 uma_.HistogramEnumeration("PDF.HasFeature.Title", has_title ? 1 : 0, 2); | |
1117 | 1121 |
1118 metadata_message.Set(pp::Var(kJSBookmarks), engine_->GetBookmarks()); | 1122 pp::VarArray bookmarks = engine_->GetBookmarks(); |
1123 metadata_message.Set(pp::Var(kJSBookmarks), bookmarks); | |
1124 uma_.HistogramEnumeration("PDF.HasFeature.Bookmarks", | |
1125 bookmarks.GetLength() > 0 ? 1 : 0, 2); | |
1119 PostMessage(metadata_message); | 1126 PostMessage(metadata_message); |
1120 | 1127 |
1121 pp::VarDictionary progress_message; | 1128 pp::VarDictionary progress_message; |
1122 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); | 1129 progress_message.Set(pp::Var(kType), pp::Var(kJSLoadProgressType)); |
1123 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); | 1130 progress_message.Set(pp::Var(kJSProgressPercentage), pp::Var(100)); |
1124 PostMessage(progress_message); | 1131 PostMessage(progress_message); |
1125 | 1132 |
1126 if (!full_) | 1133 if (!full_) |
1127 return; | 1134 return; |
1128 | 1135 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 const pp::FloatPoint& scroll_offset) { | 1423 const pp::FloatPoint& scroll_offset) { |
1417 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1424 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1418 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1425 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1419 float min_y = -top_toolbar_height_; | 1426 float min_y = -top_toolbar_height_; |
1420 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1427 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1421 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1428 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1422 return pp::FloatPoint(x, y); | 1429 return pp::FloatPoint(x, y); |
1423 } | 1430 } |
1424 | 1431 |
1425 } // namespace chrome_pdf | 1432 } // namespace chrome_pdf |
OLD | NEW |