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

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

Issue 2855953003: Handle long press in PDF documents. (Closed)
Patch Set: Review feedback Created 3 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 da5793d9b0dd2e09d771c67cb3c493645f3625ad..993f7b3aeaca9aa982d2baa2cdb2bfd256f0ed0a 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -245,6 +245,8 @@ function PDFViewer(browserApi) {
document.addEventListener('keydown', this.handleKeyEvent_.bind(this));
document.addEventListener('mousemove', this.handleMouseEvent_.bind(this));
document.addEventListener('mouseout', this.handleMouseEvent_.bind(this));
+ document.addEventListener('contextmenu',
+ this.handleContextMenuEvent_.bind(this));
var tabId = this.browserApi_.getStreamInfo().tabId;
this.navigator_ = new Navigator(
@@ -410,6 +412,17 @@ PDFViewer.prototype = {
this.toolbarManager_.hideToolbarsForMouseOut();
},
+ handleContextMenuEvent_: function(e) {
+ // Stop Chrome from popping up the context menu on long press. We need to
+ // make sure the start event did not have 2 touches because we don't want
+ // to block two finger tap opening the context menu. We check for
+ // firesTouchEvents in order to not block the context menu on right click.
+ if (e.sourceCapabilities.firesTouchEvents &&
+ !this.gestureDetector_.wasTwoFingerTouch()) {
+ e.preventDefault();
+ }
+ },
+
/**
* @private
* Rotate the plugin clockwise.

Powered by Google App Engine
This is Rietveld 408576698