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 = {
e.preventDefault();
}
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) {
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;
}
}
......
......@@ -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;
......@@ -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() &&
......
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