diff --git a/doc/install.asciidoc b/doc/install.asciidoc index 4564a8dde..7f473c6a4 100644 --- a/doc/install.asciidoc +++ b/doc/install.asciidoc @@ -170,11 +170,11 @@ Make sure you have `python3_4` in your `PYTHON_TARGETS` (`/etc/portage/make.conf`) and rebuild your system (`emerge -uDNav @world`) if necessary. -It's also recommended to install QtWebKit-NG via -https://gist.github.com/annulen/309569fb61e5d64a703c055c1e726f71[this ebuild], -or install Qt >= 5.7.1 with QtWebEngine in order to use an up-to-date backend. +You'll also need to install `dev-qt/qtwebengine` or a newer QtWebKit using +https://gist.github.com/annulen/309569fb61e5d64a703c055c1e726f71[this ebuild]. -If video or sound don't seem to work, try installing the gstreamer plugins: +If video or sound don't work with QtWebKit, try installing the gstreamer +plugins: ---- # emerge -av gst-plugins-{base,good,bad,ugly,libav} @@ -219,6 +219,8 @@ On openSUSE There are prebuilt RPMs available at https://software.opensuse.org/download.html?project=network&package=qutebrowser[OBS]. +To use the QtWebEngine backend, install `libqt5-qtwebengine`. + On OpenBSD ---------- diff --git a/pytest.ini b/pytest.ini index ae9d914e5..d47c173f7 100644 --- a/pytest.ini +++ b/pytest.ini @@ -19,8 +19,6 @@ markers = qtwebengine_todo: Features still missing with QtWebEngine qtwebengine_skip: Tests not applicable with QtWebEngine qtwebkit_skip: Tests not applicable with QtWebKit - qtwebkit_ng_xfail: Tests failing with QtWebKit-NG - qtwebkit_ng_skip: Tests skipped with QtWebKit-NG qtwebengine_flaky: Tests which are flaky (and currently skipped) with QtWebEngine qtwebengine_mac_xfail: Tests which fail on macOS with QtWebEngine js_prompt: Tests needing to display a javascript prompt diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 9278e0a0c..e0b73100c 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -332,17 +332,6 @@ def _open_special_pages(args): tabbed_browser = objreg.get('tabbed-browser', scope='window', window='last-focused') - # Legacy QtWebKit warning - - needs_warning = (objects.backend == usertypes.Backend.QtWebKit and - not qtutils.is_qtwebkit_ng()) - warning_shown = general_sect.get('backend-warning-shown') == '1' - - if not warning_shown and needs_warning: - tabbed_browser.tabopen(QUrl('qute://backend-warning'), - background=False) - general_sect['backend-warning-shown'] = '1' - # Quickstart page quickstart_done = general_sect.get('quickstart-done') == '1' diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 478769a85..d4b575260 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -224,50 +224,13 @@ def qute_history(url): return 'text/html', json.dumps(history_data(start_time, offset)) else: - if ( - config.val.content.javascript.enabled and - (objects.backend == usertypes.Backend.QtWebEngine or - qtutils.is_qtwebkit_ng()) - ): - return 'text/html', jinja.render( - 'history.html', - title='History', - gap_interval=config.val.history_gap_interval - ) - else: - # Get current date from query parameter, if not given choose today. - curr_date = datetime.date.today() - try: - query_date = QUrlQuery(url).queryItemValue("date") - if query_date: - curr_date = datetime.datetime.strptime(query_date, - "%Y-%m-%d").date() - except ValueError: - log.misc.debug("Invalid date passed to qute:history: " + - query_date) - - one_day = datetime.timedelta(days=1) - next_date = curr_date + one_day - prev_date = curr_date - one_day - - # start_time is the last second of curr_date - start_time = time.mktime(next_date.timetuple()) - 1 - history = [ - (i["url"], i["title"], - datetime.datetime.fromtimestamp(i["time"]), - QUrl(i["url"]).host()) - for i in history_data(start_time) - ] - - return 'text/html', jinja.render( - 'history_nojs.html', - title='History', - history=history, - curr_date=curr_date, - next_date=next_date, - prev_date=prev_date, - today=datetime.date.today(), - ) + if not config.val.content.javascript.enabled: + return 'text/plain', b'JavaScript is required for qute://history' + return 'text/html', jinja.render( + 'history.html', + title='History', + gap_interval=config.val.history_gap_interval + ) @add_handler('javascript') diff --git a/qutebrowser/browser/webkit/tabhistory.py b/qutebrowser/browser/webkit/tabhistory.py index 19e4ef15c..d595a6e95 100644 --- a/qutebrowser/browser/webkit/tabhistory.py +++ b/qutebrowser/browser/webkit/tabhistory.py @@ -25,13 +25,7 @@ from PyQt5.QtCore import QByteArray, QDataStream, QIODevice, QUrl from qutebrowser.utils import qtutils -def _encode_url(url): - """Encode a QUrl suitable to pass to QWebHistory.""" - data = bytes(QUrl.toPercentEncoding(url.toString(), b':/#?&+=@%*')) - return data.decode('ascii') - - -def _serialize_ng(items, current_idx, stream): +def _serialize_items(items, current_idx, stream): # {'currentItemIndex': 0, # 'history': [{'children': [], # 'documentSequenceNumber': 1485030525573123, @@ -47,13 +41,13 @@ def _serialize_ng(items, current_idx, stream): # 'urlString': 'about:blank'}]} data = {'currentItemIndex': current_idx, 'history': []} for item in items: - data['history'].append(_serialize_item_ng(item)) + data['history'].append(_serialize_item(item)) stream.writeInt(3) # history stream version stream.writeQVariantMap(data) -def _serialize_item_ng(item): +def _serialize_item(item): data = { 'originalURLString': item.original_url.toString(QUrl.FullyEncoded), 'scrollPosition': {'x': 0, 'y': 0}, @@ -68,82 +62,6 @@ def _serialize_item_ng(item): return data -def _serialize_old(items, current_idx, stream): - ### Source/WebKit/qt/Api/qwebhistory.cpp operator<< - stream.writeInt(2) # history stream version - stream.writeInt(len(items)) - stream.writeInt(current_idx) - - for i, item in enumerate(items): - _serialize_item_old(i, item, stream) - - -def _serialize_item_old(i, item, stream): - """Serialize a single WebHistoryItem into a QDataStream. - - Args: - i: The index of the current item. - item: The WebHistoryItem to write. - stream: The QDataStream to write to. - """ - ### Source/WebCore/history/qt/HistoryItemQt.cpp restoreState - ## urlString - stream.writeQString(_encode_url(item.url)) - ## title - stream.writeQString(item.title) - ## originalURLString - stream.writeQString(_encode_url(item.original_url)) - - ### Source/WebCore/history/HistoryItem.cpp decodeBackForwardTree - ## backForwardTreeEncodingVersion - stream.writeUInt32(2) - ## size (recursion stack) - stream.writeUInt64(0) - ## node->m_documentSequenceNumber - # If two HistoryItems have the same document sequence number, then they - # refer to the same instance of a document. Traversing history from one - # such HistoryItem to another preserves the document. - stream.writeInt64(i + 1) - ## size (node->m_documentState) - stream.writeUInt64(0) - ## node->m_formContentType - # info used to repost form data - stream.writeQString(None) - ## hasFormData - stream.writeBool(False) - ## node->m_itemSequenceNumber - # If two HistoryItems have the same item sequence number, then they are - # clones of one another. Traversing history from one such HistoryItem to - # another is a no-op. HistoryItem clones are created for parent and - # sibling frames when only a subframe navigates. - stream.writeInt64(i + 1) - ## node->m_referrer - stream.writeQString(None) - ## node->m_scrollPoint (x) - try: - stream.writeInt32(item.user_data['scroll-pos'].x()) - except (KeyError, TypeError): - stream.writeInt32(0) - ## node->m_scrollPoint (y) - try: - stream.writeInt32(item.user_data['scroll-pos'].y()) - except (KeyError, TypeError): - stream.writeInt32(0) - ## node->m_pageScaleFactor - stream.writeFloat(1) - ## hasStateObject - # Support for HTML5 History - stream.writeBool(False) - ## node->m_target - stream.writeQString(None) - - ### Source/WebCore/history/qt/HistoryItemQt.cpp restoreState - ## validUserData - # We could restore the user data here, but we prefer to use the - # QWebHistoryItem API for that. - stream.writeBool(False) - - def serialize(items): """Serialize a list of QWebHistoryItems to a data stream. @@ -180,10 +98,7 @@ def serialize(items): else: current_idx = 0 - if qtutils.is_qtwebkit_ng(): - _serialize_ng(items, current_idx, stream) - else: - _serialize_old(items, current_idx, stream) + _serialize_items(items, current_idx, stream) user_data += [item.user_data for item in items] diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 42e4eaeb7..94bb7f582 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -28,7 +28,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QUrl from PyQt5.QtWidgets import QMessageBox from qutebrowser.config import configdata, configexc, configtypes, configfiles -from qutebrowser.utils import utils, objreg, message, log, usertypes, jinja +from qutebrowser.utils import utils, objreg, message, log, usertypes, jinja, qtutils from qutebrowser.misc import objects, msgbox, earlyinit from qutebrowser.commands import cmdexc, cmdutils, runners from qutebrowser.completion.models import configmodel @@ -692,12 +692,12 @@ def early_init(args): def get_backend(args): """Find out what backend to use based on available libraries.""" - from qutebrowser.utils import usertypes try: import PyQt5.QtWebKit # pylint: disable=unused-variable - webkit_available = True except ImportError: webkit_available = False + else: + webkit_available = qtutils.is_new_webkit() if args.backend is not None: backends = { diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index 0ca688faa..3810bca8c 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -51,8 +51,10 @@ class StateConfig(configparser.ConfigParser): self.add_section(sect) except configparser.DuplicateSectionError: pass - # See commit a98060e020a4ba83b663813a4b9404edb47f28ad. - self['general'].pop('fooled', None) + + deleted_keys = ['fooled', 'backend-warning-shown'] + for key in deleted_keys: + self['general'].pop(key, None) def init_save_manager(self, save_manager): """Make sure the config gets saved properly. diff --git a/qutebrowser/html/backend-warning.html b/qutebrowser/html/backend-warning.html deleted file mode 100644 index 0ba8e95ee..000000000 --- a/qutebrowser/html/backend-warning.html +++ /dev/null @@ -1,100 +0,0 @@ -{% extends "styled.html" %} - -{% block style %} -{{super()}} -.note { - font-size: smaller; - color: grey; -} - -.mono { - font-family: monospace; -} -{% endblock %} - -{% block content %} -
- You're using qutebrowser with the legacy QtWebKit backend. It's still the - default until a few remaining issues are sorted out. If you can, it's - strongly suggested to switch earlier, as legacy QtWebKit has known security - issues and also breaks things on various websites. -
- --{% if distribution.parsed == Distribution.ubuntu %} - {% if distribution.version == none %} - {{ unknown_system() }} - {% elif distribution.version >= version('17.04') %} - {{ install_webengine('python3-pyqt5.qtwebengine') }} - {% elif distribution.version >= version('16.04') %} - QtWebEngine is only available in Ubuntu's repositories since 17.04, but you can install qutebrowser via tox with tox -e mkvenv-pypi to use the new backend. - {% else %} - Unfortunately, no easy way is known to install QtWebEngine on Ubuntu < 16.04. {{ please_open_issue() }} - {% endif %} -{% elif distribution.parsed == Distribution.debian %} - {% if distribution.version == none %} - {{ unknown_system() }} - {% elif distribution.version >= version('9') %} - {{ install_webengine('python3-pyqt5.qtwebengine') }} - {% else %} - Unfortunately, no easy way is known to install QtWebEngine on Debian < 9. {{ please_open_issue() }} - {% endif %} -{% elif distribution.parsed in [Distribution.arch, Distribution.manjaro] %} - {{ install_webengine('qt5-webengine') }} -{% elif distribution.parsed == Distribution.void %} - {{ install_webengine('python-PyQt5-webengine') }} -{% elif distribution.parsed == Distribution.fedora %} - {{ install_webengine('qt5-qtwebengine') }} -{% elif distribution.parsed == Distribution.opensuse %} - {{ install_webengine('libqt5-qtwebengine') }} -{% elif distribution.parsed == Distribution.gentoo %} - {{ install_webengine('dev-qt/qtwebengine') }} -{% else %} - {{ unknown_system() }} -{% endif %} -
- --{% if distribution.parsed == Distribution.debian and distribution.version != none and distribution.version >= version('9') %} - There are unofficial QtWebKit-NG packages available. -{% elif distribution.parsed in [Distribution.ubuntu, Distribution.debian] %} - No easy way is known to install QtWebKit-NG on your system. - There are unofficial QtWebKit-NG packages available, but they are intended for Debian Unstable. - {{ please_open_issue() }} -{% elif distribution.parsed in [Distribution.arch, Distribution.manjaro] %} - With an updated qt5-webkit package, you should already get QtWebKit-NG. -{% elif distribution.parsed == Distribution.gentoo %} - There's an unofficial ebuild available. -{% else %} - {{ unknown_system() }} -{% endif %} -
- -{% endblock %} diff --git a/qutebrowser/html/history_nojs.html b/qutebrowser/html/history_nojs.html deleted file mode 100644 index bcc5663c1..000000000 --- a/qutebrowser/html/history_nojs.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends "styled.html" %} - -{% block style %} -{{super()}} -body { - max-width: 1440px; -} - -td.title { - word-break: break-all; -} - -td.time { - color: #555; - text-align: right; - white-space: nowrap; -} - -table { - margin-bottom: 30px; -} - -.date { - color: #555; - font-size: 12pt; - padding-bottom: 15px; - font-weight: bold; - text-align: left; -} - -.pagination-link { - color: #555; - font-weight: bold; - margn-bottom: 15px; - text-decoration: none; -} -{% endblock %} -{% block content %} - -- {{title}} - {{host}} - | -{{time.strftime("%X")}} | -