Stop using view-source: scheme for Pygments-highlighted URLs
Doing so causes QtWebEngine to load its own view-source: page even if we supply custom data. Instead we pass the original page's URL (to not regress #2948). This partially reverts #3521 and reintroduces TabData.viewing_source. However, on QtWebEngine we can still ":view-source --pygments" and then ":view-source" (with or without "--pygments") again, because the bit gets cleaned in _on_load_started. See #3654.
This commit is contained in:
parent
6e23a6b958
commit
f052eff038
@ -99,6 +99,8 @@ class TabData:
|
|||||||
keep_icon: Whether the (e.g. cloned) icon should not be cleared on page
|
keep_icon: Whether the (e.g. cloned) icon should not be cleared on page
|
||||||
load.
|
load.
|
||||||
inspector: The QWebInspector used for this webview.
|
inspector: The QWebInspector used for this webview.
|
||||||
|
viewing_source: Set if we're currently showing a source view.
|
||||||
|
Only used when sources are shown via pygments.
|
||||||
open_target: Where to open the next link.
|
open_target: Where to open the next link.
|
||||||
Only used for QtWebKit.
|
Only used for QtWebKit.
|
||||||
override_target: Override for open_target for fake clicks (like hints).
|
override_target: Override for open_target for fake clicks (like hints).
|
||||||
@ -110,6 +112,7 @@ class TabData:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
keep_icon = attr.ib(False)
|
keep_icon = attr.ib(False)
|
||||||
|
viewing_source = attr.ib(False)
|
||||||
inspector = attr.ib(None)
|
inspector = attr.ib(None)
|
||||||
open_target = attr.ib(usertypes.ClickTarget.normal)
|
open_target = attr.ib(usertypes.ClickTarget.normal)
|
||||||
override_target = attr.ib(None)
|
override_target = attr.ib(None)
|
||||||
@ -173,12 +176,9 @@ class AbstractAction:
|
|||||||
tb = objreg.get('tabbed-browser', scope='window',
|
tb = objreg.get('tabbed-browser', scope='window',
|
||||||
window=self._tab.win_id)
|
window=self._tab.win_id)
|
||||||
new_tab = tb.tabopen(background=False, related=True)
|
new_tab = tb.tabopen(background=False, related=True)
|
||||||
# The original URL becomes the path of a view-source: URL
|
new_tab.set_html(highlighted, self._tab.url())
|
||||||
# (without a host), but query/fragment should stay.
|
new_tab.data.viewing_source = True
|
||||||
url = QUrl('view-source:' + urlstr)
|
|
||||||
new_tab.set_html(highlighted, url)
|
|
||||||
|
|
||||||
urlstr = self._tab.url().toString(QUrl.RemoveUserInfo)
|
|
||||||
self._tab.dump_async(show_source_cb)
|
self._tab.dump_async(show_source_cb)
|
||||||
|
|
||||||
|
|
||||||
@ -817,6 +817,7 @@ class AbstractTab(QWidget):
|
|||||||
def _on_load_started(self):
|
def _on_load_started(self):
|
||||||
self._progress = 0
|
self._progress = 0
|
||||||
self._has_ssl_errors = False
|
self._has_ssl_errors = False
|
||||||
|
self.data.viewing_source = False
|
||||||
self._set_load_status(usertypes.LoadStatus.loading)
|
self._set_load_status(usertypes.LoadStatus.loading)
|
||||||
self.load_started.emit()
|
self.load_started.emit()
|
||||||
|
|
||||||
|
@ -1531,7 +1531,8 @@ class CommandDispatcher:
|
|||||||
except cmdexc.CommandError as e:
|
except cmdexc.CommandError as e:
|
||||||
message.error(str(e))
|
message.error(str(e))
|
||||||
return
|
return
|
||||||
if current_url.scheme() == 'view-source':
|
|
||||||
|
if current_url.scheme() == 'view-source' or tab.data.viewing_source:
|
||||||
raise cmdexc.CommandError("Already viewing source!")
|
raise cmdexc.CommandError("Already viewing source!")
|
||||||
|
|
||||||
if edit:
|
if edit:
|
||||||
|
Loading…
Reference in New Issue
Block a user