| 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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 return true; | 525 return true; |
| 526 | 526 |
| 527 // Left/Right arrows should scroll to the beginning of the Prev/Next page if | 527 // Left/Right arrows should scroll to the beginning of the Prev/Next page if |
| 528 // there is no horizontal scroll bar. | 528 // there is no horizontal scroll bar. |
| 529 // If fit-to-height, PgDown/PgUp should scroll to the beginning of the | 529 // If fit-to-height, PgDown/PgUp should scroll to the beginning of the |
| 530 // Prev/Next page. Spacebar / shift+spacebar should do the same. | 530 // Prev/Next page. Spacebar / shift+spacebar should do the same. |
| 531 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) { | 531 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) { |
| 532 pp::KeyboardInputEvent keyboard_event(event); | 532 pp::KeyboardInputEvent keyboard_event(event); |
| 533 bool no_h_scrollbar = !h_scrollbar_.get(); | 533 bool no_h_scrollbar = !h_scrollbar_.get(); |
| 534 uint32_t key_code = keyboard_event.GetKeyCode(); | 534 uint32_t key_code = keyboard_event.GetKeyCode(); |
| 535 bool page_down = no_h_scrollbar && key_code == ui::VKEY_RIGHT; | 535 bool has_modifiers = keyboard_event.GetModifiers() != 0; |
| 536 bool page_up = no_h_scrollbar && key_code == ui::VKEY_LEFT; | 536 bool page_down = |
| 537 no_h_scrollbar && !has_modifiers && key_code == ui::VKEY_RIGHT; |
| 538 bool page_up = |
| 539 no_h_scrollbar && !has_modifiers && key_code == ui::VKEY_LEFT; |
| 537 if (zoom_mode_ == ZOOM_FIT_TO_PAGE) { | 540 if (zoom_mode_ == ZOOM_FIT_TO_PAGE) { |
| 538 bool has_shift = | 541 bool has_shift = |
| 539 keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY; | 542 keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY; |
| 540 bool key_is_space = key_code == ui::VKEY_SPACE; | 543 bool key_is_space = key_code == ui::VKEY_SPACE; |
| 541 page_down |= key_is_space || key_code == ui::VKEY_NEXT; | 544 page_down |= key_is_space || key_code == ui::VKEY_NEXT; |
| 542 page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR); | 545 page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR); |
| 543 } | 546 } |
| 544 if (page_down) { | 547 if (page_down) { |
| 545 int page = engine_->GetFirstVisiblePage(); | 548 int page = engine_->GetFirstVisiblePage(); |
| 546 if (page == -1) | 549 if (page == -1) |
| (...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 return instance_->HasScriptableMethod(name, exception); | 2802 return instance_->HasScriptableMethod(name, exception); |
| 2800 } | 2803 } |
| 2801 | 2804 |
| 2802 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2805 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2803 const std::vector<pp::Var>& args, | 2806 const std::vector<pp::Var>& args, |
| 2804 pp::Var* exception) { | 2807 pp::Var* exception) { |
| 2805 return instance_->CallScriptableMethod(method, args, exception); | 2808 return instance_->CallScriptableMethod(method, args, exception); |
| 2806 } | 2809 } |
| 2807 | 2810 |
| 2808 } // namespace chrome_pdf | 2811 } // namespace chrome_pdf |
| OLD | NEW |