[PATCH] When is KHTMLView done with rendering?

Jeroen Wijnhout Jeroen.Wijnhout at kdemail.net
Thu Jun 17 15:37:21 BST 2004


On Thursday 17 June 2004 16:12, David Faure wrote:
> On Thursday 17 June 2004 15:50, Jeroen Wijnhout wrote:
> > On Thursday 17 June 2004 15:18, David Faure wrote:
> > > Small nitpick: why not do the test   if (
> > > !m_url.encodedHtmlRef().isEmpty() ) before actually connecting to the
> > > signal?
> > > Then gotoAnchor() will only be called when we actually need to go to an
> > > anchor, as one might expect.
> >
> > Done.
>
> Actually I wonder if the test is even needed, since we already test for
> url.hasRef(). But it can't hurt to double-check :)

It was there in checkCompleted originally, just copied it. Suppose we have an 
URL:
http://url.com/index.html#
Does url.hasRef() return true? If it does, the url.htmlRef().isEmpty() is 
sensible, otherwise not I guess.

> Another issue: is finishedLayout() called if aborting the loading of the
> page? If it is, then ok (although the jumping might be strange when
> aborting). If it's not, then we might keep a connect() to the view's

If KHTMLView::layout() is called then finishedLayout is emitted. There is one 
exception, the case in which there is no khtml::RenderCanvas. In that case 
it's ok not to emit the signal.

> finishedLayout() signal, and end up being connected more than once. In this
> case it won't do much harm I suppose (just going to the same anchor
> multiple times in a row), but generally I find that dynamic
> connects/disconnects are a bit dangerous for this reason. One approach
> would be to disconnect before connecting, to ensure we're only connected

I've added a disconnect() in KHTMLPart::openURL, just before the connect. 
Better safe than sorry.

> once. Another approach would be to always connect (in the constructor), and
> put back the check for whether there's a ref in the current url :/

This would also be a good solution, however in this case I would propose to 
rename gotoAnchor to something like: afterLayouting(). Since the slot really 
provides a point where one can do stuff that really needs to be delayed until 
layouting is done. 

I've implemented the first option, because that took only five keystrokes :-)

Btw, is it good coding practice to make this slot (gotoAnchor) private? Since 
another class (KHTMLView) connects to it, shouldn't it be public? I made the 
slot private because I didn't want to change the API.

best,
Jeroen
-- 
Kile - an Integrated LaTeX Environment for KDE
http://kile.sourceforge.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: khtml_anchor_bug.diff
Type: text/x-diff
Size: 4469 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20040617/73bdfe14/attachment.diff>


More information about the kfm-devel mailing list