New version Wx::WebKit RFC

doubi on 2009-08-14T02:54:07

Submitted for your perusal, as the outcome of my Google Summer of Code efforts hitherto:

http://www.thinkollab.net/socghop/Wx-WebKit-0.01.tar.gz

The first (somewhat) working draft of a shiny new module. It's for putting a browser in your Wx apps... with a few temporary caveats.

First, it doesn't work on Windows, because wxWebKit only compiles with MSVC at the moment. So Strawberry's right out, and my ActivePerl install is GCC-built too. I'm not sure if all AP versions are (I think they used to be MSVC?) but there you go. We're going to start work on porting to GCC / MinGW, but I don't know how long that'll take.

Also, there's a bug that's only in the Gtk layer at the moment which makes it pretty unusable on Linux too <:-P You can fire it up and half-load some pages, but that's about it. You can see what it's trying to do. This bug has already been fixed, only the fix hasn't been pushed to trunk yet. It should be in the /scons branch of the wxWebKit git repo if you have the skillz and inclination to apply it yourself (although sneakily, the new build system is in fact waf, not scons.)

Building the wxWebKit binaries was a steep learning curve for me personally; it might be a lot easier for people who know what they're doing, but I've put up a Linux (Ubuntu 9.04) binary for those who want the least possible faffing about (75MB tarball mind):

http://www.thinkollab.com/socghop/wxwebkit_linuxBinary.tar.gz

Now, if anyone's still with me, there are a number of things that I'm still working on / need help with:

  1. General coding style of /Wx/DemoModules/wxWebKit.pm, suitability / readability / completeness of the pod, etc.

  2. Testing on Mac / BSD.

  3. For some reason, when I tried to change sub OnAddressBarEnter to also call SetFocus on the Wx::WebView object, it crashed with the error: "Can't locate object method "SetFocus" via package "Wx::WebView" at blib/lib/Wx/DemoModules/wxWebKit.pm line 275." (you'll see I have the line still there commented out). I went and looked through the .pm and .xs files of a number of controls in the Wx core package and couldn't see anything special or explicit that enabled them to use functions inherited from wxWindow. wxWebView is a public wxWindow as well. Anyone know what I'm missing here?

  4. The general wxWebKit API class is called wxWebView, so that's what I ran through h2xs and that's what I started hacking on at the beginning. I always thought that it'd be more convenient for users of the module to call Wx::WebKit->new, so this morning I tried to change it to that. I changed the package name in WebKit.xs, and every occurrence of 'WebView' I could find in Wx/WebKit.pm and Wx/DemoModules/wxWebKit.pm. test.pl seemed to load fine, but when I input a URL and OnAddressBarEnter eventually called $browser->LoadURL, the app crashed with the error "variable is not of type Wx::WebView at ..." and the line number of the call. I grep'd through my sources and couldn't find 'WebView' outside of the .c and .xs files, as I thought it had to be, since that's the C++ class name it's calling, so I couldn't figure what else to change (I did try changing it in the .xs out of desperation, you can guess how well that worked). When I grep'd for that error message in the Wx sources I found it in four different places in helpers.cpp, at least one of which was very near by something marked 'magic'. I've tried hard to get the inner wisdom of Wx but... it's a jungle in there. If anyone could shed some light on this one too I'd be very grateful.

  5. I haven't figured out what's involved in exposing wxWebView's special events yet. I'm going to look at Wx::ActiveX for how to do that; hopefully I'll understand what's going on, if not I'll hit it with a wrench for a while before giving up and asking here again.

So, if anyone can help with any of the above, I'd be very much obliged. Big thanks to Mattia and the wxperl-users list for all your help so far.

By the way, I've called this a 'new' module, and labelled my effort 0.01. I've made repeated reference to Dan Sugalski's existing CPAN module. I haven't been in direct contact with him about it yet but if my one works on Mac at the minute then it should be as functional as the existing one. Mac users please let me know.

Ta for now!


Version

LTjake on 2009-08-14T11:32:33

I would think, if everything goes well, your module would simply replace what Dan had done. Thus you should consider your work as a continuation of that (also, it has the same name).

I would suggest you set the version at 0.03 to follow that notion.

Cheers.

Re:Version

doubi on 2009-08-15T14:04:56

I suppose that would make more sense. Will do :)