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

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

Issue 2503633002: Propagate browser zoom changes to embedded PDFs. (Closed)
Patch Set: Apply internal pdf zoom to browser zoom. Created 4 years, 1 month 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 this.viewport_ = new Viewport(window, 134 this.viewport_ = new Viewport(window,
135 this.sizer_, 135 this.sizer_,
136 this.viewportChanged_.bind(this), 136 this.viewportChanged_.bind(this),
137 this.beforeZoom_.bind(this), 137 this.beforeZoom_.bind(this),
138 this.afterZoom_.bind(this), 138 this.afterZoom_.bind(this),
139 getScrollbarWidth(), 139 getScrollbarWidth(),
140 this.browserApi_.getDefaultZoom(), 140 this.browserApi_.getInitialZoom(),
raymes 2016/11/17 00:59:57 Hmm, how come you're changing this to InitialZoom
Sam McNally 2016/11/18 04:59:23 The reason for the default zoom was for PDFs we wa
Kevin McNee 2016/11/22 23:17:32 Right. If the tab the pdf is in has been zoomed, w
Sam McNally 2016/11/28 07:25:13 For non-embedded PDFs we still want to use the def
Kevin McNee 2016/11/28 16:18:44 Yes, if it's not embedded, we set the zoom mode to
Kevin McNee 2016/11/28 17:03:32 Done.
141 topToolbarHeight); 141 topToolbarHeight);
142 142
143 // Create the plugin object dynamically so we can set its src. The plugin 143 // 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 144 // 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 145 // positioning, acting as a viewport. The plugin renders into this viewport
146 // according to the scroll position of the window. 146 // according to the scroll position of the window.
147 this.plugin_ = document.createElement('embed'); 147 this.plugin_ = document.createElement('embed');
148 // NOTE: The plugin's 'id' field must be set to 'plugin' since 148 // NOTE: The plugin's 'id' field must be set to 'plugin' since
149 // chrome/renderer/printing/print_web_view_helper.cc actually references it. 149 // chrome/renderer/printing/print_web_view_helper.cc actually references it.
150 this.plugin_.id = 'plugin'; 150 this.plugin_.id = 'plugin';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 var disposition = 223 var disposition =
224 e.detail.newtab ? Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB : 224 e.detail.newtab ? Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB :
225 Navigator.WindowOpenDisposition.CURRENT_TAB; 225 Navigator.WindowOpenDisposition.CURRENT_TAB;
226 this.navigator_.navigate(e.detail.uri, disposition); 226 this.navigator_.navigate(e.detail.uri, disposition);
227 }.bind(this)); 227 }.bind(this));
228 228
229 this.toolbarManager_ = 229 this.toolbarManager_ =
230 new ToolbarManager(window, this.toolbar_, this.zoomToolbar_); 230 new ToolbarManager(window, this.toolbar_, this.zoomToolbar_);
231 231
232 // Set up the ZoomManager. 232 // Set up the ZoomManager.
233 this.zoomManager_ = new ZoomManager( 233 this.zoomManager_ = ZoomManager.create(this.browserApi_.getZoomBehaviour(),
234 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_), 234 this.viewport_, this.browserApi_.setZoom.bind(this.browserApi_),
235 this.browserApi_.getInitialZoom()); 235 this.browserApi_.getInitialZoom());
236 this.browserApi_.addZoomEventListener( 236 this.browserApi_.addZoomEventListener(
237 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_)); 237 this.zoomManager_.onBrowserZoomChange.bind(this.zoomManager_));
238 238
239 // Setup the keyboard event listener. 239 // Setup the keyboard event listener.
240 document.addEventListener('keydown', this.handleKeyEvent_.bind(this)); 240 document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
241 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this)); 241 document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
242 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this)); 242 document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
243 243
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 * Each bookmark is an Object containing a: 918 * Each bookmark is an Object containing a:
919 * - title 919 * - title
920 * - page (optional) 920 * - page (optional)
921 * - array of children (themselves bookmarks) 921 * - array of children (themselves bookmarks)
922 * @type {Array} the top-level bookmarks of the PDF. 922 * @type {Array} the top-level bookmarks of the PDF.
923 */ 923 */
924 get bookmarks() { 924 get bookmarks() {
925 return this.bookmarks_; 925 return this.bookmarks_;
926 } 926 }
927 }; 927 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698