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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 mouse_event.GetClickCount(), | 543 mouse_event.GetClickCount(), |
544 mouse_event.GetMovement()); | 544 mouse_event.GetMovement()); |
545 break; | 545 break; |
546 } | 546 } |
547 default: | 547 default: |
548 break; | 548 break; |
549 } | 549 } |
550 if (engine_->HandleEvent(offset_event)) | 550 if (engine_->HandleEvent(offset_event)) |
551 return true; | 551 return true; |
552 | 552 |
553 // TODO(raymes): Implement this scroll behavior in JS: | 553 // Middle click is used for scrolling and is handled by the container page. |
554 // When click+dragging, scroll the document correctly. | 554 pp::MouseInputEvent mouse_event(event_device_res); |
| 555 if (!mouse_event.is_null() && |
| 556 mouse_event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) { |
| 557 return false; |
| 558 } |
555 | 559 |
556 // Return true for unhandled clicks so the plugin takes focus. | 560 // Return true for unhandled clicks so the plugin takes focus. |
557 return (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN); | 561 return (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN); |
558 } | 562 } |
559 | 563 |
560 void OutOfProcessInstance::DidChangeView(const pp::View& view) { | 564 void OutOfProcessInstance::DidChangeView(const pp::View& view) { |
561 pp::Rect view_rect(view.GetRect()); | 565 pp::Rect view_rect(view.GetRect()); |
562 float old_device_scale = device_scale_; | 566 float old_device_scale = device_scale_; |
563 float device_scale = view.GetDeviceScale(); | 567 float device_scale = view.GetDeviceScale(); |
564 pp::Size view_device_size(view_rect.width() * device_scale, | 568 pp::Size view_device_size(view_rect.width() * device_scale, |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( | 1411 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
1408 const pp::FloatPoint& scroll_offset) { | 1412 const pp::FloatPoint& scroll_offset) { |
1409 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1413 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); |
1410 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); | 1414 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); |
1411 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); | 1415 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); |
1412 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); | 1416 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
1413 return pp::FloatPoint(x, y); | 1417 return pp::FloatPoint(x, y); |
1414 } | 1418 } |
1415 | 1419 |
1416 } // namespace chrome_pdf | 1420 } // namespace chrome_pdf |
OLD | NEW |