Bug 1882, get ref from usemap even when it contains full URL. r+sr=roc+moz.
git-svn-id: svn://10.0.0.236/trunk@136614 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
7dfa954482
commit
fa3e3d8df9
@ -55,24 +55,42 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||
NS_ENSURE_ARG_POINTER(aMap);
|
||||
*aMap = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString usemap(aUsemap);
|
||||
|
||||
/* we used to strip the whitespace from the usemap value as a Quirk, but it was too quirky and
|
||||
didn't really work correctly - see bug 87050
|
||||
*/
|
||||
|
||||
if (!usemap.IsEmpty() && usemap.First() == '#') {
|
||||
usemap.Cut(0, 1);
|
||||
if (aUsemap.IsEmpty())
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 hash = aUsemap.FindChar('#');
|
||||
nsAString::const_iterator start, end;
|
||||
if (hash > -1) {
|
||||
aUsemap.BeginReading(start);
|
||||
aUsemap.EndReading(end);
|
||||
start.advance(hash + 1);
|
||||
if (start == end)
|
||||
return NS_OK; // aUsemap == "#"
|
||||
}
|
||||
|
||||
if (usemap.IsEmpty())
|
||||
return rv;
|
||||
// At this point, if hash < 0, then there was no '#'
|
||||
// so aUsemap IS the ref. Otherwise the ref starts
|
||||
// from 'start'
|
||||
|
||||
// NOTE!
|
||||
// I'd really like to do this, but it won't compile, and casting
|
||||
// Substring return to (const nsAString&) will cause a runtime crash.
|
||||
// Therefore, to avoid doing needless work, this pattern is replicated
|
||||
// below where we actually call functions with 'usemap' values.
|
||||
//const nsAString &usemap = (hash < 0) ? aUsemap : Substring(start, end);
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
|
||||
if (htmlDoc) {
|
||||
htmlDoc->GetImageMap(usemap,aMap);
|
||||
// See above NOTE
|
||||
if (hash < 0) {
|
||||
htmlDoc->GetImageMap(aUsemap, aMap);
|
||||
} else {
|
||||
htmlDoc->GetImageMap(Substring(start, end), aMap);
|
||||
}
|
||||
} else {
|
||||
// XHTML requires that where a name attribute was used in HTML 4.01,
|
||||
// the ID attribute must be used in XHTML. name is officially deprecated.
|
||||
@ -81,12 +99,17 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aDocument));
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
domDoc->GetElementById(usemap,getter_AddRefs(element));
|
||||
// See above NOTE
|
||||
if (hash < 0) {
|
||||
domDoc->GetElementById(aUsemap, getter_AddRefs(element));
|
||||
} else {
|
||||
domDoc->GetElementById(Substring(start, end), getter_AddRefs(element));
|
||||
}
|
||||
if (element) {
|
||||
CallQueryInterface(element, aMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1144,7 +1144,7 @@ nsHTMLDocument::RemoveImageMap(nsIDOMHTMLMapElement* aMap)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetImageMap(const nsString& aMapName,
|
||||
nsHTMLDocument::GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
|
||||
@ -109,7 +109,7 @@ public:
|
||||
|
||||
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap);
|
||||
|
||||
NS_IMETHOD GetImageMap(const nsString& aMapName,
|
||||
NS_IMETHOD GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult);
|
||||
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet);
|
||||
|
||||
@ -67,7 +67,7 @@ public:
|
||||
|
||||
NS_IMETHOD AddImageMap(nsIDOMHTMLMapElement* aMap) = 0;
|
||||
|
||||
NS_IMETHOD GetImageMap(const nsString& aMapName,
|
||||
NS_IMETHOD GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult) = 0;
|
||||
|
||||
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap) = 0;
|
||||
|
||||
@ -55,24 +55,42 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||
NS_ENSURE_ARG_POINTER(aMap);
|
||||
*aMap = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString usemap(aUsemap);
|
||||
|
||||
/* we used to strip the whitespace from the usemap value as a Quirk, but it was too quirky and
|
||||
didn't really work correctly - see bug 87050
|
||||
*/
|
||||
|
||||
if (!usemap.IsEmpty() && usemap.First() == '#') {
|
||||
usemap.Cut(0, 1);
|
||||
if (aUsemap.IsEmpty())
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 hash = aUsemap.FindChar('#');
|
||||
nsAString::const_iterator start, end;
|
||||
if (hash > -1) {
|
||||
aUsemap.BeginReading(start);
|
||||
aUsemap.EndReading(end);
|
||||
start.advance(hash + 1);
|
||||
if (start == end)
|
||||
return NS_OK; // aUsemap == "#"
|
||||
}
|
||||
|
||||
if (usemap.IsEmpty())
|
||||
return rv;
|
||||
// At this point, if hash < 0, then there was no '#'
|
||||
// so aUsemap IS the ref. Otherwise the ref starts
|
||||
// from 'start'
|
||||
|
||||
// NOTE!
|
||||
// I'd really like to do this, but it won't compile, and casting
|
||||
// Substring return to (const nsAString&) will cause a runtime crash.
|
||||
// Therefore, to avoid doing needless work, this pattern is replicated
|
||||
// below where we actually call functions with 'usemap' values.
|
||||
//const nsAString &usemap = (hash < 0) ? aUsemap : Substring(start, end);
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
|
||||
if (htmlDoc) {
|
||||
htmlDoc->GetImageMap(usemap,aMap);
|
||||
// See above NOTE
|
||||
if (hash < 0) {
|
||||
htmlDoc->GetImageMap(aUsemap, aMap);
|
||||
} else {
|
||||
htmlDoc->GetImageMap(Substring(start, end), aMap);
|
||||
}
|
||||
} else {
|
||||
// XHTML requires that where a name attribute was used in HTML 4.01,
|
||||
// the ID attribute must be used in XHTML. name is officially deprecated.
|
||||
@ -81,12 +99,17 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(aDocument));
|
||||
if (domDoc) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
domDoc->GetElementById(usemap,getter_AddRefs(element));
|
||||
// See above NOTE
|
||||
if (hash < 0) {
|
||||
domDoc->GetElementById(aUsemap, getter_AddRefs(element));
|
||||
} else {
|
||||
domDoc->GetElementById(Substring(start, end), getter_AddRefs(element));
|
||||
}
|
||||
if (element) {
|
||||
CallQueryInterface(element, aMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user