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

Side by Side Diff: chrome/browser/resources/print_preview/previewarea/preview_area.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, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @typedef {{accessibility: Function, 6 * @typedef {{accessibility: Function,
7 * documentLoadComplete: Function, 7 * documentLoadComplete: Function,
8 * getHeight: Function, 8 * getHeight: Function,
9 * getHorizontalScrollbarThickness: Function, 9 * getHorizontalScrollbarThickness: Function,
10 * getPageLocationNormalized: Function, 10 * getPageLocationNormalized: Function,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 while (element) { 294 while (element) {
295 if (element.scrollHeight > element.clientHeight || 295 if (element.scrollHeight > element.clientHeight ||
296 element.scrollWidth > element.clientWidth) { 296 element.scrollWidth > element.clientWidth) {
297 return; 297 return;
298 } 298 }
299 element = element.parentElement; 299 element = element.parentElement;
300 } 300 }
301 301
302 // No scroll bar anywhere, or the active element is something else, like a 302 // No scroll bar anywhere, or the active element is something else, like a
303 // button. Note: buttons have a bigger scrollHeight than clientHeight. 303 // button. Note: buttons have a bigger scrollHeight than clientHeight.
304 this.plugin_.sendKeyEvent(e.keyCode); 304 this.plugin_.sendKeyEvent(e);
305 e.preventDefault(); 305 e.preventDefault();
306 }, 306 },
307 307
308 /** 308 /**
309 * Set a callback that gets called when a key event is received that
310 * originates in the plugin.
311 * @param {function(Event)} callback The callback to be called with a key
312 * event.
313 */
314 setPluginKeyEventCallback: function(callback) {
315 this.keyEventCallback_ = callback;
316 },
317
318 /**
309 * Shows a custom message on the preview area's overlay. 319 * Shows a custom message on the preview area's overlay.
310 * @param {string} message Custom message to show. 320 * @param {string} message Custom message to show.
311 */ 321 */
312 showCustomMessage: function(message) { 322 showCustomMessage: function(message) {
313 this.showMessage_(PreviewArea.MessageId_.CUSTOM, message); 323 this.showMessage_(PreviewArea.MessageId_.CUSTOM, message);
314 }, 324 },
315 325
316 /** @override */ 326 /** @override */
317 enterDocument: function() { 327 enterDocument: function() {
318 print_preview.Component.prototype.enterDocument.call(this); 328 print_preview.Component.prototype.enterDocument.call(this);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 567
558 if (this.pluginType_ == PreviewArea.PluginType_.IN_PROCESS) { 568 if (this.pluginType_ == PreviewArea.PluginType_.IN_PROCESS) {
559 this.plugin_ = assertInstanceof(document.createElement('embed'), 569 this.plugin_ = assertInstanceof(document.createElement('embed'),
560 HTMLEmbedElement); 570 HTMLEmbedElement);
561 this.plugin_.setAttribute( 571 this.plugin_.setAttribute(
562 'type', 'application/x-google-chrome-print-preview-pdf'); 572 'type', 'application/x-google-chrome-print-preview-pdf');
563 this.plugin_.setAttribute('src', srcUrl); 573 this.plugin_.setAttribute('src', srcUrl);
564 } else { 574 } else {
565 this.plugin_ = /** @type {print_preview.PDFPlugin} */( 575 this.plugin_ = /** @type {print_preview.PDFPlugin} */(
566 PDFCreateOutOfProcessPlugin(srcUrl)); 576 PDFCreateOutOfProcessPlugin(srcUrl));
577 this.plugin_.setKeyEventCallback(this.keyEventCallback_);
567 } 578 }
568 579
569 this.plugin_.setAttribute('class', 'preview-area-plugin'); 580 this.plugin_.setAttribute('class', 'preview-area-plugin');
570 this.plugin_.setAttribute('aria-live', 'polite'); 581 this.plugin_.setAttribute('aria-live', 'polite');
571 this.plugin_.setAttribute('aria-atomic', 'true'); 582 this.plugin_.setAttribute('aria-atomic', 'true');
572 // NOTE: The plugin's 'id' field must be set to 'pdf-viewer' since 583 // NOTE: The plugin's 'id' field must be set to 'pdf-viewer' since
573 // chrome/renderer/printing/print_web_view_helper.cc actually references 584 // chrome/renderer/printing/print_web_view_helper.cc actually references
574 // it. 585 // it.
575 this.plugin_.setAttribute('id', 'pdf-viewer'); 586 this.plugin_.setAttribute('id', 'pdf-viewer');
576 this.getChildElement('.preview-area-plugin-wrapper'). 587 this.getChildElement('.preview-area-plugin-wrapper').
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 // being draggable. 822 // being draggable.
812 this.plugin_.style.pointerEvents = isDragging ? 'none' : 'auto'; 823 this.plugin_.style.pointerEvents = isDragging ? 'none' : 'auto';
813 } 824 }
814 }; 825 };
815 826
816 // Export 827 // Export
817 return { 828 return {
818 PreviewArea: PreviewArea 829 PreviewArea: PreviewArea
819 }; 830 };
820 }); 831 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/pdf_scripting_api.js ('k') | chrome/browser/resources/print_preview/print_preview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698