> and how do you register for webprogress event ?

ok thank you it works ;-).

In a summary you register for webprogress event like this :
- register for xpcom-startup and implement observe method (of nsIObserver interface) like this :
...
NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
nsCOMPtr<nsIWebProgress> progress(do_GetService(kDocLoaderServiceCID));
rs = progress->AddProgressListener((nsIWebProgressListener*)this,


                              nsIWebProgress::NOTIFY_STATE_DOCUMENT);

...

Be carefull : you also have to implement nsIObserver and also nsSupportsWeakReference...



free_zy wrote:
 > Inherit from nsIWebProgressListener and listen for document load
 > events.

and how do you register for webprogress event ?

Giorgos Zervas wrote:

Are you trying to embed gecko or write an extension? I am not sure you
would use the same code in both cases.

When developing an extension, I do it the following way:

Inherit from nsIWebProgressListener and listen for document load
events.

Then inside:
OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) {
...


    nsCOMPtr<nsIDOMWindow> window;
    rv = aWebProgress->GetDOMWindow(getter_AddRefs(window));
    if (NS_FAILED(rv))
        return rv;

    nsCOMPtr<nsIDOMDocument> domDoc;
    rv = window->GetDocument(getter_AddRefs(domDoc));
    if (NS_FAILED(rv))
        return rv;

    nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
    if (!htmlDoc)
        return NS_OK;

    ...
}

I've never tried embedding gecko so if that's what you're trying to do
someone else will have to help you.

Regards,
Giorgos

_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to