Add AbstractTab.set_html

This commit is contained in:
Florian Bruhin 2016-07-04 16:33:49 +02:00
parent 78f425c98b
commit 04ee021bdb
3 changed files with 13 additions and 0 deletions

View File

@ -511,6 +511,9 @@ class AbstractTab(QWidget):
def run_webaction(self, action):
raise NotImplementedError
def set_html(self, html, base_url):
raise NotImplementedError
def __repr__(self):
url = utils.elide(self.cur_url.toDisplayString(QUrl.EncodeUnicode),
100)

View File

@ -159,6 +159,13 @@ class WebEngineViewTab(tab.AbstractTab):
def run_webaction(self, action):
self._widget.triggerPageAction(action)
def set_html(self, html, base_url):
# FIXME check this and raise an exception if too big:
# Warning: The content will be percent encoded before being sent to the
# renderer via IPC. This may increase its size. The maximum size of the
# percent encoded content is 2 megabytes minus 30 bytes.
self._widget.setHtml(html, base_url)
def _connect_signals(self):
view = self._widget
page = view.page()

View File

@ -502,6 +502,9 @@ class WebViewTab(tab.AbstractTab):
def run_webaction(self, action):
self._widget.triggerPageAction(action)
def set_html(self, html, base_url):
self._widget.setHtml(html, base_url)
def _connect_signals(self):
view = self._widget
page = view.page()