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/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> |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 void Instance::SelectFindResult(bool forward) { | 772 void Instance::SelectFindResult(bool forward) { |
| 773 engine_->SelectFindResult(forward); | 773 engine_->SelectFindResult(forward); |
| 774 } | 774 } |
| 775 | 775 |
| 776 void Instance::StopFind() { | 776 void Instance::StopFind() { |
| 777 engine_->StopFind(); | 777 engine_->StopFind(); |
| 778 } | 778 } |
| 779 | 779 |
| 780 void Instance::Zoom(double scale, bool text_only) { | 780 void Instance::Zoom(double scale, bool text_only) { |
| 781 UserMetricsRecordAction("PDF.ZoomFromBrowser"); | 781 UserMetricsRecordAction("PDF.ZoomFromBrowser"); |
| 782 SetZoom(ZOOM_SCALE, scale); | 782 SetZoom(ZOOM_SCALE, scale); |
|
raymes
2014/10/09 17:15:53
Could we move the check up to before this line?
wjmaclean
2014/10/09 17:19:01
This was my original thought, as then it only catc
Nikhil
2014/10/20 09:25:29
Done.
| |
| 783 } | 783 } |
| 784 | 784 |
| 785 void Instance::ZoomChanged(double factor) { | 785 void Instance::ZoomChanged(double factor) { |
| 786 if (full_) | 786 if (full_) |
| 787 Zoom_Dev::ZoomChanged(factor); | 787 Zoom_Dev::ZoomChanged(factor); |
| 788 } | 788 } |
| 789 | 789 |
| 790 void Instance::OnPaint(const std::vector<pp::Rect>& paint_rects, | 790 void Instance::OnPaint(const std::vector<pp::Rect>& paint_rects, |
| 791 std::vector<PaintManager::ReadyRect>* ready, | 791 std::vector<PaintManager::ReadyRect>* ready, |
| 792 std::vector<pp::Rect>* pending) { | 792 std::vector<pp::Rect>* pending) { |
| (...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2441 int32 doc_height = static_cast<int>(document_size_.height() * zoom_); | 2441 int32 doc_height = static_cast<int>(document_size_.height() * zoom_); |
| 2442 pp::Point origin( | 2442 pp::Point origin( |
| 2443 plugin_size_.width() - page_indicator_.rect().width() - | 2443 plugin_size_.width() - page_indicator_.rect().width() - |
| 2444 GetScaled(GetScrollbarReservedThickness()), | 2444 GetScaled(GetScrollbarReservedThickness()), |
| 2445 page_indicator_.GetYPosition(engine_->GetVerticalScrollbarYPosition(), | 2445 page_indicator_.GetYPosition(engine_->GetVerticalScrollbarYPosition(), |
| 2446 doc_height, plugin_size_.height())); | 2446 doc_height, plugin_size_.height())); |
| 2447 page_indicator_.MoveTo(origin, invalidate); | 2447 page_indicator_.MoveTo(origin, invalidate); |
| 2448 } | 2448 } |
| 2449 | 2449 |
| 2450 void Instance::SetZoom(ZoomMode zoom_mode, double scale) { | 2450 void Instance::SetZoom(ZoomMode zoom_mode, double scale) { |
| 2451 // If the zoom level doesn't change it means that this zoom change might have | |
| 2452 // been initiated by the plugin. In that case, we don't want to change the | |
| 2453 // zoom mode to ZOOM_SCALE as it may have been intentionally set to | |
| 2454 // ZOOM_FIT_TO_PAGE or some other value when the zoom was last changed. | |
| 2455 if (scale == zoom_) | |
| 2456 return; | |
| 2457 | |
| 2451 double old_zoom = zoom_; | 2458 double old_zoom = zoom_; |
| 2452 | 2459 |
| 2453 zoom_mode_ = zoom_mode; | 2460 zoom_mode_ = zoom_mode; |
| 2454 if (zoom_mode_ == ZOOM_SCALE) | 2461 if (zoom_mode_ == ZOOM_SCALE) |
| 2455 zoom_ = scale; | 2462 zoom_ = scale; |
| 2456 UpdateZoomScale(); | 2463 UpdateZoomScale(); |
| 2457 | 2464 |
| 2458 engine_->ZoomUpdated(zoom_ * device_scale_); | 2465 engine_->ZoomUpdated(zoom_ * device_scale_); |
| 2459 OnGeometryChanged(old_zoom, device_scale_); | 2466 OnGeometryChanged(old_zoom, device_scale_); |
| 2460 | 2467 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2761 return instance_->HasScriptableMethod(name, exception); | 2768 return instance_->HasScriptableMethod(name, exception); |
| 2762 } | 2769 } |
| 2763 | 2770 |
| 2764 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2771 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2765 const std::vector<pp::Var>& args, | 2772 const std::vector<pp::Var>& args, |
| 2766 pp::Var* exception) { | 2773 pp::Var* exception) { |
| 2767 return instance_->CallScriptableMethod(method, args, exception); | 2774 return instance_->CallScriptableMethod(method, args, exception); |
| 2768 } | 2775 } |
| 2769 | 2776 |
| 2770 } // namespace chrome_pdf | 2777 } // namespace chrome_pdf |
| OLD | NEW |