Reversed the order of testing for link-elements so that the most common (anchors) are tested first. Update to earlier checkin.

This commit is contained in:
attinasi%netscape.com 2000-06-22 00:41:25 +00:00
Родитель 37563f3008
Коммит 411b3bcaaf
3 изменённых файлов: 81 добавлений и 84 удалений

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

@ -3789,34 +3789,9 @@ PRBool IsValidLink(nsIContent *aContent,nsString &aHREF)
nsCOMPtr<nsIDOMHTMLAreaElement> area;
nsCOMPtr<nsIDOMHTMLLinkElement> link;
// is it an XLink?
if ((bIsXLink = IsSimpleXlink(aContent,aHREF))) {
// It's an XLink. Resolve it relative to its document.
nsCOMPtr<nsIURI> baseURI = nsnull;
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(aContent);
if (htmlContent) {
// XXX why do this? will nsIHTMLContent's
// GetBaseURL() may return something different
// than the URL of the document it lives in?
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
nsAutoString linkURI;
(void) NS_MakeAbsoluteURI(linkURI, aHREF, baseURI, CSSStyleSheetInner::gIOService);
aHREF = linkURI;
result = PR_TRUE;
} // if xlink
else if ((anchor = do_QueryInterface(aContent)) ||
(area = do_QueryInterface(aContent)) ||
(link = do_QueryInterface(aContent))) {
if ((anchor = do_QueryInterface(aContent)) ||
(area = do_QueryInterface(aContent)) ||
(link = do_QueryInterface(aContent))) {
// if it is an anchor, area or link then check the href attribute
nsresult attrState = 0;
// make sure this anchor has a link even if we are not testing state
@ -3842,6 +3817,30 @@ PRBool IsValidLink(nsIContent *aContent,nsString &aHREF)
}
} // if anchor, area, link
else if ((bIsXLink = IsSimpleXlink(aContent,aHREF))) {
// It's an XLink. Resolve it relative to its document.
nsCOMPtr<nsIURI> baseURI = nsnull;
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(aContent);
if (htmlContent) {
// XXX why do this? will nsIHTMLContent's
// GetBaseURL() may return something different
// than the URL of the document it lives in?
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
nsAutoString linkURI;
(void) NS_MakeAbsoluteURI(linkURI, aHREF, baseURI, CSSStyleSheetInner::gIOService);
aHREF = linkURI;
result = PR_TRUE;
} // if xlink
return result;
}

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

@ -3789,34 +3789,9 @@ PRBool IsValidLink(nsIContent *aContent,nsString &aHREF)
nsCOMPtr<nsIDOMHTMLAreaElement> area;
nsCOMPtr<nsIDOMHTMLLinkElement> link;
// is it an XLink?
if ((bIsXLink = IsSimpleXlink(aContent,aHREF))) {
// It's an XLink. Resolve it relative to its document.
nsCOMPtr<nsIURI> baseURI = nsnull;
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(aContent);
if (htmlContent) {
// XXX why do this? will nsIHTMLContent's
// GetBaseURL() may return something different
// than the URL of the document it lives in?
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
nsAutoString linkURI;
(void) NS_MakeAbsoluteURI(linkURI, aHREF, baseURI, CSSStyleSheetInner::gIOService);
aHREF = linkURI;
result = PR_TRUE;
} // if xlink
else if ((anchor = do_QueryInterface(aContent)) ||
(area = do_QueryInterface(aContent)) ||
(link = do_QueryInterface(aContent))) {
if ((anchor = do_QueryInterface(aContent)) ||
(area = do_QueryInterface(aContent)) ||
(link = do_QueryInterface(aContent))) {
// if it is an anchor, area or link then check the href attribute
nsresult attrState = 0;
// make sure this anchor has a link even if we are not testing state
@ -3842,6 +3817,30 @@ PRBool IsValidLink(nsIContent *aContent,nsString &aHREF)
}
} // if anchor, area, link
else if ((bIsXLink = IsSimpleXlink(aContent,aHREF))) {
// It's an XLink. Resolve it relative to its document.
nsCOMPtr<nsIURI> baseURI = nsnull;
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(aContent);
if (htmlContent) {
// XXX why do this? will nsIHTMLContent's
// GetBaseURL() may return something different
// than the URL of the document it lives in?
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
nsAutoString linkURI;
(void) NS_MakeAbsoluteURI(linkURI, aHREF, baseURI, CSSStyleSheetInner::gIOService);
aHREF = linkURI;
result = PR_TRUE;
} // if xlink
return result;
}

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

@ -3789,34 +3789,9 @@ PRBool IsValidLink(nsIContent *aContent,nsString &aHREF)
nsCOMPtr<nsIDOMHTMLAreaElement> area;
nsCOMPtr<nsIDOMHTMLLinkElement> link;
// is it an XLink?
if ((bIsXLink = IsSimpleXlink(aContent,aHREF))) {
// It's an XLink. Resolve it relative to its document.
nsCOMPtr<nsIURI> baseURI = nsnull;
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(aContent);
if (htmlContent) {
// XXX why do this? will nsIHTMLContent's
// GetBaseURL() may return something different
// than the URL of the document it lives in?
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
nsAutoString linkURI;
(void) NS_MakeAbsoluteURI(linkURI, aHREF, baseURI, CSSStyleSheetInner::gIOService);
aHREF = linkURI;
result = PR_TRUE;
} // if xlink
else if ((anchor = do_QueryInterface(aContent)) ||
(area = do_QueryInterface(aContent)) ||
(link = do_QueryInterface(aContent))) {
if ((anchor = do_QueryInterface(aContent)) ||
(area = do_QueryInterface(aContent)) ||
(link = do_QueryInterface(aContent))) {
// if it is an anchor, area or link then check the href attribute
nsresult attrState = 0;
// make sure this anchor has a link even if we are not testing state
@ -3842,6 +3817,30 @@ PRBool IsValidLink(nsIContent *aContent,nsString &aHREF)
}
} // if anchor, area, link
else if ((bIsXLink = IsSimpleXlink(aContent,aHREF))) {
// It's an XLink. Resolve it relative to its document.
nsCOMPtr<nsIURI> baseURI = nsnull;
nsCOMPtr<nsIHTMLContent> htmlContent = do_QueryInterface(aContent);
if (htmlContent) {
// XXX why do this? will nsIHTMLContent's
// GetBaseURL() may return something different
// than the URL of the document it lives in?
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
}
else {
nsCOMPtr<nsIDocument> doc;
aContent->GetDocument(*getter_AddRefs(doc));
if (doc) {
doc->GetBaseURL(*getter_AddRefs(baseURI));
}
}
nsAutoString linkURI;
(void) NS_MakeAbsoluteURI(linkURI, aHREF, baseURI, CSSStyleSheetInner::gIOService);
aHREF = linkURI;
result = PR_TRUE;
} // if xlink
return result;
}