| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 199 } |
| 200 | 200 |
| 201 const PPP_Pdf ppp_private = { | 201 const PPP_Pdf ppp_private = { |
| 202 &GetLinkAtPosition, | 202 &GetLinkAtPosition, |
| 203 &Transform, | 203 &Transform, |
| 204 &GetPrintPresetOptionsFromDocument | 204 &GetPrintPresetOptionsFromDocument |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 int ExtractPrintPreviewPageIndex(const std::string& src_url) { | 207 int ExtractPrintPreviewPageIndex(const std::string& src_url) { |
| 208 // Sample |src_url| format: chrome://print/id/page_index/print.pdf | 208 // Sample |src_url| format: chrome://print/id/page_index/print.pdf |
| 209 std::vector<std::string> url_substr; | 209 std::vector<std::string> url_substr = base::SplitString( |
| 210 base::SplitString(src_url.substr(strlen(kChromePrint)), '/', &url_substr); | 210 src_url.substr(strlen(kChromePrint)), "/", |
| 211 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 211 if (url_substr.size() != 3) | 212 if (url_substr.size() != 3) |
| 212 return -1; | 213 return -1; |
| 213 | 214 |
| 214 if (url_substr[2] != "print.pdf") | 215 if (url_substr[2] != "print.pdf") |
| 215 return -1; | 216 return -1; |
| 216 | 217 |
| 217 int page_index = 0; | 218 int page_index = 0; |
| 218 if (!base::StringToInt(url_substr[1], &page_index)) | 219 if (!base::StringToInt(url_substr[1], &page_index)) |
| 219 return -1; | 220 return -1; |
| 220 return page_index; | 221 return page_index; |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 const pp::FloatPoint& scroll_offset) { | 1430 const pp::FloatPoint& scroll_offset) { |
| 1430 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1431 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1431 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1432 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1432 float min_y = -top_toolbar_height_; | 1433 float min_y = -top_toolbar_height_; |
| 1433 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1434 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1434 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1435 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1435 return pp::FloatPoint(x, y); | 1436 return pp::FloatPoint(x, y); |
| 1436 } | 1437 } |
| 1437 | 1438 |
| 1438 } // namespace chrome_pdf | 1439 } // namespace chrome_pdf |
| OLD | NEW |