Bug 309020. SVG content references in XBL anonymous content should reference content copied from the binding document. This is a partial fix. We also refactor some code to make it shareable in nsContentUtils. r=biesi,tor sr=bzbarsky

git-svn-id: svn://10.0.0.236/trunk@182487 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
roc+%cs.cmu.edu
2005-10-18 20:33:35 +00:00
parent 195ae411fb
commit 3aa042c0b4
13 changed files with 291 additions and 212 deletions

View File

@@ -728,42 +728,6 @@ nsXMLDocument::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
return CallQueryInterface(newDoc, aReturn);
}
// Id attribute matching function used by nsXMLDocument and
// nsHTMLDocument.
nsIContent *
MatchElementId(nsIContent *aContent, const nsACString& aUTF8Id, const nsAString& aId)
{
if (aContent->IsContentOfType(nsIContent::eHTML)) {
if (aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::id)) {
nsAutoString value;
aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::id, value);
if (aId.Equals(value)) {
return aContent;
}
}
}
else if (aContent->IsContentOfType(nsIContent::eELEMENT)) {
nsCOMPtr<nsIXMLContent> xmlContent = do_QueryInterface(aContent);
if (xmlContent) {
nsIAtom* value = xmlContent->GetID();
if (value && value->EqualsUTF8(aUTF8Id)) {
return aContent;
}
}
}
nsIContent *result = nsnull;
PRUint32 i, count = aContent->GetChildCount();
for (i = 0; i < count && result == nsnull; i++) {
result = MatchElementId(aContent->GetChildAt(i), aUTF8Id, aId);
}
return result;
}
// nsIDOMDocument interface
NS_IMETHODIMP
@@ -786,9 +750,8 @@ nsXMLDocument::GetElementById(const nsAString& aElementId,
// XXX For now, we do a brute force search of the content tree.
// We should come up with a more efficient solution.
// Note that content is *not* refcounted here, so do *not* release it!
nsIContent *content = MatchElementId(mRootContent,
NS_ConvertUCS2toUTF8(aElementId),
aElementId);
nsIContent *content =
nsContentUtils::MatchElementId(mRootContent, aElementId);
if (!content) {
return NS_OK;