| 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/instance.h" | 5 #include "pdf/instance.h" |
| 6 | 6 |
| 7 #include <algorithm> // for min() | 7 #include <algorithm> // for min() |
| 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> |
| 11 #include <list> | 11 #include <list> |
| 12 | 12 |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/chrome_page_zoom_constants.h" | |
| 21 #include "chrome/common/content_restriction.h" | 20 #include "chrome/common/content_restriction.h" |
| 21 #include "components/ui/zoom/page_zoom_constants.h" |
| 22 #include "content/public/common/page_zoom.h" | 22 #include "content/public/common/page_zoom.h" |
| 23 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
| 24 #include "pdf/draw_utils.h" | 24 #include "pdf/draw_utils.h" |
| 25 #include "pdf/number_image_generator.h" | 25 #include "pdf/number_image_generator.h" |
| 26 #include "pdf/pdf.h" | 26 #include "pdf/pdf.h" |
| 27 #include "pdf/resource_consts.h" | 27 #include "pdf/resource_consts.h" |
| 28 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 28 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
| 29 #include "ppapi/c/pp_errors.h" | 29 #include "ppapi/c/pp_errors.h" |
| 30 #include "ppapi/c/pp_rect.h" | 30 #include "ppapi/c/pp_rect.h" |
| 31 #include "ppapi/c/private/ppp_pdf.h" | 31 #include "ppapi/c/private/ppp_pdf.h" |
| (...skipping 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 GetScrollbarReservedThickness()) / document_size_.width(); | 2567 GetScrollbarReservedThickness()) / document_size_.width(); |
| 2568 if (zoom_mode_ == ZOOM_AUTO && zoom_ > 1.0) | 2568 if (zoom_mode_ == ZOOM_AUTO && zoom_ > 1.0) |
| 2569 zoom_ = 1.0; | 2569 zoom_ = 1.0; |
| 2570 break; | 2570 break; |
| 2571 } | 2571 } |
| 2572 zoom_ = ClipToRange(zoom_, kMinZoom, kMaxZoom); | 2572 zoom_ = ClipToRange(zoom_, kMinZoom, kMaxZoom); |
| 2573 } | 2573 } |
| 2574 | 2574 |
| 2575 double Instance::CalculateZoom(uint32 control_id) const { | 2575 double Instance::CalculateZoom(uint32 control_id) const { |
| 2576 if (control_id == kZoomInButtonId) { | 2576 if (control_id == kZoomInButtonId) { |
| 2577 for (size_t i = 0; i < chrome_page_zoom::kPresetZoomFactorsSize; ++i) { | 2577 for (size_t i = 0; i < ui_zoom::kPresetZoomFactorsSize; ++i) { |
| 2578 double current_zoom = chrome_page_zoom::kPresetZoomFactors[i]; | 2578 double current_zoom = ui_zoom::kPresetZoomFactors[i]; |
| 2579 if (current_zoom - content::kEpsilon > zoom_) | 2579 if (current_zoom - content::kEpsilon > zoom_) |
| 2580 return current_zoom; | 2580 return current_zoom; |
| 2581 } | 2581 } |
| 2582 } else { | 2582 } else { |
| 2583 for (size_t i = chrome_page_zoom::kPresetZoomFactorsSize; i > 0; --i) { | 2583 for (size_t i = ui_zoom::kPresetZoomFactorsSize; i > 0; --i) { |
| 2584 double current_zoom = chrome_page_zoom::kPresetZoomFactors[i - 1]; | 2584 double current_zoom = ui_zoom::kPresetZoomFactors[i - 1]; |
| 2585 if (current_zoom + content::kEpsilon < zoom_) | 2585 if (current_zoom + content::kEpsilon < zoom_) |
| 2586 return current_zoom; | 2586 return current_zoom; |
| 2587 } | 2587 } |
| 2588 } | 2588 } |
| 2589 return zoom_; | 2589 return zoom_; |
| 2590 } | 2590 } |
| 2591 | 2591 |
| 2592 pp::ImageData Instance::CreateResourceImage(PP_ResourceImage image_id) { | 2592 pp::ImageData Instance::CreateResourceImage(PP_ResourceImage image_id) { |
| 2593 pp::ImageData resource_data; | 2593 pp::ImageData resource_data; |
| 2594 if (hidpi_enabled_) { | 2594 if (hidpi_enabled_) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2812 return instance_->HasScriptableMethod(name, exception); | 2812 return instance_->HasScriptableMethod(name, exception); |
| 2813 } | 2813 } |
| 2814 | 2814 |
| 2815 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2815 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2816 const std::vector<pp::Var>& args, | 2816 const std::vector<pp::Var>& args, |
| 2817 pp::Var* exception) { | 2817 pp::Var* exception) { |
| 2818 return instance_->CallScriptableMethod(method, args, exception); | 2818 return instance_->CallScriptableMethod(method, args, exception); |
| 2819 } | 2819 } |
| 2820 | 2820 |
| 2821 } // namespace chrome_pdf | 2821 } // namespace chrome_pdf |
| OLD | NEW |