Lazarus

Announcements => Third party => Topic started by: Phil on November 05, 2009, 03:57:09 am

Title: Status of Gecko SDK Port
Post by: Phil on November 05, 2009, 03:57:09 am
Because there's been a lot of interest lately in a TWebBrowser-like component for Lazarus, I went ahead and ported Takanori Ito's Gecko SDK for Delphi.

The ported code is here:

http://web.fastermac.net/~MacPgmr/Lazarus/

Download the GeckoPort .zip file, then try installing the GeckoComponents.lpk package and test the two .lpi projects (in SampleApps).

Takanori's SourceForge repository is here:

http://d-gecko.svn.sourceforge.net/viewvc/d-gecko/

I also ported and included the two sample apps from an earlier version of his SDK.

Status report:

***Windows***

Delphi 7: Packages install fine and both sample apps compile and run fine.

Lazarus 0.9.28.2 / FPC 2.2.4: FPC can't compile the TGeckoBrowser component. But the BrowseWin.dpr does not depend on the TGeckoBrowser component and compiles and runs okay.

***OS X / Intel***

Lazarus 0.9.28.2 / FPC 2.2.4: FPC compiles TGeckoBrowser component okay (unlike FPC on Windows). But neither app runs. The InitWindow call to initialize the browser requires a native window to be passed in. A Carbon window won't work since Gecko is expecting a Cocoa NSView (presumably). Since the BrowseWin.dpr app only uses TForm, I tested it with the rudimentary Cocoa widgetset, passing in the TCocoaForm's MainWindowView (declared as NSView), but the app just crashes.

***OS X / PowerPC***

Lazarus 0.9.28.2 / FPC 2.2.4: The code generated by FPC causes an assembler error, something I've never seen before. End of test.


Tasks for those interested in getting TGeckoBrowser working cross-platform:

(1) Test on Windows with more recent compiler builds to see if apparent FPC bug has been fixed.

(2) Test on Linux to see if passing the TGeckoBrowser's or TForm's Handle is the same as passing a GTK window, or whether the window pointer has to be obtained indirectly from the widgetset controls as with Carbon and Cocoa.

On Linux you may need to change the code to specify the correct path to libxpcom.so. See XRE_FindGRE in nsXRE.pas and GetGREDirectoryPath in nsInit.pas.

(3) Takanori's Delphi code for determining the location of installed Gecko libraries does not find Firefox 3.5's DLL's on Windows, so for now I just hardwired the location in the code. Someone could test to see whether an installation of XULRunner sets the registry the way the code expects. Versions of XULRunner for all platforms are here:

https://developer.mozilla.org/en/XULRunner

On OS X, this installs XUL.framework under /Library/Frameworks.

Note that on OS X, I launched the test apps from a script (included) in order to set the DYLD_LIBRARY_PATH variable to point to XUL.framework. I also tested it against the Gecko libraries included in /Applications/Firefox.app.

Please report your results here.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: alter on November 05, 2009, 04:19:52 am
Going to look morning how it works with Linux. Does it support html editing? It's 4 am here so I didn't have much time to look into it:-)

Edit:
line 180 of nsXRE: I added xpcomPath:=ExtractFilePath(Application.ExeName)+'xulrunner\xpcom.dll'; and deleted NS_StrLCopy. Now doesn't depend on any paths in Program Files (just put Gecko in xulrunner subfolder)
Title: Re: Status of Gecko SDK Port
Post by: thierrybo on November 05, 2009, 03:27:30 pm
I installed Lazarus 0.9.28-2 satble version on windows XP (no previuos lazarus installation).

I have these messages :
Quote
...\GeckoBrowser.pas(455,14) Error: There is no method in an ancestor class to be overridden: "TGeckoBrowserChrome.GetChromeFlags:DWord;"
...\GeckoBrowser.pas(460,14) Error: There is no method in an ancestor class to be overridden: "TGeckoBrowserChrome.IsWindowModal:LongBool;"
...\GeckoBrowser.pas(469,14) Error: There is no method in an ancestor class to be overridden: "TGeckoBrowserChrome.GetVisibility:LongBool;"
...\GeckoBrowser.pas(471,14) Error: There is no method in an ancestor class to be overridden: "TGeckoBrowserChrome.GetTitle:^WideChar;"
...\GeckoBrowser.pas(473,14) Error: There is no method in an ancestor class to be overridden: "TGeckoBrowserChrome.GetSiteWindow:^untyped;"
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 05, 2009, 03:34:03 pm
Yes, those are the same errors I get with FPC 2.2.4 on Windows. I think that might be an FPC bug since this component compiles okay on OS X with FPC 2.2.4.

As I suggested, perhaps you could test with FPC 2.3.1.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: thierrybo on November 05, 2009, 04:11:40 pm
By the way it compiles fine if I add
Code: [Select]
safecall to theses procedures.
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 05, 2009, 04:30:41 pm
You're a genius, although I don't understand why that would be necessary since it's not needed to compile on OS X.

I'm getting a crash now with GBrowser.dpr app, but if I comment out this line in TCustomGeckoBrowser.InitWebBrowser, it will run.

//    FListeners.InitListener(Self);

I'm getting some range checking errors, but at least the browser window comes up now!

Now we just have to get it to work on Linux and OS X.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: alter on November 05, 2009, 04:59:56 pm
I disabled range checking in compiler options and it runs smoothly
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 05, 2009, 05:03:39 pm
Right, although you're likely just covering up a bug doing that.

Have you tested on Linux?

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: alter on November 05, 2009, 05:10:42 pm
Right, although you're likely just covering up a bug doing that.

Have you tested on Linux?

Thanks.

-Phil

Not yet. I think it's better to make it first for Windows then I will check how it works with Linux.
I did this:

Code: [Select]
{$R-}
      browser.AddWebBrowserListener(weak, table.Entries[i].IID^);
{$R+}

around line 880 and

Code: [Select]
{$R-}
      browser.RemoveWebBrowserListener(weak, table.Entries[i].IID^);
{$R+}


around line 900. Those 2 lines are faulty. Now If I enable range checking in compiler options then page is loaded but still each few seconds I get out of range error.

Edit:

around line 1600:

Code: [Select]
{$R-}
    Result := QueryInterface(uuid, _result);
{$R+}
and control works (no errors at least)
Title: Re: Status of Gecko SDK Port
Post by: alter on November 05, 2009, 05:24:31 pm
In GeckoChromeWindow around 376:

Code: [Select]
{$R-}
    Result := QueryInterface(uuid, Intf);
{$R+}  
Looks like those problems may be caused not by faulty pascal code but problems with Xulrunner itself since when I changed code above program responded as it should

Another problem appeared:
When I have only one TGeckoBrowser object then it is ok but when I create second one then whenever this second one tried to load some url i get sigsegv at line 1097 in GeckoBrowser unit (line: nav.LoadURI(PWideChar(uri), Flags, referer, post, head);)
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 06, 2009, 04:12:00 am
I've uploaded an updated GeckoPort .zip:

http://web.fastermac.net/~MacPgmr/Lazarus/

This fixes a few things:

- GeckoComponents.lpk now compiles and installs in Lazarus okay on Windows.

- GBrowser.dpr sample app doesn't crash at startup - still has some range-check errors, though. Compile with range checking off or use Alter's suggestions above until I can track down and eliminate these bugs.

- BrowseWin.dpr sample app now starts okay on OS X and loads Lazarus Web site. Here's what I did:
  -- Installed xulrunner-1.9.1.4.en-US.mac-pkg.dmg
  -- Compiled against Cocoa widgetset:
       lazbuild -B --ws=cocoa browsewin.lpi
You can also compile from Lazarus if you change the widgetset to Cocoa. Note that the Cocoa widgetset is not supplied already compiled with Lazarus the way Carbon is. See Lazarus wiki for instructions on how to compile the Cocoa widgetset against PasCocoa.
  -- Ran it with supplied script:  ./run-bw-mac.sh

- GBrowser.dpr sample app still crashes on OS X, but not because of Gecko anymore. It appears as though TCustomControl (from which TGeckoBrowser is descended) is not supported yet in the Cocoa widgetset.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: MvC on November 06, 2009, 09:14:32 am
The reason this is needed is because all ActiveX interfaces must use the SafeCall
calling conventions. On systems other than Windows, SafeCall is equal to the
default calling convention, so you don't get an error...

You're a genius, although I don't understand why that would be necessary since it's not needed to compile on OS X.

I'm getting a crash now with GBrowser.dpr app, but if I comment out this line in TCustomGeckoBrowser.InitWebBrowser, it will run.

//    FListeners.InitListener(Self);

I'm getting some range checking errors, but at least the browser window comes up now!

Now we just have to get it to work on Linux and OS X.

Thanks.

-Phil

Title: Re: Status of Gecko SDK Port
Post by: MvC on November 06, 2009, 10:25:54 am
Hi,

I made 2 small changes so it compiles on Linux 64-bit.
Is yours code checked-in somewhere in a version system so I can
create some diffs or how do I communicate changes ?

I think that this component is so important that it should actually be
distributed with Lazarus; It may be a good idea to ask if it can be
committed in their components directory. If you get write permission on
this directory, you can do the maintenance yourself.

If that's not possible/allowed, I suggest trying lazarus-ccr.
Title: Re: Status of Gecko SDK Port
Post by: malcome on November 06, 2009, 11:28:33 pm
Takanori's blog is here:
http://nesitive.net/nesitive/categories/develop.html
 ;)
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 07, 2009, 12:21:07 am

I did this:

Code: [Select]
{$R-}
      browser.AddWebBrowserListener(weak, table.Entries[i].IID^);
{$R+}

around line 880 and

Code: [Select]
{$R-}
      browser.RemoveWebBrowserListener(weak, table.Entries[i].IID^);
{$R+}


around line 900. Those 2 lines are faulty. Now If I enable range checking in compiler options then page is loaded but still each few seconds I get out of range error.

This is an FPC bug. Entries is only declared Array[0..0] so of course it throws a range check error if there's more than 1 entry in the table. Delphi more sensibly declares Entries as array[0..9999]. I guess the FPC guys assume we always work with interfaces with range checking turned off.

I changed the code to this:

 {$IFOPT R+}{$DEFINE TURNED_RANGE_CHECK_OFF}{$R-}{$ENDIF}
      browser.AddWebBrowserListener(weak, table.Entries.IID^);
 {$IFDEF TURNED_RANGE_CHECK_OFF}{$UNDEFINE TURNED_RANGE_CHECK_OFF}{$R+}{$ENDIF}


Quote
around line 1600:

Code: [Select]
{$R-}
    Result := QueryInterface(uuid, _result);
{$R+}
and control works (no errors at least)

This is also an odd one. QueryInterface returns LongInt, but Result is LongWord, so anytime result returned is negative we get a range-check error. However, if negative, that means the severity bit is set, which presumably means something is wrong. So my change may only be covering up something else:

    Result := nsresult(QueryInterface(uuid, _result));
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 07, 2009, 12:25:51 am
Hi,

I made 2 small changes so it compiles on Linux 64-bit.
Is yours code checked-in somewhere in a version system so I can
create some diffs or how do I communicate changes ?

I think that this component is so important that it should actually be
distributed with Lazarus; It may be a good idea to ask if it can be
committed in their components directory. If you get write permission on
this directory, you can do the maintenance yourself.

If that's not possible/allowed, I suggest trying lazarus-ccr.


I have access to ccr, but it might be a good idea to merge with Takanori's SourceForge code instead. The number of changes I've made has been small so it shouldn't be hard to maintain a single code base.

In any case, I'll create a ccr wiki page at a minimum. There isn't much information other than the code at this point. Takanori's English on his blog looks fine so I don't think it's that he's only comfortable writing in Japanese.

But let's get this thing working first. Please send me your changes.

Thanks.

-Phil


Title: Re: Status of Gecko SDK Port
Post by: Phil on November 09, 2009, 01:19:47 am
I've uploaded a .zip file with the following changes:

- Fixes outlined above to eliminate range check errors.
- On Windows, now assumes that Gecko libraries are in xulrunner folder below app instead of assuming that Firefox is installed.

http://web.fastermac.net/~MacPgmr/Lazarus/

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: kri2512 on November 10, 2009, 09:35:33 am
Hello,
new to this xulRunner / GeckoBrowser code, i tried to test it with Delphi 2007.
it begins to work, but i have one question :
- with others versions (this one : http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/Readme.htm (http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/Readme.htm)), the LoadURI method worked fine when i was calling it in the OnCreate of the form.
- with this version, it seems that the loadURI have to be in the OnShow event.

i get this error in the OnCreate event : Cannot create instance of nsIURI by URI '10.'  (EGeckoError).

Do you have an idea why it fails in the onCreate event ?

Regards,
christophe


Title: Re: Status of Gecko SDK Port
Post by: Phil on November 10, 2009, 04:29:00 pm
I can't tell what sample app you're referring to.

Did you test the BrowseWin.dpr app included in the .zip. That app uses LoadURI in FormCreate and works with Delphi.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: kri2512 on November 10, 2009, 04:39:54 pm
Hello,
thanks for answering.
sorry i am talking about my personnal application.

but i just have done the test with the other sample app : GBrowser.dpr, and if you move the LoadURI code into a FormCreate Event instead of the OnShow event, it crashes...
a "safecall" exception, and in debug it stops while a painting event... ?

Regards,
Christophe
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 10, 2009, 04:48:02 pm
Maybe that's why the call is in FormShow (I didn't write these sample apps).

