OLD | NEW |
---|---|
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, | 190 this.navigator_ = new Navigator(this.browserApi_.getStreamInfo().originalUrl, |
191 this.viewport_, this.paramsParser_, | 191 this.viewport_, this.paramsParser_, |
192 onNavigateInCurrentTab, onNavigateInNewTab); | 192 onNavigateInCurrentTab, onNavigateInNewTab); |
193 this.viewportScroller_ = | 193 this.viewportScroller_ = |
194 new ViewportScroller(this.viewport_, this.plugin_, window); | 194 new ViewportScroller(this.viewport_, this.plugin_, window); |
195 } | 195 } |
196 | 196 |
197 PDFViewer.prototype = { | 197 PDFViewer.prototype = { |
198 /** | 198 /** |
199 * @private | 199 * @private |
200 * Whether keydown events should currently be ignored. Events are ignored when | |
201 * an editable element has focus, to allow for proper editing controls. | |
202 * @return {boolean} True if keydown events should be ignored. | |
203 */ | |
204 shouldIgnoreKeyEvents_: function() { | |
205 var activeElement = document.activeElement; | |
206 while (activeElement.shadowRoot != null) { | |
207 activeElement = activeElement.shadowRoot.activeElement; | |
208 } | |
raymes
2015/06/02 01:12:04
nit: no {} to be consistent
tsergeant
2015/06/02 05:00:39
Done.
| |
209 | |
210 return (activeElement.isContentEditable || | |
211 activeElement.tagName == 'INPUT' || | |
212 activeElement.tagName == 'TEXTAREA'); | |
213 }, | |
raymes
2015/06/02 01:12:03
We should be able to move this out of PDFViewer an
tsergeant
2015/06/02 05:00:39
Done.
| |
214 | |
215 /** | |
216 * @private | |
200 * Handle key events. These may come from the user directly or via the | 217 * Handle key events. These may come from the user directly or via the |
201 * scripting API. | 218 * scripting API. |
202 * @param {KeyboardEvent} e the event to handle. | 219 * @param {KeyboardEvent} e the event to handle. |
203 */ | 220 */ |
204 handleKeyEvent_: function(e) { | 221 handleKeyEvent_: function(e) { |
205 var position = this.viewport_.position; | 222 var position = this.viewport_.position; |
206 // Certain scroll events may be sent from outside of the extension. | 223 // Certain scroll events may be sent from outside of the extension. |
207 var fromScriptingAPI = e.fromScriptingAPI; | 224 var fromScriptingAPI = e.fromScriptingAPI; |
208 | 225 |
226 if (this.shouldIgnoreKeyEvents_() || e.defaultPrevented) return; | |
raymes
2015/06/02 01:12:03
nit: return on a newline
tsergeant
2015/06/02 05:00:39
Done.
| |
227 | |
209 var pageUpHandler = function() { | 228 var pageUpHandler = function() { |
210 // Go to the previous page if we are fit-to-page. | 229 // Go to the previous page if we are fit-to-page. |
211 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { | 230 if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { |
212 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1); | 231 this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1); |
213 // Since we do the movement of the page. | 232 // Since we do the movement of the page. |
214 e.preventDefault(); | 233 e.preventDefault(); |
215 } else if (fromScriptingAPI) { | 234 } else if (fromScriptingAPI) { |
216 position.y -= this.viewport.size.height; | 235 position.y -= this.viewport.size.height; |
217 this.viewport.position = position; | 236 this.viewport.position = position; |
218 } | 237 } |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 * Each bookmark is an Object containing a: | 776 * Each bookmark is an Object containing a: |
758 * - title | 777 * - title |
759 * - page (optional) | 778 * - page (optional) |
760 * - array of children (themselves bookmarks) | 779 * - array of children (themselves bookmarks) |
761 * @type {Array} the top-level bookmarks of the PDF. | 780 * @type {Array} the top-level bookmarks of the PDF. |
762 */ | 781 */ |
763 get bookmarks() { | 782 get bookmarks() { |
764 return this.bookmarks_; | 783 return this.bookmarks_; |
765 } | 784 } |
766 }; | 785 }; |
OLD | NEW |