Skip to content
Permalink
Browse files

fix: deprecate setLayoutZoomLevelLimits (#21296)

  • Loading branch information
nornagon committed Dec 2, 2019
1 parent c7cbc2e commit 9526c5584e93ea5cafe9e36864a3a647c1294605
@@ -114,6 +114,14 @@ const { ipcRenderer } = require('electron')
ipcRenderer.invoke('openDevTools', webview.getWebContentsId())
```

### `webFrame.setLayoutZoomLevelLimits()`

Chromium has removed support for changing the layout zoom level limits, and it
is beyond Electron's capacity to maintain it. The function will emit a warning
in Electron 8.x, and cease to exist in Electron 9.x. The layout zoom level
limits are now fixed at a minimum of 0.25 and a maximum of 5.0, as defined
[here](https://chromium.googlesource.com/chromium/src/+/938b37a6d2886bf8335fc7db792f1eb46c65b2ae/third_party/blink/common/page/page_zoom.cc#11).

## Planned Breaking API Changes (7.0)

### Node Headers URL
@@ -1113,7 +1113,7 @@ Sets the maximum and minimum pinch-to-zoom level.
> contents.setVisualZoomLevelLimits(1, 3)
> ```
#### `contents.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)`
#### `contents.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)` _Deprecated_

* `minimumLevel` Number
* `maximumLevel` Number
@@ -1122,6 +1122,8 @@ Returns `Promise<void>`

Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.

**Deprecated:** This API is no longer supported by Chromium.

#### `contents.undo()`

Executes the editing command `undo` in web page.
@@ -56,13 +56,15 @@ Sets the maximum and minimum pinch-to-zoom level.
> webFrame.setVisualZoomLevelLimits(1, 3)
> ```
### `webFrame.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)`
### `webFrame.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)` _Deprecated_

* `minimumLevel` Number
* `maximumLevel` Number

Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.

**Deprecated:** This API is no longer supported by Chromium.

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

* `language` String
@@ -635,7 +635,7 @@ Returns `Promise<void>`

Sets the maximum and minimum pinch-to-zoom level.

### `<webview>.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)`
### `<webview>.setLayoutZoomLevelLimits(minimumLevel, maximumLevel)` _Deprecated_

* `minimumLevel` Number
* `maximumLevel` Number
@@ -644,6 +644,8 @@ Returns `Promise<void>`

Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.

**Deprecated:** This API is no longer supported by Chromium.

### `<webview>.showDefinitionForSelection()` _macOS_

Shows pop-up dictionary that searches the selected word on the page.
@@ -1,7 +1,10 @@
import { EventEmitter } from 'events'
import { deprecate } from 'electron'

const binding = process.electronBinding('web_frame')

const setLayoutZoomLevelLimitsWarning = deprecate.warnOnce('setLayoutZoomLevelLimits')

class WebFrame extends EventEmitter {
constructor (public context: Window) {
super()
@@ -45,6 +48,10 @@ class WebFrame extends EventEmitter {
get routingId () {
return binding._getRoutingId(this.context)
}

setLayoutZoomLevelLimits () {
setLayoutZoomLevelLimitsWarning()
}
}

// Populate the methods.
@@ -74,7 +74,6 @@ expose_setuseragent_on_networkcontext.patch
feat_add_set_theme_source_to_allow_apps_to.patch
revert_cleanup_remove_menu_subtitles_sublabels.patch
export_fetchapi_mojo_traits_to_fix_component_build.patch
add_zoom_limit_setters_to_webcontents.patch
revert_remove_contentrendererclient_shouldfork.patch
build_win_disable_zc_twophase.patch
ignore_rc_check.patch

This file was deleted.

@@ -2316,15 +2316,6 @@ double WebContents::GetZoomFactor() const {
return blink::PageZoomLevelToZoomFactor(level);
}

void WebContents::SetZoomLimits(double min_zoom, double max_zoom) {
// Round the double to avoid returning incorrect minimum/maximum zoom
// percentages.
int minimum_percent = round(blink::PageZoomLevelToZoomFactor(min_zoom) * 100);
int maximum_percent = round(blink::PageZoomLevelToZoomFactor(max_zoom) * 100);
web_contents()->SetMinimumZoomPercent(minimum_percent);
web_contents()->SetMaximumZoomPercent(maximum_percent);
}

void WebContents::SetTemporaryZoomLevel(double level) {
zoom_controller_->SetTemporaryZoomLevel(level);
}
@@ -272,7 +272,6 @@ class WebContents : public gin_helper::TrackableObject<WebContents>,
double GetZoomLevel() const;
void SetZoomFactor(double factor);
double GetZoomFactor() const;
void SetZoomLimits(double min_zoom, double max_zoom) override;

// Callback triggered on permission response.
void OnEnterFullscreenModeForTab(
@@ -90,8 +90,6 @@ interface ElectronBrowser {

SetTemporaryZoomLevel(double zoom_level);

SetZoomLimits(double min_zoom, double max_zoom);

[Sync]
DoGetZoomLevel() => (double result);
};
@@ -264,17 +264,6 @@ void SetVisualZoomLevelLimits(v8::Local<v8::Value> window,
web_frame->View()->SetIgnoreViewportTagScaleLimits(true);
}

void SetLayoutZoomLevelLimits(v8::Local<v8::Value> window,
double min_level,
double max_level) {
content::RenderFrame* render_frame = GetRenderFrame(window);
mojom::ElectronBrowserPtr browser_ptr;
render_frame->GetRemoteInterfaces()->GetInterface(
mojo::MakeRequest(&browser_ptr));

browser_ptr->SetZoomLimits(min_level, max_level);
}

void AllowGuestViewElementDefinition(v8::Isolate* isolate,
v8::Local<v8::Value> window,
v8::Local<v8::Object> context,
@@ -580,7 +569,6 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("setZoomFactor", &SetZoomFactor);
dict.SetMethod("getZoomFactor", &GetZoomFactor);
dict.SetMethod("setVisualZoomLevelLimits", &SetVisualZoomLevelLimits);
dict.SetMethod("setLayoutZoomLevelLimits", &SetLayoutZoomLevelLimits);
dict.SetMethod("allowGuestViewElementDefinition",
&AllowGuestViewElementDefinition);
dict.SetMethod("getWebFrameId", &GetWebFrameId);
@@ -2,13 +2,6 @@ const { expect } = require('chai')
const { webFrame } = require('electron')

describe('webFrame module', function () {
it('supports setting the visual and layout zoom level limits', function () {
expect(() => {
webFrame.setVisualZoomLevelLimits(1, 50)
webFrame.setLayoutZoomLevelLimits(0, 25)
}).to.not.throw()
})

it('top is self for top frame', () => {
expect(webFrame.top.context).to.equal(webFrame.context)
})
@@ -81,7 +81,6 @@ app.on('ready', () => {
})

mainWindow.webContents.setVisualZoomLevelLimits(50, 200)
mainWindow.webContents.setLayoutZoomLevelLimits(50, 200)

mainWindow.webContents.print({ silent: true, printBackground: false })
mainWindow.webContents.print()
@@ -57,7 +57,6 @@ webFrame.setZoomLevel(200)
console.log(webFrame.getZoomLevel())

webFrame.setVisualZoomLevelLimits(50, 200)
webFrame.setLayoutZoomLevelLimits(50, 200)

webFrame.setSpellCheckProvider('en-US', {
spellCheck (words, callback) {

0 comments on commit 9526c55

Please sign in to comment.
You can’t perform that action at this time.