Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new method to set layout-based zoom level limit #8041

Merged
merged 9 commits into from
Nov 22, 2016
6 changes: 6 additions & 0 deletions atom/renderer/api/atom_api_web_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Value> WebFrame::RegisterEmbedderCustomElement(
const base::string16& name, v8::Local<v8::Object> options) {
blink::WebExceptionCode c = 0;
Expand Down Expand Up @@ -228,6 +232,8 @@ 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",
Expand Down
1 change: 1 addition & 0 deletions atom/renderer/api/atom_api_web_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class WebFrame : public mate::Wrappable<WebFrame> {
double GetZoomFactor() const;

void SetZoomLevelLimits(double min_level, double max_level);
void SetLayoutZoomLevelLimits(double min_level, double max_level);

v8::Local<v8::Value> RegisterEmbedderCustomElement(
const base::string16& name, v8::Local<v8::Object> options);
Expand Down
13 changes: 12 additions & 1 deletion docs/api/web-frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@ Returns `Number` - The current zoom level.
* `minimumLevel` Number
* `maximumLevel` Number

Sets the maximum and minimum zoom level.
Sets the maximum and minimum pinch-to-zoom level. In future versions of Electron
this method will be called `setVisualZoomLevelLimits`.

### `webFrame.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)`

* `minimumLevel` Number
* `maximumLevel` Number

Sets the maximum and minimum layout-based (i.e. non-visual only) zoom level. In
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this change should be documented in

future versions of Electron this will be renamed `setZoomLevelLimits`, but the
current naming is kept for backwards-compatibility purposes.


### `webFrame.setSpellCheckProvider(language, autoCorrectWord, provider)`

Expand Down
1 change: 1 addition & 0 deletions lib/browser/api/web-contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ WebContents.prototype.sendToAll = function (channel, ...args) {
// Following methods are mapped to webFrame.
const webFrameMethods = [
'insertText',
'setLayoutZoomLevelLimits',
'setZoomFactor',
'setZoomLevel',
'setZoomLevelLimits'
Expand Down
1 change: 1 addition & 0 deletions lib/renderer/web-view/web-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ var registerWebViewElement = function () {
'insertText',
'send',
'sendInputEvent',
'setLayoutZoomLevelLimits',
'setZoomFactor',
'setZoomLevel',
'setZoomLevelLimits'
Expand Down