Commit f0db15c1 authored by raymes's avatar raymes Committed by Commit bot

Make pinch-zoom work for OOP PDF

There are two changes to make this work:
-Set the plugins width/height to 100%. We will soon be using this for the material layout as well.
-Allow MimeHandlerViewGuests to handle pinch gestures when they are full-page plugins.

BUG=453729

Review URL: https://codereview.chromium.org/904553002

Cr-Commit-Position: refs/heads/master@{#314742}
parent 7208f4b6
...@@ -34,7 +34,9 @@ viewer-password-screen { ...@@ -34,7 +34,9 @@ viewer-password-screen {
} }
#plugin { #plugin {
height: 100%;
position: fixed; position: fixed;
width: 100%;
z-index: 1; z-index: 1;
} }
......
...@@ -108,9 +108,6 @@ function PDFViewer(streamDetails) { ...@@ -108,9 +108,6 @@ function PDFViewer(streamDetails) {
this.plugin_.type = 'application/x-google-chrome-pdf'; this.plugin_.type = 'application/x-google-chrome-pdf';
this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this), this.plugin_.addEventListener('message', this.handlePluginMessage_.bind(this),
false); false);
this.plugin_.style.height =
(window.innerHeight - this.toolbarHeight_) + 'px';
this.plugin_.style.width = window.innerWidth + 'px';
if (this.isMaterial_) if (this.isMaterial_)
this.plugin_.setAttribute('is-material', ''); this.plugin_.setAttribute('is-material', '');
...@@ -580,16 +577,6 @@ PDFViewer.prototype = { ...@@ -580,16 +577,6 @@ PDFViewer.prototype = {
* A callback that's called after the viewport changes. * A callback that's called after the viewport changes.
*/ */
viewportChanged_: function() { viewportChanged_: function() {
var hasScrollbars = this.viewport_.documentHasScrollbars();
var scrollbarWidth = this.viewport_.scrollbarWidth;
var verticalScrollbarWidth = hasScrollbars.vertical ? scrollbarWidth : 0;
var horizontalScrollbarWidth =
hasScrollbars.horizontal ? scrollbarWidth : 0;
this.plugin_.style.width =
(window.innerWidth - verticalScrollbarWidth) + 'px';
this.plugin_.style.height = (window.innerHeight -
horizontalScrollbarWidth - this.toolbarHeight_) + 'px';
if (!this.documentDimensions_) if (!this.documentDimensions_)
return; return;
...@@ -604,6 +591,11 @@ PDFViewer.prototype = { ...@@ -604,6 +591,11 @@ PDFViewer.prototype = {
} }
// Offset the toolbar position so that it doesn't move if scrollbars appear. // Offset the toolbar position so that it doesn't move if scrollbars appear.
var hasScrollbars = this.viewport_.documentHasScrollbars();
var scrollbarWidth = this.viewport_.scrollbarWidth;
var verticalScrollbarWidth = hasScrollbars.vertical ? scrollbarWidth : 0;
var horizontalScrollbarWidth =
hasScrollbars.horizontal ? scrollbarWidth : 0;
var toolbarRight = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth); var toolbarRight = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth);
var toolbarBottom = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth); var toolbarBottom = Math.max(PDFViewer.MIN_TOOLBAR_OFFSET, scrollbarWidth);
toolbarRight -= verticalScrollbarWidth; toolbarRight -= verticalScrollbarWidth;
......
...@@ -318,7 +318,7 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, ...@@ -318,7 +318,7 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
const content::FileChooserParams& params) override; const content::FileChooserParams& params) override;
bool ShouldFocusPageAfterCrash() final; bool ShouldFocusPageAfterCrash() final;
bool PreHandleGestureEvent(content::WebContents* source, bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) final; const blink::WebGestureEvent& event) override;
void UpdatePreferredSize(content::WebContents* web_contents, void UpdatePreferredSize(content::WebContents* web_contents,
const gfx::Size& pref_size) final; const gfx::Size& pref_size) final;
void UpdateTargetURL(content::WebContents* source, const GURL& url) override; void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "extensions/strings/grit/extensions_strings.h" #include "extensions/strings/grit/extensions_strings.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
using content::WebContents; using content::WebContents;
...@@ -187,6 +188,19 @@ bool MimeHandlerViewGuest::HandleContextMenu( ...@@ -187,6 +188,19 @@ bool MimeHandlerViewGuest::HandleContextMenu(
return false; return false;
} }
bool MimeHandlerViewGuest::PreHandleGestureEvent(
content::WebContents* source,
const blink::WebGestureEvent& event) {
if (event.type == blink::WebGestureEvent::GesturePinchBegin ||
event.type == blink::WebGestureEvent::GesturePinchUpdate ||
event.type == blink::WebGestureEvent::GesturePinchEnd) {
// If we're an embedded plugin we drop pinch-gestures to avoid zooming the
// guest.
return !is_full_page_plugin();
}
return false;
}
void MimeHandlerViewGuest::FindReply(content::WebContents* web_contents, void MimeHandlerViewGuest::FindReply(content::WebContents* web_contents,
int request_id, int request_id,
int number_of_matches, int number_of_matches,
......
...@@ -80,6 +80,8 @@ class MimeHandlerViewGuest : public GuestView<MimeHandlerViewGuest>, ...@@ -80,6 +80,8 @@ class MimeHandlerViewGuest : public GuestView<MimeHandlerViewGuest>,
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) override; const content::OpenURLParams& params) override;
bool HandleContextMenu(const content::ContextMenuParams& params) override; bool HandleContextMenu(const content::ContextMenuParams& params) override;
bool PreHandleGestureEvent(content::WebContents* source,
const blink::WebGestureEvent& event) override;
void FindReply(content::WebContents* web_contents, void FindReply(content::WebContents* web_contents,
int request_id, int request_id,
int number_of_matches, int number_of_matches,
......
...@@ -282,6 +282,7 @@ OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) ...@@ -282,6 +282,7 @@ OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance)
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE); RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_TOUCH);
} }
OutOfProcessInstance::~OutOfProcessInstance() { OutOfProcessInstance::~OutOfProcessInstance() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment