mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
[XForms] Revise custom control interface. Bug 306764, r=aaronr+smaug
This commit is contained in:
parent
780d910948
commit
9230d32f1f
@ -124,10 +124,12 @@ XPIDLSRCS = \
|
||||
nsIXFormsSubmissionElement.idl \
|
||||
nsIXFormsControlBase.idl \
|
||||
nsIXFormsDelegate.idl \
|
||||
nsIDelegateInternal.idl \
|
||||
nsIXFormsUIWidget.idl \
|
||||
nsIXFormsItemElement.idl \
|
||||
nsIXFormsLabelElement.idl \
|
||||
nsIXFormsItemSetUIElement.idl \
|
||||
nsIXFormsAccessors.idl \
|
||||
nsIXFormsUploadElement.idl \
|
||||
nsIXFormsUploadUIElement.idl \
|
||||
$(NULL)
|
||||
@ -185,6 +187,7 @@ CPPSRCS = \
|
||||
nsXFormsControlStub.cpp \
|
||||
nsXFormsUtilityService.cpp \
|
||||
nsXFormsDelegateStub.cpp \
|
||||
nsXFormsAccessors.cpp \
|
||||
$(NULL)
|
||||
|
||||
# Standard Mozilla make rules
|
||||
|
57
extensions/xforms/nsIDelegateInternal.idl
Normal file
57
extensions/xforms/nsIDelegateInternal.idl
Normal file
@ -0,0 +1,57 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla XForms support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Novell, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Allan Beaufour <abeaufour@novell.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIXFormsDelegate.idl"
|
||||
|
||||
/**
|
||||
* Internal interface implemented by XForms controls that delegates the UI to
|
||||
* an external entity.
|
||||
*/
|
||||
[uuid(aec21659-67e6-4808-b877-670ff756636a)]
|
||||
interface nsIDelegateInternal : nsIXFormsDelegate
|
||||
{
|
||||
/**
|
||||
* The value bound to the XForms control.
|
||||
*/
|
||||
attribute DOMString value;
|
||||
|
||||
/**
|
||||
* Is the delegate bound to a node?
|
||||
*/
|
||||
readonly attribute boolean hasBoundNode;
|
||||
};
|
84
extensions/xforms/nsIXFormsAccessors.idl
Normal file
84
extensions/xforms/nsIXFormsAccessors.idl
Normal file
@ -0,0 +1,84 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla XForms support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Novell, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Allan Beaufour <abeaufour@novell.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* Interface exposing the states of an XForms control.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://developer.mozilla.org/en/docs/XForms:Custom_Controls
|
||||
*/
|
||||
[scriptable, uuid(8e8c5022-a61d-42cf-9551-74215dc611ad)]
|
||||
interface nsIXFormsAccessors : nsISupports
|
||||
{
|
||||
/**
|
||||
* Get the value bound to the XForms control.
|
||||
*/
|
||||
DOMString getValue();
|
||||
|
||||
/**
|
||||
* Set the value bound to the XForms control.
|
||||
*/
|
||||
void setValue(in DOMString value);
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-readOnly
|
||||
*/
|
||||
boolean isReadonly();
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-relevant
|
||||
*/
|
||||
boolean isRelevant();
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-required
|
||||
*/
|
||||
boolean isRequired();
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-validate
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
/**
|
||||
* true, if XForms control is bound to a node in a data model.
|
||||
*/
|
||||
boolean hasBoundNode();
|
||||
};
|
@ -39,42 +39,23 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIXFormsAccessors;
|
||||
|
||||
/**
|
||||
* Interface implemented by XForms controls that delegates the UI to an
|
||||
* external entity.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://developer.mozilla.org/en/docs/XForms:Custom_Controls
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(3b2300dc-9311-4eb7-a5c9-ca2ee4064de6)]
|
||||
[scriptable, uuid(5e75904d-73e8-4cee-b02c-4348a071a0e1)]
|
||||
interface nsIXFormsDelegate : nsISupports
|
||||
{
|
||||
/**
|
||||
* The value bound to the XForms control.
|
||||
* Get the IXFormsAccessors object for this control.
|
||||
*/
|
||||
attribute DOMString value;
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-readOnly
|
||||
*/
|
||||
readonly attribute boolean isReadonly;
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-relevant
|
||||
*/
|
||||
readonly attribute boolean isEnabled;
|
||||
|
||||
/**
|
||||
* @see http://www.w3.org/TR/xforms/slice6.html#model-prop-required
|
||||
*/
|
||||
readonly attribute boolean isRequired;
|
||||
|
||||
/**
|
||||
* Tells whether the XForms control is valid.
|
||||
*/
|
||||
readonly attribute boolean isValid;
|
||||
|
||||
/**
|
||||
* true, if XForms control is bound to a node in a data model.
|
||||
*/
|
||||
readonly attribute boolean hasBoundNode;
|
||||
nsIXFormsAccessors getXFormsAccessors();
|
||||
|
||||
/**
|
||||
* This should be called by XBL widgets, when they are created.
|
||||
|
@ -41,6 +41,10 @@
|
||||
|
||||
/**
|
||||
* Interface implemented by XForms UI widgets.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://developer.mozilla.org/en/docs/XForms:Custom_Controls
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(b88a1c27-47a2-4c25-be7c-170501a93643)]
|
||||
interface nsIXFormsUIWidget : nsIDOMElement
|
||||
|
177
extensions/xforms/nsXFormsAccessors.cpp
Normal file
177
extensions/xforms/nsXFormsAccessors.cpp
Normal file
@ -0,0 +1,177 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla XForms support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Novell, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Allan Beaufour <abeaufour@novell.com>
|
||||
* Olli Pettay <Olli.Pettay@helsinki.fi>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsXFormsUtils.h"
|
||||
#include "nsXFormsAccessors.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIContent.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsXFormsAccessors, nsIXFormsAccessors, nsIClassInfo)
|
||||
|
||||
void
|
||||
nsXFormsAccessors::Destroy()
|
||||
{
|
||||
mElement = nsnull;
|
||||
mDelegate = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXFormsAccessors::GetState(PRInt32 aState, PRBool *aStateVal)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStateVal);
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
*aStateVal = (content && (content->IntrinsicState() & aState));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetValue(nsAString &aValue)
|
||||
{
|
||||
if (mDelegate) {
|
||||
mDelegate->GetValue(aValue);
|
||||
} else {
|
||||
SetDOMStringToNull(aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::SetValue(const nsAString & aValue)
|
||||
{
|
||||
return mDelegate ? mDelegate->SetValue(aValue) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::HasBoundNode(PRBool *aHasBoundNode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHasBoundNode);
|
||||
*aHasBoundNode = PR_FALSE;
|
||||
return mDelegate ? mDelegate->GetHasBoundNode(aHasBoundNode) : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::IsReadonly(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_MOZ_READONLY, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::IsRelevant(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_ENABLED, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::IsRequired(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_REQUIRED, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::IsValid(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_VALID, aStateVal);
|
||||
}
|
||||
|
||||
// nsIClassInfo implementation
|
||||
|
||||
static const nsIID sScriptingIIDs[] = {
|
||||
NS_IXFORMSACCESSORS_IID
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetInterfaces(PRUint32 *aCount, nsIID * **aArray)
|
||||
{
|
||||
return nsXFormsUtils::CloneScriptingInterfaces(sScriptingIIDs,
|
||||
NS_ARRAY_LENGTH(sScriptingIIDs),
|
||||
aCount, aArray);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetHelperForLanguage(PRUint32 language,
|
||||
nsISupports **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetContractID(char * *aContractID)
|
||||
{
|
||||
*aContractID = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetClassDescription(char * *aClassDescription)
|
||||
{
|
||||
*aClassDescription = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetClassID(nsCID * *aClassID)
|
||||
{
|
||||
*aClassID = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetImplementationLanguage(PRUint32 *aImplementationLanguage)
|
||||
{
|
||||
*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetFlags(PRUint32 *aFlags)
|
||||
{
|
||||
*aFlags = nsIClassInfo::DOM_OBJECT;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsAccessors::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
|
||||
{
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
81
extensions/xforms/nsXFormsAccessors.h
Normal file
81
extensions/xforms/nsXFormsAccessors.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla XForms support.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Novell, Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Allan Beaufour <abeaufour@novell.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsIXFormsAccessors.h"
|
||||
#include "nsIDelegateInternal.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
|
||||
/**
|
||||
* Implementation of the nsIXFormsAccessors object. It is always owned by a
|
||||
* nsIXFormsDelegate.
|
||||
*/
|
||||
class nsXFormsAccessors : public nsIXFormsAccessors,
|
||||
public nsIClassInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICLASSINFO
|
||||
NS_DECL_NSIXFORMSACCESSORS
|
||||
|
||||
/** Constructor */
|
||||
nsXFormsAccessors(nsIDelegateInternal* aDelegate, nsIDOMElement* aElement)
|
||||
: mDelegate(aDelegate), mElement(aElement)
|
||||
{
|
||||
}
|
||||
|
||||
/** Called by the owning delegate when it itself is destroyed */
|
||||
void Destroy();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Checks the status of the model item properties
|
||||
*
|
||||
* @param aState The state to check
|
||||
* @para aStateVal The returned state
|
||||
*/
|
||||
nsresult GetState(PRInt32 aState, PRBool *aStateVal);
|
||||
|
||||
private:
|
||||
/** The delegate owning us */
|
||||
nsIDelegateInternal* mDelegate;
|
||||
|
||||
/** The control DOM element */
|
||||
nsIDOMElement* mElement;
|
||||
};
|
@ -54,11 +54,10 @@
|
||||
#include "nsXFormsUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXFormsModelElement.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsDelegateStub,
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsDelegateStub,
|
||||
nsXFormsBindableControlStub,
|
||||
nsIDelegateInternal,
|
||||
nsIXFormsDelegate)
|
||||
|
||||
|
||||
@ -91,6 +90,9 @@ NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::OnDestroyed()
|
||||
{
|
||||
nsXFormsModelElement::CancelPostRefresh(this);
|
||||
if (mAccessor) {
|
||||
mAccessor->Destroy();
|
||||
}
|
||||
return nsXFormsBindableControlStub::OnDestroyed();
|
||||
}
|
||||
|
||||
@ -169,47 +171,10 @@ nsXFormsDelegateStub::SetValue(const nsAString& aValue)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXFormsDelegateStub::GetState(PRInt32 aState, PRBool *aStateVal)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStateVal);
|
||||
*aStateVal = PR_FALSE;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mElement));
|
||||
if (content && (content->IntrinsicState() & aState)) {
|
||||
*aStateVal = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXXbeaufour search for "enabled", "disabled", HasAttribute() and SetAttribute()
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::GetIsReadonly(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_MOZ_READONLY, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::GetIsEnabled(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_ENABLED, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::GetIsRequired(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_REQUIRED, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::GetIsValid(PRBool *aStateVal)
|
||||
{
|
||||
return GetState(NS_EVENT_STATE_VALID, aStateVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::GetHasBoundNode(PRBool *aHasBoundNode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aHasBoundNode);
|
||||
*aHasBoundNode = mBoundNode ? PR_TRUE : PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -223,6 +188,8 @@ nsXFormsDelegateStub::WidgetAttached()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsXFormsDelegateStub
|
||||
|
||||
nsRepeatState
|
||||
nsXFormsDelegateStub::UpdateRepeatState()
|
||||
{
|
||||
@ -265,3 +232,16 @@ nsXFormsDelegateStub::SetMozTypeAttribute()
|
||||
mElement->RemoveAttributeNS(mozTypeNs, mozType);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsDelegateStub::GetXFormsAccessors(nsIXFormsAccessors **aAccessor)
|
||||
{
|
||||
if (!mAccessor) {
|
||||
mAccessor = new nsXFormsAccessors(this, mElement);
|
||||
if (!mAccessor) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
NS_ADDREF(*aAccessor = mAccessor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -40,12 +40,14 @@
|
||||
#ifndef __NSXFORMSDELEGATESTUB_H__
|
||||
#define __NSXFORMSDELEGATESTUB_H__
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIXFormsDelegate.h"
|
||||
#include "nsIDelegateInternal.h"
|
||||
#include "nsXFormsControlStub.h"
|
||||
#include "nsIXFormsUIWidget.h"
|
||||
#include "nsXFormsAccessors.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
||||
@ -65,11 +67,12 @@ enum nsRepeatState {
|
||||
* Stub implementation of the nsIXFormsDelegate interface.
|
||||
*/
|
||||
class nsXFormsDelegateStub : public nsXFormsBindableControlStub,
|
||||
public nsIXFormsDelegate
|
||||
public nsIDelegateInternal
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIXFORMSDELEGATE
|
||||
NS_DECL_NSIDELEGATEINTERNAL
|
||||
|
||||
NS_IMETHOD OnCreated(nsIXTFBindableElementWrapper *aWrapper);
|
||||
NS_IMETHOD OnDestroyed();
|
||||
@ -96,9 +99,6 @@ public:
|
||||
: mControlType(aType), mRepeatState(eType_Unknown) {}
|
||||
|
||||
protected:
|
||||
// Checks the status of the model item properties.
|
||||
nsresult GetState(PRInt32 aState, PRBool *aStateVal);
|
||||
|
||||
// This is called when XBL widget is attached to the XForms control.
|
||||
// It checks the ancestors of the element and returns an nsRepeatState
|
||||
// depending on the elements place in the document.
|
||||
@ -110,6 +110,9 @@ protected:
|
||||
|
||||
nsString mControlType;
|
||||
nsRepeatState mRepeatState;
|
||||
|
||||
/** The accessors object for this delegate */
|
||||
nsRefPtr<nsXFormsAccessors> mAccessor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -77,7 +77,7 @@
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIDOMSerializer.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXFormsDelegate.h"
|
||||
#include "nsIDelegateInternal.h"
|
||||
|
||||
#define EPHEMERAL_STYLE \
|
||||
"position:absolute;z-index:2147483647; \
|
||||
@ -293,7 +293,7 @@ nsXFormsMessageElement::CloneNode(nsIDOMNode* aSrc, nsIDOMNode** aTarget)
|
||||
// to support <output> here.
|
||||
if (ns.EqualsLiteral(NS_NAMESPACE_XFORMS) &&
|
||||
localName.EqualsLiteral("output")) {
|
||||
nsCOMPtr<nsIXFormsDelegate> outEl(do_QueryInterface(aSrc));
|
||||
nsCOMPtr<nsIDelegateInternal> outEl(do_QueryInterface(aSrc));
|
||||
if (outEl) {
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
aSrc->GetOwnerDocument(getter_AddRefs(doc));
|
||||
|
@ -118,7 +118,7 @@
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<field name="_delegateValueCache">null</field>
|
||||
<field name="_accessorValueCache">null</field>
|
||||
|
||||
<!-- Make sure we don't refresh while we are refreshing (race condition).
|
||||
This happens when we are inside a repeat for example. We use the
|
||||
@ -130,7 +130,7 @@
|
||||
if (this._refreshing)
|
||||
return;
|
||||
|
||||
if (this.delegate.isReadonly) {
|
||||
if (this.accessors.isReadonly()) {
|
||||
this.uiElement.setAttribute("readonly", "readonly");
|
||||
} else {
|
||||
this.uiElement.removeAttribute("readonly");
|
||||
@ -142,8 +142,8 @@
|
||||
// changed, we simply update the selection. If it hasn't, that means
|
||||
// we rebuild the select UI. We also rebuild if the delegate cache is
|
||||
// null (first load).
|
||||
if (this._delegateValueCache == null ||
|
||||
this._delegateValueCache == this.delegate.value) {
|
||||
if (this._accessorValueCache == null ||
|
||||
this._accessorValueCache == this.accessors.getValue()) {
|
||||
// refresh was not called due to instance data changing, so build the
|
||||
// UI.
|
||||
this._buildSelect();
|
||||
@ -153,7 +153,7 @@
|
||||
}
|
||||
|
||||
// store the delegate value
|
||||
this._delegateValueCache = this.delegate.value;
|
||||
this._accessorValueCache = this.accessors.getValue();
|
||||
|
||||
this._refreshing = false;
|
||||
|
||||
@ -174,8 +174,8 @@
|
||||
// replace new line (\n), tabs (\t) and carriage returns (\r) with "".
|
||||
var value = "";
|
||||
|
||||
if (this.delegate.value)
|
||||
value = this.delegate.value.replace(/\n|\t|\r/g, " ");
|
||||
if (this.accessors.getValue())
|
||||
value = this.accessors.getValue().replace(/\n|\t|\r/g, " ");
|
||||
|
||||
// get an array of values selected in the bound node
|
||||
var selectedArray = value.split(" ");
|
||||
@ -401,8 +401,8 @@
|
||||
<method name="_setBoundValue">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.delegate.hasBoundNode)
|
||||
this.delegate.value = this._getSelectedValues();
|
||||
if (this.accessors.hasBoundNode)
|
||||
this.accessors.setValue(this._getSelectedValues());
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
@ -460,8 +460,8 @@
|
||||
<![CDATA[
|
||||
// get an array of values selected in the bound node
|
||||
var selectedArray = new Array();
|
||||
if (this.delegate.value)
|
||||
selectedArray = this.delegate.value.split(" ");
|
||||
if (this.accessors.getValue())
|
||||
selectedArray = this.accessors.getValue().split(" ");
|
||||
|
||||
// store the values in a hash for quick access
|
||||
this._defaultHash = new Object();
|
||||
|
@ -154,7 +154,7 @@
|
||||
<![CDATA[
|
||||
if (this.selectionOpen && !this._selected) {
|
||||
if (this.getAttribute("incremental") != "false") {
|
||||
this.delegate.value = this.inputField.value;
|
||||
this.accessors.setValue(this.inputField.value);
|
||||
}
|
||||
} else {
|
||||
this.togglePopup();
|
||||
@ -173,7 +173,7 @@
|
||||
this.togglePopup();
|
||||
if (open && this._selected) {
|
||||
this.updateInputField();
|
||||
this.delegate.value = this._selected.value;
|
||||
this.accessors.setValue(this._selected.value);
|
||||
}
|
||||
} else if (key == aEvent.DOM_VK_UP ||
|
||||
key == aEvent.DOM_VK_DOWN) {
|
||||
@ -188,9 +188,9 @@
|
||||
if (!this.popupOpen && this.getAttribute("incremental") != "false") {
|
||||
if (this._selected) {
|
||||
this.updateInputField();
|
||||
this.delegate.value = this._selected.value;
|
||||
this.accessors.setValue(this._selected.value);
|
||||
} else if (this.selectionOpen) {
|
||||
this.delegate.value = this.inputField.value;
|
||||
this.accessors.setValue(this.inputField.value);
|
||||
}
|
||||
}
|
||||
} else if (key == aEvent.DOM_VK_TAB) {
|
||||
@ -232,7 +232,7 @@
|
||||
this._selected = null;
|
||||
}
|
||||
if (this.getAttribute("incremental") != "false") {
|
||||
this.delegate.value = this.inputField.value;
|
||||
this.accessors.setValue(this.inputField.value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,8 +404,7 @@
|
||||
}
|
||||
|
||||
this.updateInputField();
|
||||
this.delegate.value =
|
||||
this._selected.value;
|
||||
this.accessors.setValue(this._selected.value);
|
||||
}
|
||||
this.inputField.focus();
|
||||
]]>
|
||||
@ -474,7 +473,7 @@
|
||||
<method name="togglePopup">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!this.popupOpen && !this.delegate.isReadonly) {
|
||||
if (!this.popupOpen && !this.accessors.isReadonly()) {
|
||||
// Calculating the size and position of the popup.
|
||||
var style = "";
|
||||
var containerBox = document.getBoxObjectFor(this.container);
|
||||
@ -560,7 +559,7 @@
|
||||
try {
|
||||
var newValue = this.stringValue;
|
||||
|
||||
if (!this.selectionOpen || this.delegate.isReadonly) {
|
||||
if (!this.selectionOpen || this.accessors.isReadonly()) {
|
||||
this.inputField.setAttribute("readonly", "readonly");
|
||||
} else {
|
||||
this.inputField.removeAttribute("readonly");
|
||||
@ -656,10 +655,10 @@
|
||||
}
|
||||
|
||||
if (this.selectionOpen && !this._selected) {
|
||||
this.delegate.value = this.inputField.value;
|
||||
this.accessors.setValue(this.inputField.value);
|
||||
} else if (this._selected) {
|
||||
this.updateInputField();
|
||||
this.delegate.value = this._selected.value;
|
||||
this.accessors.setValue(this._selected.value);
|
||||
}
|
||||
}
|
||||
]]>
|
||||
|
@ -65,16 +65,17 @@
|
||||
|
||||
<destructor>
|
||||
this._delegate = null;
|
||||
this._accessors = null;
|
||||
</destructor>
|
||||
|
||||
<field name="_delegate">null</field>
|
||||
|
||||
<property name="XFORMS_NS" readonly="true">
|
||||
<getter>
|
||||
return "http://www.w3.org/2002/xforms";
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<field name="_delegate">null</field>
|
||||
|
||||
<property name="delegate" readonly="true">
|
||||
<getter>
|
||||
if (!this._delegate)
|
||||
@ -83,9 +84,21 @@
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<field name="_accessors">null</field>
|
||||
|
||||
<property name="accessors" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
if (!this._accessors && this.delegate)
|
||||
this._accessors = this.delegate.getXFormsAccessors();
|
||||
return this._accessors;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<property name="stringValue" readonly="true">
|
||||
<getter>
|
||||
var value = this.delegate.value;
|
||||
var value = this.accessors.getValue();
|
||||
return value != null ? value : "";
|
||||
</getter>
|
||||
</property>
|
||||
@ -157,7 +170,7 @@
|
||||
var anoncontent =
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "anoncontent");
|
||||
|
||||
if (this.delegate.hasBoundNode || this.delegate.value != null) {
|
||||
if (this.accessors.hasBoundNode() || this.accessors.getValue() != null) {
|
||||
anoncontent.setAttribute("style", "display:none;");
|
||||
} else {
|
||||
anoncontent.removeAttribute("style");
|
||||
@ -178,7 +191,7 @@
|
||||
<children includes="label"/>
|
||||
<html:input anonid="control"
|
||||
class="xf-value"
|
||||
onblur="this.parentNode.delegate.value = this.value; this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
|
||||
onblur="this.parentNode.accessors.setValue(this.value); this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
|
||||
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
|
||||
onclick="this.parentNode._change();"
|
||||
onkeyup="if (event.keyCode != event.DOM_VK_TAB) this.parentNode._change();"
|
||||
@ -203,7 +216,7 @@
|
||||
<method name="_change">
|
||||
<body>
|
||||
if (this.getAttribute("incremental") == "true") {
|
||||
this.delegate.value = this.inputField.value;
|
||||
this.accessors.setValue(this.inputField.value);
|
||||
}
|
||||
return true;
|
||||
</body>
|
||||
@ -212,7 +225,7 @@
|
||||
<method name="refresh">
|
||||
<body>
|
||||
this.inputField.value = this.stringValue;
|
||||
if (this.delegate.isReadonly) {
|
||||
if (this.accessors.isReadonly()) {
|
||||
this.inputField.setAttribute("readonly", "readonly");
|
||||
} else {
|
||||
this.inputField.removeAttribute("readonly");
|
||||
@ -245,7 +258,7 @@
|
||||
}
|
||||
|
||||
this.inputField.value = value;
|
||||
if (this.delegate.isReadonly) {
|
||||
if (this.accessors.isReadonly()) {
|
||||
this.inputField.setAttribute("readonly", "readonly");
|
||||
} else {
|
||||
this.inputField.removeAttribute("readonly");
|
||||
@ -262,9 +275,9 @@
|
||||
<body>
|
||||
if (this.getAttribute("incremental") != "false") {
|
||||
if (this.inputField.checked) {
|
||||
this.delegate.value = "true";
|
||||
this.accessors.setValue("true");
|
||||
} else {
|
||||
this.delegate.value = "false";
|
||||
this.accessors.setValue("false");
|
||||
}
|
||||
}
|
||||
</body>
|
||||
@ -281,7 +294,7 @@
|
||||
<body>
|
||||
this.inputField.setAttribute("type","password");
|
||||
this.inputField.value = this.stringValue;
|
||||
this.inputField.readonly = this.delegate.isReadonly;
|
||||
this.inputField.readonly = this.accessors.isReadonly();
|
||||
return true;
|
||||
</body>
|
||||
</method>
|
||||
@ -295,7 +308,7 @@
|
||||
<children includes="label"/>
|
||||
<html:textarea anonid="control"
|
||||
class="xf-value"
|
||||
onblur="this.parentNode.delegate.value = this.value; this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
|
||||
onblur="this.parentNode.accessors.setValue(this.value); this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
|
||||
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
|
||||
onkeyup="this.parentNode._change();"
|
||||
xbl:inherits="accesskey"/>
|
||||
@ -317,7 +330,7 @@
|
||||
|
||||
<method name="refresh">
|
||||
<body>
|
||||
this.controlField.readonly = this.delegate.isReadonly;
|
||||
this.controlField.readonly = this.accessors.isReadonly();
|
||||
// If the value has not changed, no need to update the
|
||||
// value of the control, because that makes the textarea widget
|
||||
// to scroll up.
|
||||
@ -331,7 +344,7 @@
|
||||
<method name="_change">
|
||||
<body>
|
||||
if (this.getAttribute("incremental") == "true") {
|
||||
this.delegate.value = this.controlField.value;
|
||||
this.accessors.setValue(this.controlField.value);
|
||||
}
|
||||
return true;
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user