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/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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 } | 493 } |
| 494 if (try_engine_first && engine_->HandleEvent(offset_event)) | 494 if (try_engine_first && engine_->HandleEvent(offset_event)) |
| 495 return true; | 495 return true; |
| 496 | 496 |
| 497 // Left/Right arrows should scroll to the beginning of the Prev/Next page if | 497 // Left/Right arrows should scroll to the beginning of the Prev/Next page if |
| 498 // there is no horizontal scroll bar. | 498 // there is no horizontal scroll bar. |
| 499 // If fit-to-height, PgDown/PgUp should scroll to the beginning of the | 499 // If fit-to-height, PgDown/PgUp should scroll to the beginning of the |
| 500 // Prev/Next page. | 500 // Prev/Next page. |
| 501 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) { | 501 if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) { |
| 502 pp::KeyboardInputEvent keyboard_event(event); | 502 pp::KeyboardInputEvent keyboard_event(event); |
| 503 bool is_fit_to_page = zoom_mode_ == ZOOM_FIT_TO_PAGE; | |
| 504 bool no_h_scrollbar = !h_scrollbar_.get(); | |
| 505 uint32_t key_code = keyboard_event.GetKeyCode(); | |
| 503 bool page_down = | 506 bool page_down = |
| 504 (!h_scrollbar_.get() && | 507 (no_h_scrollbar && key_code == ui::VKEY_RIGHT) || |
| 505 keyboard_event.GetKeyCode() == ui::VKEY_RIGHT) || | 508 (is_fit_to_page && |
| 506 (zoom_mode_ == ZOOM_FIT_TO_PAGE && | 509 (key_code == ui::VKEY_NEXT || key_code == ui::VKEY_SPACE)); |
| 507 keyboard_event.GetKeyCode() == ui::VKEY_NEXT); | |
| 508 bool page_up = | 510 bool page_up = |
| 509 (!h_scrollbar_.get() && | 511 (no_h_scrollbar && key_code == ui::VKEY_LEFT) || |
| 510 keyboard_event.GetKeyCode() == ui::VKEY_LEFT) || | 512 (is_fit_to_page && key_code == ui::VKEY_PRIOR); |
|
Peter Kasting
2014/08/01 07:23:08
You also need to treat shift-space as page up. (T
Lei Zhang
2014/08/01 19:41:21
Neat. Never knew you can do that. Onwards to patch
| |
| 511 (zoom_mode_ == ZOOM_FIT_TO_PAGE && | |
| 512 keyboard_event.GetKeyCode() == ui::VKEY_PRIOR); | |
| 513 | 513 |
| 514 if (page_down) { | 514 if (page_down) { |
| 515 int page = engine_->GetFirstVisiblePage(); | 515 int page = engine_->GetFirstVisiblePage(); |
| 516 // Engine calculates visible page including delimiter to the page size. | 516 // Engine calculates visible page including delimiter to the page size. |
| 517 // We need to check here if the page itself is completely out of view and | 517 // We need to check here if the page itself is completely out of view and |
| 518 // scroll to the next one in that case. | 518 // scroll to the next one in that case. |
| 519 if (engine_->GetPageRect(page).bottom() * zoom_ <= | 519 if (engine_->GetPageRect(page).bottom() * zoom_ <= |
| 520 v_scrollbar_->GetValue()) | 520 v_scrollbar_->GetValue()) |
| 521 page++; | 521 page++; |
| 522 ScrollToPage(page + 1); | 522 ScrollToPage(page + 1); |
| (...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2723 return instance_->HasScriptableMethod(name, exception); | 2723 return instance_->HasScriptableMethod(name, exception); |
| 2724 } | 2724 } |
| 2725 | 2725 |
| 2726 pp::Var PDFScriptableObject::Call(const pp::Var& method, | 2726 pp::Var PDFScriptableObject::Call(const pp::Var& method, |
| 2727 const std::vector<pp::Var>& args, | 2727 const std::vector<pp::Var>& args, |
| 2728 pp::Var* exception) { | 2728 pp::Var* exception) { |
| 2729 return instance_->CallScriptableMethod(method, args, exception); | 2729 return instance_->CallScriptableMethod(method, args, exception); |
| 2730 } | 2730 } |
| 2731 | 2731 |
| 2732 } // namespace chrome_pdf | 2732 } // namespace chrome_pdf |
| OLD | NEW |