Fixing bugs 138138 and 138663. Making boxobjects clear their presentation related data when a XUL document is hidden. r=jkeiser@netscape.com, sr=rpotts@netscape.com

This commit is contained in:
jst%netscape.com 2002-04-22 23:48:14 +00:00
Родитель 3f18bfadd3
Коммит bd4273a092
11 изменённых файлов: 61 добавлений и 23 удалений

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

@ -2081,8 +2081,9 @@ DocumentViewerImpl::Hide(void)
mPreviousViewer = nsnull;
}
if (mDeviceContext)
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
}
// Break circular reference (or something)
mPresShell->EndObservingDocument();
@ -2092,13 +2093,14 @@ DocumentViewerImpl::Hide(void)
nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));
if (selPrivate && mSelectionListener)
if (selPrivate && mSelectionListener) {
selPrivate->RemoveSelectionListener(mSelectionListener);
}
nsCOMPtr<nsIXULDocument> xul_doc(do_QueryInterface(mDocument));
if (xul_doc) {
xul_doc->ClearBoxObjectTable();
xul_doc->OnHide();
}
mPresShell->Destroy();

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

@ -513,6 +513,8 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
old_data.Append(aData);
rv = SetText(old_data, PR_FALSE);
} else {
// We know aData and the current data is ASCII, so use a
// nsC*String, no need for any fancy unicode stuff here.
nsCAutoString old_data;
mText.AppendTo(old_data);
length = old_data.Length();

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

@ -167,9 +167,9 @@ public:
NS_IMETHOD OnResumeContentSink() = 0;
/**
* Clear the box object hash
* Notify the XUL document that it's being hidden
*/
NS_IMETHOD ClearBoxObjectTable() = 0;
NS_IMETHOD OnHide() = 0;
};
// factory functions

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

@ -1843,11 +1843,25 @@ nsXULDocument::OnResumeContentSink()
return NS_OK;
}
NS_IMETHODIMP
nsXULDocument::ClearBoxObjectTable()
PR_STATIC_CALLBACK(PRBool)
ClearPresentationStuff(nsHashKey *aKey, void *aData, void* aClosure)
{
delete mBoxObjectTable;
mBoxObjectTable = nsnull;
nsISupports *supp = NS_STATIC_CAST(nsISupports *, aData);
nsCOMPtr<nsPIBoxObject> boxObject(do_QueryInterface(supp));
if (boxObject) {
boxObject->InvalidatePresentationStuff();
}
return PR_TRUE;
}
NS_IMETHODIMP
nsXULDocument::OnHide()
{
if (mBoxObjectTable) {
mBoxObjectTable->Enumerate(ClearPresentationStuff, nsnull);
}
return NS_OK;
}

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

@ -369,7 +369,7 @@ public:
NS_IMETHOD GetTemplateBuilderFor(nsIContent* aContent, nsIXULTemplateBuilder** aResult);
NS_IMETHOD OnPrototypeLoadDone();
NS_IMETHOD OnResumeContentSink();
NS_IMETHOD ClearBoxObjectTable();
NS_IMETHOD OnHide();
// nsIDOMEventCapturer interface
NS_IMETHOD CaptureEvent(const nsAString& aType);

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

@ -2081,8 +2081,9 @@ DocumentViewerImpl::Hide(void)
mPreviousViewer = nsnull;
}
if (mDeviceContext)
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
}
// Break circular reference (or something)
mPresShell->EndObservingDocument();
@ -2092,13 +2093,14 @@ DocumentViewerImpl::Hide(void)
nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));
if (selPrivate && mSelectionListener)
if (selPrivate && mSelectionListener) {
selPrivate->RemoveSelectionListener(mSelectionListener);
}
nsCOMPtr<nsIXULDocument> xul_doc(do_QueryInterface(mDocument));
if (xul_doc) {
xul_doc->ClearBoxObjectTable();
xul_doc->OnHide();
}
mPresShell->Destroy();

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

@ -53,6 +53,8 @@ public:
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aShell) = 0;
NS_IMETHOD SetDocument(nsIDocument* aDocument) = 0;
NS_IMETHOD InvalidatePresentationStuff() = 0;
};
#endif

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

