Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QtWebEngine backend #666

Closed
77 of 87 tasks
The-Compiler opened this issue May 11, 2015 · 19 comments
Closed
77 of 87 tasks

QtWebEngine backend #666

The-Compiler opened this issue May 11, 2015 · 19 comments
Labels
component: QtWebEngine Issues related to the QtWebEngine backend, based on Chromium. priority: 0 - high Issues which are currently the primary focus.

Comments

@The-Compiler
Copy link
Member

The-Compiler commented May 11, 2015

TODO

  • Basic backend/browsing
  • Loading status
  • Scroll position
  • Settings
    • Support to mark settings as QtWebKit/QtWebEngine only
    • Basic QWebEngineSettings
    • Proxy (blocked by Crashes with libproxy 0.14.3 #2082)
    • Custom headers (DNT/Accept-Language) (?)
    • User-stylesheet (relevant code in QupZilla: 1, 2)
    • Cookies-related settings
    • Cache-related settings
    • Private browsing
    • User agent
  • Custom cookie handling
  • Custom cache handling
  • Downloads
    • Basic downloads / unsupported content
    • Download tests
    • Downloading via hints
      • via QtNetwork
      • via QtWebEngine
    • Downloading via :download
      • via QtNetwork
      • via QtWebEngine
    • Downloading adblock filterlists
      • via QtNetwork
      • via QtWebEngine
    • MHTML downloads
  • Authentication handling
  • SSL error handling
  • Commands
    • Support to mark commands as QtWebKit/QtWebEngine only
    • Make as many commands as possible work.
      • :navigate
      • :open-editor
      • :insert-text
      • :paste-primary
  • Support for Qt 5.5+ (not going to happen, 5.6+ only)
  • Custom URL handlers (qute://*)
    • qute:settings / JS bridge
  • Host blocking
  • Hinting
    • Adjust for zoom position
    • Only show visible hints
    • frames
    • iframes
  • History
  • Sessions
  • Inspector
  • Custom error pages
  • Feature permissions (geolocation, notifications, etc)
  • Fullscreen support for videos etc.
  • Javascript:
    • log
    • alert
    • confirm
    • open window/tab (createWindow)
    • close window/tab
  • Selecting files
  • View source
  • auto-insert-mode
  • Mouse handling
    • Insert mode on click
    • Ctrl-Click / Middle-click (open links in new tab)
    • Mouse wheel zooming
    • Rocker gestures
    • Back/forward mouse buttons
  • Other customizations in WebView/WebPage subclasses
    • page background color (had some issues)
    • preventing keyboard focus during insert mode (had some issues)
  • printing (available with Qt 5.8 - :print --pdf is implemented but untested, normal printing is not implemented - also see Add initial printing support with QtWebEngine >= 5.7.0 QupZilla/qupzilla#2068)
  • Make tests run for QtWebEngine
    • end2end tests
      • get testsuite to run cleanly
      • Integrate into CI
      • Investigate why xfail(run=False) tests in caret.feature are so slow
      • Add run=False to some slow xfails or reduce wait timeout
      • Investigate unknown-broken/flaky tests
    • unittests
  • Running without QtWebKit
    • Enforcing that via CI
  • pdfjs? (though QTBUG-50556 talks about adding PDFium))
  • Showing audible tabs / muting

Notes about individual features

Hints

The hints (labels to click links via keyboard, see screenshot) are currently implemented in Python, via the QWebElement API (see hints.py and webelem.py).

Since that API doesn't exist anymore with QtWebEngine, a big part of it will have to be reimplemented in Javascript, either using QWebEnginePage::runJavaScript or QWebChannel.

  • Write more tests for :hint features (see hints.feature)
  • Write more HTML hint tests (see simple.html)
  • Split current HintManager class (see hints.py) into separate classes for finding elements/drawing labels/clicking elements
  • Start implementing those parts in javascript
@addisonamiri
Copy link

I'd like this feature a lot. There's only one open source blink-based browser I know of (chromium) so you'll be doubling the number :D

@The-Compiler
Copy link
Member Author

For the lack of a better place to put this - here's a great example by Kovid Goyal on how to use QtWebChannel:

#!/usr/bin/env python3
# vim:fileencoding=utf-8

from PyQt5.Qt import *

qwebchannel_js = QFile(':/qtwebchannel/qwebchannel.js')
if not qwebchannel_js.open(QIODevice.ReadOnly):
    raise SystemExit(
        'Failed to load qwebchannel.js with error: %s' %
        qwebchannel_js.errorString())
qwebchannel_js = bytes(qwebchannel_js.readAll()).decode('utf-8')


def client_script():
    script = QWebEngineScript()
    script.setSourceCode(qwebchannel_js + '''
    new QWebChannel(qt.webChannelTransport, function(channel) {
        channel.objects.bridge.print('Hello world!');
    });
''')
    script.setName('xxx')
    script.setWorldId(QWebEngineScript.MainWorld)
    script.setInjectionPoint(QWebEngineScript.DocumentReady)
    script.setRunsOnSubFrames(True)
    return script


class WebPage(QWebEnginePage):

    def javaScriptConsoleMessage(self, level, msg, linenumber, source_id):
        try:
            print('%s:%s: %s' % (source_id, linenumber, msg))
        except OSError:
            pass

    @pyqtSlot(str)
    def print(self, text):
        print('From JS:', text)


app = QApplication([])
p = WebPage()
v = QWebEngineView()
v.setPage(p)
p.profile().scripts().insert(client_script())
c = QWebChannel(p)
p.setWebChannel(c)
c.registerObject('bridge', p)
v.setHtml('<p>Hello world!')
v.show()
app.exec_()

@vyp
Copy link
Contributor

vyp commented Oct 12, 2015

Not sure if this is the right place but I just wanted to point out https://wiki.qt.io/New_Features_in_Qt_5.6#Removed_Modules. Not sure what that means for qutebrowser though.

@The-Compiler
Copy link
Member Author

@vyp See my answer to the Archlinux BBS (and the comment on the Phoronix post quoted there).

@vyp
Copy link
Contributor

vyp commented Oct 12, 2015

@The-Compiler Oh I didn't know about that, sorry! Also, I'm not blaming you, just trying to point out information which may be helpful.

But I guess all this means is that as long as distributions continue to package qtwebkit, this shouldn't be an issue.

@The-Compiler
Copy link
Member Author

No worries - I just got into a bit of rage-mode there because of the Phoronix commenter 😉

But I guess all this means is that as long as distributions continue to package qtwebkit, this shouldn't be an issue.

Indeed. And looking at how much still is using QtWebKit, I'm quite sure they'll continue packaging it rather than dropping all that.

@The-Compiler
Copy link
Member Author

The-Compiler commented Jun 13, 2016

Refactoring notes

Currently working on refactoring everything QtWebKit-specific - some random notes here:

  • Can we simplify the WebView.url_text_changed signal, get rid of it, or move it to webkittab.py?
  • How much of webview.py should go to webkittab.py?
  • A lot of FIXME:qtwebengine tags in source files

@The-Compiler
Copy link
Member Author

The qtwebengine branch got merged today, so now you can do --backend webengine to use QtWebEngine in master - however a lot of stuff will still be broken 😉

@The-Compiler
Copy link
Member Author

@artur-shaik Would you be interested in working on caret browsing for QtWebEngine by any chance?

Since the related web actions aren't available like in QtWebKit, you'd need to do it all in JS - you can add a new file to javascript/ like I did with scroll.js, and then you'd need to implement WebEngineCaret in webenginetab.py.

Then you can call functions from that file similar to what I did in b78b89f.

@artur-shaik
Copy link
Contributor

@The-Compiler, unfortunatly I'm quite busy right now. Not sure how long I will be busy, but if nobody will do it I can try to implement this when I will have some free time.

@The-Compiler
Copy link
Member Author

Okay, thanks for the update - anyone else with a bit more JS knowledge than me stepping up? 😉

@lahwaacz
Copy link
Contributor

There are couple of things that currently don't work with webengine and are not listed above:

  1. Special mouse buttons for going backward/forward in history. Works out of the box with QtWebkit and in Chromium.
  2. Webengine does not understand the qute:// scheme, so e.g. :help does not work.

@The-Compiler
Copy link
Member Author

"Custom URL handlers" is there. I added "Other customizations in WebView/WebPage subclasses" where the mouse buttons are included.

@cosminadrianpopescu
Copy link
Contributor

@The-Compiler
I am interested in doing the WebCaret part and also the proxy for QtWebEngine if nobody is working on it. Please let me know.

@The-Compiler
Copy link
Member Author

The caret part would be nice, but I think it involves a lot of javascript as the needed feature doesn't exist for QtWebEngine at all...

As for the proxy we're currently dealing with weird proxy-related crashes (see e.g. libproxy/libproxy#45 and #1891 (comment)) so I'd like to avoid adding new code for that currently.

@cosminadrianpopescu
Copy link
Contributor

I don't mind the javascript part. I am ok with javascript, in general.

@The-Compiler
Copy link
Member Author

I started some work on fullscreen videos in the webengine-fullscreen branch, but exiting fullscreen doesn't work like it should yet - I haven't found out how QupZilla handled this yet.

@Ninja3047
Copy link

They create a key event handler in webview that checks if the escape key is pressed and then it triggers the ExitFullscreen action.

void WebView::_keyReleaseEvent(QKeyEvent *event)
{
    if (mApp->plugins()->processKeyRelease(Qz::ON_WebView, this, event)) {
        event->accept();
    }

    switch (event->key()) {
    case Qt::Key_Escape:
        if (isFullScreen()) {
            triggerPageAction(QWebEnginePage::ExitFullScreen);
            event->accept();
        }
        break;

    default:
        break;
    }
}

https://github.com/QupZilla/qupzilla/blob/master/src/lib/webengine/webview.cpp (Line 1144)

The-Compiler added a commit that referenced this issue Feb 4, 2017
@The-Compiler The-Compiler added the component: QtWebEngine Issues related to the QtWebEngine backend, based on Chromium. label Feb 20, 2017
@The-Compiler
Copy link
Member Author

Many of the missing features are implemented with the upcoming v0.10.0 release (see the changelog), and I think it's time to close this! 🎉

For the things which are still missing, I opened separate issues, see this search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: QtWebEngine Issues related to the QtWebEngine backend, based on Chromium. priority: 0 - high Issues which are currently the primary focus.
Projects
None yet
Development

No branches or pull requests

7 participants