Can you track down where the exception is occurring?

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: kri2512 on November 10, 2009, 05:04:41 pm
I talk about that, because i was using an "old" GeckoSDK, GeckoComponents, GRE library (extract from here : http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/Readme.htm (http://ftp.newbielabs.com/Delphi%20Gecko%20SDK/Readme.htm)) and with this version in the OnCreate, the LoadURI call didn't cause problem.

But it is not problematic for me, i move my code in the OnShow  ;)

for information the safecall error is in GeckoBrowser.pas, TCustomGeckoBrowser.Paint : baseWin.Repaint(True); line 1727.

Another question : is it possible to insert dynamically the html source code in the TGeckoBrowser ?

Regards,
Christophe

Title: Re: Status of Gecko SDK Port
Post by: Phil on November 10, 2009, 07:22:19 pm
I started with the old SDK but couldn't get anything to work with it on Delphi.

Is this exception occurring before FormCreate is exiting? With Delphi the sequence with a new form is:

OnCreate
OnShow
OnActivate
OnPaint

Yet it looks like maybe InitWebBrowser is causing the TGeckoBrowser to paint itself, maybe before everything is ready.

For inserting HTML, you could probably generate a temporary file containing the HTML, then load it.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 11, 2009, 03:08:46 am
I've posted an updated .zip with these changes:

- Glyph for TGeckoBrowser on Lazarus palette.
- Michael Van Canneyt's Linux changes - it should compile okay on Linux now.
- Now compiles okay on PowerPC Mac.

http://web.fastermac.net/~MacPgmr/Lazarus/

Keep testing!

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: kri2512 on November 12, 2009, 10:53:58 am
Hello,
about the insertion of HTML code, i already generate a html file, and load it after.

but i 've found a code that was nearly working with the an old version of bagel components, here it is :

Code: [Select]
procedure TGeckoBrowser.LoadHTML(htmlcode: String);
var
  wbchrome: nsIWebBrowserChrome;
  wb: nsIWebBrowser;
  domwindow: nsIDOMWindow;
  domdoc: nsIDOMDocument;
  domhtmldoc: nsIDOMHTMLDocument;
  nsstr: IInterfacedString;
begin
  wbchrome := Self as nsIWebBrowserChrome;
  wbchrome.GetWebBrowser(wb);
  wb.GetContentDOMWindow(domwindow);
  domwindow.GetDocument(domdoc);
  domhtmldoc:= domdoc as nsIDOMHTMLDocument;

  nsstr:= NewString;
  nsstr.Assign(htmlcode);
  domhtmldoc.Write(nsstr.AString);
end;

what do you think of that ?

Regards,
Christophe
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 12, 2009, 07:23:11 pm
Does it work?

You probably know more about this than I do.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: kri2512 on November 13, 2009, 11:47:43 am
Hi,
it used to work with the "TBagelBrowser" components, but not with these one.

i get a message "Interface not supported" on the line :
wbchrome := self as nsiWebBrowserChrome;

would be nice if it could work... any help is welcome ;-)

Regards,
Christophe
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 13, 2009, 04:50:24 pm
Not sure what you're trying to do there. Offhand I don't think casting Self (descendant of TCustomControl) as an interface would work!

If you need an instance of nsIWebBrowser, just use the WebBrowser property of TGeckoBrowser.

See also TCustomGeckoBrowser.InitWebBrowser.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: kri2512 on November 13, 2009, 05:00:44 pm
You are right,
i've rewritten the procedure Loadhtml, it looks like this now :
Code: [Select]
procedure TCustomGeckoBrowser.LoadHTML(htmlcode: string);
var domwindow: nsIDOMWindow;
    domdoc: nsIDOMDocument;
    domhtmldoc: nsIDOMHTMLDocument;
    nsstr: IInterfacedString;
begin
  domwindow:=GetContentWindow;
  domdoc:=GetContentDocument;
  domhtmldoc:=domdoc as nsIDOMHTMLDocument;

  nsstr:= NewString;
  nsstr.Assign(htmlcode);
  domhtmldoc.Write(nsstr.AString);
end;

but i get a different error on the domhtmldoc.write : "OLE ERROR 805303E8"
i've check this error and it corresponds to NS_ERROR_DOM_SECURITY_ERR
but it does not really advance me...




Title: Re: Status of Gecko SDK Port
Post by: Phil on November 13, 2009, 10:05:17 pm
I would use the property names (ContentWindow, ContentDocument) instead of the getter functions.

Can you do anything with dochtmldoc? For example, get the page's title or HTML?

You could search the Web and see if you can find a C++ or Java example of what you're trying to do. I have a feeling that Write doesn't do what you think it does.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: Phil on November 16, 2009, 01:15:05 am
I've committed the ported Gecko source to CCR Subversion and created a wiki page:

http://wiki.lazarus.freepascal.org/GeckoPort

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: Phil on December 01, 2009, 05:07:38 am
I've expanded the GeckoPort wiki topic:

http://wiki.lazarus.freepascal.org/GeckoPort

I also committed an updated version of the GeckoPort package:

- Replaced BrowseWin sample app with ChromeWin app that works better since it implements all required interfaces.

- Several changes to GeckoChromeWindow.pas

- Now assumes new ObjC-based Cocoa widgetset instead of old PasCocoa-based Cocoa widgetset. The new widgetset does not work as well with Gecko as the old widgetset did (nothing displayed in ChromeWin window), but it's the future so GeckoPort is now using it even though it's very new.

Note that several Linux users have confirmed that an exception is raised in libmozjs.so when libxul.so's XRE_InitEmbedding function is called from nsXRE.pas. If anyone has any ideas on what's wrong, please post them here.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: troops on January 08, 2010, 03:42:00 pm
Dear sir,

