Skip to content

Commit

Permalink
PDF Viewer - Add keyboard shortcuts for rotation
Browse files Browse the repository at this point in the history
Currently there are no keyboard shortcuts to rotate pdf
documents. This patch adds the following keyboard shortcuts
to rotate pdf documents :

Rotate counterclockwise : Control + [
Rotate clockwise        : Control + ]

BUG=111232

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

Cr-Commit-Position: refs/heads/master@{#295757}
  • Loading branch information
n.bansal authored and Commit bot committed Sep 19, 2014
1 parent 62bb80a commit cb01146
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions chrome/browser/resources/pdf/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ PDFViewer.prototype = {
e.preventDefault();
}
return;
case 219: // left bracket.
this.plugin_.postMessage({
type: 'rotateCounterclockwise',
});
return;
case 221: // right bracket.
this.plugin_.postMessage({
type: 'rotateClockwise',
});
return;
}
},

Expand Down
8 changes: 8 additions & 0 deletions pdf/instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,14 @@ bool Instance::HandleInputEvent(const pp::InputEvent& event) {
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;
}
}

Expand Down
7 changes: 7 additions & 0 deletions pdf/out_of_process_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ const char kJSEmailCc[] = "cc";
const char kJSEmailBcc[] = "bcc";
const char kJSEmailSubject[] = "subject";
const char kJSEmailBody[] = "body";
// Rotation (Page -> Plugin)
const char kJSRotateClockwiseType[] = "rotateClockwise";
const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise";

const int kFindResultCooldownMs = 100;

Expand Down Expand Up @@ -374,6 +377,10 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
}
} else if (type == kJSPrintType) {
Print();
} else if (type == kJSRotateClockwiseType) {
RotateClockwise();
} else if (type == kJSRotateCounterclockwiseType) {
RotateCounterclockwise();
} else if (type == kJSResetPrintPreviewModeType &&
dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() &&
dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() &&
Expand Down

0 comments on commit cb01146

Please sign in to comment.