Skip to content

Commit

Permalink
PDF: Change the rotate shortcut keys to ctrl+[] on all platforms.
Browse files Browse the repository at this point in the history
The default modifier key on Mac is Command, but that conflicts with
the forward and backward keys.

BUG=111232,417902

Review URL: https://codereview.chromium.org/606933002

Cr-Commit-Position: refs/heads/master@{#297033}
  • Loading branch information
leizleiz authored and Commit bot committed Sep 26, 2014
1 parent 49264e0 commit 48fa973
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
16 changes: 10 additions & 6 deletions chrome/browser/resources/pdf/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,18 @@ PDFViewer.prototype = {
}
return;
case 219: // left bracket.
this.plugin_.postMessage({
type: 'rotateCounterclockwise',
});
if (e.ctrlKey) {
this.plugin_.postMessage({
type: 'rotateCounterclockwise',
});
}
return;
case 221: // right bracket.
this.plugin_.postMessage({
type: 'rotateClockwise',
});
if (e.ctrlKey) {
this.plugin_.postMessage({
type: 'rotateClockwise',
});
}
return;
}
},
Expand Down
33 changes: 19 additions & 14 deletions pdf/instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,21 +587,26 @@ bool Instance::HandleInputEvent(const pp::InputEvent& event) {
}
}

if (event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN &&
event.GetModifiers() & kDefaultKeyModifier) {
if (event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN) {
pp::KeyboardInputEvent keyboard_event(event);
switch (keyboard_event.GetKeyCode()) {
case 'A':
engine_->SelectAll();
return true;
case ui::VKEY_OEM_4:
// Left bracket.
engine_->RotateCounterclockwise();
return true;
case ui::VKEY_OEM_6:
// Right bracket.
engine_->RotateClockwise();
return true;
const uint32 modifier = event.GetModifiers();
if (modifier & kDefaultKeyModifier) {
switch (keyboard_event.GetKeyCode()) {
case 'A':
engine_->SelectAll();
return true;
}
} else if (modifier & PP_INPUTEVENT_MODIFIER_CONTROLKEY) {
switch (keyboard_event.GetKeyCode()) {
case ui::VKEY_OEM_4:
// Left bracket.
engine_->RotateCounterclockwise();
return true;
case ui::VKEY_OEM_6:
// Right bracket.
engine_->RotateClockwise();
return true;
}
}
}

Expand Down

0 comments on commit 48fa973

Please sign in to comment.