Bug 739004. When cloning a static clone, set the mOriginalDocument of the new clone to the mOriginalDocument of the thing being cloned, not to the thing being cloned (which is not an original document at all). r=smaug

This commit is contained in:
Boris Zbarsky 2012-03-24 20:46:03 -04:00
Родитель 0714ed6312
Коммит 1bd6168046
3 изменённых файлов: 13 добавлений и 9 удалений

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

@ -1421,7 +1421,11 @@ public:
* If this document is a static clone, this returns the original
* document.
*/
nsIDocument* GetOriginalDocument() { return mOriginalDocument; }
nsIDocument* GetOriginalDocument()
{
MOZ_ASSERT(!mOriginalDocument || !mOriginalDocument->GetOriginalDocument());
return mOriginalDocument;
}
/**
* Called by nsParser to preload images. Can be removed and code moved

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

@ -8086,9 +8086,12 @@ nsIDocument::CreateStaticClone(nsISupports* aCloneContainer)
nsCOMPtr<nsIDocument> clonedDoc;
if (NS_SUCCEEDED(rv)) {
clonedDoc = do_QueryInterface(clonedNode);
nsCOMPtr<nsIDOMDocument> clonedDOMDoc = do_QueryInterface(clonedDoc);
if (clonedDOMDoc) {
clonedDoc->mOriginalDocument = this;
if (clonedDoc) {
if (IsStaticDocument()) {
clonedDoc->mOriginalDocument = mOriginalDocument;
} else {
clonedDoc->mOriginalDocument = this;
}
PRInt32 sheetsCount = GetNumberOfStyleSheets();
for (PRInt32 i = 0; i < sheetsCount; ++i) {
nsRefPtr<nsCSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));

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

@ -1413,11 +1413,8 @@ PresShell::SetPrefNoScriptRule()
// also handle the case where print is done from print preview
// see bug #342439 for more details
nsIDocument* doc = mDocument;
if (mPresContext->Type() == nsPresContext::eContext_PrintPreview ||
mPresContext->Type() == nsPresContext::eContext_Print) {
while (doc->GetOriginalDocument()) {
doc = doc->GetOriginalDocument();
}
if (doc->IsStaticDocument()) {
doc = doc->GetOriginalDocument();
}
bool scriptEnabled = doc->IsScriptEnabled();