Bug 577607 part 3. Use the main doc refresh driver for resource documents and the parent document's refresh driver for documents that are not roots of their type. r=roc, a=joe

This commit is contained in:
Boris Zbarsky 2010-08-11 17:05:27 -04:00
parent cfd42187e4
commit 8f3c379aaf
3 changed files with 41 additions and 6 deletions

View File

@ -264,7 +264,7 @@ nsPresContext::~nsPresContext()
// Disconnect the refresh driver *after* the transition manager, which
// needs it.
if (mRefreshDriver) {
if (mRefreshDriver && mRefreshDriver->PresContext() == this) {
mRefreshDriver->Disconnect();
}
@ -891,9 +891,37 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
if (!mTransitionManager)
return NS_ERROR_OUT_OF_MEMORY;
mRefreshDriver = new nsRefreshDriver(this);
if (!mRefreshDriver)
return NS_ERROR_OUT_OF_MEMORY;
if (mDocument->GetDisplayDocument()) {
NS_ASSERTION(mDocument->GetDisplayDocument()->GetShell() &&
mDocument->GetDisplayDocument()->GetShell()->GetPresContext(),
"Why are we being initialized?");
mRefreshDriver = mDocument->GetDisplayDocument()->GetShell()->
GetPresContext()->RefreshDriver();
} else {
nsIDocument* parent = mDocument->GetParentDocument();
if (parent) {
NS_ASSERTION(parent->GetShell() && parent->GetShell()->GetPresContext(),
"How did we get a presshell?");
// We don't have our container set yet at this point
nsCOMPtr<nsISupports> ourContainer = mDocument->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> ourItem = do_QueryInterface(ourContainer);
if (ourItem) {
nsCOMPtr<nsIDocShellTreeItem> parentItem;
ourItem->GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {
mRefreshDriver = parent->GetShell()->GetPresContext()->RefreshDriver();
}
}
}
if (!mRefreshDriver) {
mRefreshDriver = new nsRefreshDriver(this);
if (!mRefreshDriver)
return NS_ERROR_OUT_OF_MEMORY;
}
}
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);

View File

@ -7267,7 +7267,8 @@ PresShell::Freeze()
mDocument->EnumerateSubDocuments(FreezeSubDocument, nsnull);
nsPresContext* presContext = GetPresContext();
if (presContext) {
if (presContext &&
presContext->RefreshDriver()->PresContext() == presContext) {
presContext->RefreshDriver()->Freeze();
}
}
@ -7320,7 +7321,8 @@ void
PresShell::Thaw()
{
nsPresContext* presContext = GetPresContext();
if (presContext) {
if (presContext &&
presContext->RefreshDriver()->PresContext() == presContext) {
presContext->RefreshDriver()->Thaw();
}

View File

@ -162,6 +162,11 @@ public:
*/
void Thaw();
/**
* Return the prescontext we were initialized with
*/
nsPresContext* PresContext() const { return mPresContext; }
#ifdef DEBUG
/**
* Check whether the given observer is an observer for the given flush type