Recent

Author Topic: Gecko (HTML engine) in Lazarus app  (Read 51577 times)

ZL

  • New Member
  • *
  • Posts: 16
Gecko (HTML engine) in Lazarus app
« on: January 14, 2009, 09:32:57 pm »
Hello all,

I managed to install GeckoSDK and GeckoComponents packages from http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/ (with minor changes to compile with Lazarus) on Windows.
And I was able to build app with Lazarus that uses these components (but there are some issues: 1. I must create browser object in runtime, because when compilling with component form window dows not show [but I believe it is solvable]; 2. submit buttons in webpages does not work [this should be solvable too]).

Ok, now about what I want to know :)
First of all I must say that I have no (programming) experience with Linux...

And... I am wondering how much GeckoSDK and GeckoComponents code is not portable.
I looked through all sources and only one unit (nsXPCOMGlue.pas) has Windows in uses. The not portable (= I don't know how to port these) functions it uses for example are:
Code: [Select]
...
SUCCEEDED(GetModuleFileName(0, buf, SizeOf(buf)))
...
ZeroMemory(@Result, SizeOf(Result));
...
and some registry reading. As I understand this unit is the "lowest" in the hierarchy as it loads dll's, so it shouldn't be a big problem to port it for people with experience with Linux.

But I am not sure about portability of other things... For example is this code portable to Linux:
Code: [Select]
type
  IGeckoCreateWindowTarget = interface
  ['{934D4785-B78A-43D0-ABAD-1CC71AC06E24}']
    function DoCreateChromeWindow(
        chromeFlags: Longword;
        out newChrome: nsIWebBrowserChrome): Longword;
    function GetWebBrowserChrome: nsIWebBrowserChrome;
  end;

?

And in general - does anybode else looked at these packages? Are they worth "playing" with in Lazarus?



« Last Edit: January 14, 2009, 10:36:09 pm by ZL »

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Gecko (HTML engine) in Lazarus app
« Reply #1 on: January 15, 2009, 12:30:00 am »
Interfaces are supported on all platforms. Please see the Free Pascal ref.pdf, Chapter 7.

I assume you've already looked at the Lazarus TIpHtmlPanel on the IProp components tab (ported from TurboPower Internet Professional).

In the two units that use Windows, try replacing Windows by LclIntf in your uses and then try compiling to see what Win API functions it's using that are not available cross-platform. Depending on what they are, sometimes it's possible to write functions with the same name as the Win API functions in order to intercept the call - the intercept functions try to implement or mimic the missing Win API functions.

Take a look at this thread for some other issues related to cross-platform programming:

http://forum.lazarus.freepascal.org/index.php/topic,6152.0.html

I also assume you have the Linux and OS X Gecko libraries too and not just the Windows DLL's, right?

These could be useful. Is the Gecko engine something you need for your work or a project?

Thanks.

-Phil

ZL

  • New Member
  • *
  • Posts: 16
Re: Gecko (HTML engine) in Lazarus app
« Reply #2 on: January 15, 2009, 11:22:30 am »
Yes, Phil, I'm currently using TIpHtmlPanel to display HTML and to do some http browsing.
I'm developing freeware dictionary: http://www.dict.lt/?k=screens - KZod v3.00 BETA is made using Lazarus. Older versions (and screenshoots) are built using Delphi 5.
Now I have code that compiles under Windows and MacOS (didn't try on Linux yet but it shouldn't have any problems) :) only few new things are left to implement and after a month or two I'm going to release new version.

Currently I'm quite satisfied with TIpHtmlPanel, but I could use beter css handling and javascript support for some features so that's why I'm interested in embedding Gecko.

Quote
In the two units that use Windows, try replacing Windows by LclIntf in your uses and then try compiling to see what Win API functions it's using that are not available cross-platform.
Yes, I managed to remove Windows from one of the units and as I wrote I'm left with nsXPCOMGlue.pas unit (edit: actually I missed nsProfile.pas unit before... so there are two units...). hmm... it can be that I didn't try to put LclIntf in uses in this unit - I will try when I'll get home.

Quote
I also assume you have the Linux and OS X Gecko libraries too and not just the Windows DLL's, right?
No, I don't have Linux and OS X Gecko libraries but it is not a problem to get them :)
I'm planing to test my dictionary app on Linux in a few weeks so I'll try to build these units there too.
« Last Edit: January 15, 2009, 06:45:37 pm by ZL »

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Gecko (HTML engine) in Lazarus app
« Reply #3 on: January 15, 2009, 06:44:22 pm »
Have you looked at this HTML viewer, which is now in public domain?

http://www.pbear.com/

The example FrameDem.dpr app is quite impressive when compiled with Delphi. I don't believe it has support for CSS and certainly not for JavaScript.

You might also look at this:

http://webkit.org/

One advantage to WebKit over Gecko is that it's already part of OS X as a system framework that you can link to so you wouldn't have to distribute any external libraries with your app on OS X at least.

Thanks.

-Phil



ZL

  • New Member
  • *
  • Posts: 16
Re: Gecko (HTML engine) in Lazarus app
« Reply #4 on: January 15, 2009, 07:22:04 pm »
Have you looked at this HTML viewer, which is now in public domain?

http://www.pbear.com/

The example FrameDem.dpr app is quite impressive when compiled with Delphi. I don't believe it has support for CSS and certainly not for JavaScript.

