Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 431303002: PDF: Handle the space bar key like page down. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pdf/instance.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index 3a35c97e2087d6e44f818152fdf9effd77220947..7c3d906bf68dc831ca37c47fc447c616c5c2fa25 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -164,28 +164,41 @@ PDFViewer.prototype = {
// Certain scroll events may be sent from outside of the extension.
var fromScriptingAPI = e.type == 'scriptingKeypress';
+ var pageUpHandler = function() {
+ // Go to the previous page if we are fit-to-page.
+ if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {
+ this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1);
+ // Since we do the movement of the page.
+ e.preventDefault();
+ } else if (fromScriptingAPI) {
+ position.y -= this.viewport.size.height;
+ this.viewport.position = position;
+ }
+ };
+ var pageDownHandler = function() {
+ // Go to the next page if we are fit-to-page.
+ if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {
+ this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1);
+ // Since we do the movement of the page.
+ e.preventDefault();
+ } else if (fromScriptingAPI) {
+ position.y += this.viewport.size.height;
+ this.viewport.position = position;
+ }
+ };
+
switch (e.keyCode) {
+ case 32: // Space key.
+ if (e.shiftKey)
+ pageUpHandler();
+ else
+ pageDownHandler();
+ return;
case 33: // Page up key.
- // Go to the previous page if we are fit-to-page.
- if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {
- this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1);
- // Since we do the movement of the page.
- e.preventDefault();
- } else if (fromScriptingAPI) {
- position.y -= this.viewport.size.height;
- this.viewport.position = position;
- }
+ pageUpHandler();
return;
case 34: // Page down key.
- // Go to the next page if we are fit-to-page.
- if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {
- this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1);
- // Since we do the movement of the page.
- e.preventDefault();
- } else if (fromScriptingAPI) {
- position.y += this.viewport.size.height;
- this.viewport.position = position;
- }
+ pageDownHandler();
return;
case 37: // Left arrow key.
// Go to the previous page if there are no horizontal scrollbars.
« no previous file with comments | « no previous file | pdf/instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698