[XForms] repeat-attrs on table causing complex content binding error. Bug 377874, r=olli+surkov

This commit is contained in:
aaronr%us.ibm.com 2007-04-20 02:08:54 +00:00
Родитель 2513e4fdd8
Коммит 88d3b8f069
3 изменённых файлов: 67 добавлений и 1 удалений

Просмотреть файл

@ -331,6 +331,15 @@ protected:
// nsXFormsControlStub override
virtual void AfterSetAttribute(nsIAtom *aName);
/**
* Override of nsXFormsStubElement's function. Needed to properly handle
* the case where the repeat is generated as anonymous content to
* elements with repeat attrs on them.
*
* @param aParent The new parent of the XForms control
*/
nsRepeatState UpdateRepeatState(nsIDOMNode *aParent);
public:
NS_DECL_ISUPPORTS_INHERITED
@ -1364,6 +1373,35 @@ nsXFormsRepeatElement::GetAnonymousContent()
return anon;
}
nsRepeatState
nsXFormsRepeatElement::UpdateRepeatState(nsIDOMNode *aParent)
{
// If the repeat is attribute based, then it is generated by anonymous
// content. In that case its repeat type is eType_NotApplicable. Otherwise,
// calculate the repeat state using the normal logic.
nsRepeatState repeatState = eType_Unknown;
if (aParent) {
PRBool isAttributeBased = PR_FALSE;
nsresult rv =
mElement->HasAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_MOZ_XFORMS_TYPE),
NS_LITERAL_STRING("attrBased"),
&isAttributeBased);
if (NS_SUCCEEDED(rv)) {
// if repeat is attribute based, it won't go through the normal
// attribute change processing, so should set the mIsAttributeBased
// variable here
mIsAttributeBased = isAttributeBased;
if (isAttributeBased) {
repeatState = eType_NotApplicable;
SetRepeatState(repeatState);
return repeatState;
}
}
}
return nsXFormsStubElement::UpdateRepeatState(aParent);
}
// Factory
NS_HIDDEN_(nsresult)
NS_NewXFormsRepeatElement(nsIXTFElement **aResult)

Просмотреть файл

@ -263,6 +263,34 @@ nsXFormsStubElement::UpdateRepeatState(nsIDOMNode *aParent)
if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("item"))) {
childIsItem = PR_TRUE;
} else {
nsCOMPtr<nsIDOMElement> parentEle(do_QueryInterface(parent));
if (!parentEle) {
// I don't know how this can possibly happen, but if it does I guess
// we should just ignore it and coninue on our way.
break;
}
// if this control is contained underneath an element that contains
// an xforms binding attribute that introduces an anonymous xf:repeat
// then the control is part of a template
PRBool repeatAttr = PR_FALSE;
parentEle->HasAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS),
NS_LITERAL_STRING("repeat-bind"),
&repeatAttr);
if (repeatAttr) {
repeatState = eType_Template;
break;
}
parentEle->HasAttributeNS(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS),
NS_LITERAL_STRING("repeat-nodeset"),
&repeatAttr);
if (repeatAttr) {
repeatState = eType_Template;
break;
}
}
nsCOMPtr<nsIDOMNode> tmp;
parent->GetParentNode(getter_AddRefs(tmp));

Просмотреть файл

@ -85,7 +85,7 @@ protected:
*
* @param aParent The new parent of the XForms control
*/
nsRepeatState UpdateRepeatState(nsIDOMNode *aParent);
virtual nsRepeatState UpdateRepeatState(nsIDOMNode *aParent);
nsRepeatState mRepeatState;