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

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: 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
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..ef52bbb9045d4f8221ff9835c60b946113cf32a8 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -197,6 +197,23 @@ function PDFViewer(browserApi) {
PDFViewer.prototype = {
/**
* @private
+ * Whether keydown events should currently be ignored. Events are ignored when
+ * an editable element has focus, to allow for proper editing controls.
+ * @return {boolean} True if keydown events should be ignored.
+ */
+ shouldIgnoreKeyEvents_: function() {
+ var activeElement = document.activeElement;
+ while (activeElement.shadowRoot != null) {
+ activeElement = activeElement.shadowRoot.activeElement;
+ }
raymes 2015/06/02 01:12:04 nit: no {} to be consistent
tsergeant 2015/06/02 05:00:39 Done.
+
+ return (activeElement.isContentEditable ||
+ activeElement.tagName == 'INPUT' ||
+ activeElement.tagName == 'TEXTAREA');
+ },
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.
+
+ /**
+ * @private
* Handle key events. These may come from the user directly or via the
* scripting API.
* @param {KeyboardEvent} e the event to handle.
@@ -206,6 +223,8 @@ PDFViewer.prototype = {
// Certain scroll events may be sent from outside of the extension.
var fromScriptingAPI = e.fromScriptingAPI;
+ 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.
+
var pageUpHandler = function() {
// Go to the previous page if we are fit-to-page.
if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) {

Powered by Google App Engine
This is Rietveld 408576698