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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } // namespace | 276 } // namespace |
277 | 277 |
278 OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) | 278 OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) |
279 : pp::Instance(instance), | 279 : pp::Instance(instance), |
280 pp::Find_Private(this), | 280 pp::Find_Private(this), |
281 pp::Printing_Dev(this), | 281 pp::Printing_Dev(this), |
282 cursor_(PP_CURSORTYPE_POINTER), | 282 cursor_(PP_CURSORTYPE_POINTER), |
283 zoom_(1.0), | 283 zoom_(1.0), |
284 needs_reraster_(true), | 284 needs_reraster_(true), |
285 last_bitmap_smaller_(false), | 285 last_bitmap_smaller_(false), |
286 last_zoom_when_smaller_(1.0), | |
287 device_scale_(1.0), | 286 device_scale_(1.0), |
288 full_(false), | 287 full_(false), |
289 paint_manager_(this, this, true), | 288 paint_manager_(this, this, true), |
290 first_paint_(true), | 289 first_paint_(true), |
291 document_load_state_(LOAD_STATE_LOADING), | 290 document_load_state_(LOAD_STATE_LOADING), |
292 preview_document_load_state_(LOAD_STATE_COMPLETE), | 291 preview_document_load_state_(LOAD_STATE_COMPLETE), |
293 uma_(this), | 292 uma_(this), |
294 told_browser_about_unsupported_feature_(false), | 293 told_browser_about_unsupported_feature_(false), |
295 font_substitution_reported_(false), | 294 font_substitution_reported_(false), |
296 print_preview_page_count_(0), | 295 print_preview_page_count_(0), |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 | 458 |
460 if (plugin_size_.width() > GetDocumentPixelWidth() * zoom_ratio) { | 459 if (plugin_size_.width() > GetDocumentPixelWidth() * zoom_ratio) { |
461 // We want to keep the paint in the middle but it must stay in the same | 460 // We want to keep the paint in the middle but it must stay in the same |
462 // position relative to the scroll bars. | 461 // position relative to the scroll bars. |
463 paint_offset = pp::Point(0, (1 - zoom_ratio) * pinch_center.y()); | 462 paint_offset = pp::Point(0, (1 - zoom_ratio) * pinch_center.y()); |
464 scroll_delta = pp::Point(0, | 463 scroll_delta = pp::Point(0, |
465 (scroll_offset.y() - | 464 (scroll_offset.y() - |
466 starting_scroll_offset_.y() * zoom_ratio / initial_zoom_ratio_)); | 465 starting_scroll_offset_.y() * zoom_ratio / initial_zoom_ratio_)); |
467 | 466 |
468 pinch_vector = pp::Point(); | 467 pinch_vector = pp::Point(); |
469 last_zoom_when_smaller_ = zoom; | |
470 last_bitmap_smaller_ = true; | 468 last_bitmap_smaller_ = true; |
471 } else if (last_bitmap_smaller_) { | 469 } else if (last_bitmap_smaller_) { |
472 pinch_center = pp::Point((plugin_size_.width() / device_scale_) / 2, | 470 pinch_center = pp::Point((plugin_size_.width() / device_scale_) / 2, |
473 (plugin_size_.height() / device_scale_) / 2); | 471 (plugin_size_.height() / device_scale_) / 2); |
| 472 const double zoom_when_doc_covers_plugin_width = |
| 473 zoom_ * plugin_size_.width() / GetDocumentPixelWidth(); |
474 paint_offset = pp::Point( | 474 paint_offset = pp::Point( |
475 (1 - zoom / last_zoom_when_smaller_) * pinch_center.x(), | 475 (1 - zoom / zoom_when_doc_covers_plugin_width) * pinch_center.x(), |
476 (1 - zoom_ratio) * pinch_center.y()); | 476 (1 - zoom_ratio) * pinch_center.y()); |
477 pinch_vector = pp::Point(); | 477 pinch_vector = pp::Point(); |
478 scroll_delta = pp::Point( | 478 scroll_delta = pp::Point( |
479 (scroll_offset.x() - | 479 (scroll_offset.x() - |
480 starting_scroll_offset_.x() * zoom_ratio / initial_zoom_ratio_), | 480 starting_scroll_offset_.x() * zoom_ratio / initial_zoom_ratio_), |
481 (scroll_offset.y() - | 481 (scroll_offset.y() - |
482 starting_scroll_offset_.y() * zoom_ratio / initial_zoom_ratio_)); | 482 starting_scroll_offset_.y() * zoom_ratio / initial_zoom_ratio_)); |
483 } | 483 } |
484 | 484 |
485 paint_manager_.SetTransform(zoom_ratio, pinch_center, | 485 paint_manager_.SetTransform(zoom_ratio, pinch_center, |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1650 const pp::FloatPoint& scroll_offset) { | 1650 const pp::FloatPoint& scroll_offset) { |
1651 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1651 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1652 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1652 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1653 float min_y = -top_toolbar_height_; | 1653 float min_y = -top_toolbar_height_; |
1654 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1654 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1655 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1655 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
1656 return pp::FloatPoint(x, y); | 1656 return pp::FloatPoint(x, y); |
1657 } | 1657 } |
1658 | 1658 |
1659 } // namespace chrome_pdf | 1659 } // namespace chrome_pdf |
OLD | NEW |