Commit cb011463 authored by n.bansal's avatar n.bansal Committed by Commit bot

PDF Viewer - Add keyboard shortcuts for rotation

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}
parent 62bb80ad
...@@ -234,6 +234,16 @@ PDFViewer.prototype = { ...@@ -234,6 +234,16 @@ PDFViewer.prototype = {
e.preventDefault(); e.preventDefault();
} }
return; return;
case 219: // left bracket.
this.plugin_.postMessage({
type: 'rotateCounterclockwise',
});
return;
case 221: // right bracket.
this.plugin_.postMessage({
type: 'rotateClockwise',
});
return;
} }
}, },
......
...@@ -594,6 +594,14 @@ bool Instance::HandleInputEvent(const pp::InputEvent& event) { ...@@ -594,6 +594,14 @@ bool Instance::HandleInputEvent(const pp::InputEvent& event) {
case 'A': case 'A':
engine_->SelectAll(); engine_->SelectAll();
return true; return true;
case ui::VKEY_OEM_4:
// Left bracket.
engine_->RotateCounterclockwise();
return true;
case ui::VKEY_OEM_6:
// Right bracket.
engine_->RotateClockwise();
return true;
} }
} }
......
...@@ -124,6 +124,9 @@ const char kJSEmailCc[] = "cc"; ...@@ -124,6 +124,9 @@ const char kJSEmailCc[] = "cc";
const char kJSEmailBcc[] = "bcc"; const char kJSEmailBcc[] = "bcc";
const char kJSEmailSubject[] = "subject"; const char kJSEmailSubject[] = "subject";
const char kJSEmailBody[] = "body"; const char kJSEmailBody[] = "body";
// Rotation (Page -> Plugin)
const char kJSRotateClockwiseType[] = "rotateClockwise";
const char kJSRotateCounterclockwiseType[] = "rotateCounterclockwise";
const int kFindResultCooldownMs = 100; const int kFindResultCooldownMs = 100;
...@@ -374,6 +377,10 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { ...@@ -374,6 +377,10 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) {
} }
} else if (type == kJSPrintType) { } else if (type == kJSPrintType) {
Print(); Print();
} else if (type == kJSRotateClockwiseType) {
RotateClockwise();
} else if (type == kJSRotateCounterclockwiseType) {
RotateCounterclockwise();
} else if (type == kJSResetPrintPreviewModeType && } else if (type == kJSResetPrintPreviewModeType &&
dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() &&
dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment