Skip to content
Commit 8ec324c8 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Documentation view: fix overriding CSS on Web Engine pages

The current runJavaScript()-based code doesn't work for two reasons:
1. The URL passed to StandardDocumentationView::setOverrideCss() always
points to a local file (file:///) in practice. Qt WebEngine does not
allow loading such local resources.
2. 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.

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.
parent 1cc6f7d6
Pipeline #195830 passed with stage
in 26 minutes and 56 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment