Remove redundant CheckLoadURI function in nsXMLElement. Bug 41907, r+sr=jst
git-svn-id: svn://10.0.0.236/trunk@152967 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
b4e54422d2
commit
4d7fce5e2d
@ -3164,7 +3164,8 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext,
|
||||
nsIURI* aOriginURI,
|
||||
nsIURI* aLinkURI,
|
||||
const nsAFlatString& aTargetSpec,
|
||||
PRBool aClick)
|
||||
PRBool aClick,
|
||||
PRBool aIsUserTriggered)
|
||||
{
|
||||
NS_PRECONDITION(aLinkURI, "No link URI");
|
||||
nsresult rv = NS_OK;
|
||||
@ -3180,7 +3181,9 @@ nsGenericElement::TriggerLink(nsIPresContext* aPresContext,
|
||||
if (NS_SUCCEEDED(rv))
|
||||
proceed =
|
||||
securityManager->CheckLoadURI(aOriginURI, aLinkURI,
|
||||
nsIScriptSecurityManager::STANDARD);
|
||||
aIsUserTriggered ?
|
||||
nsIScriptSecurityManager::STANDARD :
|
||||
nsIScriptSecurityManager::DISALLOW_FROM_MAIL);
|
||||
|
||||
// Only pass off the click event if the script security manager
|
||||
// says it's ok.
|
||||
|
||||
@ -559,13 +559,17 @@ public:
|
||||
* @param aTargetSpec the target (like target=, may be empty)
|
||||
* @param aClick whether this was a click or not (if false, it assumes you
|
||||
* just hovered over the link)
|
||||
* @param aIsUserTriggered whether the user triggered the link.
|
||||
* This would be false for loads from auto XLinks or from the
|
||||
* click() method if we ever implement it.
|
||||
*/
|
||||
nsresult TriggerLink(nsIPresContext* aPresContext,
|
||||
nsLinkVerb aVerb,
|
||||
nsIURI* aOriginURI,
|
||||
nsIURI* aLinkURI,
|
||||
const nsAFlatString& aTargetSpec,
|
||||
PRBool aClick);
|
||||
PRBool aClick,
|
||||
PRBool aIsUserTriggered);
|
||||
/**
|
||||
* Do whatever needs to be done when the mouse leaves a link
|
||||
*/
|
||||
|
||||
@ -1444,7 +1444,7 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext,
|
||||
}
|
||||
|
||||
ret = TriggerLink(aPresContext, eLinkVerb_Replace, baseURI, hrefURI,
|
||||
target, PR_TRUE);
|
||||
target, PR_TRUE, PR_TRUE);
|
||||
|
||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
@ -1491,7 +1491,7 @@ nsGenericHTMLElement::HandleDOMEventForAnchors(nsIPresContext* aPresContext,
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
ret = TriggerLink(aPresContext, eLinkVerb_Replace, baseURI,
|
||||
hrefURI, target, PR_FALSE);
|
||||
hrefURI, target, PR_FALSE, PR_TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@ -176,31 +176,6 @@ DocShellToPresContext(nsIDocShell *aShell, nsIPresContext **aPresContext)
|
||||
return ds->GetPresContext(aPresContext);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
CheckLoadURI(const nsString& aSpec, nsIURI *aBaseURI, nsIDocument* aDocument,
|
||||
nsIURI **aAbsURI)
|
||||
{
|
||||
*aAbsURI = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(aAbsURI, aSpec, aDocument,
|
||||
aBaseURI);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIScriptSecurityManager *securityManager =
|
||||
nsContentUtils::GetSecurityManager();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = securityManager->CheckLoadURI(aBaseURI, *aAbsURI,
|
||||
nsIScriptSecurityManager::DISALLOW_FROM_MAIL);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_IF_RELEASE(*aAbsURI);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static inline
|
||||
nsresult SpecialAutoLoadReturn(nsresult aRv, nsLinkVerb aVerb)
|
||||
{
|
||||
@ -306,13 +281,16 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
|
||||
value);
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE && !value.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = CheckLoadURI(value, base, mDocument, getter_AddRefs(uri));
|
||||
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
|
||||
value,
|
||||
mDocument,
|
||||
base);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIPresContext> pc;
|
||||
rv = DocShellToPresContext(aShell, getter_AddRefs(pc));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = TriggerLink(pc, verb, base, uri,
|
||||
EmptyString(), PR_TRUE);
|
||||
EmptyString(), PR_TRUE, PR_FALSE);
|
||||
|
||||
return SpecialAutoLoadReturn(rv,verb);
|
||||
}
|
||||
@ -362,7 +340,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
inputEvent->isAlt || inputEvent->isShift) {
|
||||
break; // let the click go through so we can handle it in JS/XUL
|
||||
}
|
||||
nsAutoString show, href, target;
|
||||
nsAutoString show, href;
|
||||
nsLinkVerb verb = eLinkVerb_Undefined; // basically means same as replace
|
||||
nsGenericContainerElement::GetAttr(kNameSpaceID_XLink,
|
||||
nsHTMLAtoms::href,
|
||||
@ -402,8 +380,8 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
mDocument,
|
||||
baseURI);
|
||||
if (NS_SUCCEEDED(ret)) {
|
||||
ret = TriggerLink(aPresContext, verb, baseURI, uri, target,
|
||||
PR_TRUE);
|
||||
ret = TriggerLink(aPresContext, verb, baseURI, uri, EmptyString(),
|
||||
PR_TRUE, PR_TRUE);
|
||||
}
|
||||
|
||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
@ -444,7 +422,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
|
||||
case NS_MOUSE_ENTER_SYNTH:
|
||||
{
|
||||
nsAutoString href, target;
|
||||
nsAutoString href;
|
||||
nsGenericContainerElement::GetAttr(kNameSpaceID_XLink,
|
||||
nsHTMLAtoms::href,
|
||||
href);
|
||||
@ -462,7 +440,7 @@ nsXMLElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
||||
baseURI);
|
||||
if (NS_SUCCEEDED(ret)) {
|
||||
ret = TriggerLink(aPresContext, eLinkVerb_Replace, baseURI, uri,
|
||||
target, PR_FALSE);
|
||||
EmptyString(), PR_FALSE, PR_TRUE);
|
||||
}
|
||||
|
||||
*aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user