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

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

Issue 1359613002: PDF: Prevent left/right arrow shortcuts when a PDF text field is focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename variable Created 5 years, 3 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 | « chrome/browser/pdf/pdf_extension_test.cc ('k') | chrome/test/data/pdf/page_change_test.js » ('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 536e7eab42f64138a56d2cf24648854b92f7ad6e..32b7e0c0fc0afeb2e3dbf00df249a802202da5a7 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -115,6 +115,7 @@ function PDFViewer(browserApi) {
this.loadState_ = LoadState.LOADING;
this.parentWindow_ = null;
this.parentOrigin_ = null;
+ this.isFormFieldFocused_ = false;
this.delayedScriptingMessages_ = [];
@@ -325,8 +326,10 @@ PDFViewer.prototype = {
return;
case 37: // Left arrow key.
if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
- // Go to the previous page if there are no horizontal scrollbars.
- if (!this.viewport_.documentHasScrollbars().horizontal) {
+ // Go to the previous page if there are no horizontal scrollbars and
+ // no form field is focused.
+ if (!(this.viewport_.documentHasScrollbars().horizontal ||
+ this.isFormFieldFocused_)) {
this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1);
// Since we do the movement of the page.
e.preventDefault();
@@ -344,8 +347,10 @@ PDFViewer.prototype = {
return;
case 39: // Right arrow key.
if (!(e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)) {
- // Go to the next page if there are no horizontal scrollbars.
- if (!this.viewport_.documentHasScrollbars().horizontal) {
+ // Go to the next page if there are no horizontal scrollbars and no
+ // form field is focused.
+ if (!(this.viewport_.documentHasScrollbars().horizontal ||
+ this.isFormFieldFocused_)) {
this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1);
// Since we do the movement of the page.
e.preventDefault();
@@ -667,6 +672,9 @@ PDFViewer.prototype = {
this.paramsParser_.onNamedDestinationReceived(
message.data.pageNumber);
break;
+ case 'formFocusChange':
+ this.isFormFieldFocused_ = message.data.focused;
+ break;
}
},
« no previous file with comments | « chrome/browser/pdf/pdf_extension_test.cc ('k') | chrome/test/data/pdf/page_change_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698