Index: chrome/browser/resources/pdf/pdf.js |
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js |
index 97b7fa095aed2354f975e821e937f50c8b7af3ba..5a1821bc59cad0e216d9966a3901edfa53198b0d 100644 |
--- a/chrome/browser/resources/pdf/pdf.js |
+++ b/chrome/browser/resources/pdf/pdf.js |
@@ -52,6 +52,23 @@ function onNavigateInNewTab(url) { |
} |
/** |
+ * Whether keydown events should currently be ignored. Events are ignored when |
+ * an editable element has focus, to allow for proper editing controls. |
+ * @param {HTMLElement} activeElement The currently selected DOM node. |
+ * @return {boolean} True if keydown events should be ignored. |
+ */ |
+function shouldIgnoreKeyEvents(activeElement) { |
+ while (activeElement.shadowRoot != null && |
+ activeElement.shadowRoot.activeElement != null) { |
+ activeElement = activeElement.shadowRoot.activeElement; |
+ } |
+ |
+ return (activeElement.isContentEditable || |
+ activeElement.tagName == 'INPUT' || |
+ activeElement.tagName == 'TEXTAREA'); |
+} |
+ |
+/** |
* The minimum number of pixels to offset the toolbar by from the bottom and |
* right side of the screen. |
*/ |
@@ -206,6 +223,9 @@ PDFViewer.prototype = { |
// Certain scroll events may be sent from outside of the extension. |
var fromScriptingAPI = e.fromScriptingAPI; |
+ if (shouldIgnoreKeyEvents(document.activeElement) || e.defaultPrevented) |
+ return; |
+ |
var pageUpHandler = function() { |
// Go to the previous page if we are fit-to-page. |
if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { |
@@ -623,7 +643,7 @@ PDFViewer.prototype = { |
// Update the page indicator. |
var visiblePage = this.viewport_.getMostVisiblePage(); |
if (this.isMaterial_) { |
- this.materialToolbar_.pageIndex = visiblePage; |
+ this.materialToolbar_.pageNo = visiblePage + 1; |
} else { |
this.pageIndicator_.index = visiblePage; |
if (this.documentDimensions_.pageDimensions.length > 1 && |