astroid icon indicating copy to clipboard operation
astroid copied to clipboard

Use native WebKit on macOS

Open c-alpha opened this issue 3 years ago • 2 comments

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! 🤞

c-alpha avatar Aug 09 '21 17:08 c-alpha

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

c-alpha avatar Aug 10 '21 23:08 c-alpha

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
  • [x] modes/thread_view/page_client.cc
  • [x] 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.

c-alpha avatar Aug 10 '21 23:08 c-alpha