Development :  K-Meleon Forum
K-Meleon development related discussions. 
Reload frame thoughts
Posted by: asmpgmr
Date: March 07, 2003 02:10AM

Andrew,

As far as I can figure Mozilla reloads frames by calling the reload function in the context of the selected frame.

For a normal page reload we have:

void CBrowserView:surprised smileynNavReload()
{
if(mWebNav)
mWebNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
}

Where mWebNav = do_QueryInterface(mWebBrowser, &rv);

Therefore I'm guessing that if the current frame equivalent to mWebNav was used then the current frame will be reloaded though I'm not sure how the layout is figured out since there's no special call from the Javascript that Mozilla uses to implement frame reload. Anyway perhaps it's as simple as using mCtxMenuCurrentFrameURL instead of mWebNav ?? Probably not but I didn't see anything else that represents the current frame.

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: MonkeeSage
Date: March 08, 2003 05:07AM

asmpgmr:

I was looking over this yesterday, and as far as I can tell mWebNav is the instantiation of the nsIWebNavigation service that is attached to mWebBroswer.


They they are calling methods out of that object like

mWebNav-> Stop(nsIWebNavigation::STOP_ALL);

mWebNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);


So I don't think it will work if you change that object to something else (cause I think the Reload(), Stop(), &c., are methods of that particular object).

There were two ways I could think of to reload a frame...

1. Figure out how to send messages to single DOM objects instead of the whole thing--e.g., send messages to a single frame. Then find out the message (if there is one) that causes individual objects to be reloaded (I would assume there is something like this for, e.g., the "Show Picture..." menu command in Mozilla).

2. Get the DOM object at a point (the frame to reload), then remove the old frame, insert a new frame with the same URI as the old frame, in the exact same location in the DOM object; then reload the DOM object.


I'm going to check more on 1. later today..


Shelumi`El
Jordan

S.D.G.

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: MonkeeSage
Date: March 08, 2003 06:36AM

Andrew or asmpgmr:

Where is the javascript that Mozilla uses to reload single frames?

The only thing I could find in all the source is in a file (content AreaCommands.dtd) that ends up in one of the .jar files:

<!ENTITY reloadFrameCmd.label "Reload Frame">
<!ENTITY reloadFrameCmd.accesskey "R">

But I can't seem to find what is actually being called when a frame is reloaded...?


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: MonkeeSage
Date: March 08, 2003 06:57AM

In \mozilla\layout\base\src\nsFrameList.cpp:

PRBool
nsFrameList:grinning smileyestroyFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
{
NS_PRECONDITION(nsnull != aFrame, "null ptr");
if (RemoveFrame(aFrame)) {
aFrame->Destroy(aPresContext);
return PR_TRUE;
}
return PR_FALSE;
}

void
nsFrameList::InsertFrame(nsIFrame* aParent, nsIFrame* aPrevSibling, nsIFrame* aNewFrame)
NS_PRECONDITION(nsnull != aNewFrame, "null ptr");
if (nsnull != aNewFrame) {
if (nsnull == aPrevSibling) {
aNewFrame->SetNextSibling(mFirstChild);
mFirstChild = aNewFrame;
}
else {
nsIFrame* nextFrame;
aPrevSibling->GetNextSibling(&nextFrame);
aPrevSibling->SetNextSibling(aNewFrame);
aNewFrame->SetNextSibling(nextFrame);
}
if (nsnull != aParent) {
aNewFrame->SetParent(aParent);
}
}
}


========

Those look like the basic functions needed to do my second idea, just destroy the old frame, and insert a new one in the exact location as the old one with the exact same URI; effectively "refreshing" the frame.

But there should be an easier way, I would think...by just sending a particular frame a refresh message...but then again, mabye not.

I'm going for for awhile, but I'll try playing with it some when I get back and see what I can see.


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: MonkeeSage
Date: March 08, 2003 07:01AM

Even better...same file, a little further down...one function to do both destroy and insert (if called with aDestroy as TRUE):

PRBool
nsFrameList::ReplaceFrame(nsIPresContext* aPresContext, nsIFrame* aParent, nsIFrame* aOldFrame, nsIFrame* aNewFrame, PRBool aDestroy)
{
NS_PRECONDITION(aOldFrame, "null ptr");
NS_PRECONDITION(aNewFrame, "null ptr");
if (DoReplaceFrame(aParent, aOldFrame, aNewFrame)) {
if (aDestroy) {
aOldFrame->Destroy(aPresContext);
}
return PR_TRUE;
}
return PR_FALSE;
}


Shelumi`El
Jordan

S.D.G

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: asmpgmr
Date: March 08, 2003 07:27AM

This from source/xpfe/communicator/resources/content/nsContextMenu.js:

// Reload clicked-in frame.
reloadFrame : function () {
this.target.ownerDocument.location.reload();
},
// Open clicked-in frame in its own window.
openFrame : function () {
openNewWindowWith( this.target.ownerDocument.location.href );
},
// Open clicked-in frame in the same window
showOnlyThisFrame : function () {
window.loadURI(this.target.ownerDocument.location.href);
},

Whatever kind of entity this.target.ownerDocument.location is, apparently it can be used in different ways and seems analogous to mCtxMenuCurrentFrameURL.

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: Andrew
Date: March 08, 2003 10:59AM

asmpgmr,

It's a standard Javascript reference to a window frame. Their way of reloading the frame is to use a Javascript function to reload the frame window.

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: asmpgmr
Date: March 08, 2003 11:45PM

Andrew,

So it should be possible to do this now in K-Meleon via a macro open(javascript:...) though it would be a hack and wouldn't work if Javascript is disabled or restricted via policies.

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: Andrew
Date: March 09, 2003 03:36AM

asmpgmr,

Yup.

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: asmpgmr
Date: March 15, 2003 01:43AM

If this can be done from Javascript via this.target.ownerDocument.location.reload(); then is there a way to do whatever the Javascript is doing in K-Meleon ? Also would it be possible to implement a similar reload image function which would reload an image without affecting the rest of the page ?

Options: ReplyQuote
Re: Reload frame thoughts
Posted by: zoom
Date: March 16, 2003 07:00AM

I sure would like a Reload Image Function, And to be able to see the Properties of an object, No matter if It's an image, sound file or whatever type of file that You have on a website.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.