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

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

Issue 861673002: Implement Page Selection in PDF Toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pdf-toolbar
Patch Set: Restore viewer-progress-bar in index.html 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 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 for (var header in this.streamDetails_.responseHeaders) { 105 for (var header in this.streamDetails_.responseHeaders) {
106 headers += header + ': ' + 106 headers += header + ': ' +
107 this.streamDetails_.responseHeaders[header] + '\n'; 107 this.streamDetails_.responseHeaders[header] + '\n';
108 } 108 }
109 this.plugin_.setAttribute('headers', headers); 109 this.plugin_.setAttribute('headers', headers);
110 110
111 if (!this.streamDetails_.embedded) 111 if (!this.streamDetails_.embedded)
112 this.plugin_.setAttribute('full-frame', ''); 112 this.plugin_.setAttribute('full-frame', '');
113 document.body.appendChild(this.plugin_); 113 document.body.appendChild(this.plugin_);
114 114
115 this.pageIndicator_.addEventListener('changePage', function(e) {
116 this.viewport_.goToPage(e.detail.page);
117 }.bind(this));
118
115 // Setup the button event listeners. 119 // Setup the button event listeners.
116 $('fit-to-width-button').addEventListener('click', 120 $('fit-to-width-button').addEventListener('click',
117 this.viewport_.fitToWidth.bind(this.viewport_)); 121 this.viewport_.fitToWidth.bind(this.viewport_));
118 $('fit-to-page-button').addEventListener('click', 122 $('fit-to-page-button').addEventListener('click',
119 this.viewport_.fitToPage.bind(this.viewport_)); 123 this.viewport_.fitToPage.bind(this.viewport_));
120 $('zoom-in-button').addEventListener('click', 124 $('zoom-in-button').addEventListener('click',
121 this.viewport_.zoomIn.bind(this.viewport_)); 125 this.viewport_.zoomIn.bind(this.viewport_));
122 $('zoom-out-button').addEventListener('click', 126 $('zoom-out-button').addEventListener('click',
123 this.viewport_.zoomOut.bind(this.viewport_)); 127 this.viewport_.zoomOut.bind(this.viewport_));
124 $('save-button').addEventListener('click', this.save_.bind(this)); 128 $('save-button').addEventListener('click', this.save_.bind(this));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 this.sizer_.style.display = 'none'; 337 this.sizer_.style.display = 'none';
334 this.toolbar_.style.visibility = 'hidden'; 338 this.toolbar_.style.visibility = 'hidden';
335 if (this.passwordScreen_.active) { 339 if (this.passwordScreen_.active) {
336 this.passwordScreen_.deny(); 340 this.passwordScreen_.deny();
337 this.passwordScreen_.active = false; 341 this.passwordScreen_.active = false;
338 } 342 }
339 } else if (progress == 100) { 343 } else if (progress == 100) {
340 // Document load complete. 344 // Document load complete.
341 if (this.lastViewportPosition_) 345 if (this.lastViewportPosition_)
342 this.viewport_.position = this.lastViewportPosition_; 346 this.viewport_.position = this.lastViewportPosition_;
347 if (this.isMaterial_)
348 this.pageIndicator_.style.visibility = 'visible';
343 this.handleURLParams_(); 349 this.handleURLParams_();
344 this.loaded_ = true; 350 this.loaded_ = true;
345 this.sendScriptingMessage_({ 351 this.sendScriptingMessage_({
346 type: 'documentLoaded' 352 type: 'documentLoaded'
347 }); 353 });
348 while (this.delayedScriptingMessages_.length > 0) 354 while (this.delayedScriptingMessages_.length > 0)
349 this.handleScriptingMessage(this.delayedScriptingMessages_.shift()); 355 this.handleScriptingMessage(this.delayedScriptingMessages_.shift());
350 } 356 }
351 }, 357 },
352 358
(...skipping 18 matching lines...) Expand all
371 handlePluginMessage_: function(message) { 377 handlePluginMessage_: function(message) {
372 switch (message.data.type.toString()) { 378 switch (message.data.type.toString()) {
373 case 'documentDimensions': 379 case 'documentDimensions':
374 this.documentDimensions_ = message.data; 380 this.documentDimensions_ = message.data;
375 this.viewport_.setDocumentDimensions(this.documentDimensions_); 381 this.viewport_.setDocumentDimensions(this.documentDimensions_);
376 // If we received the document dimensions, the password was good so we 382 // If we received the document dimensions, the password was good so we
377 // can dismiss the password screen. 383 // can dismiss the password screen.
378 if (this.passwordScreen_.active) 384 if (this.passwordScreen_.active)
379 this.passwordScreen_.accept(); 385 this.passwordScreen_.accept();
380 386
381 this.pageIndicator_.initialFadeIn(); 387 if (this.isMaterial_) {
388 this.pageIndicator_.docLength =
389 this.documentDimensions_.pageDimensions.length;
390 } else {
391 this.pageIndicator_.initialFadeIn();
392 }
393
382 this.toolbar_.initialFadeIn(); 394 this.toolbar_.initialFadeIn();
383 break; 395 break;
384 case 'email': 396 case 'email':
385 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc + 397 var href = 'mailto:' + message.data.to + '?cc=' + message.data.cc +
386 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject + 398 '&bcc=' + message.data.bcc + '&subject=' + message.data.subject +
387 '&body=' + message.data.body; 399 '&body=' + message.data.body;
388 window.location.href = href; 400 window.location.href = href;
389 break; 401 break;
390 case 'getAccessibilityJSONReply': 402 case 'getAccessibilityJSONReply':
391 this.sendScriptingMessage_(message.data); 403 this.sendScriptingMessage_(message.data);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 this.toolbar_.style.bottom = toolbarBottom + 'px'; 540 this.toolbar_.style.bottom = toolbarBottom + 'px';
529 // Hide the toolbar if it doesn't fit in the viewport. 541 // Hide the toolbar if it doesn't fit in the viewport.
530 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0) 542 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0)
531 this.toolbar_.style.visibility = 'hidden'; 543 this.toolbar_.style.visibility = 'hidden';
532 else 544 else
533 this.toolbar_.style.visibility = 'visible'; 545 this.toolbar_.style.visibility = 'visible';
534 546
535 // Update the page indicator. 547 // Update the page indicator.
536 var visiblePage = this.viewport_.getMostVisiblePage(); 548 var visiblePage = this.viewport_.getMostVisiblePage();
537 this.pageIndicator_.index = visiblePage; 549 this.pageIndicator_.index = visiblePage;
538 if (this.documentDimensions_.pageDimensions.length > 1 && 550 if (!this.isMaterial_) {
539 hasScrollbars.vertical) { 551 if (this.documentDimensions_.pageDimensions.length > 1 &&
540 this.pageIndicator_.style.visibility = 'visible'; 552 hasScrollbars.vertical) {
541 } else { 553 this.pageIndicator_.style.visibility = 'visible';
542 this.pageIndicator_.style.visibility = 'hidden'; 554 } else {
555 this.pageIndicator_.style.visibility = 'hidden';
556 }
543 } 557 }
544 558
545 var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage); 559 var visiblePageDimensions = this.viewport_.getPageScreenRect(visiblePage);
546 var size = this.viewport_.size; 560 var size = this.viewport_.size;
547 this.sendScriptingMessage_({ 561 this.sendScriptingMessage_({
548 type: 'viewport', 562 type: 'viewport',
549 pageX: visiblePageDimensions.x, 563 pageX: visiblePageDimensions.x,
550 pageY: visiblePageDimensions.y, 564 pageY: visiblePageDimensions.y,
551 pageWidth: visiblePageDimensions.width, 565 pageWidth: visiblePageDimensions.width,
552 viewportWidth: size.width, 566 viewportWidth: size.width,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 * Each bookmark is an Object containing a: 694 * Each bookmark is an Object containing a:
681 * - title 695 * - title
682 * - page (optional) 696 * - page (optional)
683 * - array of children (themselves bookmarks) 697 * - array of children (themselves bookmarks)
684 * @type {Array} the top-level bookmarks of the PDF. 698 * @type {Array} the top-level bookmarks of the PDF.
685 */ 699 */
686 get bookmarks() { 700 get bookmarks() {
687 return this.bookmarks_; 701 return this.bookmarks_;
688 } 702 }
689 }; 703 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/index-material.html ('k') | ui/webui/resources/polymer_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698