From e2649ce7d82c6ab3cef9a96318805f05cead7786 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Mon, 21 Nov 2016 14:59:27 -0500 Subject: [PATCH] Add new method to set layout-based zoom level limit --- atom/renderer/api/atom_api_web_frame.cc | 5 +++++ atom/renderer/api/atom_api_web_frame.h | 1 + lib/browser/api/web-contents.js | 1 + lib/renderer/web-view/web-view.js | 1 + 4 files changed, 8 insertions(+) diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index d4cf54b684a6..d00f2deb3266 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -92,6 +92,10 @@ void WebFrame::SetZoomLevelLimits(double min_level, double max_level) { web_frame_->view()->setDefaultPageScaleLimits(min_level, max_level); } +void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) { + web_frame_->view()->zoomLimitsChanged(min_level, max_level); +} + v8::Local WebFrame::RegisterEmbedderCustomElement( const base::string16& name, v8::Local options) { blink::WebExceptionCode c = 0; @@ -228,6 +232,7 @@ void WebFrame::BuildPrototype( .SetMethod("setZoomFactor", &WebFrame::SetZoomFactor) .SetMethod("getZoomFactor", &WebFrame::GetZoomFactor) .SetMethod("setZoomLevelLimits", &WebFrame::SetZoomLevelLimits) + .SetMethod("setLayoutZoomLevelLimits", &WebFrame::SetLayoutZoomLevelLimits) .SetMethod("registerEmbedderCustomElement", &WebFrame::RegisterEmbedderCustomElement) .SetMethod("registerElementResizeCallback", diff --git a/atom/renderer/api/atom_api_web_frame.h b/atom/renderer/api/atom_api_web_frame.h index f530612a4840..37bb94ac8fae 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -46,6 +46,7 @@ class WebFrame : public mate::Wrappable { double GetZoomFactor() const; void SetZoomLevelLimits(double min_level, double max_level); + void SetLayoutZoomLevelLimits(double min_level, double max_level); v8::Local RegisterEmbedderCustomElement( const base::string16& name, v8::Local options); diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index d363bb051b8b..7e359e6c2d7f 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -100,6 +100,7 @@ WebContents.prototype.sendToAll = function (channel, ...args) { // Following methods are mapped to webFrame. const webFrameMethods = [ 'insertText', + 'setLayoutZoomLevelLimits', 'setZoomFactor', 'setZoomLevel', 'setZoomLevelLimits' diff --git a/lib/renderer/web-view/web-view.js b/lib/renderer/web-view/web-view.js index c8033bea0468..59bbbd89b141 100644 --- a/lib/renderer/web-view/web-view.js +++ b/lib/renderer/web-view/web-view.js @@ -390,6 +390,7 @@ var registerWebViewElement = function () { 'insertText', 'send', 'sendInputEvent', + 'setLayoutZoomLevelLimits', 'setZoomFactor', 'setZoomLevel', 'setZoomLevelLimits'