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/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 const char kAccessibleLoaded[] = "loaded"; | 56 const char kAccessibleLoaded[] = "loaded"; |
| 57 const char kAccessibleCopyable[] = "copyable"; | 57 const char kAccessibleCopyable[] = "copyable"; |
| 58 | 58 |
| 59 // Constants used in handling postMessage() messages. | 59 // Constants used in handling postMessage() messages. |
| 60 const char kType[] = "type"; | 60 const char kType[] = "type"; |
| 61 // Viewport message arguments. (Page -> Plugin). | 61 // Viewport message arguments. (Page -> Plugin). |
| 62 const char kJSViewportType[] = "viewport"; | 62 const char kJSViewportType[] = "viewport"; |
| 63 const char kJSXOffset[] = "xOffset"; | 63 const char kJSXOffset[] = "xOffset"; |
| 64 const char kJSYOffset[] = "yOffset"; | 64 const char kJSYOffset[] = "yOffset"; |
| 65 const char kJSZoom[] = "zoom"; | 65 const char kJSZoom[] = "zoom"; |
| 66 const char kJSRender[] = "render"; | |
| 67 const char kJSPx[] = "px"; | |
| 68 const char kJSPy[] = "py"; | |
|
bokan
2016/04/21 18:20:17
more descriptive name please
alessandroa
2016/04/22 14:33:04
Acknowledged.
| |
| 69 const char kJSPinchVectorX[] = "pinchVectorX"; | |
|
bokan
2016/04/21 18:20:17
add a comment to say what pinch vector is (i.e. th
alessandroa
2016/04/22 14:33:05
Done.
| |
| 70 const char kJSPinchVectorY[] = "pinchVectorY"; | |
| 66 // Stop scrolling message (Page -> Plugin) | 71 // Stop scrolling message (Page -> Plugin) |
| 67 const char kJSStopScrollingType[] = "stopScrolling"; | 72 const char kJSStopScrollingType[] = "stopScrolling"; |
| 68 // Document dimension arguments (Plugin -> Page). | 73 // Document dimension arguments (Plugin -> Page). |
| 69 const char kJSDocumentDimensionsType[] = "documentDimensions"; | 74 const char kJSDocumentDimensionsType[] = "documentDimensions"; |
| 70 const char kJSDocumentWidth[] = "width"; | 75 const char kJSDocumentWidth[] = "width"; |
| 71 const char kJSDocumentHeight[] = "height"; | 76 const char kJSDocumentHeight[] = "height"; |
| 72 const char kJSPageDimensions[] = "pageDimensions"; | 77 const char kJSPageDimensions[] = "pageDimensions"; |
| 73 const char kJSPageX[] = "x"; | 78 const char kJSPageX[] = "x"; |
| 74 const char kJSPageY[] = "y"; | 79 const char kJSPageY[] = "y"; |
| 75 const char kJSPageWidth[] = "width"; | 80 const char kJSPageWidth[] = "width"; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 } | 271 } |
| 267 | 272 |
| 268 } // namespace | 273 } // namespace |
| 269 | 274 |
| 270 OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) | 275 OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) |
| 271 : pp::Instance(instance), | 276 : pp::Instance(instance), |
| 272 pp::Find_Private(this), | 277 pp::Find_Private(this), |
| 273 pp::Printing_Dev(this), | 278 pp::Printing_Dev(this), |
| 274 cursor_(PP_CURSORTYPE_POINTER), | 279 cursor_(PP_CURSORTYPE_POINTER), |
| 275 zoom_(1.0), | 280 zoom_(1.0), |
| 281 do_render_(1), | |
| 282 last_current_scroll_(0,0), | |
|
bokan
2016/04/21 18:20:17
nit: space after comma: (0,0) -> (0, 0)
alessandroa
2016/04/22 14:33:05
Done.
| |
| 283 was_smaller_(false), | |
| 276 device_scale_(1.0), | 284 device_scale_(1.0), |
| 277 full_(false), | 285 full_(false), |
| 278 paint_manager_(this, this, true), | 286 paint_manager_(this, this, true), |
| 279 first_paint_(true), | 287 first_paint_(true), |
| 280 document_load_state_(LOAD_STATE_LOADING), | 288 document_load_state_(LOAD_STATE_LOADING), |
| 281 preview_document_load_state_(LOAD_STATE_COMPLETE), | 289 preview_document_load_state_(LOAD_STATE_COMPLETE), |
| 282 uma_(this), | 290 uma_(this), |
| 283 told_browser_about_unsupported_feature_(false), | 291 told_browser_about_unsupported_feature_(false), |
| 284 print_preview_page_count_(0), | 292 print_preview_page_count_(0), |
| 285 last_progress_sent_(0), | 293 last_progress_sent_(0), |
| 286 recently_sent_find_update_(false), | 294 recently_sent_find_update_(false), |
| 287 received_viewport_message_(false), | 295 received_viewport_message_(false), |
| 288 did_call_start_loading_(false), | 296 did_call_start_loading_(false), |
| 289 stop_scrolling_(false), | 297 stop_scrolling_(false), |
| 290 background_color_(0), | 298 background_color_(0), |
| 291 top_toolbar_height_(0) { | 299 top_toolbar_height_(0){ |
| 292 loader_factory_.Initialize(this); | 300 loader_factory_.Initialize(this); |
| 293 timer_factory_.Initialize(this); | 301 timer_factory_.Initialize(this); |
| 294 form_factory_.Initialize(this); | 302 form_factory_.Initialize(this); |
| 295 print_callback_factory_.Initialize(this); | 303 print_callback_factory_.Initialize(this); |
| 296 engine_.reset(PDFEngine::Create(this)); | 304 engine_.reset(PDFEngine::Create(this)); |
| 297 pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private); | 305 pp::Module::Get()->AddPluginInterface(kPPPPdfInterface, &ppp_private); |
| 298 AddPerInstanceObject(kPPPPdfInterface, this); | 306 AddPerInstanceObject(kPPPPdfInterface, this); |
| 299 | 307 |
| 300 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE); | 308 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE); |
| 301 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); | 309 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 } | 387 } |
| 380 | 388 |
| 381 void OutOfProcessInstance::HandleMessage(const pp::Var& message) { | 389 void OutOfProcessInstance::HandleMessage(const pp::Var& message) { |
| 382 pp::VarDictionary dict(message); | 390 pp::VarDictionary dict(message); |
| 383 if (!dict.Get(kType).is_string()) { | 391 if (!dict.Get(kType).is_string()) { |
| 384 NOTREACHED(); | 392 NOTREACHED(); |
| 385 return; | 393 return; |
| 386 } | 394 } |
| 387 | 395 |
| 388 std::string type = dict.Get(kType).AsString(); | 396 std::string type = dict.Get(kType).AsString(); |
| 389 | |
| 390 if (type == kJSViewportType && | 397 if (type == kJSViewportType && |
| 391 dict.Get(pp::Var(kJSXOffset)).is_number() && | 398 dict.Get(pp::Var(kJSXOffset)).is_number() && |
| 392 dict.Get(pp::Var(kJSYOffset)).is_number() && | 399 dict.Get(pp::Var(kJSYOffset)).is_number() && |
| 393 dict.Get(pp::Var(kJSZoom)).is_number()) { | 400 dict.Get(pp::Var(kJSZoom)).is_number() && |
| 401 dict.Get(pp::Var(kJSRender)).is_bool() && | |
| 402 dict.Get(pp::Var(kJSPx)).is_number() && | |
| 403 dict.Get(pp::Var(kJSPy)).is_number()) { | |
| 394 received_viewport_message_ = true; | 404 received_viewport_message_ = true; |
| 395 stop_scrolling_ = false; | 405 stop_scrolling_ = false; |
| 406 bool do_render = dict.Get(pp::Var(kJSRender)).AsBool(); | |
| 396 double zoom = dict.Get(pp::Var(kJSZoom)).AsDouble(); | 407 double zoom = dict.Get(pp::Var(kJSZoom)).AsDouble(); |
| 408 double zoom_delta = zoom / zoom_; | |
| 409 | |
| 410 // Pinch vector is the vector that computes fingers panning. | |
|
bokan
2016/04/21 18:20:17
These kinds of comments belong where kJSPinchVecto
alessandroa
2016/04/22 14:33:05
Acknowledged.
| |
| 411 pp::Point pinch_vector = | |
| 412 pp::Point(dict.Get(kJSPinchVectorX).AsDouble() * zoom_delta, | |
| 413 dict.Get(kJSPinchVectorY).AsDouble() * zoom_delta); | |
| 397 pp::FloatPoint scroll_offset(dict.Get(pp::Var(kJSXOffset)).AsDouble(), | 414 pp::FloatPoint scroll_offset(dict.Get(pp::Var(kJSXOffset)).AsDouble(), |
| 398 dict.Get(pp::Var(kJSYOffset)).AsDouble()); | 415 dict.Get(pp::Var(kJSYOffset)).AsDouble()); |
| 416 pp::Point pinch_center(dict.Get(pp::Var(kJSPx)).AsDouble(), | |
| 417 dict.Get(pp::Var(kJSPy)).AsDouble()); | |
| 418 pp::Point scroll_delta(0,0); | |
| 419 | |
| 420 // If we have the grey parts we will use paint_offset to anchor the paint | |
|
wjmaclean
2016/04/21 14:11:02
"have the grey parts" -> "the rendered document do
alessandroa
2016/04/22 14:33:05
Done.
| |
| 421 // vertically into the same place. We use the scroll bars instead of the | |
| 422 // pinch vector to get the actual position on screen of the paint. | |
| 423 pp::Point paint_offset(0,0); | |
| 424 | |
| 425 // Pinch start. | |
|
wjmaclean
2016/04/21 14:11:02
Is it worth having an enum like "enum PinchPhase {
bokan
2016/04/21 18:20:17
+1. In fact, I would argue you should be passing t
| |
| 426 if (!do_render && do_render_) { | |
|
bokan
2016/04/21 18:20:17
We can also get into this block if we switch from
| |
| 427 last_current_scroll_ = scroll_offset; | |
| 428 old_zoom_ = zoom; | |
| 429 initial_zoom_delta_ = zoom / zoom_; | |
| 430 was_smaller_ = false; | |
| 431 do_render_ = false; | |
| 432 return; | |
| 433 } | |
| 434 | |
| 435 if (!do_render && | |
| 436 plugin_size_.width() > GetDocumentPixelWidth() * zoom_delta) { | |
| 437 // We want to keep the paint in the middle but it must stay in the same | |
| 438 // position relative to the scroll bars. | |
| 439 paint_offset = pp::Point(0, (1 - zoom_delta) * pinch_center.y()); | |
|
bokan
2016/04/21 18:20:17
I don't understand what we're doing here. Why are
alessandroa
2016/04/22 14:33:05
We anchor the paint on the Oy axis and after that
bokan
2016/04/22 15:45:35
Acknowledged.
| |
| 440 scroll_delta = pp::Point( | |
| 441 0, (scroll_offset.y() - | |
| 442 last_current_scroll_.y() * zoom_delta / initial_zoom_delta_)); | |
| 443 | |
| 444 pinch_vector = pp::Point(); | |
| 445 old_zoom_ = zoom; | |
| 446 was_smaller_ = true; | |
| 447 } else { | |
| 448 if(was_smaller_) { | |
|
wjmaclean
2016/04/21 14:11:02
space after 'if'
alessandroa
2016/04/22 14:33:05
Done.
| |
| 449 pinch_center = pp::Point((plugin_size_.width() / device_scale_) / 2, | |
| 450 (plugin_size_.height() / device_scale_) / 2); | |
| 451 paint_offset = pp::Point((1 - zoom / old_zoom_) * pinch_center.x(), | |
| 452 (1 - zoom_delta) * pinch_center.y()); | |
| 453 pinch_vector = pp::Point(0, 0); | |
| 454 scroll_delta = pp::Point( | |
| 455 (scroll_offset.x() - | |
| 456 last_current_scroll_.x() * zoom_delta / initial_zoom_delta_), | |
| 457 (scroll_offset.y() - | |
| 458 last_current_scroll_.y() * zoom_delta / initial_zoom_delta_)); | |
| 459 } | |
| 460 } | |
| 461 | |
| 462 // While pinching. | |
|
wjmaclean
2016/04/21 14:11:01
See comment about tracking pinch state above ...
bokan
2016/04/21 18:20:17
The if ... else branch above is also part of "whil
| |
| 463 if (!do_render) { | |
| 464 paint_manager_.SetTransform(zoom_delta, pinch_center, | |
| 465 pinch_vector + paint_offset + scroll_delta); | |
| 466 do_render_ = do_render; | |
| 467 return; | |
| 468 } | |
| 469 | |
| 470 // On pinch end the scale is again 1.f and we request a render in the new | |
| 471 // position. | |
|
wjmaclean
2016/04/21 14:11:01
PinchEnd state.
| |
| 472 if (do_render && !do_render_) { | |
| 473 paint_manager_.SetTransform(1.f); | |
| 474 was_smaller_ = false; | |
| 475 } | |
| 399 | 476 |
| 400 // Bound the input parameters. | 477 // Bound the input parameters. |
| 401 zoom = std::max(kMinZoom, zoom); | 478 zoom = std::max(kMinZoom, zoom); |
| 402 SetZoom(zoom); | 479 SetZoom(zoom); |
| 480 | |
| 481 do_render_ = do_render; | |
| 403 scroll_offset = BoundScrollOffsetToDocument(scroll_offset); | 482 scroll_offset = BoundScrollOffsetToDocument(scroll_offset); |
| 404 engine_->ScrolledToXPosition(scroll_offset.x() * device_scale_); | 483 engine_->ScrolledToXPosition(scroll_offset.x() * device_scale_); |
| 405 engine_->ScrolledToYPosition(scroll_offset.y() * device_scale_); | 484 engine_->ScrolledToYPosition(scroll_offset.y() * device_scale_); |
| 406 } else if (type == kJSGetPasswordCompleteType && | 485 } else if (type == kJSGetPasswordCompleteType && |
| 407 dict.Get(pp::Var(kJSPassword)).is_string()) { | 486 dict.Get(pp::Var(kJSPassword)).is_string()) { |
| 408 if (password_callback_) { | 487 if (password_callback_) { |
| 409 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; | 488 pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; |
| 410 password_callback_.reset(); | 489 password_callback_.reset(); |
| 411 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); | 490 *callback.output() = dict.Get(pp::Var(kJSPassword)).pp_var(); |
| 412 callback.Run(PP_OK); | 491 callback.Run(PP_OK); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 float device_scale = view.GetDeviceScale(); | 640 float device_scale = view.GetDeviceScale(); |
| 562 pp::Size view_device_size(view_rect.width() * device_scale, | 641 pp::Size view_device_size(view_rect.width() * device_scale, |
| 563 view_rect.height() * device_scale); | 642 view_rect.height() * device_scale); |
| 564 | 643 |
| 565 if (view_device_size != plugin_size_ || device_scale != device_scale_) { | 644 if (view_device_size != plugin_size_ || device_scale != device_scale_) { |
| 566 device_scale_ = device_scale; | 645 device_scale_ = device_scale; |
| 567 plugin_dip_size_ = view_rect.size(); | 646 plugin_dip_size_ = view_rect.size(); |
| 568 plugin_size_ = view_device_size; | 647 plugin_size_ = view_device_size; |
| 569 | 648 |
| 570 paint_manager_.SetSize(view_device_size, device_scale_); | 649 paint_manager_.SetSize(view_device_size, device_scale_); |
| 571 | |
|
wjmaclean
2016/04/21 14:11:02
Undo white-space changes.
| |
| 572 pp::Size new_image_data_size = PaintManager::GetNewContextSize( | 650 pp::Size new_image_data_size = PaintManager::GetNewContextSize( |
| 573 image_data_.size(), | 651 image_data_.size(), |
| 574 plugin_size_); | 652 plugin_size_); |
| 575 if (new_image_data_size != image_data_.size()) { | 653 if (new_image_data_size != image_data_.size()) { |
| 576 image_data_ = pp::ImageData(this, | 654 image_data_ = pp::ImageData(this, |
| 577 PP_IMAGEDATAFORMAT_BGRA_PREMUL, | 655 PP_IMAGEDATAFORMAT_BGRA_PREMUL, |
| 578 new_image_data_size, | 656 new_image_data_size, |
| 579 false); | 657 false); |
| 580 first_paint_ = true; | 658 first_paint_ = true; |
| 581 } | 659 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 DCHECK(plugin_size_.IsEmpty()); | 768 DCHECK(plugin_size_.IsEmpty()); |
| 691 return; | 769 return; |
| 692 } | 770 } |
| 693 if (first_paint_) { | 771 if (first_paint_) { |
| 694 first_paint_ = false; | 772 first_paint_ = false; |
| 695 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); | 773 pp::Rect rect = pp::Rect(pp::Point(), image_data_.size()); |
| 696 FillRect(rect, background_color_); | 774 FillRect(rect, background_color_); |
| 697 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); | 775 ready->push_back(PaintManager::ReadyRect(rect, image_data_, true)); |
| 698 } | 776 } |
| 699 | 777 |
| 700 if (!received_viewport_message_) | 778 if (!received_viewport_message_ || !do_render_) |
| 701 return; | 779 return; |
| 702 | 780 |
| 703 engine_->PrePaint(); | 781 engine_->PrePaint(); |
| 704 | 782 |
| 705 for (const auto& paint_rect : paint_rects) { | 783 for (const auto& paint_rect : paint_rects) { |
| 706 // Intersect with plugin area since there could be pending invalidates from | 784 // Intersect with plugin area since there could be pending invalidates from |
| 707 // when the plugin area was larger. | 785 // when the plugin area was larger. |
| 708 pp::Rect rect = | 786 pp::Rect rect = |
| 709 paint_rect.Intersect(pp::Rect(pp::Point(), plugin_size_)); | 787 paint_rect.Intersect(pp::Rect(pp::Point(), plugin_size_)); |
| 710 if (rect.IsEmpty()) | 788 if (rect.IsEmpty()) |
| 711 continue; | 789 continue; |
| 712 | 790 |
| 713 pp::Rect pdf_rect = available_area_.Intersect(rect); | 791 pp::Rect pdf_rect = available_area_.Intersect(rect); |
| 714 if (!pdf_rect.IsEmpty()) { | 792 if (!pdf_rect.IsEmpty()) { |
| 715 pdf_rect.Offset(available_area_.x() * -1, 0); | 793 pdf_rect.Offset(available_area_.x() * -1, 0); |
| 716 | 794 |
| 717 std::vector<pp::Rect> pdf_ready; | 795 std::vector<pp::Rect> pdf_ready; |
| 718 std::vector<pp::Rect> pdf_pending; | 796 std::vector<pp::Rect> pdf_pending; |
| 719 engine_->Paint(pdf_rect, &image_data_, &pdf_ready, &pdf_pending); | 797 engine_->Paint(pdf_rect, &image_data_, &pdf_ready, &pdf_pending); |
| 798 | |
|
wjmaclean
2016/04/21 14:11:01
Ditto.
| |
| 720 for (auto& ready_rect : pdf_ready) { | 799 for (auto& ready_rect : pdf_ready) { |
| 721 ready_rect.Offset(available_area_.point()); | 800 ready_rect.Offset(available_area_.point()); |
| 722 ready->push_back( | 801 ready->push_back( |
| 723 PaintManager::ReadyRect(ready_rect, image_data_, false)); | 802 PaintManager::ReadyRect(ready_rect, image_data_, false)); |
| 724 } | 803 } |
| 725 for (auto& pending_rect : pdf_pending) { | 804 for (auto& pending_rect : pdf_pending) { |
| 726 pending_rect.Offset(available_area_.point()); | 805 pending_rect.Offset(available_area_.point()); |
| 727 pending->push_back(pending_rect); | 806 pending->push_back(pending_rect); |
| 728 } | 807 } |
| 729 } | 808 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 OnGeometryChanged(zoom_, device_scale_); | 936 OnGeometryChanged(zoom_, device_scale_); |
| 858 } | 937 } |
| 859 | 938 |
| 860 void OutOfProcessInstance::Invalidate(const pp::Rect& rect) { | 939 void OutOfProcessInstance::Invalidate(const pp::Rect& rect) { |
| 861 pp::Rect offset_rect(rect); | 940 pp::Rect offset_rect(rect); |
| 862 offset_rect.Offset(available_area_.point()); | 941 offset_rect.Offset(available_area_.point()); |
| 863 paint_manager_.InvalidateRect(offset_rect); | 942 paint_manager_.InvalidateRect(offset_rect); |
| 864 } | 943 } |
| 865 | 944 |
| 866 void OutOfProcessInstance::Scroll(const pp::Point& point) { | 945 void OutOfProcessInstance::Scroll(const pp::Point& point) { |
| 867 if (!image_data_.is_null()) | 946 if (!image_data_.is_null()) { |
|
wjmaclean
2016/04/21 14:11:02
You don't need the curly braces here. I assume thi
alessandroa
2016/04/22 14:33:05
Done.
| |
| 868 paint_manager_.ScrollRect(available_area_, point); | 947 paint_manager_.ScrollRect(available_area_, point); |
| 948 } | |
| 869 } | 949 } |
| 870 | 950 |
| 871 void OutOfProcessInstance::ScrollToX(int x) { | 951 void OutOfProcessInstance::ScrollToX(int x) { |
| 872 pp::VarDictionary position; | 952 pp::VarDictionary position; |
| 873 position.Set(kType, kJSSetScrollPositionType); | 953 position.Set(kType, kJSSetScrollPositionType); |
| 874 position.Set(kJSPositionX, pp::Var(x / device_scale_)); | 954 position.Set(kJSPositionX, pp::Var(x / device_scale_)); |
| 875 PostMessage(position); | 955 PostMessage(position); |
| 876 } | 956 } |
| 877 | 957 |
| 878 void OutOfProcessInstance::ScrollToY(int y) { | 958 void OutOfProcessInstance::ScrollToY(int y) { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1305 } | 1385 } |
| 1306 | 1386 |
| 1307 void OutOfProcessInstance::OnGeometryChanged(double old_zoom, | 1387 void OutOfProcessInstance::OnGeometryChanged(double old_zoom, |
| 1308 float old_device_scale) { | 1388 float old_device_scale) { |
| 1309 if (zoom_ != old_zoom || device_scale_ != old_device_scale) | 1389 if (zoom_ != old_zoom || device_scale_ != old_device_scale) |
| 1310 engine_->ZoomUpdated(zoom_ * device_scale_); | 1390 engine_->ZoomUpdated(zoom_ * device_scale_); |
| 1311 | 1391 |
| 1312 available_area_ = pp::Rect(plugin_size_); | 1392 available_area_ = pp::Rect(plugin_size_); |
| 1313 int doc_width = GetDocumentPixelWidth(); | 1393 int doc_width = GetDocumentPixelWidth(); |
| 1314 if (doc_width < available_area_.width()) { | 1394 if (doc_width < available_area_.width()) { |
| 1315 available_area_.Offset((available_area_.width() - doc_width) / 2, 0); | 1395 available_area_.Offset((available_area_.width() - doc_width) / 2 , 0); |
|
wjmaclean
2016/04/21 14:11:01
Undo this change.
alessandroa
2016/04/22 14:33:05
Done.
| |
| 1316 available_area_.set_width(doc_width); | 1396 available_area_.set_width(doc_width); |
| 1317 } | 1397 } |
| 1318 int bottom_of_document = | 1398 int bottom_of_document = |
| 1319 GetDocumentPixelHeight() + (top_toolbar_height_ * device_scale_); | 1399 GetDocumentPixelHeight() + (top_toolbar_height_ * device_scale_); |
| 1320 if (bottom_of_document < available_area_.height()) | 1400 if (bottom_of_document < available_area_.height()) |
| 1321 available_area_.set_height(bottom_of_document); | 1401 available_area_.set_height(bottom_of_document); |
| 1322 | 1402 |
| 1323 CalculateBackgroundParts(); | 1403 CalculateBackgroundParts(); |
| 1324 engine_->PageOffsetUpdated(available_area_.point()); | 1404 engine_->PageOffsetUpdated(available_area_.point()); |
| 1325 engine_->PluginSizeUpdated(available_area_.size()); | 1405 engine_->PluginSizeUpdated(available_area_.size()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 reinterpret_cast<const PPB_URLLoaderTrusted*>( | 1440 reinterpret_cast<const PPB_URLLoaderTrusted*>( |
| 1361 pp::Module::Get()->GetBrowserInterface( | 1441 pp::Module::Get()->GetBrowserInterface( |
| 1362 PPB_URLLOADERTRUSTED_INTERFACE)); | 1442 PPB_URLLOADERTRUSTED_INTERFACE)); |
| 1363 if (trusted_interface) | 1443 if (trusted_interface) |
| 1364 trusted_interface->GrantUniversalAccess(loader.pp_resource()); | 1444 trusted_interface->GrantUniversalAccess(loader.pp_resource()); |
| 1365 return loader; | 1445 return loader; |
| 1366 } | 1446 } |
| 1367 | 1447 |
| 1368 void OutOfProcessInstance::SetZoom(double scale) { | 1448 void OutOfProcessInstance::SetZoom(double scale) { |
| 1369 double old_zoom = zoom_; | 1449 double old_zoom = zoom_; |
| 1450 | |
|
wjmaclean
2016/04/21 14:11:01
Undo.
alessandroa
2016/04/22 14:33:04
Done.
| |
| 1370 zoom_ = scale; | 1451 zoom_ = scale; |
| 1371 OnGeometryChanged(old_zoom, device_scale_); | 1452 OnGeometryChanged(old_zoom, device_scale_); |
| 1372 } | 1453 } |
| 1373 | 1454 |
| 1374 void OutOfProcessInstance::AppendBlankPrintPreviewPages() { | 1455 void OutOfProcessInstance::AppendBlankPrintPreviewPages() { |
| 1375 if (print_preview_page_count_ == 0) | 1456 if (print_preview_page_count_ == 0) |
| 1376 return; | 1457 return; |
| 1377 engine_->AppendBlankPages(print_preview_page_count_); | 1458 engine_->AppendBlankPages(print_preview_page_count_); |
| 1378 if (!preview_pages_info_.empty()) | 1459 if (!preview_pages_info_.empty()) |
| 1379 LoadAvailablePreviewPage(); | 1460 LoadAvailablePreviewPage(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 const pp::FloatPoint& scroll_offset) { | 1517 const pp::FloatPoint& scroll_offset) { |
| 1437 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1518 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
| 1438 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1519 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
| 1439 float min_y = -top_toolbar_height_; | 1520 float min_y = -top_toolbar_height_; |
| 1440 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1521 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
| 1441 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); | 1522 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); |
| 1442 return pp::FloatPoint(x, y); | 1523 return pp::FloatPoint(x, y); |
| 1443 } | 1524 } |
| 1444 | 1525 |
| 1445 } // namespace chrome_pdf | 1526 } // namespace chrome_pdf |
| OLD | NEW |