summaryrefslogtreecommitdiffstats
path: root/pdf
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-05 12:19:45 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-05 12:19:45 +0000
commit8aa550651406320c6614f56fe1f717d33b65cb3d (patch)
treea54b238b656c04b26372f1fcf004b62bd829b9bf /pdf
parent8854fe5620500060fe36e486d8903120f4fbff43 (diff)
downloadchromium_src-8aa550651406320c6614f56fe1f717d33b65cb3d.zip
chromium_src-8aa550651406320c6614f56fe1f717d33b65cb3d.tar.gz
chromium_src-8aa550651406320c6614f56fe1f717d33b65cb3d.tar.bz2
PDF: Handle the space bar key like page down.
BUG=397624 Review URL: https://codereview.chromium.org/431303002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'pdf')
-rw-r--r--pdf/instance.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/pdf/instance.cc b/pdf/instance.cc
index 0ba1e66..0feeff4 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.