Changed docshell so it turns the mouse pointer "busy" in the associated window while it is loading a document. Removed the hack in the navigator chrome that used the throbber status to set the busy pointer. b=30375 sr=rpotts@netscape.com

This commit is contained in:
locka%iol.ie 2001-01-26 12:35:32 +00:00
Родитель e2b1d15a17
Коммит 8c837042a5
7 изменённых файлов: 77 добавлений и 23 удалений

Просмотреть файл

@ -1414,6 +1414,21 @@ nsEventStateManager::UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent,
}
}
// Check whether or not to show the busy cursor
nsCOMPtr<nsISupports> pcContainer;
aPresContext->GetContainer(getter_AddRefs(pcContainer));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
PRUint32 busyFlags = nsIDocShell::BUSY_FLAGS_NONE;
docShell->GetBusyFlags(&busyFlags);
// Show busy cursor everywhere before page loads
// and just replace the arrow cursor after page starts loading
if (busyFlags & nsIDocShell::BUSY_FLAGS_BUSY &&
(cursor == NS_STYLE_CURSOR_AUTO || cursor == NS_STYLE_CURSOR_DEFAULT))
{
cursor = NS_STYLE_CURSOR_SPINNING;
}
if (aTargetFrame) {
nsCOMPtr<nsIWidget> window;
aTargetFrame->GetWindow(aPresContext, getter_AddRefs(window));

Просмотреть файл

@ -131,7 +131,8 @@ nsDocShell::nsDocShell() :
mUseExternalProtocolHandler (PR_FALSE),
mParent(nsnull),
mTreeOwner(nsnull),
mChromeEventHandler(nsnull)
mChromeEventHandler(nsnull),
mBusyFlags(BUSY_FLAGS_NONE)
{
NS_INIT_REFCNT();
}
@ -778,6 +779,14 @@ NS_IMETHODIMP nsDocShell::SetMarginHeight(PRInt32 aHeight)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetBusyFlags(PRUint32 *aBusyFlags)
{
NS_ENSURE_ARG_POINTER(aBusyFlags);
*aBusyFlags = mBusyFlags;
return NS_OK;
}
//*****************************************************************************
// nsDocShell::nsIDocShellTreeItem
//*****************************************************************************
@ -2563,7 +2572,33 @@ NS_IMETHODIMP
nsDocShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
PRInt32 aStateFlags, nsresult aStatus)
{
if ((aStateFlags & STATE_IS_DOCUMENT) && (aStateFlags & STATE_STOP)) {
// Update the busy cursor
if ((~aStateFlags & (STATE_START | STATE_IS_NETWORK)) == 0) {
// Page has begun to load
mBusyFlags = BUSY_FLAGS_BUSY | BUSY_FLAGS_BEFORE_PAGE_LOAD;
nsCOMPtr<nsIWidget> mainWidget;
GetMainWidget(getter_AddRefs(mainWidget));
if(mainWidget)
{
mainWidget->SetCursor(eCursor_spinning);
}
}
else if ((~aStateFlags & (STATE_TRANSFERRING | STATE_IS_DOCUMENT)) == 0) {
// Page is loading
mBusyFlags = BUSY_FLAGS_BUSY | BUSY_FLAGS_PAGE_LOADING;
}
else if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK)) {
// Page has finished loading
mBusyFlags = BUSY_FLAGS_NONE;
nsCOMPtr<nsIWidget> mainWidget;
GetMainWidget(getter_AddRefs(mainWidget));
if(mainWidget)
{
mainWidget->SetCursor(eCursor_standard);
}
}
if ((~aStateFlags & (STATE_IS_DOCUMENT | STATE_STOP)) == 0) {
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));
// Is the document stop notification for this document?
@ -2573,7 +2608,7 @@ nsDocShell::OnStateChange(nsIWebProgress *aProgress, nsIRequest *aRequest,
EndPageLoad(aProgress, channel, aStatus);
}
}
else if ((aStateFlags & STATE_IS_DOCUMENT) && (aStateFlags & STATE_REDIRECTING)) {
else if ((~aStateFlags & (STATE_IS_DOCUMENT | STATE_REDIRECTING)) == 0) {
// XXX Is it enough if I check just for the above 2 flags for redirection
nsCOMPtr<nsIWebProgress> webProgress(do_QueryInterface(mLoadCookie));

Просмотреть файл

@ -301,6 +301,7 @@ protected:
PRInt32 mLastViewMode;
PRBool mRestoreViewMode;
PRInt32 mChildOffset; // Offset in the parent's child list.
PRUint32 mBusyFlags;
// Reference to the SHEntry for this docshell until the page is destroyed.
// Somebody give me better name
nsCOMPtr<nsISHEntry> OSHE;

Просмотреть файл

@ -172,5 +172,13 @@ interface nsIDocShell : nsISupports
XXX Comment here!
*/
attribute long marginHeight;
/* Current busy state for DocShell */
const unsigned long BUSY_FLAGS_NONE = 0;
const unsigned long BUSY_FLAGS_BUSY = 1;
const unsigned long BUSY_FLAGS_BEFORE_PAGE_LOAD = 2;
const unsigned long BUSY_FLAGS_PAGE_LOADING = 4;
readonly attribute unsigned long busyFlags;
};

Просмотреть файл

@ -1414,6 +1414,21 @@ nsEventStateManager::UpdateCursor(nsIPresContext* aPresContext, nsEvent* aEvent,
}
}
// Check whether or not to show the busy cursor
nsCOMPtr<nsISupports> pcContainer;
aPresContext->GetContainer(getter_AddRefs(pcContainer));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
PRUint32 busyFlags = nsIDocShell::BUSY_FLAGS_NONE;
docShell->GetBusyFlags(&busyFlags);
// Show busy cursor everywhere before page loads
// and just replace the arrow cursor after page starts loading
if (busyFlags & nsIDocShell::BUSY_FLAGS_BUSY &&
(cursor == NS_STYLE_CURSOR_AUTO || cursor == NS_STYLE_CURSOR_DEFAULT))
{
cursor = NS_STYLE_CURSOR_SPINNING;
}
if (aTargetFrame) {
nsCOMPtr<nsIWidget> window;
aTargetFrame->GetWindow(aPresContext, getter_AddRefs(window));

Просмотреть файл

@ -251,7 +251,6 @@ nsXULBrowserWindow.prototype =
if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
this.totalRequests += 1;
}
EnableBusyCursor(throbberElement.getAttribute("busy") == "true");
}
else if (state & nsIWebProgressListener.STATE_STOP) {
if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
@ -284,8 +283,6 @@ nsXULBrowserWindow.prototype =
// Set buttons in form menu
setFormToolbar();
EnableBusyCursor(false);
}
}
else if (state & nsIWebProgressListener.STATE_TRANSFERRING) {
@ -1188,21 +1185,6 @@ function FillInHTMLTooltip(tipElement)
return retVal;
}
function EnableBusyCursor(doEnable)
{
if (doEnable) {
// set the spinning cursor everywhere but mac, we have our own way to
// do this thankyouverymuch.
if (navigator.platform.indexOf("Mac") == -1) {
setCursor("spinning");
_content.setCursor("spinning");
}
} else {
setCursor("auto");
_content.setCursor("auto");
}
}
/**
* Use Stylesheet functions.
* Written by Tim Hill (bug 6782)

Просмотреть файл

@ -313,8 +313,6 @@ Contributor(s): ______________________________________. -->
<browser id="content" type="content-primary" src="about:blank"
flex="1" tooltip="aHTMLTooltip"
context="contentAreaContextMenu"
onmouseover="if (throbberElement)
EnableBusyCursor(throbberElement.getAttribute('busy') == 'true');"
onclick="return contentAreaClick(event);"
ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"/>
</box>