[XForms] NPOTDB We need to be able to set context information for xforms events. Bug 280423, p=msterlin r=surkov+olli sr=jonas a=dveditz
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@247050 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -198,6 +198,13 @@ private:
|
||||
*/
|
||||
PRBool IsEphemeral();
|
||||
|
||||
/** Set context info for events.
|
||||
*
|
||||
* @param aName Name of the context property.
|
||||
* @param aValue Value of the context property.
|
||||
*/
|
||||
nsresult SetContextInfo(const char *aName, const nsAString &aValue);
|
||||
|
||||
MessageType mType;
|
||||
|
||||
// The position of the ephemeral message
|
||||
@@ -210,6 +217,9 @@ private:
|
||||
StopType mStopType;
|
||||
nsCString mSrcAttrText;
|
||||
PRBool mDoneAddingChildren;
|
||||
// Context Info for events.
|
||||
nsCOMArray<nsIXFormsContextInfo> mContextInfo;
|
||||
nsString mSrc;
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsXFormsMessageElement, nsXFormsDelegateStub)
|
||||
@@ -467,7 +477,13 @@ nsXFormsMessageElement::HandleSingleAction(nsIDOMEvent *aEvent,
|
||||
nsCOMPtr<nsIModelElementPrivate> modelPriv =
|
||||
nsXFormsUtils::GetModel(mElement);
|
||||
nsCOMPtr<nsIDOMNode> model = do_QueryInterface(modelPriv);
|
||||
nsXFormsUtils::DispatchEvent(model, eEvent_LinkError);
|
||||
|
||||
// Context Info: 'resource-uri'
|
||||
// The URI associated with the failed link.
|
||||
SetContextInfo("resource-uri", mSrc);
|
||||
|
||||
nsXFormsUtils::DispatchEvent(model, eEvent_LinkError, nsnull, nsnull,
|
||||
&mContextInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -929,6 +945,9 @@ nsXFormsMessageElement::TestExternalFile()
|
||||
if (src.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
// Remember the src attribute so we can set it in the context info
|
||||
// for the xforms-link-error event if the link fails.
|
||||
mSrc = src;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
mElement->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
@@ -993,6 +1012,9 @@ nsXFormsMessageElement::TestExternalFile()
|
||||
nsXFormsUtils::ReportError(NS_LITERAL_STRING("externalLink1Error"),
|
||||
strings, 2, mElement, mElement);
|
||||
mStopType = eStopType_LinkError;
|
||||
// Remember the src attribute so we can set it in the context info
|
||||
// for the xforms-link-error event.
|
||||
mSrc = src;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -1103,6 +1125,9 @@ nsXFormsMessageElement::OnStartRequest(nsIRequest *aRequest,
|
||||
nsXFormsUtils::ReportError(NS_LITERAL_STRING("externalLink2Error"),
|
||||
strings, 2, mElement, mElement);
|
||||
mStopType = eStopType_LinkError;
|
||||
// Remember the src attribute so we can set it in the context info
|
||||
// for the xforms-link-error event.
|
||||
mSrc = src;
|
||||
}
|
||||
|
||||
AddRemoveExternalResource(PR_FALSE);
|
||||
@@ -1129,6 +1154,9 @@ nsXFormsMessageElement::OnStartRequest(nsIRequest *aRequest,
|
||||
nsXFormsUtils::ReportError(NS_LITERAL_STRING("externalLink2Error"),
|
||||
strings, 2, mElement, mElement);
|
||||
mStopType = eStopType_LinkError;
|
||||
// Remember the src attribute so we can set it in the context info
|
||||
// for the xforms-link-error event.
|
||||
mSrc = src;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,6 +1284,24 @@ PRBool nsXFormsMessageElement::IsEphemeral()
|
||||
return level.Equals(NS_LITERAL_STRING("ephemeral"));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXFormsMessageElement::SetContextInfo(const char *aName, const nsAString &aValue)
|
||||
{
|
||||
nsCOMPtr<nsXFormsContextInfo> contextInfo = new nsXFormsContextInfo(mElement);
|
||||
NS_ENSURE_TRUE(contextInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
contextInfo->SetStringValue(aName, aValue);
|
||||
mContextInfo.AppendObject(contextInfo);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsMessageElement::GetCurrentEvent(nsIDOMEvent **aEvent)
|
||||
{
|
||||
NS_IF_ADDREF(*aEvent = mCurrentEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_HIDDEN_(nsresult)
|
||||
NS_NewXFormsMessageElement(nsIXTFElement **aResult)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user