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

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

Issue 885813003: OOP PDF: Allow print preview to handle key events when the plugin has focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | chrome/browser/resources/pdf/pdf_scripting_api.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 a207c9ebb48abd42b682148002e214b8d8f1a221..3b916e8bd82e3642fdc255ceadf95a5cdad8d8f5 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -165,7 +165,7 @@ PDFViewer.prototype = {
handleKeyEvent_: function(e) {
var position = this.viewport_.position;
// Certain scroll events may be sent from outside of the extension.
- var fromScriptingAPI = e.type == 'scriptingKeypress';
+ var fromScriptingAPI = e.fromScriptingAPI;
var pageUpHandler = function() {
// Go to the previous page if we are fit-to-page.
@@ -270,6 +270,14 @@ PDFViewer.prototype = {
}
return;
}
+
+ // Give print preview a chance to handle the key event.
+ if (!fromScriptingAPI && this.isPrintPreview_) {
+ this.sendScriptingMessage_({
+ type: 'sendKeyEvent',
+ keyEvent: SerializeKeyEvent(e)
+ });
+ }
},
/**
@@ -637,10 +645,7 @@ PDFViewer.prototype = {
});
return true;
case 'sendKeyEvent':
- var e = document.createEvent('Event');
- e.initEvent('scriptingKeypress');
- e.keyCode = message.data.keyCode;
- this.handleKeyEvent_(e);
+ this.handleKeyEvent_(DeserializeKeyEvent(message.data.keyEvent));
return true;
}
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/pdf_scripting_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698