Documentation view: fix overriding CSS on Web Engine pages
The current runJavaScript()
-based code doesn't work for two reasons:
- The URL passed to
StandardDocumentationView::setOverrideCss()
always points to a local file (file:///
) in practice. Qt WebEngine does not allow loading such local resources. - The JavaScript code passed to
runJavaScript()
attempts to manipulate DOM but runs before the HTML document is loaded, and therefore has no effect.
Fix the local file security issue (1) by embedding CSS inline instead of referencing an external CSS file.
Fix the JavaScript execution timing issue (2) by replacing
runJavaScript()
with QWebEngineScript
injected at DocumentReady
point.
Don't override CSS in ManPageDocumentation::documentationWidget()
if the
CSS file was not found.
As far as I can tell, overriding CSS has never worked with Qt WebEngine.
So this commit restricts to Qt WebKit likely obsolete CSS workarounds in
QtHelpDocumentation::setUserStyleSheet()
, which where implemented in
245f8e98 10 years ago.
This gets rid of the following warnings in KDevelop's output:
js: Not allowed to load local resource: file:///tmp/kdevelop.qWHueg
js: Not allowed to load local resource: file:///usr/share/kdevmanpage/manpagedocumentation.css
manpagedocumentation.css is applied to man pages now: the top banner and the extra margins are removed.