diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 99439fafbd4c..3d0aba2729ac 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -3060,13 +3060,18 @@ XULDocumentImpl::CreatePopupDocument(nsIContent* aPopupElement, nsIDocument** aR return rv; } // Now we need to copy all of the style sheets from the parent document - /*PRInt32 count = mStyleSheets.Count(); - for (PRInt32 i = 0; i < count; i++) { + PRInt32 count = mStyleSheets.Count(); + for (PRInt32 i = 1; i < count-1; i++) { // Don't bother addrefing. We don't live as long as our parent document nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(i); - sheet->SetOwningDocument(popupDoc); - popupDoc->mStyleSheets.AppendElement(sheet); - }*/ + nsCOMPtr cssSheet = do_QueryInterface(sheet); + if (cssSheet) { + nsCOMPtr clonedSheet; + if (NS_SUCCEEDED(cssSheet->Clone(*getter_AddRefs(clonedSheet)))) { + popupDoc->AddStyleSheet(clonedSheet); + } + } + } // We don't share builders, but we do share the DB that the current // XUL builder has. diff --git a/rdf/content/src/nsRDFXULBuilder.cpp b/rdf/content/src/nsRDFXULBuilder.cpp index 0a0223dfa95b..afa35f90c09d 100644 --- a/rdf/content/src/nsRDFXULBuilder.cpp +++ b/rdf/content/src/nsRDFXULBuilder.cpp @@ -622,33 +622,6 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement) rv = GetContainingNameSpace(aElement, getter_AddRefs(containingNameSpace)); if (NS_FAILED(rv)) return rv; - // Iterate through all of the element's children, and construct - // appropriate children for each arc. - nsCOMPtr children; - rv = NS_NewContainerEnumerator(mDB, resource, getter_AddRefs(children)); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create cursor for children"); - if (NS_FAILED(rv)) return rv; - - while (1) { - PRBool hasMore; - rv = children->HasMoreElements(&hasMore); - if (NS_FAILED(rv)) return rv; - - if (! hasMore) - break; - - nsCOMPtr isupports; - rv = children->GetNext(getter_AddRefs(isupports)); - NS_ASSERTION(NS_SUCCEEDED(rv), "error reading cursor"); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr child = do_QueryInterface(isupports); - - rv = AppendChild(containingNameSpace, aElement, child); - NS_ASSERTION(NS_SUCCEEDED(rv), "problem appending child to content model"); - if (NS_FAILED(rv)) return rv; - } - // If we're the root content, then prepend a special hidden form // element. if (aElement == mRoot.get()) { @@ -681,6 +654,33 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement) } } + // Iterate through all of the element's children, and construct + // appropriate children for each arc. + nsCOMPtr children; + rv = NS_NewContainerEnumerator(mDB, resource, getter_AddRefs(children)); + NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create cursor for children"); + if (NS_FAILED(rv)) return rv; + + while (1) { + PRBool hasMore; + rv = children->HasMoreElements(&hasMore); + if (NS_FAILED(rv)) return rv; + + if (! hasMore) + break; + + nsCOMPtr isupports; + rv = children->GetNext(getter_AddRefs(isupports)); + NS_ASSERTION(NS_SUCCEEDED(rv), "error reading cursor"); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr child = do_QueryInterface(isupports); + + rv = AppendChild(containingNameSpace, aElement, child); + NS_ASSERTION(NS_SUCCEEDED(rv), "problem appending child to content model"); + if (NS_FAILED(rv)) return rv; + } + // Now that we've built the children, check to see if the includesrc attribute // exists on the node. nsString includeSrc; diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 99439fafbd4c..3d0aba2729ac 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -3060,13 +3060,18 @@ XULDocumentImpl::CreatePopupDocument(nsIContent* aPopupElement, nsIDocument** aR return rv; } // Now we need to copy all of the style sheets from the parent document - /*PRInt32 count = mStyleSheets.Count(); - for (PRInt32 i = 0; i < count; i++) { + PRInt32 count = mStyleSheets.Count(); + for (PRInt32 i = 1; i < count-1; i++) { // Don't bother addrefing. We don't live as long as our parent document nsIStyleSheet* sheet = (nsIStyleSheet*) mStyleSheets.ElementAt(i); - sheet->SetOwningDocument(popupDoc); - popupDoc->mStyleSheets.AppendElement(sheet); - }*/ + nsCOMPtr cssSheet = do_QueryInterface(sheet); + if (cssSheet) { + nsCOMPtr clonedSheet; + if (NS_SUCCEEDED(cssSheet->Clone(*getter_AddRefs(clonedSheet)))) { + popupDoc->AddStyleSheet(clonedSheet); + } + } + } // We don't share builders, but we do share the DB that the current // XUL builder has.