Re: Why use BeforeNavigate2 when capturing frame creation and destruction?



christoffer.bjorklund@xxxxxxxxx wrote:
I understand that I want to remove old frames. But if I add a frame
and children to that frame during BeforeNavigate2 to my list, how do
I know in NavigateComplete2 that these are new frames and not old
frames that should be removed.

When a frame fires BeforeNavigate2, or even NavigateComplete2, no child
frames can possibly be in existence yet. Before the browser can create
child frames, it has to actually see the HTML of the parent frame. By
the time NavigateComplete2 is fired, no content has yet arrived.

BeforeNavigate2 for child frames always fires after NavigateComplete2 of
their parent frame.

Take this scenario for example:

BeforeNavigate2 ptr: 0x001 Parent frame, add to list
BeforeNavigate2 ptr: 0x002 Child frame, add to list

Impossible. Frame 0x001 has not yet seen a single byte of its HTML. How
is it supposed to create child frames? Which URL is it supposed to
navigate them to?

I thought that new frames aren't created in BeforeNavigate2 only when
you get to NavigateComplete2 the new frames are created.

What pointer do you think you get in BeforeNavigate2, then? A pointer to
object that has not yet been created? Doesn't make any sense to me.

What I got from running this was:

BeforeNavigate2: WBUnk: 0x00171954 Url: Frameset.htm
BeforeNavigate2: WBUnk: 0x001799C4 Url: http://www.discogs.com/
BeforeNavigate2: WBUnk: 0x001782F4 Url:
http://en.wikipedia.org/wiki/Main_Page NavigateComplete2: WBUnk:
0x00171954 Url: Frameset.htm

There is something wrong with your logging. This sequence is impossible,
as far as I can tell. At least, I've never seen anything like this
before.

If you look
at the pointer for www.discogs.com it changes during loading!

This is not unusual. You must use COM identitiy check to see if two COM
pointers refer to the same object: query both pointers for IUnknown,
compare resulting IUnknown pointers. If you are using ATL, see
CComPtr::IsEqualObject

And it
gets the same value as the wikipedia.org frame in the end!

The wrapper got reused. Again, use COM identity.

I thought
that the IUnknown pointer of each frame should be constant during
loading.

Do you explicitly query for IUnknown?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages