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 <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.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) | |
|
Sam McNally
2015/03/05 02:05:06
What if the event isn't a mouse event?
raymes
2015/03/05 23:06:56
Oops, done.
| |
| 556 return false; | |
| 555 | 557 |
| 556 // Return true for unhandled clicks so the plugin takes focus. | 558 // Return true for unhandled clicks so the plugin takes focus. |
| 557 return (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN); | 559 return (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN); |
| 558 } | 560 } |
| 559 | 561 |
| 560 void OutOfProcessInstance::DidChangeView(const pp::View& view) { | 562 void OutOfProcessInstance::DidChangeView(const pp::View& view) { |
| 561 pp::Rect view_rect(view.GetRect()); | 563 pp::Rect view_rect(view.GetRect()); |
| 562 float old_device_scale = device_scale_; | 564 float old_device_scale = device_scale_; |
| 563 float device_scale = view.GetDeviceScale(); | 565 float device_scale = view.GetDeviceScale(); |
| 564 pp::Size view_device_size(view_rect.width() * device_scale, | 566 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( | 1409 pp::FloatPoint OutOfProcessInstance::BoundScrollOffsetToDocument( |
| 1408 const pp::FloatPoint& scroll_offset) { | 1410 const pp::FloatPoint& scroll_offset) { |
| 1409 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); | 1411 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); | 1412 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(); | 1413 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); | 1414 float y = std::max(std::min(scroll_offset.y(), max_y), 0.0f); |
| 1413 return pp::FloatPoint(x, y); | 1415 return pp::FloatPoint(x, y); |
| 1414 } | 1416 } |
| 1415 | 1417 |
| 1416 } // namespace chrome_pdf | 1418 } // namespace chrome_pdf |
| OLD | NEW |