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

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

Issue 2503633002: Propagate browser zoom changes to embedded PDFs. (Closed)
Patch Set: Use American spelling of behaviour. Created 4 years 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/browser_api.js ('k') | chrome/browser/resources/pdf/viewport.js » ('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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (chrome.tabs && this.browserApi_.getStreamInfo().tabId != -1) { 124 if (chrome.tabs && this.browserApi_.getStreamInfo().tabId != -1) {
125 this.errorScreen_.reloadFn = function() { 125 this.errorScreen_.reloadFn = function() {
126 chrome.tabs.reload(this.browserApi_.getStreamInfo().tabId); 126 chrome.tabs.reload(this.browserApi_.getStreamInfo().tabId);
127 }.bind(this); 127 }.bind(this);
128 } 128 }
129 129
130 // Create the viewport. 130 // Create the viewport.
131 var shortWindow = window.innerHeight < PDFViewer.TOOLBAR_WINDOW_MIN_HEIGHT; 131 var shortWindow = window.innerHeight < PDFViewer.TOOLBAR_WINDOW_MIN_HEIGHT;
132 var topToolbarHeight = 132 var topToolbarHeight =
133 (toolbarEnabled) ? PDFViewer.MATERIAL_TOOLBAR_HEIGHT : 0; 133 (toolbarEnabled) ? PDFViewer.MATERIAL_TOOLBAR_HEIGHT : 0;
134 var defaultZoom =
135 this.browserApi_.getZoomBehavior() == BrowserApi.ZoomBehavior.MANAGE ?
136 this.browserApi_.getDefaultZoom() : 1.0;
134 this.viewport_ = new Viewport(window, 137 this.viewport_ = new Viewport(window,
135 this.sizer_, 138 this.sizer_,
136 this.viewportChanged_.bind(this), 139 this.viewportChanged_.bind(this),
137 this.beforeZoom_.bind(this), 140 this.beforeZoom_.bind(this),
138 this.afterZoom_.bind(this), 141 this.afterZoom_.bind(this),
139 getScrollbarWidth(), 142 getScrollbarWidth(),
140 this.browserApi_.getDefaultZoom(), 143 defaultZoom,
141 topToolbarHeight); 144 topToolbarHeight);
142 145
143 // Create the plugin object dynamically so we can set its src. The plugin 146 // Create the plugin object dynamically so we can set its src. The plugin
144 // element is sized to fill the entire window and is set to be fixed 147 // element is sized to fill the entire window and is set to be fixed
145 // positioning, acting as a viewport. The plugin renders into this viewport 148 // positioning, acting as a viewport. The plugin renders into this viewport
146 // according to the scroll position of the window. 149 // according to the scroll position of the window.
147 this.plugin_ = document.createElement('embed'); 150 this.plugin_ = document.createElement('embed');
148 // NOTE: The plugin's 'id' field must be set to 'plugin' since 151 // NOTE: The plugin's 'id' field must be set to 'plugin' since
149 // chrome/renderer/printing/print_web_view_helper.cc actually references it. 152 // chrome/renderer/printing/print_web_view_helper.cc actually references it.
150 this.plugin_.id = 'plugin'; 153 this.plugin_.id = 'plugin';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 var disposition = 226 var disposition =
224 e.detail.newtab ? Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB : 227 e.detail.newtab ? Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB :
225 Navigator.WindowOpenDisposition.CURRENT_TAB; 228 Navigator.WindowOpenDisposition.CURRENT_TAB;
226 this.navigator_.navigate(e.detail.uri, disposition); 229 this.navigator_.navigate(e.detail.uri, disposition);
227 }.bind(this)); 230 }.bind(this));
228 231
229 this.toolbarManager_ = 232 this.toolbarManager_ =
230 new ToolbarManager(window, this.toolbar_, this.zoomToolbar_); 233 new ToolbarManager(window, this.toolbar_, this.zoomToolbar_);
231 234
232 // Set up the ZoomManager. 235 // Set up the ZoomManager.
233 this.zoomManager_ = new ZoomManager( 236 this.zoomManager_ = ZoomManager.create(
234 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_), 237 this.browserApi_.getZoomBehavior(), this.viewport_,
238 this.browserApi_.setZoom.bind(this.browserApi_),
235 this.browserApi_.getInitialZoom()); 239 this.browserApi_.getInitialZoom());
240 this.viewport_.zoomManager = this.zoomManager_;
236 this.browserApi_.addZoomEventListener( 241 this.browserApi_.addZoomEventListener(
237 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 242 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
238 243
239 // Setup the keyboard event listener. 244 // Setup the keyboard event listener.
240 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 245 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
241 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 246 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
242 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 247 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
243 248
244 var isInTab = this.browserApi_.getStreamInfo().tabId != -1; 249 var isInTab = this.browserApi_.getStreamInfo().tabId != -1;
245 this.navigator_ = new Navigator( 250 this.navigator_ = new Navigator(
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 * Each bookmark is an Object containing a: 923 * Each bookmark is an Object containing a:
919 * - title 924 * - title
920 * - page (optional) 925 * - page (optional)
921 * - array of children (themselves bookmarks) 926 * - array of children (themselves bookmarks)
922 * @type {Array} the top-level bookmarks of the PDF. 927 * @type {Array} the top-level bookmarks of the PDF.
923 */ 928 */
924 get bookmarks() { 929 get bookmarks() {
925 return this.bookmarks_; 930 return this.bookmarks_;
926 } 931 }
927 }; 932 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/browser_api.js ('k') | chrome/browser/resources/pdf/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698