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

Side by Side Diff: chrome/browser/resources/pdf/pdf.js

Issue 2283803003: PDF: Add shortcut to toggle fit-to-{page,width}. (Closed)
Patch Set: Extend testZoomToolbarToggle Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @return {number} Width of a scrollbar in pixels 8 * @return {number} Width of a scrollbar in pixels
9 */ 9 */
10 function getScrollbarWidth() { 10 function getScrollbarWidth() {
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 this.viewport.position = position; 370 this.viewport.position = position;
371 } 371 }
372 } 372 }
373 return; 373 return;
374 case 40: // Down arrow key. 374 case 40: // Down arrow key.
375 if (fromScriptingAPI) { 375 if (fromScriptingAPI) {
376 position.y += Viewport.SCROLL_INCREMENT; 376 position.y += Viewport.SCROLL_INCREMENT;
377 this.viewport.position = position; 377 this.viewport.position = position;
378 } 378 }
379 return; 379 return;
380 case 65: // a key. 380 case 65: // 'a' key.
381 if (e.ctrlKey || e.metaKey) { 381 if (e.ctrlKey || e.metaKey) {
382 this.plugin_.postMessage({ 382 this.plugin_.postMessage({
383 type: 'selectAll' 383 type: 'selectAll'
384 }); 384 });
385 // Since we do selection ourselves. 385 // Since we do selection ourselves.
386 e.preventDefault(); 386 e.preventDefault();
387 } 387 }
388 return; 388 return;
389 case 71: // g key. 389 case 71: // 'g' key.
390 if (this.toolbar_ && (e.ctrlKey || e.metaKey) && e.altKey) { 390 if (this.toolbar_ && (e.ctrlKey || e.metaKey) && e.altKey) {
391 this.toolbarManager_.showToolbars(); 391 this.toolbarManager_.showToolbars();
392 this.toolbar_.selectPageNumber(); 392 this.toolbar_.selectPageNumber();
393 } 393 }
394 return; 394 return;
395 case 219: // left bracket. 395 case 219: // Left bracket key.
396 if (e.ctrlKey) 396 if (e.ctrlKey)
397 this.rotateCounterClockwise_(); 397 this.rotateCounterClockwise_();
398 return; 398 return;
399 case 221: // right bracket. 399 case 220: // Backslash key.
400 if (e.ctrlKey)
401 this.zoomToolbar_.fitToggleFromHotKey();
402 return;
403 case 221: // Right bracket key.
400 if (e.ctrlKey) 404 if (e.ctrlKey)
401 this.rotateClockwise_(); 405 this.rotateClockwise_();
402 return; 406 return;
403 } 407 }
404 408
405 // Give print preview a chance to handle the key event. 409 // Give print preview a chance to handle the key event.
406 if (!fromScriptingAPI && this.isPrintPreview_) { 410 if (!fromScriptingAPI && this.isPrintPreview_) {
407 this.sendScriptingMessage_({ 411 this.sendScriptingMessage_({
408 type: 'sendKeyEvent', 412 type: 'sendKeyEvent',
409 keyEvent: SerializeKeyEvent(e) 413 keyEvent: SerializeKeyEvent(e)
(...skipping 25 matching lines...) Expand all
435 /** 439 /**
436 * @private 440 * @private
437 * Rotate the plugin counter-clockwise. 441 * Rotate the plugin counter-clockwise.
438 */ 442 */
439 rotateCounterClockwise_: function() { 443 rotateCounterClockwise_: function() {
440 this.plugin_.postMessage({ 444 this.plugin_.postMessage({
441 type: 'rotateCounterclockwise' 445 type: 'rotateCounterclockwise'
442 }); 446 });
443 }, 447 },
444 448
449 /**
450 * @private
451 * Set zoom to "fit to page".
452 */
445 fitToPage_: function() { 453 fitToPage_: function() {
446 this.viewport_.fitToPage(); 454 this.viewport_.fitToPage();
447 this.toolbarManager_.forceHideTopToolbar(); 455 this.toolbarManager_.forceHideTopToolbar();
448 }, 456 },
449 457
450 /** 458 /**
451 * @private 459 * @private
452 * Notify the plugin to print. 460 * Notify the plugin to print.
453 */ 461 */
454 print_: function() { 462 print_: function() {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 * Each bookmark is an Object containing a: 888 * Each bookmark is an Object containing a:
881 * - title 889 * - title
882 * - page (optional) 890 * - page (optional)
883 * - array of children (themselves bookmarks) 891 * - array of children (themselves bookmarks)
884 * @type {Array} the top-level bookmarks of the PDF. 892 * @type {Array} the top-level bookmarks of the PDF.
885 */ 893 */
886 get bookmarks() { 894 get bookmarks() {
887 return this.bookmarks_; 895 return this.bookmarks_;
888 } 896 }
889 }; 897 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698