| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 427 } |
| 428 | 428 |
| 429 #ifdef ENABLE_THUMBNAILS | 429 #ifdef ENABLE_THUMBNAILS |
| 430 if (event.GetType() == PP_INPUTEVENT_TYPE_MOUSELEAVE) | 430 if (event.GetType() == PP_INPUTEVENT_TYPE_MOUSELEAVE) |
| 431 thumbnails_.SlideOut(); | 431 thumbnails_.SlideOut(); |
| 432 | 432 |
| 433 if (thumbnails_.HandleEvent(event_device_res)) | 433 if (thumbnails_.HandleEvent(event_device_res)) |
| 434 return true; | 434 return true; |
| 435 #endif | 435 #endif |
| 436 | 436 |
| 437 if (toolbar_->HandleEvent(event_device_res)) | 437 if (!IsMouseOnScrollbar(event_device_res) && |
| 438 toolbar_->HandleEvent(event_device_res)) |
| 438 return true; | 439 return true; |
| 439 | 440 |
| 440 #ifdef ENABLE_THUMBNAILS | 441 #ifdef ENABLE_THUMBNAILS |
| 441 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_MOUSEMOVE) { | 442 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_MOUSEMOVE) { |
| 442 pp::MouseInputEvent mouse_event(event); | 443 pp::MouseInputEvent mouse_event(event); |
| 443 pp::Point pt = mouse_event.GetPosition(); | 444 pp::Point pt = mouse_event.GetPosition(); |
| 444 pp::Rect v_scrollbar_rc; | 445 pp::Rect v_scrollbar_rc; |
| 445 v_scrollbar_->GetLocation(&v_scrollbar_rc); | 446 v_scrollbar_->GetLocation(&v_scrollbar_rc); |
| 446 // There is a bug (https://bugs.webkit.org/show_bug.cgi?id=45208) | 447 // There is a bug (https://bugs.webkit.org/show_bug.cgi?id=45208) |
| 447 // in the webkit that makes event.u.mouse.button | 448 // in the webkit that makes event.u.mouse.button |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 event.GetTimeStamp(), | 490 event.GetTimeStamp(), |
| 490 event.GetModifiers(), | 491 event.GetModifiers(), |
| 491 mouse_event.GetButton(), | 492 mouse_event.GetButton(), |
| 492 point, | 493 point, |
| 493 mouse_event.GetClickCount(), | 494 mouse_event.GetClickCount(), |
| 494 mouse_event.GetMovement()); | 495 mouse_event.GetMovement()); |
| 495 if (!engine_->IsSelecting()) { | 496 if (!engine_->IsSelecting()) { |
| 496 if (!IsOverlayScrollbar() && | 497 if (!IsOverlayScrollbar() && |
| 497 !available_area_.Contains(mouse_event.GetPosition())) { | 498 !available_area_.Contains(mouse_event.GetPosition())) { |
| 498 try_engine_first = false; | 499 try_engine_first = false; |
| 499 } else if (IsOverlayScrollbar()) { | 500 } else if (IsOverlayScrollbar() && IsMouseOnScrollbar(event)) { |
| 500 pp::Rect temp; | |
| 501 if ((v_scrollbar_.get() && v_scrollbar_->GetLocation(&temp) && | |
| 502 temp.Contains(mouse_event_dip.GetPosition())) || | |
| 503 (h_scrollbar_.get() && h_scrollbar_->GetLocation(&temp) && | |
| 504 temp.Contains(mouse_event_dip.GetPosition()))) { | |
| 505 try_engine_first = false; | 501 try_engine_first = false; |
| 506 } | |
| 507 } | 502 } |
| 508 } | 503 } |
| 509 break; | 504 break; |
| 510 } | 505 } |
| 511 default: | 506 default: |
| 512 break; | 507 break; |
| 513 } | 508 } |
| 514 if (try_engine_first && engine_->HandleEvent(offset_event)) | 509 if (try_engine_first && engine_->HandleEvent(offset_event)) |
| 515 return true; | 510 return true; |
| 516 | 511 |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 } | 1592 } |
| 1598 | 1593 |
| 1599 void Instance::RotateClockwise() { | 1594 void Instance::RotateClockwise() { |
| 1600 engine_->RotateClockwise(); | 1595 engine_->RotateClockwise(); |
| 1601 } | 1596 } |
| 1602 | 1597 |
| 1603 void Instance::RotateCounterclockwise() { | 1598 void Instance::RotateCounterclockwise() { |
| 1604 engine_->RotateCounterclockwise(); | 1599 engine_->RotateCounterclockwise(); |
| 1605 } | 1600 } |
| 1606 | 1601 |
| 1602 bool Instance::IsMouseOnScrollbar(const pp::InputEvent& event) { |
| 1603 pp::MouseInputEvent mouse_event(event); |
| 1604 if (mouse_event.is_null()) |
| 1605 return false; |
| 1606 |
| 1607 pp::Point pt = mouse_event.GetPosition(); |
| 1608 pp::Rect temp; |
| 1609 if ((v_scrollbar_.get() && v_scrollbar_->GetLocation(&temp) && |
| 1610 temp.Contains(pt)) || |
| 1611 (h_scrollbar_.get() && h_scrollbar_->GetLocation(&temp) && |
| 1612 temp.Contains(pt))) { |
| 1613 return true; |
| 1614 } |
| 1615 return false; |
| 1616 } |
| 1617 |
| 1607 void Instance::PreviewDocumentLoadComplete() { | 1618 void Instance::PreviewDocumentLoadComplete() { |
| 1608 if (preview_document_load_state_ != LOAD_STATE_LOADING || | 1619 if (preview_document_load_state_ != LOAD_STATE_LOADING || |
| 1609 preview_pages_info_.empty()) { | 1620 preview_pages_info_.empty()) { |
| 1610 return; | 1621 return; |
| 1611 } | 1622 } |
| 1612 | 1623 |
| 1613 preview_document_load_state_ = LOAD_STATE_COMPLETE; | 1624 preview_document_load_state_ = LOAD_STATE_COMPLETE; |
| 1614 | 1625 |
| 1615 int dest_page_index = preview_pages_info_.front().second; | 1626 int dest_page_index = preview_pages_info_.front().second; |
| 1616 int src_page_index = | 1627 int src_page_index = |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 return instance_->HasScriptableMethod(name, exception); | 2803 return instance_->HasScriptableMethod(name, exception); |
| 2793 } | 2804 } |
| 2794 | 2805 |
| 2795 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2806 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2796 const std::vector<pp::Var>& args, | 2807 const std::vector<pp::Var>& args, |
| 2797 pp::Var* exception) { | 2808 pp::Var* exception) { |
| 2798 return instance_->CallScriptableMethod(method, args, exception); | 2809 return instance_->CallScriptableMethod(method, args, exception); |
| 2799 } | 2810 } |
| 2800 | 2811 |
| 2801 } // namespace chrome_pdf | 2812 } // namespace chrome_pdf |
| OLD | NEW |