Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Unified Diff: pdf/instance.cc

Issue 431303002: PDF: Handle the space bar key like page down. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/instance.cc
diff --git a/pdf/instance.cc b/pdf/instance.cc
index c796cd5588c103d8299890d5c4a7a26a4cb742c9..bf40971d0b8e85c5ae90ec473c02b0433f09e461 100644
--- a/pdf/instance.cc
+++ b/pdf/instance.cc
@@ -497,20 +497,20 @@ bool Instance::HandleInputEvent(const pp::InputEvent& event) {
// Left/Right arrows should scroll to the beginning of the Prev/Next page if
// there is no horizontal scroll bar.
// If fit-to-height, PgDown/PgUp should scroll to the beginning of the
- // Prev/Next page.
+ // Prev/Next page. Spacebar / shift+spacebar should do the same.
if (v_scrollbar_.get() && event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) {
pp::KeyboardInputEvent keyboard_event(event);
- bool page_down =
- (!h_scrollbar_.get() &&
- keyboard_event.GetKeyCode() == ui::VKEY_RIGHT) ||
- (zoom_mode_ == ZOOM_FIT_TO_PAGE &&
- keyboard_event.GetKeyCode() == ui::VKEY_NEXT);
- bool page_up =
- (!h_scrollbar_.get() &&
- keyboard_event.GetKeyCode() == ui::VKEY_LEFT) ||
- (zoom_mode_ == ZOOM_FIT_TO_PAGE &&
- keyboard_event.GetKeyCode() == ui::VKEY_PRIOR);
-
+ bool no_h_scrollbar = !h_scrollbar_.get();
+ uint32_t key_code = keyboard_event.GetKeyCode();
+ bool page_down = no_h_scrollbar && key_code == ui::VKEY_RIGHT;
+ bool page_up = no_h_scrollbar && key_code == ui::VKEY_LEFT;
+ if (zoom_mode_ == ZOOM_FIT_TO_PAGE) {
+ bool has_shift =
+ keyboard_event.GetModifiers() & PP_INPUTEVENT_MODIFIER_SHIFTKEY;
+ bool key_is_space = key_code == ui::VKEY_SPACE;
+ page_down |= key_is_space || key_code == ui::VKEY_NEXT;
+ page_up |= (key_is_space && has_shift) || (key_code == ui::VKEY_PRIOR);
+ }
if (page_down) {
int page = engine_->GetFirstVisiblePage();
// Engine calculates visible page including delimiter to the page size.
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698