From 8a09cf5369cae07136ca8de92eba4aebd8c395f4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 27 Aug 2015 22:08:25 +0800 Subject: [PATCH] Add webFrame.setZoomLevelLimits API --- atom/renderer/api/atom_api_web_frame.cc | 5 +++++ atom/renderer/api/atom_api_web_frame.h | 2 ++ docs/api/web-frame.md | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index d2c4ed2fa7b0..6e2054453a79 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -50,6 +50,10 @@ double WebFrame::GetZoomFactor() const { return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel()); } +void WebFrame::SetZoomLevelLimits(double min_level, double max_level) { + web_frame_->view()->setDefaultPageScaleLimits(min_level, max_level); +} + v8::Local WebFrame::RegisterEmbedderCustomElement( const base::string16& name, v8::Local options) { blink::WebExceptionCode c = 0; @@ -102,6 +106,7 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder( .SetMethod("getZoomLevel", &WebFrame::GetZoomLevel) .SetMethod("setZoomFactor", &WebFrame::SetZoomFactor) .SetMethod("getZoomFactor", &WebFrame::GetZoomFactor) + .SetMethod("setZoomLevelLimits", &WebFrame::SetZoomLevelLimits) .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 26b8178e98ab..f3895353b97c 100644 --- a/atom/renderer/api/atom_api_web_frame.h +++ b/atom/renderer/api/atom_api_web_frame.h @@ -41,6 +41,8 @@ class WebFrame : public mate::Wrappable { double SetZoomFactor(double factor); double GetZoomFactor() const; + void SetZoomLevelLimits(double min_level, double max_level); + v8::Local RegisterEmbedderCustomElement( const base::string16& name, v8::Local options); void RegisterElementResizeCallback( diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index e0b04bfe3f08..810c31a4ecdd 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -32,6 +32,13 @@ limits of 300% and 50% of original size, respectively. Returns the current zoom level. +## webFrame.setZoomLevelLimits(minimumLevel, maximumLevel) + +* `minimumLevel` Number +* `maximumLevel` Number + +Sets the maximum and minimum zoom level. + ## webFrame.setSpellCheckProvider(language, autoCorrectWord, provider) * `language` String