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

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

Issue 2865633004: Fix all remaining print preview closure compiler errors (Closed)
Patch Set: Address comments Created 3 years, 7 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
Index: chrome/browser/resources/pdf/pdf_scripting_api.js
diff --git a/chrome/browser/resources/pdf/pdf_scripting_api.js b/chrome/browser/resources/pdf/pdf_scripting_api.js
index 712e390207e2cb443611cab2cfcf26eddbfb633b..8e44b1ff8820a04554c66ef1518cda6625bda633 100644
--- a/chrome/browser/resources/pdf/pdf_scripting_api.js
+++ b/chrome/browser/resources/pdf/pdf_scripting_api.js
@@ -9,7 +9,7 @@
*/
function DeserializeKeyEvent(dict) {
var e = document.createEvent('Event');
- e.initEvent('keydown');
+ e.initEvent('keydown', true, true);
e.keyCode = dict.keyCode;
e.shiftKey = dict.shiftKey;
e.ctrlKey = dict.ctrlKey;
@@ -37,6 +37,7 @@ function SerializeKeyEvent(event) {
/**
* An enum containing a value specifying whether the PDF is currently loading,
* has finished loading or failed to load.
+ * @enum {string}
*/
var LoadState = {
LOADING: 'loading',
@@ -49,6 +50,7 @@ var LoadState = {
* the PDF viewer so that it can be customized by things like print preview.
* @param {Window} window the window of the page containing the pdf viewer.
* @param {Object} plugin the plugin element containing the pdf viewer.
+ * @constructor
*/
function PDFScriptingAPI(window, plugin) {
this.loadState_ = LoadState.LOADING;
@@ -64,6 +66,13 @@ function PDFScriptingAPI(window, plugin) {
}
switch (event.data.type) {
case 'viewport':
+ event.data = /**
+ * @type {{pageX: number,
+ * pageY: number,
+ * pageWidth: number,
+ * viewportWidth: number,
+ * viewportHeight: number}}
+ */ (event.data);
Dan Beam 2017/05/10 00:00:14 nit: this is prettier, imo /** * @type {{ * p
rbpotter 2017/05/10 01:56:23 Done.
if (this.viewportChangedCallback_)
this.viewportChangedCallback_(event.data.pageX,
event.data.pageY,
@@ -72,11 +81,13 @@ function PDFScriptingAPI(window, plugin) {
event.data.viewportHeight);
break;
case 'documentLoaded':
+ event.data = /** @type {{load_state: LoadState}} */ (event.data);
this.loadState_ = event.data.load_state;
if (this.loadCallback_)
this.loadCallback_(this.loadState_ == LoadState.SUCCESS);
break;
case 'getSelectedTextReply':
+ event.data = /**@type {{selectedText: string}} */(event.data);
if (this.selectedTextCallback_) {
this.selectedTextCallback_(event.data.selectedText);
this.selectedTextCallback_ = null;
@@ -240,8 +251,9 @@ PDFScriptingAPI.prototype = {
* @return {HTMLIFrameElement} the iframe element containing the PDF viewer.
*/
function PDFCreateOutOfProcessPlugin(src) {
- var client = new PDFScriptingAPI(window);
- var iframe = window.document.createElement('iframe');
+ var client = new PDFScriptingAPI(window, null);
+ var iframe = assertInstanceof(window.document.createElement('iframe'),
+ HTMLIFrameElement);
iframe.setAttribute('src', 'pdf_preview.html?' + src);
// Prevent the frame from being tab-focusable.
iframe.setAttribute('tabindex', '-1');

Powered by Google App Engine
This is Rietveld 408576698