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

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

Issue 904553002: Make pinch-zoom work for OOP PDF (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
« no previous file with comments | « chrome/browser/resources/pdf/index.css ('k') | extensions/browser/guest_view/guest_view_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // element is sized to fill the entire window and is set to be fixed 101 // element is sized to fill the entire window and is set to be fixed
102 // positioning, acting as a viewport. The plugin renders into this viewport 102 // positioning, acting as a viewport. The plugin renders into this viewport
103 // according to the scroll position of the window. 103 // according to the scroll position of the window.
104 this.plugin_ = document.createElement('embed'); 104 this.plugin_ = document.createElement('embed');
105 // NOTE: The plugin's 'id' field must be set to 'plugin' since 105 // NOTE: The plugin's 'id' field must be set to 'plugin' since
106 // chrome/renderer/printing/print_web_view_helper.cc actually references it. 106 // chrome/renderer/printing/print_web_view_helper.cc actually references it.
107 this.plugin_.id = 'plugin'; 107 this.plugin_.id = 'plugin';
108 this.plugin_.type = 'application/x-google-chrome-pdf'; 108 this.plugin_.type = 'application/x-google-chrome-pdf';
109 this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this), 109 this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this),
110 false); 110 false);
111 this.plugin_.style.height =
112 (window.innerHeight - this.toolbarHeight_) + 'px';
113 this.plugin_.style.width = window.innerWidth + 'px';
114 111
115 if (this.isMaterial_) 112 if (this.isMaterial_)
116 this.plugin_.setAttribute('is-material', ''); 113 this.plugin_.setAttribute('is-material', '');
117 114
118 // Handle scripting messages from outside the extension that wish to interact 115 // Handle scripting messages from outside the extension that wish to interact
119 // with it. We also send a message indicating that extension has loaded and 116 // with it. We also send a message indicating that extension has loaded and
120 // is ready to receive messages. 117 // is ready to receive messages.
121 window.addEventListener('message', this.handleScriptingMessage.bind(this), 118 window.addEventListener('message', this.handleScriptingMessage.bind(this),
122 false); 119 false);
123 120
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } else { 546 } else {
550 this.setZoomInProgress_ = false; 547 this.setZoomInProgress_ = false;
551 } 548 }
552 }, 549 },
553 550
554 /** 551 /**
555 * @private 552 * @private
556 * A callback that's called after the viewport changes. 553 * A callback that's called after the viewport changes.
557 */ 554 */
558 viewportChanged_: function() { 555 viewportChanged_: function() {
559 var hasScrollbars = this.viewport_.documentHasScrollbars();
560 var scrollbarWidth = this.viewport_.scrollbarWidth;
561 var verticalScrollbarWidth = hasScrollbars.vertical ? scrollbarWidth : 0;
562 var horizontalScrollbarWidth =
563 hasScrollbars.horizontal ? scrollbarWidth : 0;
564 this.plugin_.style.width =
565 (window.innerWidth - verticalScrollbarWidth) + 'px';
566 this.plugin_.style.height = (window.innerHeight -
567 horizontalScrollbarWidth - this.toolbarHeight_) + 'px';
568
569 if (!this.documentDimensions_) 556 if (!this.documentDimensions_)
570 return; 557 return;
571 558
572 // Update the buttons selected. 559 // Update the buttons selected.
573 $('fit-to-page-button').classList.remove('polymer-selected'); 560 $('fit-to-page-button').classList.remove('polymer-selected');
574 $('fit-to-width-button').classList.remove('polymer-selected'); 561 $('fit-to-width-button').classList.remove('polymer-selected');
575 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { 562 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {
576 $('fit-to-page-button').classList.add('polymer-selected'); 563 $('fit-to-page-button').classList.add('polymer-selected');
577 } else if (this.viewport_.fittingType == 564 } else if (this.viewport_.fittingType ==
578 Viewport.FittingType.FIT_TO_WIDTH) { 565 Viewport.FittingType.FIT_TO_WIDTH) {
579 $('fit-to-width-button').classList.add('polymer-selected'); 566 $('fit-to-width-button').classList.add('polymer-selected');
580 } 567 }
581 568
582 // Offset the toolbar position so that it doesn't move if scrollbars appear. 569 // Offset the toolbar position so that it doesn't move if scrollbars appear.
570 var hasScrollbars = this.viewport_.documentHasScrollbars();
571 var scrollbarWidth = this.viewport_.scrollbarWidth;
572 var verticalScrollbarWidth = hasScrollbars.vertical ? scrollbarWidth : 0;
573 var horizontalScrollbarWidth =
574 hasScrollbars.horizontal ? scrollbarWidth : 0;
583 var toolbarRight = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth); 575 var toolbarRight = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth);
584 var toolbarBottom = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth); 576 var toolbarBottom = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth);
585 toolbarRight -= verticalScrollbarWidth; 577 toolbarRight -= verticalScrollbarWidth;
586 toolbarBottom -= horizontalScrollbarWidth; 578 toolbarBottom -= horizontalScrollbarWidth;
587 this.toolbar_.style.right = toolbarRight + 'px'; 579 this.toolbar_.style.right = toolbarRight + 'px';
588 this.toolbar_.style.bottom = toolbarBottom + 'px'; 580 this.toolbar_.style.bottom = toolbarBottom + 'px';
589 // Hide the toolbar if it doesn't fit in the viewport. 581 // Hide the toolbar if it doesn't fit in the viewport.
590 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0) 582 if (this.toolbar_.offsetLeft < 0 || this.toolbar_.offsetTop < 0)
591 this.toolbar_.style.visibility = 'hidden'; 583 this.toolbar_.style.visibility = 'hidden';
592 else 584 else
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 * Each bookmark is an Object containing a: 734 * Each bookmark is an Object containing a:
743 * - title 735 * - title
744 * - page (optional) 736 * - page (optional)
745 * - array of children (themselves bookmarks) 737 * - array of children (themselves bookmarks)
746 * @type {Array} the top-level bookmarks of the PDF. 738 * @type {Array} the top-level bookmarks of the PDF.
747 */ 739 */
748 get bookmarks() { 740 get bookmarks() {
749 return this.bookmarks_; 741 return this.bookmarks_;
750 } 742 }
751 }; 743 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/index.css ('k') | extensions/browser/guest_view/guest_view_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698