features request in KHTML for interaction with another KDE project

Tobias Anton tobias.anton at esc-electronics.de
Sun Apr 17 17:40:12 BST 2005


Am Freitag, 15. April 2005 21:04 schrieb Sebastien Raveau:
> > > - a KHTMLPart::listReferences() method that would return the list of
> > > UR[LI]s a webpage would load automatically
> >
> > "would load"... so you mean before it actually loads them? This doesn't
> > seem to go well with how KHTMLPart works. It starts loading things while
> > parsing the HTML. You'd need to intercept the calls to the loader I guess
> > - which means you'd have to start reading KHTMLPart's misc/loader.cpp for
> > instance; and adding some hook or something there.
>
> I understand... Maybe a simpler solution would be to use a dedicated HTML
> parser, like libhtmlparse ( http://msalem.translator.cx/libhtmlparse.html )
> to preprocess the webpages and assign callbacks on tags like <embed>
> <object> <img> <link> <frame> <iframe>... if the KDE community doesn't mind
> the growth of dependencies to external libraries ;-)

Your approach won't work in some complex cases. Imagine e.g. a page with 
javaScript code that is executed onLoad. Assume further that this code 
changes an IMG tag's "src"-attribute so the image referred to by the new 
value will be loaded only after completion of the page itself. You won't be 
able to intercept this URL, no matter how many libraries or function calls 
you add to the parsing step of KHTML.

Otherwise, you'll be able to get a list of all links by creating a 
      new HTMLCollectionImpl( d->m_doc, HTMLCollectionImpl::DOC_ANCHORS);
and filter them by their href-attribute, doing the same for frames and imgs 
with their src-attribute afterwards. This way, you can use KHTML for parsing 
and retrieving the information you desire.

However, I have not yet understood why you want to interfere with KHTML in 
that way, if hawKeye's main purpose is to show the links in a web page...

Cheers
Tobias





More information about the kfm-devel mailing list