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

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 1162863002: Material PDF: Fix inconsistent behaviour in page selector, update styling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase mistake Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/pdf/index-material.css ('k') | chrome/test/data/pdf/basic_test_material.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 &&
« no previous file with comments | « chrome/browser/resources/pdf/index-material.css ('k') | chrome/test/data/pdf/basic_test_material.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698