Yes, I looked at it few months ago but it is too complex for me to port it to Lazarus :)


You might also look at this:

http://webkit.org/

One advantage to WebKit over Gecko is that it's already part of OS X as a system framework that you can link to so you wouldn't have to distribute any external libraries with your app on OS X at least.

Thanks.

-Phil

It caught my attention whan I saw someone post in mailinglist with screenshoot. Maybe it is worth looking closer, but I think I'll come back to it a little later (I hope :) ).

Thanks for the replies and help ;)

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Gecko (HTML engine) in Lazarus app
« Reply #5 on: January 15, 2009, 07:30:59 pm »
I ported the "pbear" components last summer, but don't yet have them working correctly. If you're serious I could commit the ported source to the Code and Components Repository SVN and you can see if you can get them to work.

Also, what about just doing your app as a Web app, maybe something that can even be run in the browser off-line? That way you automatically get the fully HTML viewer support from the browser.

Thanks.

-Phil

ZL

  • New Member
  • *
  • Posts: 16
Re: Gecko (HTML engine) in Lazarus app
« Reply #6 on: January 15, 2009, 08:14:40 pm »
I ported the "pbear" components last summer, but don't yet have them working correctly. If you're serious I could commit the ported source to the Code and Components Repository SVN and you can see if you can get them to work.
It would be nice to see what is working and what is not. I'm not sure I'll have enough time to contribute much, but who knows.

Also, what about just doing your app as a Web app, maybe something that can even be run in the browser off-line? That way you automatically get the fully HTML viewer support from the browser.
I didn't thought about this option much. But I believe that having not web app one can and get more functionality from app and extend it in more ways - this is one of my wishes - to do some "experments" with code and features. Either way this project is just as spare-time-hobby-when-I-want-to-do-some-programming :)

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Gecko (HTML engine) in Lazarus app
« Reply #7 on: January 15, 2009, 08:22:15 pm »
If I have time I'll take a look at where I am on the port. It almost works on Windows but there are some range-check errors when I turn range checks on that don't occur with Delphi, so there's something I need to track down why this is happening. With GTK2 I've gotten some results, but nothing works yet on Carbon.

Generally the less you have to depend on other packages or browsers, the better off you'll be for many types of apps. That's one big advantage to the IPro and pbear components - they're all Pascal and completely linked into your executable.

Thanks.

-Phil

ZL

  • New Member
  • *
  • Posts: 16
Re: Gecko (HTML engine) in Lazarus app
« Reply #8 on: January 15, 2009, 08:30:57 pm »
Generally the less you have to depend on other packages or browsers, the better off you'll be for many types of apps. That's one big advantage to the IPro and pbear components - they're all Pascal and completely linked into your executable.
Yes, that's true but I believe if one can get redistributable libraries/packages that he can pack with his app it is almost as good as linked into executable. That's why I'm quite interested in Gecko ;)
Either way, pbear would be an update compared to IPro :)

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Gecko (HTML engine) in Lazarus app
« Reply #9 on: January 20, 2009, 02:43:14 pm »
BTW, has anyone tried using WebKit with Lazarus?
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Gecko (HTML engine) in Lazarus app
« Reply #10 on: January 20, 2009, 04:35:19 pm »
I'm not aware of anyone doing this currently. The first thing needed would be a Pascal interface to the WebKit C++ libraries. Since Den Jean has already created a Pascal interface to the Qt C++ libraries (used by Lazarus Qt widgetset), it might make sense to add support for WebKit to Den's Qt interface library. Basically what's need is a "procedural" interface to the C++ classes, which is what Den provides for Qt. I don't know how much work that would be.

http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html

http://wiki.freepascal.org/Qt4_binding

Maybe you could investigate this a bit more.

http://trac.webkit.org/wiki

Thanks.

-Phil

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Gecko (HTML engine) in Lazarus app
« Reply #11 on: January 20, 2009, 06:20:56 pm »
That sounds interesting. There also is the GTK WebKit port, so it could be used too. Perhaps it would be easier to get procedural interfaces, since GTK is written in C?
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: Gecko (HTML engine) in Lazarus app
« Reply #12 on: January 20, 2009, 06:48:47 pm »
That might be okay for Linux, but it wouldn't be a satisfactory solution for OS X or Windows. The advantage of Qt is that it has the potential to look good on all platforms. For an example Qt app that looks terrific on both OS X and Windows, take a look at this open-source GIS:

http://www.qgis.org/

The Qt guys have really done their homework and license changes in the forthcoming Qt 4.5 apparently will be to Laz's benefit.

Webkit really appears to be on a roll now. The list of apps that use it is pretty long:

http://trac.webkit.org/wiki/Applications%20using%20WebKit

It would be great if we had cross-platform support for Webkit in Delphi and Lazarus but I suspect it will take quite a bit of work.

Thanks.

-Phil

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Gecko (HTML engine) in Lazarus app
« Reply #13 on: January 20, 2009, 06:54:32 pm »
Well, I' not sure for MacOS, but there already is a Windows version based on Cairo! So I guess there is some chance with GTK...

GTK or QT whatever, the hard part is to make it work  ;)

Thanks for your suggestions!
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

ZL

  • New Member
  • *
  • Posts: 16
Re: Gecko (HTML engine) in Lazarus app
« Reply #14 on: January 21, 2009, 01:07:27 pm »