Permalink
Browse files

QtWebEngine: Restore Qt 5.6 compatibility

  • Loading branch information...
The-Compiler committed Aug 4, 2016
1 parent 029ea2e commit 94cf3fa4ff1f040329f177dbee30cd8204908fd9
@@ -149,7 +149,7 @@
|<<content-allow-images,allow-images>>|Whether images are automatically loaded in web pages.
|<<content-allow-javascript,allow-javascript>>|Enables or disables the running of JavaScript programs.
|<<content-allow-plugins,allow-plugins>>|Enables or disables plugins in Web pages.
-|<<content-webgl,webgl>>|Enables or disables WebGL.
+|<<content-webgl,webgl>>|Enables or disables WebGL. For QtWebEngine, Qt/PyQt >= 5.7 is required for this setting.
|<<content-css-regions,css-regions>>|Enable or disable support for CSS regions.
|<<content-hyperlink-auditing,hyperlink-auditing>>|Enable or disable hyperlink auditing (<a ping>).
|<<content-geolocation,geolocation>>|Allow websites to request geolocations.
@@ -1377,7 +1377,7 @@ Default: +pass:[false]+
[[content-webgl]]
=== webgl
-Enables or disables WebGL.
+Enables or disables WebGL. For QtWebEngine, Qt/PyQt >= 5.7 is required for this setting.
Valid values:
@@ -110,8 +110,6 @@ def init():
Attribute(QWebEngineSettings.JavascriptCanAccessClipboard),
'allow-plugins':
Attribute(QWebEngineSettings.PluginsEnabled),
- 'webgl':
- Attribute(QWebEngineSettings.WebGLEnabled),
'hyperlink-auditing':
Attribute(QWebEngineSettings.HyperlinkAuditingEnabled),
'local-content-can-access-remote-urls':
@@ -183,3 +181,9 @@ def init():
setter=QWebEngineSettings.setDefaultTextEncoding),
}
}
+
+try:
+ MAPPINGS['content']['webgl'] = Attribute(QWebEngineSettings.WebGLEnabled)
+except AttributeError:
+ # Added in Qt 5.7
+ pass
@@ -348,10 +348,17 @@ def dump_async(self, callback, *, plain=False):
def run_js_async(self, code, callback=None):
world = QWebEngineScript.ApplicationWorld
- if callback is None:
- self._widget.page().runJavaScript(code, world)
- else:
- self._widget.page().runJavaScript(code, world, callback)
+ try:
+ if callback is None:
+ self._widget.page().runJavaScript(code, world)
+ else:
+ self._widget.page().runJavaScript(code, world, callback)
+ except TypeError:
+ # Qt < 5.7
+ if callback is None:
+ self._widget.page().runJavaScript(code)
+ else:
+ self._widget.page().runJavaScript(code, callback)
def run_js_blocking(self, code):
unset = object()
@@ -775,7 +775,8 @@ def data(readonly=False):
('webgl',
SettingValue(typ.Bool(), 'false'),
- "Enables or disables WebGL."),
+ "Enables or disables WebGL. For QtWebEngine, Qt/PyQt >= 5.7 is "
+ "required for this setting."),
('css-regions',
SettingValue(typ.Bool(), 'true',

0 comments on commit 94cf3fa

Please sign in to comment.