@ -153,6 +153,14 @@ nsBoxObject::SetDocument(nsIDocument* aDocument)
return NS_OK;
}
NS_IMETHODIMP
nsBoxObject::InvalidatePresentationStuff()
{
// Nothing to do here, subclasses might care though...
return NS_OK;
}
nsIFrame*
nsBoxObject::GetFrame()
{
@ -451,7 +459,7 @@ nsBoxObject::GetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports**
return NS_OK;
}
nsAutoString propertyName(aPropertyName);
nsDependentString propertyName(aPropertyName);
return mPresState->GetStatePropertyAsSupports(propertyName, aResult); // Addref here.
}
@ -461,7 +469,7 @@ nsBoxObject::SetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports*
if (!mPresState)
NS_NewPresState(getter_AddRefs(mPresState));
nsAutoString propertyName(aPropertyName);
nsDependentString propertyName(aPropertyName);
return mPresState->SetStatePropertyAsSupports(propertyName, aValue);
}
@ -473,7 +481,7 @@ nsBoxObject::GetProperty(const PRUnichar* aPropertyName, PRUnichar** aResult)
return NS_OK;
}
nsAutoString propertyName(aPropertyName);
nsDependentString propertyName(aPropertyName);
nsAutoString result;
nsresult rv = mPresState->GetStateProperty(propertyName, result);
if (NS_FAILED(rv))
@ -488,8 +496,8 @@ nsBoxObject::SetProperty(const PRUnichar* aPropertyName, const PRUnichar* aPrope
if (!mPresState)
NS_NewPresState(getter_AddRefs(mPresState));
nsAutoString propertyName(aPropertyName);
nsAutoString propertyValue(aPropertyValue);
nsDependentString propertyName(aPropertyName);
nsDependentString propertyValue(aPropertyValue);
return mPresState->SetStateProperty(propertyName, propertyValue);
}
@ -499,7 +507,7 @@ nsBoxObject::RemoveProperty(const PRUnichar* aPropertyName)
if (!mPresState)
return NS_OK;
nsAutoString propertyName(aPropertyName);
nsDependentString propertyName(aPropertyName);
return mPresState->RemoveStateProperty(propertyName);
}

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

@ -57,6 +57,7 @@ public:
// nsPIBoxObject
NS_IMETHOD Init(nsIContent* aContent, nsIPresShell* aPresShell);
NS_IMETHOD SetDocument(nsIDocument* aDocument);
NS_IMETHOD InvalidatePresentationStuff();
virtual nsIFrame* GetFrame();
nsresult GetOffsetRect(nsRect& aRect);

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

@ -203,13 +203,13 @@ nsListBoxBodyFrame::~nsListBoxBodyFrame()
NS_IMETHODIMP_(nsrefcnt)
nsListBoxBodyFrame::AddRef(void)
{
return NS_OK;
return 2;
}
NS_IMETHODIMP_(nsrefcnt)
nsListBoxBodyFrame::Release(void)
{
return NS_OK;
return 1;
}
//

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

@ -57,6 +57,8 @@ public:
virtual ~nsListBoxObject();
nsIListBoxObject* GetListBoxBody();
NS_IMETHOD InvalidatePresentationStuff();
protected:
};
@ -210,8 +212,7 @@ FindBodyContent(nsIContent* aParent, nsIContent** aResult)
nsIListBoxObject*
nsListBoxObject::GetListBoxBody()
{
nsAutoString listboxbody;
listboxbody.AssignWithConversion("listboxbody");
NS_NAMED_LITERAL_STRING(listboxbody, "listboxbody");
nsCOMPtr<nsISupports> supp;
GetPropertyAsSupports(listboxbody.get(), getter_AddRefs(supp));
@ -256,6 +257,12 @@ nsListBoxObject::GetListBoxBody()
return body;
}
NS_IMETHODIMP
nsListBoxObject::InvalidatePresentationStuff()
{
return SetPropertyAsSupports(NS_LITERAL_STRING("listboxbody").get(), nsnull);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult