зеркало из https://github.com/mozilla/gecko-dev.git
Remaining controls implement nsIXFormsContextControl, through nsXFormsControlStub, bug 280017, r=smaug, sr=bryner
This commit is contained in:
Родитель
c2480fc4f6
Коммит
9fc0546e03
|
@ -36,7 +36,7 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
#include "nsIXFormsContextControl.idl"
|
||||||
|
|
||||||
interface nsIArray;
|
interface nsIArray;
|
||||||
interface nsIDOMNode;
|
interface nsIDOMNode;
|
||||||
|
@ -46,7 +46,7 @@ interface nsIDOMElement;
|
||||||
* Interface implemented by all XForms form control classes.
|
* Interface implemented by all XForms form control classes.
|
||||||
*/
|
*/
|
||||||
[uuid(8377c845-5d55-4eee-9a76-0f86751dcbc8)]
|
[uuid(8377c845-5d55-4eee-9a76-0f86751dcbc8)]
|
||||||
interface nsIXFormsControl : nsISupports
|
interface nsIXFormsControl : nsIXFormsContextControl
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This tells the form control to update its node binding based on the
|
* This tells the form control to update its node binding based on the
|
||||||
|
|
|
@ -67,16 +67,13 @@
|
||||||
* @see http://www.w3.org/TR/xforms/sliceF.html#id2645142
|
* @see http://www.w3.org/TR/xforms/sliceF.html#id2645142
|
||||||
* @see http://bugzilla.mozilla.org/show_bug.cgi?id=271724
|
* @see http://bugzilla.mozilla.org/show_bug.cgi?id=271724
|
||||||
*/
|
*/
|
||||||
class nsXFormsContextContainer : public nsXFormsControlStub,
|
class nsXFormsContextContainer : public nsXFormsControlStub
|
||||||
public nsIXFormsContextControl
|
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** The HTML representation for the node */
|
/** The HTML representation for the node */
|
||||||
nsCOMPtr<nsIDOMElement> mHTMLElement;
|
nsCOMPtr<nsIDOMElement> mHTMLElement;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual overrides
|
// nsIXTFXMLVisual overrides
|
||||||
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
||||||
|
|
||||||
|
@ -94,15 +91,8 @@ public:
|
||||||
|
|
||||||
// nsIXFormsContextControl
|
// nsIXFormsContextControl
|
||||||
NS_DECL_NSIXFORMSCONTEXTCONTROL
|
NS_DECL_NSIXFORMSCONTEXTCONTROL
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsContextContainer,
|
|
||||||
nsXFormsXMLVisualStub,
|
|
||||||
nsIXFormsControl,
|
|
||||||
nsIXFormsContextControl)
|
|
||||||
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual
|
// nsIXTFXMLVisual
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsContextContainer::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
nsXFormsContextContainer::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||||
|
|
|
@ -79,6 +79,11 @@ nsXFormsHintHelpListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsControlStub,
|
||||||
|
nsXFormsXMLVisualStub,
|
||||||
|
nsIXFormsContextControl,
|
||||||
|
nsIXFormsControl)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsControlStub::GetBoundNode(nsIDOMNode **aBoundNode)
|
nsXFormsControlStub::GetBoundNode(nsIDOMNode **aBoundNode)
|
||||||
{
|
{
|
||||||
|
@ -374,3 +379,39 @@ nsXFormsControlStub::AttributeSet(nsIAtom *aName, const nsAString &aValue)
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nsIXFormsContextControl
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsXFormsControlStub::SetContextNode(nsIDOMNode *aContextNode)
|
||||||
|
{
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsXFormsControlStub::GetContext(nsAString &aModelID,
|
||||||
|
nsIDOMNode **aContextNode,
|
||||||
|
PRInt32 *aContextPosition,
|
||||||
|
PRInt32 *aContextSize)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG(aContextSize);
|
||||||
|
NS_ENSURE_ARG(aContextPosition);
|
||||||
|
|
||||||
|
*aContextPosition = 1;
|
||||||
|
*aContextSize = 1;
|
||||||
|
|
||||||
|
if (mBoundNode && aContextNode) {
|
||||||
|
CallQueryInterface(mBoundNode, aContextNode); // addrefs
|
||||||
|
NS_ASSERTION(*aContextNode, "could not QI context node from bound node?");
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @todo expensive to run this
|
||||||
|
nsCOMPtr<nsIDOMElement> model = do_QueryInterface(mModel);
|
||||||
|
if (model) {
|
||||||
|
model->GetAttribute(NS_LITERAL_STRING("id"), aModelID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,17 @@ class nsIXTFXMLVisualWrapper;
|
||||||
* It also inherits from nsXFormsXMLVisualStub, and overrides a couple of its
|
* It also inherits from nsXFormsXMLVisualStub, and overrides a couple of its
|
||||||
* functions.
|
* functions.
|
||||||
*
|
*
|
||||||
* @todo nsIXFormsContextControl-stub should probably also be included here
|
* @bug If a control has a model attribute, but no binding attributes we fail
|
||||||
* (mBoundNode is in fact also the context) (XXX)
|
* to set this as the context for children. We need to return the contextnode
|
||||||
|
* from EvaluateNodeBinding in that case, and return that in GetContext(). (XXX)
|
||||||
|
* @see http://bugzilla.mozilla.org/show_bug.cgi?id=280366
|
||||||
*/
|
*/
|
||||||
class nsXFormsControlStub : public nsIXFormsControl,
|
class nsXFormsControlStub : public nsIXFormsControl,
|
||||||
public nsXFormsXMLVisualStub
|
public nsXFormsXMLVisualStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
/** The standard notification flags set on nsIXTFElement */
|
/** The standard notification flags set on nsIXTFElement */
|
||||||
const PRUint32 kStandardNotificationMask;
|
const PRUint32 kStandardNotificationMask;
|
||||||
/**
|
/**
|
||||||
|
@ -99,6 +103,9 @@ public:
|
||||||
NS_IMETHOD ParentChanged(nsIDOMElement *aNewParent);
|
NS_IMETHOD ParentChanged(nsIDOMElement *aNewParent);
|
||||||
NS_IMETHOD WillSetAttribute(nsIAtom *aName, const nsAString &aValue);
|
NS_IMETHOD WillSetAttribute(nsIAtom *aName, const nsAString &aValue);
|
||||||
NS_IMETHOD AttributeSet(nsIAtom *aName, const nsAString &aValue);
|
NS_IMETHOD AttributeSet(nsIAtom *aName, const nsAString &aValue);
|
||||||
|
|
||||||
|
// nsIXFormsContextControl
|
||||||
|
NS_DECL_NSIXFORMSCONTEXTCONTROL
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
nsXFormsControlStub() :
|
nsXFormsControlStub() :
|
||||||
|
|
|
@ -51,7 +51,6 @@
|
||||||
#include "nsIXTFXMLVisualWrapper.h"
|
#include "nsIXTFXMLVisualWrapper.h"
|
||||||
|
|
||||||
#include "nsXFormsControlStub.h"
|
#include "nsXFormsControlStub.h"
|
||||||
#include "nsIXFormsContextControl.h"
|
|
||||||
#include "nsIModelElementPrivate.h"
|
#include "nsIModelElementPrivate.h"
|
||||||
#include "nsXFormsUtils.h"
|
#include "nsXFormsUtils.h"
|
||||||
|
|
||||||
|
@ -67,34 +66,19 @@
|
||||||
* @todo If a \<label\> is the first element child for \<group\> it is the
|
* @todo If a \<label\> is the first element child for \<group\> it is the
|
||||||
* label for the entire group
|
* label for the entire group
|
||||||
*
|
*
|
||||||
* @todo "Setting the input focus on a group results in the focus being set to
|
* @todo With some small adjustments we could let nsXFormsContextContainer
|
||||||
* the first form control in the navigation order within that group."
|
* implement group, and get rid of this class (XXX).
|
||||||
* (spec. 9.1.1)
|
|
||||||
*
|
|
||||||
* @bug If a group only has a model attribute, the group fails to set this for
|
|
||||||
* children, as it is impossible to distinguish between a failure and absence
|
|
||||||
* of binding attributes when calling ProcessNodeBinding().
|
|
||||||
*/
|
*/
|
||||||
class nsXFormsGroupElement : public nsXFormsControlStub,
|
class nsXFormsGroupElement : public nsXFormsControlStub
|
||||||
public nsIXFormsContextControl
|
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/** Tries to focus a child form control.*/
|
/** Tries to focus a child form control.*/
|
||||||
PRBool TryFocusChildControl(nsIDOMNode* aParent);
|
PRBool TryFocusChildControl(nsIDOMNode *aParent);
|
||||||
|
|
||||||
/** The UI HTML element used to represent the tag */
|
/** The UI HTML element used to represent the tag */
|
||||||
nsCOMPtr<nsIDOMHTMLDivElement> mHTMLElement;
|
nsCOMPtr<nsIDOMHTMLDivElement> mHTMLElement;
|
||||||
|
|
||||||
/** The current ID of the model node is bound to */
|
|
||||||
nsString mModelID;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
nsXFormsGroupElement();
|
|
||||||
~nsXFormsGroupElement();
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual overrides
|
// nsIXTFXMLVisual overrides
|
||||||
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
||||||
|
|
||||||
|
@ -106,31 +90,10 @@ public:
|
||||||
NS_IMETHOD OnDestroyed();
|
NS_IMETHOD OnDestroyed();
|
||||||
|
|
||||||
// nsIXFormsControl
|
// nsIXFormsControl
|
||||||
NS_IMETHOD Bind();
|
|
||||||
NS_IMETHOD Refresh();
|
NS_IMETHOD Refresh();
|
||||||
NS_IMETHOD TryFocus(PRBool* aOK);
|
NS_IMETHOD TryFocus(PRBool *aOK);
|
||||||
|
|
||||||
// nsIXFormsContextControl
|
|
||||||
NS_DECL_NSIXFORMSCONTEXTCONTROL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsGroupElement,
|
|
||||||
nsXFormsXMLVisualStub,
|
|
||||||
nsIXFormsControl,
|
|
||||||
nsIXFormsContextControl)
|
|
||||||
|
|
||||||
MOZ_DECL_CTOR_COUNTER(nsXFormsGroupElement)
|
|
||||||
|
|
||||||
nsXFormsGroupElement::nsXFormsGroupElement()
|
|
||||||
{
|
|
||||||
MOZ_COUNT_CTOR(nsXFormsGroupElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsXFormsGroupElement::~nsXFormsGroupElement()
|
|
||||||
{
|
|
||||||
MOZ_COUNT_DTOR(nsXFormsGroupElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual
|
// nsIXTFXMLVisual
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsGroupElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
nsXFormsGroupElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||||
|
@ -182,22 +145,6 @@ nsXFormsGroupElement::OnDestroyed()
|
||||||
|
|
||||||
// nsIXFormsControl
|
// nsIXFormsControl
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXFormsGroupElement::Bind()
|
|
||||||
{
|
|
||||||
mModelID.Truncate();
|
|
||||||
|
|
||||||
// Re-evaluate what instance node this element is bound to.
|
|
||||||
ResetBoundNode();
|
|
||||||
|
|
||||||
// Get model ID
|
|
||||||
nsCOMPtr<nsIDOMElement> modelElement = do_QueryInterface(mModel);
|
|
||||||
NS_ENSURE_TRUE(modelElement, NS_ERROR_FAILURE);
|
|
||||||
modelElement->GetAttribute(NS_LITERAL_STRING("id"), mModelID);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsGroupElement::Refresh()
|
nsXFormsGroupElement::Refresh()
|
||||||
{
|
{
|
||||||
|
@ -250,35 +197,6 @@ nsXFormsGroupElement::TryFocus(PRBool* aOK)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIXFormsContextControl
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXFormsGroupElement::SetContextNode(nsIDOMNode *aContextNode)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsXFormsGroupElement::GetContext(nsAString& aModelID,
|
|
||||||
nsIDOMNode **aContextNode,
|
|
||||||
PRInt32 *aContextPosition,
|
|
||||||
PRInt32 *aContextSize)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG_XF_GROUP
|
|
||||||
printf("nsXFormsGroupElement::GetContext()\n");
|
|
||||||
#endif
|
|
||||||
NS_ENSURE_ARG(aContextSize);
|
|
||||||
NS_ENSURE_ARG(aContextPosition);
|
|
||||||
|
|
||||||
*aContextPosition = 1;
|
|
||||||
*aContextSize = 1;
|
|
||||||
|
|
||||||
if (mBoundNode && aContextNode)
|
|
||||||
CallQueryInterface(mBoundNode, aContextNode); // addrefs
|
|
||||||
aModelID = mModelID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Factory
|
// Factory
|
||||||
NS_HIDDEN_(nsresult)
|
NS_HIDDEN_(nsresult)
|
||||||
NS_NewXFormsGroupElement(nsIXTFElement **aResult)
|
NS_NewXFormsGroupElement(nsIXTFElement **aResult)
|
||||||
|
|
|
@ -111,9 +111,8 @@ private:
|
||||||
PRBool mIncremental;
|
PRBool mIncremental;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED3(nsXFormsInputElement,
|
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsInputElement,
|
||||||
nsXFormsXMLVisualStub,
|
nsXFormsControlStub,
|
||||||
nsIXFormsControl,
|
|
||||||
nsIDOMFocusListener,
|
nsIDOMFocusListener,
|
||||||
nsIDOMEventListener)
|
nsIDOMEventListener)
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,6 @@
|
||||||
class nsXFormsLabelElement : public nsXFormsControlStub
|
class nsXFormsLabelElement : public nsXFormsControlStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// nsIXFormsControl
|
// nsIXFormsControl
|
||||||
NS_IMETHOD Refresh();
|
NS_IMETHOD Refresh();
|
||||||
|
|
||||||
|
@ -79,10 +77,6 @@ private:
|
||||||
nsCOMPtr<nsIDOMElement> mInnerSpan;
|
nsCOMPtr<nsIDOMElement> mInnerSpan;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsLabelElement,
|
|
||||||
nsXFormsXMLVisualStub,
|
|
||||||
nsIXFormsControl)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsLabelElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
nsXFormsLabelElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,8 +68,6 @@
|
||||||
class nsXFormsOutputElement : public nsXFormsControlStub
|
class nsXFormsOutputElement : public nsXFormsControlStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual overrides
|
// nsIXTFXMLVisual overrides
|
||||||
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
||||||
|
|
||||||
|
@ -93,10 +91,6 @@ private:
|
||||||
PRBool mHasBinding;
|
PRBool mHasBinding;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsOutputElement,
|
|
||||||
nsXFormsXMLVisualStub,
|
|
||||||
nsIXFormsControl)
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual
|
// nsIXTFXMLVisual
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -143,8 +143,6 @@ protected:
|
||||||
const PRUint16 aType);
|
const PRUint16 aType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual overrides
|
// nsIXTFXMLVisual overrides
|
||||||
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
||||||
|
|
||||||
|
@ -166,11 +164,6 @@ public:
|
||||||
nsXFormsRepeatElement() : mAddingChildren(PR_FALSE) {};
|
nsXFormsRepeatElement() : mAddingChildren(PR_FALSE) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsRepeatElement,
|
|
||||||
nsXFormsXMLVisualStub,
|
|
||||||
nsIXFormsControl)
|
|
||||||
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual
|
// nsIXTFXMLVisual
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsRepeatElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
nsXFormsRepeatElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||||
|
@ -450,7 +443,9 @@ nsXFormsRepeatElement::TryFocus(PRBool* aOK)
|
||||||
* only live here until this is implemented there. (XXX)
|
* only live here until this is implemented there. (XXX)
|
||||||
*/
|
*/
|
||||||
nsresult
|
nsresult
|
||||||
nsXFormsRepeatElement::GetIntAttr(const nsAString& aName, PRInt32* aVal, const PRUint16 aType)
|
nsXFormsRepeatElement::GetIntAttr(const nsAString &aName,
|
||||||
|
PRInt32 *aVal,
|
||||||
|
const PRUint16 aType)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
|
|
@ -95,9 +95,8 @@ private:
|
||||||
nsVoidArray mOptions;
|
nsVoidArray mOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsSelectElement,
|
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsSelectElement,
|
||||||
nsXFormsXMLVisualStub,
|
nsXFormsControlStub,
|
||||||
nsIXFormsControl,
|
|
||||||
nsIDOMEventListener)
|
nsIDOMEventListener)
|
||||||
|
|
||||||
// nsIXTFXMLVisual
|
// nsIXTFXMLVisual
|
||||||
|
|
|
@ -55,29 +55,25 @@
|
||||||
#include "nsIModelElementPrivate.h"
|
#include "nsIModelElementPrivate.h"
|
||||||
#include "nsIXFormsSwitchElement.h"
|
#include "nsIXFormsSwitchElement.h"
|
||||||
#include "nsIXFormsCaseElement.h"
|
#include "nsIXFormsCaseElement.h"
|
||||||
#include "nsIXFormsContextControl.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the XForms \<switch\> element.
|
* Implementation of the XForms \<switch\> element.
|
||||||
*
|
*
|
||||||
* @see http://www.w3.org/TR/xforms/slice9.html#id2631571
|
* @see http://www.w3.org/TR/xforms/slice9.html#id2631571
|
||||||
*
|
|
||||||
* The implementation of the context control is based on
|
|
||||||
* nsXFormsGroupElement.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class nsXFormsSwitchElement : public nsIXFormsSwitchElement,
|
class nsXFormsSwitchElement : public nsIXFormsSwitchElement,
|
||||||
public nsIXFormsContextControl,
|
|
||||||
public nsXFormsControlStub
|
public nsXFormsControlStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsXFormsSwitchElement();
|
nsXFormsSwitchElement() : mAddingChildren(PR_FALSE) {}
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
|
||||||
NS_IMETHOD ChildInserted(nsIDOMNode *aChild, PRUint32 aIndex);
|
NS_IMETHOD ChildInserted(nsIDOMNode *aChild, PRUint32 aIndex);
|
||||||
NS_IMETHOD ChildAppended(nsIDOMNode *aChild);
|
NS_IMETHOD ChildAppended(nsIDOMNode *aChild);
|
||||||
NS_IMETHOD WillRemoveChild(PRUint32 aIndex);
|
NS_IMETHOD WillRemoveChild(PRUint32 aIndex);
|
||||||
|
NS_IMETHOD BeginAddingChildren();
|
||||||
NS_IMETHOD DoneAddingChildren();
|
NS_IMETHOD DoneAddingChildren();
|
||||||
NS_IMETHOD OnDestroyed();
|
NS_IMETHOD OnDestroyed();
|
||||||
|
|
||||||
|
@ -88,11 +84,8 @@ public:
|
||||||
NS_DECL_NSIXFORMSSWITCHELEMENT
|
NS_DECL_NSIXFORMSSWITCHELEMENT
|
||||||
|
|
||||||
// nsIXFormsControl
|
// nsIXFormsControl
|
||||||
NS_IMETHOD Bind();
|
|
||||||
NS_IMETHOD Refresh();
|
NS_IMETHOD Refresh();
|
||||||
|
|
||||||
NS_DECL_NSIXFORMSCONTEXTCONTROL
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* http://www.w3.org/TR/xforms/slice9.html#ui-case
|
* http://www.w3.org/TR/xforms/slice9.html#ui-case
|
||||||
|
@ -120,19 +113,13 @@ private:
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMElement> mVisual;
|
nsCOMPtr<nsIDOMElement> mVisual;
|
||||||
nsCOMPtr<nsIDOMElement> mSelected;
|
nsCOMPtr<nsIDOMElement> mSelected;
|
||||||
PRBool mDoneAddingChildren;
|
PRBool mAddingChildren;
|
||||||
nsString mModelID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nsXFormsSwitchElement::nsXFormsSwitchElement() : mDoneAddingChildren(PR_FALSE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED3(nsXFormsSwitchElement,
|
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsSwitchElement,
|
||||||
nsXFormsXMLVisualStub,
|
nsXFormsControlStub,
|
||||||
nsIXFormsSwitchElement,
|
nsIXFormsSwitchElement)
|
||||||
nsIXFormsControl,
|
|
||||||
nsIXFormsContextControl)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsSwitchElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
nsXFormsSwitchElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||||
|
@ -141,6 +128,7 @@ nsXFormsSwitchElement::OnCreated(nsIXTFXMLVisualWrapper *aWrapper)
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
aWrapper->SetNotificationMask(kStandardNotificationMask |
|
aWrapper->SetNotificationMask(kStandardNotificationMask |
|
||||||
|
nsIXTFElement::NOTIFY_BEGIN_ADDING_CHILDREN |
|
||||||
nsIXTFElement::NOTIFY_DONE_ADDING_CHILDREN |
|
nsIXTFElement::NOTIFY_DONE_ADDING_CHILDREN |
|
||||||
nsIXTFElement::NOTIFY_CHILD_APPENDED |
|
nsIXTFElement::NOTIFY_CHILD_APPENDED |
|
||||||
nsIXTFElement::NOTIFY_CHILD_INSERTED |
|
nsIXTFElement::NOTIFY_CHILD_INSERTED |
|
||||||
|
@ -183,7 +171,7 @@ nsXFormsSwitchElement::OnDestroyed()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsSwitchElement::ChildInserted(nsIDOMNode *aChild, PRUint32 aIndex)
|
nsXFormsSwitchElement::ChildInserted(nsIDOMNode *aChild, PRUint32 aIndex)
|
||||||
{
|
{
|
||||||
if (mDoneAddingChildren)
|
if (!mAddingChildren)
|
||||||
CaseChanged(aChild, PR_FALSE);
|
CaseChanged(aChild, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +179,7 @@ nsXFormsSwitchElement::ChildInserted(nsIDOMNode *aChild, PRUint32 aIndex)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsSwitchElement::ChildAppended(nsIDOMNode *aChild)
|
nsXFormsSwitchElement::ChildAppended(nsIDOMNode *aChild)
|
||||||
{
|
{
|
||||||
if (mDoneAddingChildren)
|
if (!mAddingChildren)
|
||||||
CaseChanged(aChild, PR_FALSE);
|
CaseChanged(aChild, PR_FALSE);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +187,7 @@ nsXFormsSwitchElement::ChildAppended(nsIDOMNode *aChild)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsSwitchElement::WillRemoveChild(PRUint32 aIndex)
|
nsXFormsSwitchElement::WillRemoveChild(PRUint32 aIndex)
|
||||||
{
|
{
|
||||||
if (mDoneAddingChildren) {
|
if (!mAddingChildren) {
|
||||||
nsCOMPtr<nsIDOMNodeList> list;
|
nsCOMPtr<nsIDOMNodeList> list;
|
||||||
mElement->GetChildNodes(getter_AddRefs(list));
|
mElement->GetChildNodes(getter_AddRefs(list));
|
||||||
if (list) {
|
if (list) {
|
||||||
|
@ -211,6 +199,13 @@ nsXFormsSwitchElement::WillRemoveChild(PRUint32 aIndex)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsXFormsSwitchElement::BeginAddingChildren()
|
||||||
|
{
|
||||||
|
mAddingChildren = PR_TRUE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsSwitchElement::DoneAddingChildren()
|
nsXFormsSwitchElement::DoneAddingChildren()
|
||||||
{
|
{
|
||||||
|
@ -218,29 +213,13 @@ nsXFormsSwitchElement::DoneAddingChildren()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
mDoneAddingChildren = PR_TRUE;
|
mAddingChildren = PR_FALSE;
|
||||||
Refresh();
|
Refresh();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIXFormsControl
|
// nsIXFormsControl
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXFormsSwitchElement::Bind()
|
|
||||||
{
|
|
||||||
mModelID.Truncate();
|
|
||||||
|
|
||||||
// Re-evaluate what instance node this element is bound to.
|
|
||||||
ResetBoundNode();
|
|
||||||
|
|
||||||
// Get model ID
|
|
||||||
nsCOMPtr<nsIDOMElement> modelElement = do_QueryInterface(mModel);
|
|
||||||
NS_ENSURE_TRUE(modelElement, NS_ERROR_FAILURE);
|
|
||||||
modelElement->GetAttribute(NS_LITERAL_STRING("id"), mModelID);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXFormsSwitchElement::Refresh()
|
nsXFormsSwitchElement::Refresh()
|
||||||
{
|
{
|
||||||
|
@ -249,36 +228,6 @@ nsXFormsSwitchElement::Refresh()
|
||||||
|
|
||||||
// nsXFormsSwitchElement
|
// nsXFormsSwitchElement
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsXFormsSwitchElement::SetContextNode(nsIDOMNode *aContextNode)
|
|
||||||
{
|
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsXFormsSwitchElement::GetContext(nsAString& aModelID,
|
|
||||||
nsIDOMNode **aContextNode,
|
|
||||||
PRInt32 *aContextPosition,
|
|
||||||
PRInt32 *aContextSize)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG(aContextSize);
|
|
||||||
NS_ENSURE_ARG(aContextPosition);
|
|
||||||
|
|
||||||
/** @todo Not too elegant to call Process() here, but DoneAddingChildren is,
|
|
||||||
* logically, called on children before us. We need a notification
|
|
||||||
* that goes from the document node and DOWN, where the controls
|
|
||||||
* should Refresh().
|
|
||||||
*/
|
|
||||||
*aContextPosition = 1;
|
|
||||||
*aContextSize = 1;
|
|
||||||
|
|
||||||
if (mBoundNode && aContextNode)
|
|
||||||
CallQueryInterface(mBoundNode, aContextNode); // addrefs
|
|
||||||
aModelID = mModelID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsXFormsSwitchElement::Init(nsIDOMElement* aDeselected)
|
nsXFormsSwitchElement::Init(nsIDOMElement* aDeselected)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,8 +52,6 @@
|
||||||
class nsXFormsTriggerElement : public nsXFormsControlStub
|
class nsXFormsTriggerElement : public nsXFormsControlStub
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual overrides
|
// nsIXTFXMLVisual overrides
|
||||||
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
NS_IMETHOD OnCreated(nsIXTFXMLVisualWrapper *aWrapper);
|
||||||
|
|
||||||
|
@ -69,10 +67,6 @@ protected:
|
||||||
nsCOMPtr<nsIDOMHTMLButtonElement> mButton;
|
nsCOMPtr<nsIDOMHTMLButtonElement> mButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsTriggerElement,
|
|
||||||
nsXFormsXMLVisualStub,
|
|
||||||
nsIXFormsControl)
|
|
||||||
|
|
||||||
// nsIXTFXMLVisual
|
// nsIXTFXMLVisual
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -102,9 +102,8 @@ private:
|
||||||
nsCOMPtr<nsIDOMHTMLInputElement> mInput;
|
nsCOMPtr<nsIDOMHTMLInputElement> mInput;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED3(nsXFormsUploadElement,
|
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsUploadElement,
|
||||||
nsXFormsXMLVisualStub,
|
nsXFormsControlStub,
|
||||||
nsIXFormsControl,
|
|
||||||
nsIDOMFocusListener,
|
nsIDOMFocusListener,
|
||||||
nsIDOMEventListener)
|
nsIDOMEventListener)
|
||||||
|
|
||||||
|
|
|
@ -316,7 +316,6 @@ nsXFormsUtils::GetModel(nsIDOMElement *aElement,
|
||||||
PRUint32 aElementFlags)
|
PRUint32 aElementFlags)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
nsCOMPtr<nsIModelElementPrivate> model;
|
nsCOMPtr<nsIModelElementPrivate> model;
|
||||||
nsCOMPtr<nsIDOMNode> contextNode;
|
nsCOMPtr<nsIDOMNode> contextNode;
|
||||||
nsCOMPtr<nsIDOMElement> bind;
|
nsCOMPtr<nsIDOMElement> bind;
|
||||||
|
@ -820,12 +819,15 @@ nsXFormsUtils::FindParentContext(nsIDOMElement *aElement,
|
||||||
nsAutoString contextModelID;
|
nsAutoString contextModelID;
|
||||||
while (curNode) {
|
while (curNode) {
|
||||||
nsCOMPtr<nsIXFormsContextControl> contextControl = do_QueryInterface(curNode);
|
nsCOMPtr<nsIXFormsContextControl> contextControl = do_QueryInterface(curNode);
|
||||||
nsCOMPtr<nsIDOMElement> cElement = do_QueryInterface(curNode);
|
|
||||||
if (contextControl && cElement) {
|
if (contextControl) {
|
||||||
PRInt32 cSize;
|
PRInt32 cSize;
|
||||||
PRInt32 cPosition;
|
PRInt32 cPosition;
|
||||||
nsCOMPtr<nsIDOMNode> tempNode;
|
nsCOMPtr<nsIDOMNode> tempNode;
|
||||||
rv = contextControl->GetContext(contextModelID, getter_AddRefs(tempNode), &cPosition, &cSize);
|
rv = contextControl->GetContext(contextModelID,
|
||||||
|
getter_AddRefs(tempNode),
|
||||||
|
&cPosition,
|
||||||
|
&cSize);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// If the call failed, it means that we _have_ a parent which sets the
|
// If the call failed, it means that we _have_ a parent which sets the
|
||||||
// context but it is invalid, ie. the XPath expression could have
|
// context but it is invalid, ie. the XPath expression could have
|
||||||
|
|
Загрузка…
Ссылка в новой задаче