Skip to content

Commit 6c5eaf6

Browse files
authored
Merge pull request electron#5923 from electron/disable-blink-features
Support disabling Blink features
2 parents 013bd00 + 02e0ca6 commit 6c5eaf6

File tree

8 files changed

+43
-7
lines changed

8 files changed

+43
-7
lines changed

atom/browser/web_contents_preferences.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
166166
command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures,
167167
blink_features);
168168

169+
// Disable blink features.
170+
std::string disable_blink_features;
171+
if (web_preferences.GetString(options::kDisableBlinkFeatures,
172+
&disable_blink_features))
173+
command_line->AppendSwitchASCII(::switches::kDisableBlinkFeatures,
174+
disable_blink_features);
175+
169176
// The initial visibility state.
170177
NativeWindow* window = NativeWindow::FromWebContents(web_contents);
171178

atom/common/options_switches.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ const char kOpenerID[] = "openerId";
107107
const char kScrollBounce[] = "scrollBounce";
108108

109109
// Enable blink features.
110+
// TODO(kevinsawicki) Rename to enableBlinkFeatures in 2.0
110111
const char kBlinkFeatures[] = "blinkFeatures";
111112

113+
// Disable blink features.
114+
const char kDisableBlinkFeatures[] = "disableBlinkFeatures";
115+
112116
} // namespace options
113117

114118
namespace switches {

atom/common/options_switches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern const char kExperimentalCanvasFeatures[];
5858
extern const char kOpenerID[];
5959
extern const char kScrollBounce[];
6060
extern const char kBlinkFeatures[];
61+
extern const char kDisableBlinkFeatures[];
6162

6263
} // namespace options
6364

docs/api/browser-window.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,13 @@ The `webPreferences` option is an object that can have following properties:
175175
* `scrollBounce` Boolean - Enables scroll bounce (rubber banding) effect on
176176
OS X. Default is `false`.
177177
* `blinkFeatures` String - A list of feature strings separated by `,`, like
178-
`CSSVariables,KeyboardEventKey`. The full list of supported feature strings
179-
can be found in the [setFeatureEnabledFromString][blink-feature-string]
180-
function.
178+
`CSSVariables,KeyboardEventKey` to enable. The full list of supported feature
179+
strings can be found in the [RuntimeEnabledFeatures.in][blink-feature-string]
180+
file.
181+
* `disableBlinkFeatures` String - A list of feature strings separated by `,`,
182+
like `CSSVariables,KeyboardEventKey` to disable. The full list of supported
183+
feature strings can be found in the
184+
[RuntimeEnabledFeatures.in][blink-feature-string] file.
181185
* `defaultFontFamily` Object - Sets the default font for the font-family.
182186
* `standard` String - Defaults to `Times New Roman`.
183187
* `serif` String - Defaults to `Times New Roman`.
@@ -938,4 +942,4 @@ All mouse events happened in this window will be passed to the window bellow
938942
this window, but if this window has focus, it will still receive keyboard
939943
events.
940944

941-
[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=576
945+
[blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in

docs/api/web-view-tag.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,17 @@ If "on", the guest page will be allowed to open new windows.
205205

206206
A list of strings which specifies the blink features to be enabled separated by `,`.
207207
The full list of supported feature strings can be found in the
208-
[setFeatureEnabledFromString][blink-feature-string] function.
208+
[RuntimeEnabledFeatures.in][blink-feature-string] file.
209+
210+
### `disableblinkfeatures`
211+
212+
```html
213+
<webview src="https://www.github.com/" disableblinkfeatures="PreciseMemoryInfo, CSSVariables"></webview>
214+
```
215+
216+
A list of strings which specifies the blink features to be disabled separated by `,`.
217+
The full list of supported feature strings can be found in the
218+
[RuntimeEnabledFeatures.in][blink-feature-string] file.
209219

210220
## Methods
211221

@@ -802,4 +812,4 @@ Emitted when DevTools is closed.
802812

803813
Emitted when DevTools is focused / opened.
804814

805-
[blink-feature-string]: https://code.google.com/p/chromium/codesearch#chromium/src/out/Debug/gen/blink/platform/RuntimeEnabledFeatures.cpp&sq=package:chromium&type=cs&l=527
815+
[blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in

lib/browser/guest-view-manager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ const attachGuest = function (embedder, elementInstanceId, guestInstanceId, para
177177
plugins: params.plugins,
178178
zoomFactor: params.zoomFactor,
179179
webSecurity: !params.disablewebsecurity,
180-
blinkFeatures: params.blinkfeatures
180+
blinkFeatures: params.blinkfeatures,
181+
disableBlinkFeatures: params.disableblinkfeatures
181182
}
182183

183184
if (params.preload) {

lib/renderer/web-view/web-view-attributes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ class BlinkFeaturesAttribute extends WebViewAttribute {
264264
}
265265
}
266266

267+
// Attribute that specifies the blink features to be disabled.
268+
class DisableBlinkFeaturesAttribute extends WebViewAttribute {
269+
constructor (webViewImpl) {
270+
super(webViewConstants.ATTRIBUTE_DISABLEBLINKFEATURES, webViewImpl)
271+
}
272+
}
273+
267274
// Sets up all of the webview attributes.
268275
WebViewImpl.prototype.setupWebViewAttributes = function () {
269276
this.attributes = {}
@@ -278,6 +285,7 @@ WebViewImpl.prototype.setupWebViewAttributes = function () {
278285
this.attributes[webViewConstants.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_ALLOWPOPUPS, this)
279286
this.attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this)
280287
this.attributes[webViewConstants.ATTRIBUTE_BLINKFEATURES] = new BlinkFeaturesAttribute(this)
288+
this.attributes[webViewConstants.ATTRIBUTE_DISABLEBLINKFEATURES] = new DisableBlinkFeaturesAttribute(this)
281289

282290
const autosizeAttributes = [webViewConstants.ATTRIBUTE_MAXHEIGHT, webViewConstants.ATTRIBUTE_MAXWIDTH, webViewConstants.ATTRIBUTE_MINHEIGHT, webViewConstants.ATTRIBUTE_MINWIDTH]
283291
autosizeAttributes.forEach((attribute) => {

lib/renderer/web-view/web-view-constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
ATTRIBUTE_PRELOAD: 'preload',
1717
ATTRIBUTE_USERAGENT: 'useragent',
1818
ATTRIBUTE_BLINKFEATURES: 'blinkfeatures',
19+
ATTRIBUTE_DISABLEBLINKFEATURES: 'disableblinkfeatures',
1920

2021
// Internal attribute.
2122
ATTRIBUTE_INTERNALINSTANCEID: 'internalinstanceid',

0 commit comments

Comments
 (0)