How implement a OnBeforeNavigate and OnDocumentCompete at this excellent component ? :)
And similar function activeElement :o)

I'm try migration ie to gecko ;)

(sorry for my english i'am french)

thanks!
Title: Re: Status of Gecko SDK Port
Post by: Phil on January 08, 2010, 04:20:48 pm
I don't know what those are.

Maybe you could take a look at TGeckoBrowserListener.OnStateChange?

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: troops on January 08, 2010, 04:35:06 pm
Hi Phil, thanks for reply,

I tried to use OnStateChange, but this event is not accessible from the component TGeckoBrowser (I use the SVN version and makes regular updates). Are you a example ?

Just as I had not found a method GeckoBrowser.Stop/Abort
Title: Re: Status of Gecko SDK Port
Post by: Phil on January 08, 2010, 08:23:46 pm
Sorry, you're beyond my understanding of this. You'll probably need to spend some time with the ported source.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: troops on January 12, 2010, 08:42:23 pm
Hi

I'm create a SVN in Sourceforge with my modifications.

https://geckobrowser.svn.sourceforge.net/svnroot/geckobrowser

If you want i can update your SVN (or not...)

- LoadURI (about:blank) by default. If not necessary add LoadURI onShow of Tform.

Add events:

OnDocumentBegin
OnDocumentComplete
OnDocumentUnload
OnDOMBlur
OnDOMInputChanged
OnDOMInputFocus
OnPageShow


Add Property's:
Popupmenu;
Stop;
StopAll;
StopNetwork;

January, 12 2010

Add Property Links in TGeckoBrowser
---------------------------------------------------
Count            -> Count links in page
Href[index]         -> Return HREF link by Index
AnchorText[index]    -> Return AnchorText of Link by Index (include HTML)
Element[index]      -> Return XPCOM nsIDOMHTMLAnchorElement by Index.


Add Property Forms in TGeckoBrowser
---------------------------------------------------
Count                  -> Count forms in page
GetFormControlCount       -> Return Count control by form Index (Include INPUT, TEXTAREA, SELECT)
Values[fIndex, iIndex]      -> Return ou write Value of control iIndex to form fIndex
Names[fIndex, iIndex]      -> Return Name of control iIndex to form fIndex (readonly)


Add Property's
---------------------------------------------------
AllowImages: Boolean      -> Enabled/Disabled Images in Browser (Read and write)
AllowJavascript: Boolean   -> Enabled/Disabled Javascript in Browser (Read and write)
AllowPlugins: Boolean      -> Enabled/Disabled Plugins in Browser (Read and write)
AllowSubFrames: Boolean      -> Enabled/Disabled Subframes in Browser document. (Read and write)
Title: Re: Status of Gecko SDK Port
Post by: Phil on January 12, 2010, 08:46:42 pm
Maybe once you've reached a point where you think you've added most of what you want changed, we can look at merging them into the Lazarus CCR. It appears that you're using Delphi so just remember that changes need to be FPC / Lazarus compatible.

Also, normally you don't post compiled files like .dcu to a Subversion site.

Thanks.

-Phil


Hi

I'm create a SVN in Sourceforge with my modifications.

https://geckobrowser.svn.sourceforge.net/svnroot/geckobrowser

If you want i can update your SVN (or not...)

Add events:

OnDocumentBegin
OnDocumentComplete
OnDocumentUnload
OnDOMBlur
OnDOMInputChanged
OnDOMInputFocus
OnPageShow


Add Property's:
Popupmenu;
Stop;
StopAll;
StopNetwork;

January, 12 2010

Add Property Links in TGeckoBrowser
---------------------------------------------------
Count            -> Count links in page
Href[index]         -> Return HREF link by Index
AnchorText[index]    -> Return AnchorText of Link by Index (include HTML)
Element[index]      -> Return XPCOM nsIDOMHTMLAnchorElement by Index.


Add Property Forms in TGeckoBrowser
---------------------------------------------------
Count                  -> Count forms in page
GetFormControlCount       -> Return Count control by form Index (Include INPUT, TEXTAREA, SELECT)
Values[fIndex, iIndex]      -> Return ou write Value of control iIndex to form fIndex
Names[fIndex, iIndex]      -> Return Name of control iIndex to form fIndex (readonly)


Add Property's
---------------------------------------------------
AllowImages: Boolean      -> Enabled/Disabled Images in Browser (Read and write)
AllowJavascript: Boolean   -> Enabled/Disabled Javascript in Browser (Read and write)
AllowPlugins: Boolean      -> Enabled/Disabled Plugins in Browser (Read and write)
AllowSubFrames: Boolean      -> Enabled/Disabled Subframes in Browser document. (Read and write)
Title: Re: Status of Gecko SDK Port
Post by: troops on January 12, 2010, 08:49:31 pm
I think it is compatible with Lazarus. (oups... for DCU Files)
Title: Re: Status of Gecko SDK Port
Post by: vrode on January 13, 2010, 10:49:54 am
On WindowsXP with FireFox 3.0 i have error on init GeckoBrowser.
I had add code in unit nsInit
function GRE_GetGREPathWithProperties and now all OK.
Code: [Select]
var
  LenS: DWORD;   
  S, sValue: AnsiString; 
...

...
  sValue := 'SOFTWARE\Mozilla\Mozilla Firefox';
  if RegOpenKeyEx(HKEY_LOCAL_MACHINE, PAnsiChar(sValue), 0,
                  KEY_QUERY_VALUE, hRegKey) = ERROR_SUCCESS then
  begin
    SetLength(S, buflen);
    LenS := buflen;
    ok := RegQueryValueExA(hRegKey, PAnsiChar('CurrentVersion'), nil, nil,
        @S[1], @LenS) = ERROR_SUCCESS;
    RegCloseKey(hRegKey);
    if ok then
      begin
        S := PAnsiChar(S);
        sValue := sValue + '\' + S + '\Main';
        LenS := buflen;
        ok := (RegOpenKeyEx(HKEY_LOCAL_MACHINE, PAnsiChar(sValue), 0,
                  KEY_QUERY_VALUE, hRegKey) = ERROR_SUCCESS) and
              (RegQueryValueExA(hRegKey, PAnsiChar('Install Directory'), nil, nil,
                  PByte(buf), @LenS) = ERROR_SUCCESS);
        RegCloseKey(hRegKey);
        if ok then
          begin
            NS_StrLCat(Buf, '\xpcom.dll', BufLen);
            Result := NS_OK;
            Exit;
          end;
      end;
  end;
Title: Re: Status of Gecko SDK Port
Post by: Phil on January 13, 2010, 06:42:18 pm
Thanks. Where did you insert that code in GRE_GetGREPathWithProperties?

The original code I ported did not work with the current version of Firefox, hence why I hardwired the location if the function failed.

In my testing it seems like it stopped working with my Firefox DLL's following a point upgrade, but I haven't tested with the latest point upgrade. What version of Firefox are you using?

If you're planning to distribute an app that uses your user's Firefox DLL's, that might be risky if what I observed is true. By distributing your own xulrunner DLL's below your app, everyone will be using a version that you tested and is known to work correctly.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: vrode on January 13, 2010, 07:35:58 pm
I insert the code in the end of function before last line
Code: [Select]
Result := NS_ERROR_FAILURE;
Firefox version 3.0.
Now update to 3.5.7 and my app run OK.
Title: Re: Status of Gecko SDK Port
Post by: Phil on January 13, 2010, 07:59:37 pm
If I have time, I'll test here and maybe introduce your changes in the SVN version, although I might check first to see if xulrunner is installed below the app and, if not, then use your approach to use the installed Firefox .dll's. That way if somebody wants to use a local copy of xulrunner, they don't have to change the code to prevent it from using Firefox dll's.

Also, maybe I'll introduce some of the new events and properties (see above).

We haven't been able to get this to work on Linux or OS X yet, so Gecko SDK is not real useful to me yet.

Thanks.

-Phil
Title: Re: Status of Gecko SDK Port
Post by: cd on January 19, 2010, 03:19:34 pm
I get a RunError(229) at line
1709 baseWin.Repaint(True);   
of GeckoBrowser while trying to run GBrowser app.
Can anyone tell what this means?

I also failed to run ChromeWin with the same error.

xulrunner is a subfolder of SampleApp folder.
Title: Re: Status of Gecko SDK Port
Post by: cd on February 12, 2010, 11:14:30 am
i still cannot find the reason for this RunError(229)
can anyone help?
Title: Re: Status of Gecko SDK Port
Post by: B4rr4cuda on February 14, 2010, 11:44:55 pm
Hello.
I've tried to find the problem with SIGFPE at application start on linux. During the experiments, I found that there is no crash if we manually create directory components in demo application's path and copy there compreg.dat from /opt/firefox/components dir.
Application still doesn't start but SIGFPE crash error disappears. May be this hint will help to find out real problem :\
Title: Re: Status of Gecko SDK Port
Post by: Slavikk on March 25, 2010, 12:45:18 pm
Good morning.
How to save the page HTML (save as)? How to save an image from the page?
Thanks in advance.
Title: Re: Status of Gecko SDK Port
Post by: XcanadamanX on April 01, 2010, 12:01:54 am
Hi im just wondering where we are supposed to put the files from XULRunner and which files we need. Thanks in advance!

edit: just read the wiki for the 50th time and seems that i finally read the one sentence i needed :p

edit2: ok i still cant get it to work. could someone write some complete instructions on where to put stuff? sorry for being a complete noob.
Title: Re: Status of Gecko SDK Port
Post by: José Mejuto on May 28, 2010, 05:19:07 pm
Hi im just wondering where we are supposed to put the files from XULRunner and which files we need. Thanks in advance!
edit: just read the wiki for the 50th time and seems that i finally read the one sentence i needed :p
edit2: ok i still cant get it to work. could someone write some complete instructions on where to put stuff? sorry for being a complete noob.

Hello,

Current state of GeckoPort can not run Gecko higher than 1.9.1.11 or use any FireFox >3.5 (FireFox not tested by me at all).

To run it in Windows, just decompress the XULRunner in the same application folder, so you get a "xulrunner" folder at your application level. If you have GRE paths defined (maybe FireFox or Mozilla defines some of them) they take preference, now I had changed it to take preference in local xulrunner, either in the same folder or in a xulrunner folder.

In Linux it does not compile right now due some Windows specific things that I'm changing step by step, but I lost near a week trying to understand why Gecko 1.9.2.x does not work with the "GeckoPort" and seems to be some kind of JavaScript problem, maybe related to the lack of a directory service or maybe some kind of bugs in the new JavaScript engine in 1.9.2.x.

Finally (on Windows) it works if this .js files from the xulrunner are removed:

Code: [Select]
nsFormAutoComplete.js
 nsHelperAppDlg.js
 nsProgressDialog.js
 nsSearchService.js
 nsUpdateService.js

And JavaScript is disabled, so it renders a page, but no JavaScript at all. Also recent Geckos have a lot of float point errors so your project must use "Set8087CW($133F)" to hide this errors as C programs do, but you lost some checks like overflow in Pascal code.

My goal now it to make it work with GTK2 using any Gecko that works fine on Windows but for such task I had changed some things here and there and now it only compiles in Windows, I hope only for a while.
Title: Re: Status of Gecko SDK Port
Post by: ammari on February 08, 2011, 11:35:19 pm
Good morning.
How to save the page HTML (save as)? How to save an image from the page?
Thanks in advance.

hello
I work on the component gecko in Delphi and I also try how how to open, save and display the source code of an html page.
do you have answers
thank you
Title: Re: Status of Gecko SDK Port
Post by: José Mejuto on February 10, 2011, 06:02:09 pm
hello
I work on the component gecko in Delphi and I also try how how to open, save and display the source code of an html page.
do you have answers
thank you

Hello,

To save the html you must wait for the next update to the GeckoPort because the nsIDocumentEncoder is missing currently, I'm now implementing it. But take care that Gecko does not give you access to the raw html (or I had not found a way except using InputStreams to filter the data) but to the already parsed html which can be converted in a raw html using nsIDocumentEncoder.

I hope to get the next update ready for this weekend.
Title: Re: Status of Gecko SDK Port
Post by: iannak on February 28, 2011, 09:04:49 pm
Hello.

I'm trying to print a page which is loaded in to the GeckoBrowser, but i can't find any way to do that. I found that there is an interface - nsIWebBrowserPrint- in the nsXPCOM.pas unit which has several methods (like Print, PrintPreview...) for printing, but they are not public.

Is there any way to use these methods from my program?

Thanks in advance.
Title: Re: Status of Gecko SDK Port :designe mode
Post by: ammari on March 01, 2011, 05:05:52 pm
Hello.

I'm trying to print a page which is loaded in to the GeckoBrowser, but i can't find any way to do that. I found that there is an interface - nsIWebBrowserPrint- in the nsXPCOM.pas unit which has several methods (like Print, PrintPreview...) for printing, but they are not public.

Is there any way to use these methods from my program?

Thanks in advance.


hello
  I want to use the gecko to create an e psd html editor.
So I open the web page in a document that allows me to change the page loaded (gilisser and move images, add a table, add a html code ...).
Service: GeckoBrowser1.LoadURI (openDialog.FileName). loads the page in navigation mode.
I essey to enter Edit mode with the following code:
var
   ed: nsIDOMNSHTMLDocument;
   s: IInterfacedString;
   aa: nsIDOMHTMLIFrameElement;
/ / c: IInterfacedCString;
/ / aa: nsIDOMHTMLFrameElement;
begin
/ /
   s: = newstring ('on ');
   ed: = GeckoBrowser1.ContentWindow.GetDocument () as nsIDOMNSHTMLDocument;
   ed.SetDesignMode (s.AString);
  but this code does not allow me to change the wab page (it can just drag and drop images to the text but can not do anything).
So my question is: are what can go into edit mode which allows us to modify any page.
thank you
Title: Re: Status of Gecko SDK Port
Post by: José Mejuto on March 04, 2011, 12:17:00 pm
Hello.

I'm trying to print a page which is loaded in to the GeckoBrowser, but i can't find any way to do that. I found that there is an interface - nsIWebBrowserPrint- in the nsXPCOM.pas unit which has several methods (like Print, PrintPreview...) for printing, but they are not public.

Is there any way to use these methods from my program?

Thanks in advance.

Hello,

You can get the interface for printing casting the gecktobrowser control to a TCustomGeckoBrowser, and them you can access to the "GetWebBrowserPrint". Then you must implement the parameters to get a print.

I'll try to add a simple Print method to the GeckoBrowser. Advanced print should be implemented by each user.
Title: comment récupérer les propriètés d'une image en gecko
Post by: ammari on April 12, 2011, 11:03:15 am
bonjour à tous
 j'utilise le gecko port pour faire éditeur html . pour l'instant j'arrive à ajouter des images , des tableaux , ajouter et supprimer des liens html dans la page web .
mais la chose qui me bloque actuellement est la récupération des propriétés de l’élément html sélectionné.(les propriété d'une image  ou d'un tableau par exemple).

Sel:=GeckoBrowser1.ContentWindow.GetSelection;
  Range:=Sel.GetRangeAt(0); // le premier élément selectioné

  // tout déselectionner
  sel.RemoveAllRanges();
  // supprimer le contenu de la sélection en cours du document
  range.deleteContents();

  // obtenir l'alocation de la sélection courante
  Container:=Range.StartContainer;
  ipos:=Range.startOffset;

  // faire une nouvelle Range pour la nouvelle sélection
  DocR:=mDocument as nsIDOMDocumentRange;
  Range:=DocR.CreateRange;

.........................je ne sais pas quoi faire après.

avez vous une piste pour résoudre ce problème.
 
Title: Re: Status of Gecko SDK Port
Post by: ammari on April 13, 2011, 11:56:44 am
hello phil
I have the same problem with the "write ".
how to load HTML directly into geckobrowser?
Title: Afficher le code html de la selection courante dans le geckobrowser
Post by: ammari on April 18, 2011, 10:58:25 am
hello
  I want to know how to retrieve the properties (the source, height, width ...) an image loaded with gecko (gecko sdk delphi). xpcom help. Here's the function Add:

procedure inserer_image()
var
ss,src,dest,dest1:string;
img,br: nsIDOMElement;
s1,s2: IInterfacedString;
EditorDocument: nsIDOMNSHTMLDocument;
begin

//Insérer un Elèment image
s1:=NewString('img');
img:=mDocument.CreateElement(s1.AString);
//border


s1:=NewString('border');
s2:=NewString(FormValideEditionImage.Edit_LargeurBordure.text);
img.SetAttribute(s1.AString,s2.AString);

//
s1:=NewString('src');
s2:=NewString('file:///'+c:/image.png);
img.SetAttribute(s1.AString,s2.AString);
......
InsertNode(img);
end;

procedure TForm6.InsertNode(const aInsertNode: nsIDOMElement);
var
mDocument: nsIDOMDocument;
Sel: nsISelection;
Range: nsIDOMRange;
Container: nsIDOMNode;
DocR: nsIDOMDocumentRange;
iPos: PRUint32;
NodeValue: IInterfacedString;
AfterNode: nsIDOMNode;
BeforeNode: nsIDOMNode;
TextNode: nsIDOMNode;
TextBefore,TextAfter: WideString;
begin
// récupèrer la l'objet sélectioné
Sel:=GeckoBrowser1.ContentWindow.GetSelection;
Range:=Sel.GetRangeAt(0); // le premier élément selectioné

// tout déselectionner
sel.RemoveAllRanges();
// supprimer le contenu de la sélection en cours du document
range.deleteContents();

// obtenir l'alocation de la sélection courante
Container:=Range.StartContainer;
ipos:=Range.startOffset;

// faire une nouvelle Range pour la nouvelle sélection
DocR:=mDocument as nsIDOMDocumentRange;
Range:=DocR.CreateRange;

if (Container.NodeType=3) and (aInsertNode.NodeType=3) then
begin
// if we insert text in a textnode, do optimized insertion
NodeValue:=NewString;
aInsertNode.GetNodeValue(NodeValue.AString);
(Container as nsIDOMCharacterData).InsertData(iPos, NodeValue.AString);

// put cursor after inserted text
Range.SetEnd(Container, iPos+(aInsertNode as nsIDOMCharacterData).Length);
Range.SetStart(Container, iPos+(aInsertNode as nsIDOMCharacterData).Length);
....

....

// insert the 3 new nodes before the old one
Container.InsertBefore(AfterNode, TextNode);
Container.InsertBefore(aInsertNode, AfterNode);
Container.InsertBefore(BeforeNode, aInsertNode);

// remove the old node
Container.RemoveChild(TextNode);

end
else
begin
// else simply insert the node
AfterNode:=Container.ChildNodes.Item(ipos);
Container.InsertBefore(aInsertNode, AfterNode);
end;
Range.SetEnd(AfterNode, 0);
Range.SetStart(AfterNode, 0);
end;
Sel.AddRange(Range);
end;

I want to retrieve the html code of the image selected when I double click on the image.
        Have you a track to solve this problem (in Delphi or other programming language)
Thank you
TinyPortal © 2005-2018