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

Use native WebKit on macOS #713

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

c-alpha
Copy link
Member

@c-alpha c-alpha commented Aug 9, 2021

WebKitGTK is a nightmare to build on macOS. It takes hours to compile (literally), it needs patches, and it doubles up functionality that is already available on the platform.

Hence, it would seem tempting to try to use the native WebKit that ships with the macOS platform. This is what this PR attempts.

I plan to do this in two steps:

  • [Phase 1] Refactor existing code to remove all WebKit references from header files.
    Move anything specific to WebKitGTK from the header to the corresponding implementation file using the C++ PIMPL pattern. If everything works ok, this should produce an executable that works identically to before the refactoring.
  • [Phase 2] Reimplement the classes affected by Phase 1 to use WKWebView on macOS.
    As all the public class interfaces have been freed from WebKitGtk references in the previous phase, I can start adding macOS-specific class implementations, that implement the public class interface (using ObjC++), but use a native WKWebView. Whether these new files, or the "standard" ones for Linux are compiled will be determined by the CMakeLists.txt build specs.

A key challenge will of course be to hook the WKWebView into the hierarchy of Gtk graphics objects. For sure, somewhere deep down the Gtk implementation there must be a pointer or reference to some macOS native window or similar. Perhaps I can find a way to access that, and hook the WKWebView up with that. Fingers crossed! 🤞

Moving the pImpl declaration near the top of the class declaration so
it's easier to spot.
Making the pImpl pointer public again, because we need to use it from
the "extern C" pure functions.

Fix misspelled pImpl destructor declaration.

Re-remove default implementation assignments for the copy ctor and the
assignment operator as the compiler complains bout them.
@c-alpha
Copy link
Member Author

c-alpha commented Aug 10, 2021

thread_view.cc compiles without errors, while thread_view.hh is free from any webkit references. So far. so good.

@c-alpha
Copy link
Member Author

c-alpha commented Aug 10, 2021

Further files with webkit references are:

  • modes/thread_view/webextension/tvextension.cc
  • modes/thread_view/webextension/tvextension.hh
  • modes/thread_view/webextension/dom_utils.cc
  • modes/thread_view/webextension/dom_utils.hh
  • modes/thread_view/page_client.cc
  • modes/thread_view/page_client.hh
  • plugin/thread_view_activatable.c

The next logical target would seem page_client.cc|hh, since it is a friend class of ThreadView, and it is also the next translation unit from the above list in the build process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant