| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 bool page_up = no_h_scrollbar && key_code == ui::VKEY_LEFT; | 513 bool page_up = no_h_scrollbar && key_code == ui::VKEY_LEFT; |
| 514 if (zoom_mode_ == ZOOM_FIT_TO_PAGE) { | 514 if (zoom_mode_ == ZOOM_FIT_TO_PAGE) { |
| 515 bool has_shift = | 515 bool has_shift = |
| 516 keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY; | 516 keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY; |
| 517 bool key_is_space = key_code == ui::VKEY_SPACE; | 517 bool key_is_space = key_code == ui::VKEY_SPACE; |
| 518 page_down |= key_is_space || key_code == ui::VKEY_NEXT; | 518 page_down |= key_is_space || key_code == ui::VKEY_NEXT; |
| 519 page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR); | 519 page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR); |
| 520 } | 520 } |
| 521 if (page_down) { | 521 if (page_down) { |
| 522 int page = engine_->GetFirstVisiblePage(); | 522 int page = engine_->GetFirstVisiblePage(); |
| 523 if (page == -1) |
| 524 return true; |
| 523 // Engine calculates visible page including delimiter to the page size. | 525 // Engine calculates visible page including delimiter to the page size. |
| 524 // We need to check here if the page itself is completely out of view and | 526 // We need to check here if the page itself is completely out of view and |
| 525 // scroll to the next one in that case. | 527 // scroll to the next one in that case. |
| 526 if (engine_->GetPageRect(page).bottom() * zoom_ <= | 528 if (engine_->GetPageRect(page).bottom() * zoom_ <= |
| 527 v_scrollbar_->GetValue()) | 529 v_scrollbar_->GetValue()) |
| 528 page++; | 530 page++; |
| 529 ScrollToPage(page + 1); | 531 ScrollToPage(page + 1); |
| 530 UpdateCursor(PP_CURSORTYPE_POINTER); | 532 UpdateCursor(PP_CURSORTYPE_POINTER); |
| 531 return true; | 533 return true; |
| 532 } else if (page_up) { | 534 } else if (page_up) { |
| 533 int page = engine_->GetFirstVisiblePage(); | 535 int page = engine_->GetFirstVisiblePage(); |
| 536 if (page == -1) |
| 537 return true; |
| 534 if (engine_->GetPageRect(page).y() * zoom_ >= v_scrollbar_->GetValue()) | 538 if (engine_->GetPageRect(page).y() * zoom_ >= v_scrollbar_->GetValue()) |
| 535 page--; | 539 page--; |
| 536 ScrollToPage(page); | 540 ScrollToPage(page); |
| 537 UpdateCursor(PP_CURSORTYPE_POINTER); | 541 UpdateCursor(PP_CURSORTYPE_POINTER); |
| 538 return true; | 542 return true; |
| 539 } | 543 } |
| 540 } | 544 } |
| 541 | 545 |
| 542 if (v_scrollbar_.get() && v_scrollbar_->HandleEvent(event)) { | 546 if (v_scrollbar_.get() && v_scrollbar_->HandleEvent(event)) { |
| 543 UpdateCursor(PP_CURSORTYPE_POINTER); | 547 UpdateCursor(PP_CURSORTYPE_POINTER); |
| (...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2739 return instance_->HasScriptableMethod(name, exception); | 2743 return instance_->HasScriptableMethod(name, exception); |
| 2740 } | 2744 } |
| 2741 | 2745 |
| 2742 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2746 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2743 const std::vector<pp::Var>& args, | 2747 const std::vector<pp::Var>& args, |
| 2744 pp::Var* exception) { | 2748 pp::Var* exception) { |
| 2745 return instance_->CallScriptableMethod(method, args, exception); | 2749 return instance_->CallScriptableMethod(method, args, exception); |
| 2746 } | 2750 } |
| 2747 | 2751 |
| 2748 } // namespace chrome_pdf | 2752 } // namespace chrome_pdf |
| OLD | NEW |