зеркало из https://github.com/mozilla/pjs.git
Fix bugs with computing containment.
This commit is contained in:
Родитель
b7862591d9
Коммит
4312c7deef
|
@ -1774,12 +1774,12 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||||
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
|
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
if (IsContainer(realKid, aChild)) {
|
if (IsContainer(tmplKid, aChild)) {
|
||||||
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
|
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// test to see if the container has contents
|
// test to see if the container has contents
|
||||||
nsAutoString isEmpty = IsEmpty(realKid, aChild) ? (const char *)"true" : (const char *)"false";
|
nsAutoString isEmpty = IsEmpty(tmplKid, aChild) ? (const char *)"true" : (const char *)"false";
|
||||||
rv = realKid->SetAttribute(kNameSpaceID_None, kEmptyAtom, isEmpty, PR_FALSE);
|
rv = realKid->SetAttribute(kNameSpaceID_None, kEmptyAtom, isEmpty, PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
@ -2379,43 +2379,32 @@ RDFGenericBuilderImpl::IsContainmentProperty(nsIContent* aElement, nsIRDFResourc
|
||||||
if (isOrdinal)
|
if (isOrdinal)
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
const char *propertyURI;
|
const char* propertyURI;
|
||||||
if (NS_FAILED(rv = aProperty->GetValueConst( &propertyURI ))) {
|
rv = aProperty->GetValueConst(&propertyURI);
|
||||||
NS_ERROR("unable to get property URI");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get property URI");
|
||||||
return PR_FALSE;
|
if (NS_FAILED(rv)) return PR_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoString uri;
|
nsAutoString containment;
|
||||||
|
|
||||||
// Walk up the content tree looking for the "rdf:containment"
|
// Walk up the content tree looking for the "rdf:containment"
|
||||||
// attribute, so we can determine if the specified property
|
// attribute, so we can determine if the specified property
|
||||||
// actually defines containment.
|
// actually defines containment.
|
||||||
nsCOMPtr<nsIContent> element( dont_QueryInterface(aElement) );
|
nsCOMPtr<nsIContent> element( dont_QueryInterface(aElement) );
|
||||||
while (element) {
|
while (element) {
|
||||||
// Never ever ask an HTML element about non-HTML attributes.
|
// Is this the "containment" property?
|
||||||
PRInt32 nameSpaceID;
|
rv = element->GetAttribute(kNameSpaceID_None, kContainmentAtom, containment);
|
||||||
if (NS_FAILED(rv = element->GetNameSpaceID(nameSpaceID))) {
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get attribute value");
|
||||||
NS_ERROR("unable to get element namespace");
|
if (NS_FAILED(rv)) return PR_FALSE;
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nameSpaceID != kNameSpaceID_HTML) {
|
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||||
// Is this the "containment" property?
|
// Okay we've found the locally-scoped tree properties,
|
||||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kContainmentAtom, uri))) {
|
// a whitespace-separated list of property URIs. So we
|
||||||
NS_ERROR("unable to get attribute value");
|
// definitively know whether this is a tree property or
|
||||||
|
// not.
|
||||||
|
if (containment.Find(propertyURI) >= 0)
|
||||||
|
return PR_TRUE;
|
||||||
|
else
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
|
||||||
// Okay we've found the locally-scoped tree properties,
|
|
||||||
// a whitespace-separated list of property URIs. So we
|
|
||||||
// definitively know whether this is a tree property or
|
|
||||||
// not.
|
|
||||||
if (uri.Find(propertyURI) >= 0)
|
|
||||||
return PR_TRUE;
|
|
||||||
else
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> parent;
|
nsCOMPtr<nsIContent> parent;
|
||||||
|
@ -2433,10 +2422,9 @@ RDFGenericBuilderImpl::IsContainmentProperty(nsIContent* aElement, nsIRDFResourc
|
||||||
(aProperty == kRDF_child)) {
|
(aProperty == kRDF_child)) {
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif // defined(TREE_PROPERTY_HACK)
|
#endif // defined(TREE_PROPERTY_HACK)
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1774,12 +1774,12 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||||
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
|
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
if (IsContainer(realKid, aChild)) {
|
if (IsContainer(tmplKid, aChild)) {
|
||||||
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
|
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// test to see if the container has contents
|
// test to see if the container has contents
|
||||||
nsAutoString isEmpty = IsEmpty(realKid, aChild) ? (const char *)"true" : (const char *)"false";
|
nsAutoString isEmpty = IsEmpty(tmplKid, aChild) ? (const char *)"true" : (const char *)"false";
|
||||||
rv = realKid->SetAttribute(kNameSpaceID_None, kEmptyAtom, isEmpty, PR_FALSE);
|
rv = realKid->SetAttribute(kNameSpaceID_None, kEmptyAtom, isEmpty, PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
@ -2379,43 +2379,32 @@ RDFGenericBuilderImpl::IsContainmentProperty(nsIContent* aElement, nsIRDFResourc
|
||||||
if (isOrdinal)
|
if (isOrdinal)
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
const char *propertyURI;
|
const char* propertyURI;
|
||||||
if (NS_FAILED(rv = aProperty->GetValueConst( &propertyURI ))) {
|
rv = aProperty->GetValueConst(&propertyURI);
|
||||||
NS_ERROR("unable to get property URI");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get property URI");
|
||||||
return PR_FALSE;
|
if (NS_FAILED(rv)) return PR_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoString uri;
|
nsAutoString containment;
|
||||||
|
|
||||||
// Walk up the content tree looking for the "rdf:containment"
|
// Walk up the content tree looking for the "rdf:containment"
|
||||||
// attribute, so we can determine if the specified property
|
// attribute, so we can determine if the specified property
|
||||||
// actually defines containment.
|
// actually defines containment.
|
||||||
nsCOMPtr<nsIContent> element( dont_QueryInterface(aElement) );
|
nsCOMPtr<nsIContent> element( dont_QueryInterface(aElement) );
|
||||||
while (element) {
|
while (element) {
|
||||||
// Never ever ask an HTML element about non-HTML attributes.
|
// Is this the "containment" property?
|
||||||
PRInt32 nameSpaceID;
|
rv = element->GetAttribute(kNameSpaceID_None, kContainmentAtom, containment);
|
||||||
if (NS_FAILED(rv = element->GetNameSpaceID(nameSpaceID))) {
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get attribute value");
|
||||||
NS_ERROR("unable to get element namespace");
|
if (NS_FAILED(rv)) return PR_FALSE;
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nameSpaceID != kNameSpaceID_HTML) {
|
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||||
// Is this the "containment" property?
|
// Okay we've found the locally-scoped tree properties,
|
||||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kContainmentAtom, uri))) {
|
// a whitespace-separated list of property URIs. So we
|
||||||
NS_ERROR("unable to get attribute value");
|
// definitively know whether this is a tree property or
|
||||||
|
// not.
|
||||||
|
if (containment.Find(propertyURI) >= 0)
|
||||||
|
return PR_TRUE;
|
||||||
|
else
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
|
||||||
// Okay we've found the locally-scoped tree properties,
|
|
||||||
// a whitespace-separated list of property URIs. So we
|
|
||||||
// definitively know whether this is a tree property or
|
|
||||||
// not.
|
|
||||||
if (uri.Find(propertyURI) >= 0)
|
|
||||||
return PR_TRUE;
|
|
||||||
else
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> parent;
|
nsCOMPtr<nsIContent> parent;
|
||||||
|
@ -2433,10 +2422,9 @@ RDFGenericBuilderImpl::IsContainmentProperty(nsIContent* aElement, nsIRDFResourc
|
||||||
(aProperty == kRDF_child)) {
|
(aProperty == kRDF_child)) {
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif // defined(TREE_PROPERTY_HACK)
|
#endif // defined(TREE_PROPERTY_HACK)
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1774,12 +1774,12 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||||
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
|
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
if (IsContainer(realKid, aChild)) {
|
if (IsContainer(tmplKid, aChild)) {
|
||||||
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
|
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
// test to see if the container has contents
|
// test to see if the container has contents
|
||||||
nsAutoString isEmpty = IsEmpty(realKid, aChild) ? (const char *)"true" : (const char *)"false";
|
nsAutoString isEmpty = IsEmpty(tmplKid, aChild) ? (const char *)"true" : (const char *)"false";
|
||||||
rv = realKid->SetAttribute(kNameSpaceID_None, kEmptyAtom, isEmpty, PR_FALSE);
|
rv = realKid->SetAttribute(kNameSpaceID_None, kEmptyAtom, isEmpty, PR_FALSE);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
@ -2379,43 +2379,32 @@ RDFGenericBuilderImpl::IsContainmentProperty(nsIContent* aElement, nsIRDFResourc
|
||||||
if (isOrdinal)
|
if (isOrdinal)
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
|
|
||||||
const char *propertyURI;
|
const char* propertyURI;
|
||||||
if (NS_FAILED(rv = aProperty->GetValueConst( &propertyURI ))) {
|
rv = aProperty->GetValueConst(&propertyURI);
|
||||||
NS_ERROR("unable to get property URI");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get property URI");
|
||||||
return PR_FALSE;
|
if (NS_FAILED(rv)) return PR_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoString uri;
|
nsAutoString containment;
|
||||||
|
|
||||||
// Walk up the content tree looking for the "rdf:containment"
|
// Walk up the content tree looking for the "rdf:containment"
|
||||||
// attribute, so we can determine if the specified property
|
// attribute, so we can determine if the specified property
|
||||||
// actually defines containment.
|
// actually defines containment.
|
||||||
nsCOMPtr<nsIContent> element( dont_QueryInterface(aElement) );
|
nsCOMPtr<nsIContent> element( dont_QueryInterface(aElement) );
|
||||||
while (element) {
|
while (element) {
|
||||||
// Never ever ask an HTML element about non-HTML attributes.
|
// Is this the "containment" property?
|
||||||
PRInt32 nameSpaceID;
|
rv = element->GetAttribute(kNameSpaceID_None, kContainmentAtom, containment);
|
||||||
if (NS_FAILED(rv = element->GetNameSpaceID(nameSpaceID))) {
|
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get attribute value");
|
||||||
NS_ERROR("unable to get element namespace");
|
if (NS_FAILED(rv)) return PR_FALSE;
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nameSpaceID != kNameSpaceID_HTML) {
|
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||||
// Is this the "containment" property?
|
// Okay we've found the locally-scoped tree properties,
|
||||||
if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None, kContainmentAtom, uri))) {
|
// a whitespace-separated list of property URIs. So we
|
||||||
NS_ERROR("unable to get attribute value");
|
// definitively know whether this is a tree property or
|
||||||
|
// not.
|
||||||
|
if (containment.Find(propertyURI) >= 0)
|
||||||
|
return PR_TRUE;
|
||||||
|
else
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
|
||||||
// Okay we've found the locally-scoped tree properties,
|
|
||||||
// a whitespace-separated list of property URIs. So we
|
|
||||||
// definitively know whether this is a tree property or
|
|
||||||
// not.
|
|
||||||
if (uri.Find(propertyURI) >= 0)
|
|
||||||
return PR_TRUE;
|
|
||||||
else
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIContent> parent;
|
nsCOMPtr<nsIContent> parent;
|
||||||
|
@ -2433,10 +2422,9 @@ RDFGenericBuilderImpl::IsContainmentProperty(nsIContent* aElement, nsIRDFResourc
|
||||||
(aProperty == kRDF_child)) {
|
(aProperty == kRDF_child)) {
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif // defined(TREE_PROPERTY_HACK)
|
#endif // defined(TREE_PROPERTY_HACK)
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче