зеркало из https://github.com/mozilla/gecko-dev.git
Bug 121833. Fix assertion (and optimize) string-fu in rdf_MakeRelativeRef. Remove unused rdf_MakeRelativeName. r=timeless, sr=shaver.
This commit is contained in:
Родитель
a3571e41ba
Коммит
fa52183c37
|
@ -75,34 +75,17 @@ rdf_MakeRelativeRef(const nsString& aBaseURI, nsString& aURI)
|
||||||
// This implementation is extremely simple: e.g., it can't compute
|
// This implementation is extremely simple: e.g., it can't compute
|
||||||
// relative paths, or anything fancy like that. If the context URI
|
// relative paths, or anything fancy like that. If the context URI
|
||||||
// is not a prefix of the URI in question, we'll just bail.
|
// is not a prefix of the URI in question, we'll just bail.
|
||||||
if (aURI.Find(aBaseURI) != 0)
|
PRUint32 prefixLen = aBaseURI.Length();
|
||||||
return NS_OK;
|
if (prefixLen && Substring(aURI, 0, prefixLen) == aBaseURI) {
|
||||||
|
if (prefixLen < aURI.Length() && aURI.CharAt(prefixLen) == '/')
|
||||||
|
++prefixLen; // chop the leading slash so it's not `absolute'
|
||||||
|
|
||||||
// Otherwise, pare down the target URI, removing the context URI.
|
aURI.Cut(0, prefixLen);
|
||||||
aURI.Cut(0, aBaseURI.Length());
|
}
|
||||||
|
|
||||||
if (aURI.First() == '/')
|
|
||||||
aURI.Cut(0, 1);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
rdf_MakeRelativeName(const nsString& aBaseURI, nsString& aURI)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
rv = rdf_MakeRelativeRef(aBaseURI, aURI);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
if (aURI.First() == '#')
|
|
||||||
aURI.Cut(0, 1);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
rdf_RequiresAbsoluteURI(const nsString& uri)
|
rdf_RequiresAbsoluteURI(const nsString& uri)
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,9 +64,6 @@ class nsIURI;
|
||||||
nsresult
|
nsresult
|
||||||
rdf_MakeRelativeRef(const nsString& aBaseURI, nsString& aURI);
|
rdf_MakeRelativeRef(const nsString& aBaseURI, nsString& aURI);
|
||||||
|
|
||||||
nsresult
|
|
||||||
rdf_MakeRelativeName(const nsString& aBaseURI, nsString& aURI);
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
rdf_MakeAbsoluteURI(const nsString& aBaseURI, nsString& aURI);
|
rdf_MakeAbsoluteURI(const nsString& aBaseURI, nsString& aURI);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ void XXXNeverCalled()
|
||||||
|
|
||||||
// rdfutils
|
// rdfutils
|
||||||
rdf_MakeRelativeRef(s, s);
|
rdf_MakeRelativeRef(s, s);
|
||||||
rdf_MakeRelativeName(s, s);
|
|
||||||
rdf_MakeAbsoluteURI(s, s);
|
rdf_MakeAbsoluteURI(s, s);
|
||||||
rdf_MakeAbsoluteURI(s, cStr);
|
rdf_MakeAbsoluteURI(s, cStr);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче