зеркало из https://github.com/mozilla/pjs.git
[XForms] Fix excessive refreshing for delegate controls. Bug 327985, r=aaronr+me, patch by surkov@dc.baikal.ru
This commit is contained in:
Родитель
5f6eb6ecbc
Коммит
85aa37d6cb
|
@ -102,19 +102,19 @@ NS_IMETHODIMP
|
|||
nsXFormsDelegateStub::Refresh()
|
||||
{
|
||||
if (mRepeatState == eType_Template)
|
||||
return NS_OK;
|
||||
return NS_OK_XFORMS_NOREFRESH;
|
||||
|
||||
const nsVoidArray* list = nsPostRefresh::PostRefreshList();
|
||||
if (list && list->IndexOf(this) >= 0) {
|
||||
// This control will be refreshed later.
|
||||
return NS_OK;
|
||||
return NS_OK_XFORMS_NOREFRESH;
|
||||
}
|
||||
|
||||
SetMozTypeAttribute();
|
||||
|
||||
nsCOMPtr<nsIXFormsUIWidget> widget = do_QueryInterface(mElement);
|
||||
if (!widget)
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return widget->Refresh();
|
||||
}
|
||||
|
@ -224,6 +224,10 @@ nsXFormsDelegateStub::UpdateRepeatState()
|
|||
mRepeatState = eType_Template;
|
||||
break;
|
||||
}
|
||||
if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("itemset"))) {
|
||||
mRepeatState = eType_Template;
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
parent->GetParentNode(getter_AddRefs(tmp));
|
||||
parent = tmp;
|
||||
|
|
|
@ -259,7 +259,10 @@ nsXFormsLabelElement::LoadExternalLabel(const nsAString& aSrc)
|
|||
NS_IMETHODIMP
|
||||
nsXFormsLabelElement::Refresh()
|
||||
{
|
||||
nsXFormsDelegateStub::Refresh();
|
||||
nsresult rv = nsXFormsDelegateStub::Refresh();
|
||||
if (NS_FAILED(rv) || rv == NS_OK_XFORMS_NOREFRESH)
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
mElement->GetParentNode(getter_AddRefs(parent));
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
private:
|
||||
PRBool mHasBinding;
|
||||
nsString mValue;
|
||||
PRBool mValueIsDirty;
|
||||
};
|
||||
|
||||
// nsIXFormsControl
|
||||
|
@ -142,43 +143,35 @@ nsXFormsOutputElement::Bind()
|
|||
NS_IMETHODIMP
|
||||
nsXFormsOutputElement::Refresh()
|
||||
{
|
||||
if (mRepeatState == eType_Template)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
SetDOMStringToNull(mValue);
|
||||
|
||||
if (mModel) {
|
||||
if (mHasBinding) {
|
||||
if (mBoundNode) {
|
||||
nsXFormsUtils::GetNodeValue(mBoundNode, mValue);
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMXPathResult> result;
|
||||
rv = ProcessNodeBinding(NS_LITERAL_STRING("value"),
|
||||
nsIDOMXPathResult::STRING_TYPE,
|
||||
getter_AddRefs(result));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (result) {
|
||||
rv = result->GetStringValue(mValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetMozTypeAttribute();
|
||||
|
||||
nsCOMPtr<nsIXFormsUIWidget> widget = do_QueryInterface(mElement);
|
||||
if (widget)
|
||||
widget->Refresh();
|
||||
|
||||
return rv;
|
||||
mValueIsDirty = PR_TRUE;
|
||||
return nsXFormsDelegateStub::Refresh();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsOutputElement::GetValue(nsAString& aValue)
|
||||
{
|
||||
NS_ENSURE_STATE(mModel);
|
||||
|
||||
if (mValueIsDirty) {
|
||||
if (mHasBinding) {
|
||||
NS_ENSURE_STATE(mBoundNode);
|
||||
nsXFormsUtils::GetNodeValue(mBoundNode, mValue);
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMXPathResult> result;
|
||||
nsresult rv = ProcessNodeBinding(NS_LITERAL_STRING("value"),
|
||||
nsIDOMXPathResult::STRING_TYPE,
|
||||
getter_AddRefs(result));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (result) {
|
||||
SetDOMStringToNull(mValue);
|
||||
rv = result->GetStringValue(mValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
mValueIsDirty = PR_FALSE;
|
||||
}
|
||||
|
||||
aValue = mValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ nsXFormsUploadElement::Refresh()
|
|||
// type 'anyURI', 'base64Binary', or 'hexBinary'.
|
||||
|
||||
nsresult rv = nsXFormsDelegateStub::Refresh();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_FAILED(rv) || rv == NS_OK_XFORMS_NOREFRESH)
|
||||
return rv;
|
||||
|
||||
if (!mBoundNode)
|
||||
return NS_OK;
|
||||
|
|
|
@ -66,6 +66,13 @@ class nsIDOMEvent;
|
|||
#define NS_NAMESPACE_SOAP_ENVELOPE "http://schemas.xmlsoap.org/soap/envelope/"
|
||||
#define NS_NAMESPACE_MOZ_XFORMS_LAZY "http://www.mozilla.org/projects/xforms/2005/lazy"
|
||||
|
||||
/**
|
||||
* Error codes
|
||||
*/
|
||||
|
||||
#define NS_OK_XFORMS_NOREFRESH \
|
||||
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 1)
|
||||
|
||||
/**
|
||||
* XForms event types
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче