зеркало из 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()
|
nsXFormsDelegateStub::Refresh()
|
||||||
{
|
{
|
||||||
if (mRepeatState == eType_Template)
|
if (mRepeatState == eType_Template)
|
||||||
return NS_OK;
|
return NS_OK_XFORMS_NOREFRESH;
|
||||||
|
|
||||||
const nsVoidArray* list = nsPostRefresh::PostRefreshList();
|
const nsVoidArray* list = nsPostRefresh::PostRefreshList();
|
||||||
if (list && list->IndexOf(this) >= 0) {
|
if (list && list->IndexOf(this) >= 0) {
|
||||||
// This control will be refreshed later.
|
// This control will be refreshed later.
|
||||||
return NS_OK;
|
return NS_OK_XFORMS_NOREFRESH;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMozTypeAttribute();
|
SetMozTypeAttribute();
|
||||||
|
|
||||||
nsCOMPtr<nsIXFormsUIWidget> widget = do_QueryInterface(mElement);
|
nsCOMPtr<nsIXFormsUIWidget> widget = do_QueryInterface(mElement);
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return NS_OK;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
return widget->Refresh();
|
return widget->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,10 @@ nsXFormsDelegateStub::UpdateRepeatState()
|
||||||
mRepeatState = eType_Template;
|
mRepeatState = eType_Template;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("itemset"))) {
|
||||||
|
mRepeatState = eType_Template;
|
||||||
|
break;
|
||||||
|
}
|
||||||
nsCOMPtr<nsIDOMNode> tmp;
|
nsCOMPtr<nsIDOMNode> tmp;
|
||||||
parent->GetParentNode(getter_AddRefs(tmp));
|
parent->GetParentNode(getter_AddRefs(tmp));
|
||||||
parent = tmp;
|
parent = tmp;
|
||||||
|
|
|
@ -259,7 +259,10 @@ nsXFormsLabelElement::LoadExternalLabel(const nsAString& aSrc)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsLabelElement::Refresh()
|
nsXFormsLabelElement::Refresh()
|
||||||
{
|
{
|
||||||
nsXFormsDelegateStub::Refresh();
|
nsresult rv = nsXFormsDelegateStub::Refresh();
|
||||||
|
if (NS_FAILED(rv) || rv == NS_OK_XFORMS_NOREFRESH)
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNode> parent;
|
nsCOMPtr<nsIDOMNode> parent;
|
||||||
mElement->GetParentNode(getter_AddRefs(parent));
|
mElement->GetParentNode(getter_AddRefs(parent));
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
private:
|
private:
|
||||||
PRBool mHasBinding;
|
PRBool mHasBinding;
|
||||||
nsString mValue;
|
nsString mValue;
|
||||||
|
PRBool mValueIsDirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
// nsIXFormsControl
|
// nsIXFormsControl
|
||||||
|
@ -142,43 +143,35 @@ nsXFormsOutputElement::Bind()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsOutputElement::Refresh()
|
nsXFormsOutputElement::Refresh()
|
||||||
{
|
{
|
||||||
if (mRepeatState == eType_Template)
|
mValueIsDirty = PR_TRUE;
|
||||||
return NS_OK;
|
return nsXFormsDelegateStub::Refresh();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsOutputElement::GetValue(nsAString& aValue)
|
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;
|
aValue = mValue;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,8 @@ nsXFormsUploadElement::Refresh()
|
||||||
// type 'anyURI', 'base64Binary', or 'hexBinary'.
|
// type 'anyURI', 'base64Binary', or 'hexBinary'.
|
||||||
|
|
||||||
nsresult rv = nsXFormsDelegateStub::Refresh();
|
nsresult rv = nsXFormsDelegateStub::Refresh();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv) || rv == NS_OK_XFORMS_NOREFRESH)
|
||||||
|
return rv;
|
||||||
|
|
||||||
if (!mBoundNode)
|
if (!mBoundNode)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -66,6 +66,13 @@ class nsIDOMEvent;
|
||||||
#define NS_NAMESPACE_SOAP_ENVELOPE "http://schemas.xmlsoap.org/soap/envelope/"
|
#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"
|
#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
|
* XForms event types
|
||||||
*
|
*
|
||||||
|
|
Загрузка…
Ссылка в новой задаче