From cfca86c09802b7a072a0e93566fdd296051eb5a7 Mon Sep 17 00:00:00 2001 From: "aaronr%us.ibm.com" Date: Mon, 2 Apr 2007 20:21:08 +0000 Subject: [PATCH] [XForms] Actions inside itemsets behave incorrectly. Bug 374994, r=surkov+olli git-svn-id: svn://10.0.0.236/trunk@224026 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xforms/nsXFormsActionElement.cpp | 43 ++++++ .../extensions/xforms/nsXFormsActionElement.h | 4 + .../xforms/nsXFormsActionModuleBase.cpp | 43 ++++++ .../xforms/nsXFormsActionModuleBase.h | 4 + .../xforms/nsXFormsContextContainer.cpp | 101 +------------ .../xforms/nsXFormsContextContainer.h | 142 ++++++++++++++++++ .../extensions/xforms/nsXFormsControlStub.cpp | 49 +----- .../extensions/xforms/nsXFormsControlStub.h | 42 +----- .../extensions/xforms/nsXFormsCopyElement.cpp | 19 +-- .../extensions/xforms/nsXFormsItemElement.cpp | 78 +++++----- .../xforms/nsXFormsItemSetElement.cpp | 78 +++++++--- .../xforms/nsXFormsMessageElement.cpp | 9 ++ .../extensions/xforms/nsXFormsStubElement.cpp | 72 +++++++++ .../extensions/xforms/nsXFormsStubElement.h | 66 ++++++++ .../xforms/resources/content/select1.xml | 8 +- .../xforms/resources/content/selects.xml | 18 +-- .../resources/content/selectsnw-xhtml.xml | 2 +- .../xforms/resources/content/selectsnw.xml | 24 +-- .../xforms/resources/content/xforms.css | 2 +- 19 files changed, 501 insertions(+), 303 deletions(-) create mode 100644 mozilla/extensions/xforms/nsXFormsContextContainer.h diff --git a/mozilla/extensions/xforms/nsXFormsActionElement.cpp b/mozilla/extensions/xforms/nsXFormsActionElement.cpp index c2d3244ddaf..6b96cf51802 100644 --- a/mozilla/extensions/xforms/nsXFormsActionElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsActionElement.cpp @@ -75,6 +75,12 @@ nsXFormsActionElement::OnCreated(nsIXTFElementWrapper* aWrapper) aWrapper->GetElementNode(getter_AddRefs(node)); mElement = node; NS_ASSERTION(mElement, "Wrapper is not an nsIDOMElement, we'll crash soon"); + + aWrapper->SetNotificationMask(nsIXTFElement::NOTIFY_WILL_CHANGE_DOCUMENT | + nsIXTFElement::NOTIFY_WILL_CHANGE_PARENT | + nsIXTFElement::NOTIFY_DOCUMENT_CHANGED | + nsIXTFElement::NOTIFY_PARENT_CHANGED); + return NS_OK; } @@ -85,9 +91,46 @@ nsXFormsActionElement::OnDestroyed() { return NS_OK; } +NS_IMETHODIMP +nsXFormsActionElement::WillChangeParent(nsIDOMElement *aNewParent) +{ + SetRepeatState(eType_Unknown); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsActionElement::ParentChanged(nsIDOMElement *aNewParent) +{ + nsXFormsStubElement::ParentChanged(aNewParent); + UpdateRepeatState(aNewParent); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsActionElement::WillChangeDocument(nsIDOMDocument *aNewDocument) +{ + SetRepeatState(eType_Unknown); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsActionElement::DocumentChanged(nsIDOMDocument *aNewDocument) +{ + nsXFormsStubElement::DocumentChanged(aNewDocument); + + nsCOMPtr parent; + mElement->GetParentNode(getter_AddRefs(parent)); + UpdateRepeatState(parent); + return NS_OK; +} + NS_IMETHODIMP nsXFormsActionElement::HandleEvent(nsIDOMEvent* aEvent) { + if (GetRepeatState() == eType_Template) { + return NS_OK; + } + return nsXFormsUtils::EventHandlingAllowed(aEvent, mElement) ? HandleAction(aEvent, nsnull) : NS_OK; } diff --git a/mozilla/extensions/xforms/nsXFormsActionElement.h b/mozilla/extensions/xforms/nsXFormsActionElement.h index 2ebca37dce3..b3848a54349 100644 --- a/mozilla/extensions/xforms/nsXFormsActionElement.h +++ b/mozilla/extensions/xforms/nsXFormsActionElement.h @@ -59,6 +59,10 @@ public: NS_DECL_NSIXFORMSACTIONMODULEELEMENT NS_IMETHOD OnCreated(nsIXTFElementWrapper* aWrapper); NS_IMETHOD OnDestroyed(); + NS_IMETHOD WillChangeDocument(nsIDOMDocument *aNewDocument); + NS_IMETHOD DocumentChanged(nsIDOMDocument *aNewDocument); + NS_IMETHOD WillChangeParent(nsIDOMElement *aNewParent); + NS_IMETHOD ParentChanged(nsIDOMElement *aNewParent); private: nsIDOMElement* mElement; nsCOMPtr mParentAction; diff --git a/mozilla/extensions/xforms/nsXFormsActionModuleBase.cpp b/mozilla/extensions/xforms/nsXFormsActionModuleBase.cpp index df6eb35ece5..69e10fed5b3 100644 --- a/mozilla/extensions/xforms/nsXFormsActionModuleBase.cpp +++ b/mozilla/extensions/xforms/nsXFormsActionModuleBase.cpp @@ -72,6 +72,12 @@ nsXFormsActionModuleBase::OnCreated(nsIXTFElementWrapper *aWrapper) aWrapper->GetElementNode(getter_AddRefs(node)); mElement = node; NS_ASSERTION(mElement, "Wrapper is not an nsIDOMElement, we'll crash soon"); + + aWrapper->SetNotificationMask(nsIXTFElement::NOTIFY_WILL_CHANGE_DOCUMENT | + nsIXTFElement::NOTIFY_WILL_CHANGE_PARENT | + nsIXTFElement::NOTIFY_DOCUMENT_CHANGED | + nsIXTFElement::NOTIFY_PARENT_CHANGED); + return NS_OK; } @@ -81,9 +87,46 @@ NS_IMETHODIMP nsXFormsActionModuleBase::OnDestroyed() return NS_OK; } +NS_IMETHODIMP +nsXFormsActionModuleBase::WillChangeParent(nsIDOMElement *aNewParent) +{ + SetRepeatState(eType_Unknown); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsActionModuleBase::ParentChanged(nsIDOMElement *aNewParent) +{ + nsXFormsStubElement::ParentChanged(aNewParent); + UpdateRepeatState(aNewParent); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsActionModuleBase::WillChangeDocument(nsIDOMDocument *aNewDocument) +{ + SetRepeatState(eType_Unknown); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsActionModuleBase::DocumentChanged(nsIDOMDocument *aNewDocument) +{ + nsXFormsStubElement::DocumentChanged(aNewDocument); + + nsCOMPtr parent; + mElement->GetParentNode(getter_AddRefs(parent)); + UpdateRepeatState(parent); + return NS_OK; +} + NS_IMETHODIMP nsXFormsActionModuleBase::HandleEvent(nsIDOMEvent* aEvent) { + if (GetRepeatState() == eType_Template) { + return NS_OK; + } + return nsXFormsUtils::EventHandlingAllowed(aEvent, mElement) ? HandleAction(aEvent, nsnull) : NS_OK; } diff --git a/mozilla/extensions/xforms/nsXFormsActionModuleBase.h b/mozilla/extensions/xforms/nsXFormsActionModuleBase.h index 66dd8e95c78..02a0d070ebb 100644 --- a/mozilla/extensions/xforms/nsXFormsActionModuleBase.h +++ b/mozilla/extensions/xforms/nsXFormsActionModuleBase.h @@ -57,6 +57,10 @@ public: NS_DECL_NSIDOMEVENTLISTENER NS_IMETHOD OnCreated(nsIXTFElementWrapper *aWrapper); NS_IMETHOD OnDestroyed(); + NS_IMETHOD WillChangeDocument(nsIDOMDocument *aNewDocument); + NS_IMETHOD DocumentChanged(nsIDOMDocument *aNewDocument); + NS_IMETHOD WillChangeParent(nsIDOMElement *aNewParent); + NS_IMETHOD ParentChanged(nsIDOMElement *aNewParent); protected: nsIDOMElement* mElement; }; diff --git a/mozilla/extensions/xforms/nsXFormsContextContainer.cpp b/mozilla/extensions/xforms/nsXFormsContextContainer.cpp index 2b22480ea37..6eaa77aea1e 100644 --- a/mozilla/extensions/xforms/nsXFormsContextContainer.cpp +++ b/mozilla/extensions/xforms/nsXFormsContextContainer.cpp @@ -36,25 +36,16 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsIXTFElementWrapper.h" - -#include "nsCOMPtr.h" -#include "nsAutoPtr.h" -#include "nsString.h" - -#include "nsIDOM3Node.h" +#include "nsXFormsContextContainer.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMEvent.h" #include "nsIDOMNSEvent.h" #include "nsIDOMEventTarget.h" #include "nsIDOMSerializer.h" #include "nsIDOMXPathResult.h" -#include "nsXFormsControlStub.h" #include "nsIModelElementPrivate.h" #include "nsIXFormsContextControl.h" -#include "nsIXFormsRepeatItemElement.h" #include "nsIXFormsRepeatElement.h" #include "nsXFormsUtils.h" @@ -62,96 +53,6 @@ //#define DEBUG_XF_CONTEXTCONTAINER #endif -class nsXFormsContextContainer; - -class nsXFormsFocusListener : public nsIDOMEventListener { -public: - nsXFormsFocusListener(nsXFormsContextContainer* aContainer) - : mContainer(aContainer) {} - - NS_DECL_ISUPPORTS - NS_DECL_NSIDOMEVENTLISTENER - void Detach() - { - mContainer = nsnull; - } -protected: - nsXFormsContextContainer* mContainer; -}; - - -/** - * Implementation of \. - * - * \ is a pseudo-element that is wrapped around each row in - * an "unrolled" \ or \. @see nsXFormsRepeatElement and - * nsXFormsItemSetElement. - * - * @todo Support ::repeat-item and ::repeat-index pseudo-elements. (XXX) - * @see http://www.w3.org/TR/xforms/sliceF.html#id2645142 - * @see http://bugzilla.mozilla.org/show_bug.cgi?id=271724 - */ -class nsXFormsContextContainer : public nsXFormsControlStub, - public nsIXFormsRepeatItemElement -{ -protected: - /** The handler for the focus event */ - nsRefPtr mFocusListener; - - /** The context position for the element */ - PRInt32 mContextPosition; - - /** The context size for the element */ - PRInt32 mContextSize; - - /** Does this element have the repeat-index? */ - PRPackedBool mHasIndex; - - /** Has context changed since last bind? */ - PRPackedBool mContextIsDirty; - -public: - nsXFormsContextContainer() - : mContextPosition(1), mContextSize(1), mHasIndex(PR_FALSE), - mContextIsDirty(PR_FALSE) {} - - NS_DECL_ISUPPORTS_INHERITED - - // nsIXTFElement overrides - NS_IMETHOD CloneState(nsIDOMElement *aElement); - NS_IMETHOD DocumentChanged(nsIDOMDocument *aNewDocument); - - // nsIXFormsControl - NS_IMETHOD Bind(PRBool *aContextChanged); - NS_IMETHOD SetContext(nsIDOMNode *aContextNode, - PRInt32 aContextPosition, - PRInt32 aContextSize); - NS_IMETHOD GetContext(nsAString &aModelID, - nsIDOMNode **aContextNode, - PRInt32 *aContextPosition, - PRInt32 *aContextSize); - NS_IMETHOD IsEventTarget(PRBool *aOK); - - // nsIXFormsRepeatItemElement - NS_DECL_NSIXFORMSREPEATITEMELEMENT - - nsresult HandleFocus(nsIDOMEvent *aEvent); - - // Overriding to make sure only appropriate values can be set. - void SetRepeatState(nsRepeatState aState); - -#ifdef DEBUG_smaug - virtual const char* Name() { - if (mElement) { - nsAutoString localName; - mElement->GetLocalName(localName); - return NS_ConvertUTF16toUTF8(localName).get(); - } - return "contextcontainer(inline?)"; - } -#endif -}; - NS_IMPL_ISUPPORTS1(nsXFormsFocusListener, nsIDOMEventListener) NS_IMETHODIMP diff --git a/mozilla/extensions/xforms/nsXFormsContextContainer.h b/mozilla/extensions/xforms/nsXFormsContextContainer.h new file mode 100644 index 00000000000..9895682b845 --- /dev/null +++ b/mozilla/extensions/xforms/nsXFormsContextContainer.h @@ -0,0 +1,142 @@ +/* -*- 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 + * IBM Corporation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Aaron Reed (aaronr@us.ibm.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 ***** */ + +#ifndef nsXFormsContextControl_h_ +#define nsXFormsContextControl_h_ + +#include "nsCOMPtr.h" +#include "nsAutoPtr.h" + +#include "nsIXTFElementWrapper.h" +#include "nsIXFormsRepeatItemElement.h" +#include "nsIDOMEvent.h" +#include "nsIDOM3Node.h" +#include "nsXFormsControlStub.h" + +class nsXFormsContextContainer; + +class nsXFormsFocusListener : public nsIDOMEventListener { +public: + nsXFormsFocusListener(nsXFormsContextContainer* aContainer) + : mContainer(aContainer) {} + + NS_DECL_ISUPPORTS + NS_DECL_NSIDOMEVENTLISTENER + void Detach() + { + mContainer = nsnull; + } +protected: + nsXFormsContextContainer* mContainer; +}; + +/** + * Implementation of \. + * + * \ is a pseudo-element that is wrapped around each row in + * an "unrolled" \. @see nsXFormsRepeatElement + * + * @todo Support ::repeat-item and ::repeat-index pseudo-elements. (XXX) + * @see http://www.w3.org/TR/xforms/sliceF.html#id2645142 + * @see http://bugzilla.mozilla.org/show_bug.cgi?id=271724 + */ +class nsXFormsContextContainer : public nsXFormsControlStub, + public nsIXFormsRepeatItemElement +{ +protected: + /** The handler for the focus event */ + nsRefPtr mFocusListener; + + /** The context position for the element */ + PRInt32 mContextPosition; + + /** The context size for the element */ + PRInt32 mContextSize; + + /** Does this element have the repeat-index? */ + PRPackedBool mHasIndex; + + /** Has context changed since last bind? */ + PRPackedBool mContextIsDirty; + +public: + nsXFormsContextContainer() + : mContextPosition(1), mContextSize(1), mHasIndex(PR_FALSE), + mContextIsDirty(PR_FALSE) {} + + NS_DECL_ISUPPORTS_INHERITED + + // nsIXTFElement overrides + NS_IMETHOD CloneState(nsIDOMElement *aElement); + NS_IMETHOD DocumentChanged(nsIDOMDocument *aNewDocument); + + // nsIXFormsControl + NS_IMETHOD Bind(PRBool *aContextChanged); + NS_IMETHOD SetContext(nsIDOMNode *aContextNode, + PRInt32 aContextPosition, + PRInt32 aContextSize); + NS_IMETHOD GetContext(nsAString &aModelID, + nsIDOMNode **aContextNode, + PRInt32 *aContextPosition, + PRInt32 *aContextSize); + NS_IMETHOD IsEventTarget(PRBool *aOK); + + // nsIXFormsRepeatItemElement + NS_DECL_NSIXFORMSREPEATITEMELEMENT + + nsresult HandleFocus(nsIDOMEvent *aEvent); + + // Overriding to make sure only appropriate values can be set. + void SetRepeatState(nsRepeatState aState); + +#ifdef DEBUG_smaug + virtual const char* Name() { + if (mElement) { + nsAutoString localName; + mElement->GetLocalName(localName); + return NS_ConvertUTF16toUTF8(localName).get(); + } + return "contextcontainer(inline?)"; + } +#endif +}; + +/* Factory methods */ +NS_HIDDEN_(nsresult) +NS_NewXFormsContextContainer(nsIXTFElement **aResult); +#endif diff --git a/mozilla/extensions/xforms/nsXFormsControlStub.cpp b/mozilla/extensions/xforms/nsXFormsControlStub.cpp index 2945b089d40..c0e9f159663 100644 --- a/mozilla/extensions/xforms/nsXFormsControlStub.cpp +++ b/mozilla/extensions/xforms/nsXFormsControlStub.cpp @@ -736,7 +736,7 @@ nsXFormsControlStub::WillChangeDocument(nsIDOMDocument *aNewDocument) NS_IMETHODIMP nsXFormsControlStub::DocumentChanged(nsIDOMDocument *aNewDocument) { - mHasDoc = aNewDocument != nsnull; + nsXFormsStubElement::DocumentChanged(aNewDocument); if (aNewDocument) { ResetHelpAndHint(PR_TRUE); @@ -753,6 +753,10 @@ nsXFormsControlStub::DocumentChanged(nsIDOMDocument *aNewDocument) } } + nsCOMPtr parent; + mElement->GetParentNode(getter_AddRefs(parent)); + UpdateRepeatState(parent); + return ForceModelDetach(mHasParent && mHasDoc); } @@ -773,7 +777,7 @@ nsXFormsControlStub::WillChangeParent(nsIDOMElement *aNewParent) NS_IMETHODIMP nsXFormsControlStub::ParentChanged(nsIDOMElement *aNewParent) { - mHasParent = aNewParent != nsnull; + nsXFormsStubElement::ParentChanged(aNewParent); UpdateRepeatState(aNewParent); @@ -1027,47 +1031,6 @@ nsXFormsControlStub::IsContentComplex() return isComplex; } -nsRepeatState -nsXFormsControlStub::GetRepeatState() -{ - return mRepeatState; -} - -void -nsXFormsControlStub::SetRepeatState(nsRepeatState aState) -{ - mRepeatState = aState; - return; -} - -nsRepeatState -nsXFormsControlStub::UpdateRepeatState(nsIDOMNode *aParent) -{ - nsRepeatState repeatState = eType_NotApplicable; - - nsCOMPtr parent = aParent; - while (parent) { - if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("contextcontainer"))) { - repeatState = eType_GeneratedContent; - break; - } - if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("repeat"))) { - repeatState = eType_Template; - break; - } - if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("itemset"))) { - repeatState = eType_Template; - break; - } - nsCOMPtr tmp; - parent->GetParentNode(getter_AddRefs(tmp)); - parent = tmp; - } - - SetRepeatState(repeatState); - return repeatState; -} - NS_IMPL_ISUPPORTS_INHERITED3(nsXFormsControlStub, nsXFormsStubElement, nsIXFormsContextControl, diff --git a/mozilla/extensions/xforms/nsXFormsControlStub.h b/mozilla/extensions/xforms/nsXFormsControlStub.h index 4aa590fed56..9db377f19fd 100644 --- a/mozilla/extensions/xforms/nsXFormsControlStub.h +++ b/mozilla/extensions/xforms/nsXFormsControlStub.h @@ -60,18 +60,6 @@ class nsIDOMEvent; class nsIDOMXPathResult; -/** - * nsRepeatState is used to indicate whether the element - * is inside \'s template. If it is, there is no need - * to refresh the widget bound to the element. - */ -enum nsRepeatState { - eType_Unknown, - eType_Template, - eType_GeneratedContent, - eType_NotApplicable -}; - /** * Common stub for all XForms controls that inherit from nsIXFormsControl and * is bound to an instance node. @@ -161,14 +149,6 @@ public: */ virtual PRBool IsContentComplex(); - /** - * Get/Set the repeat state for the control. The repeat state indicates - * whether the control lives inside a context container, a repeat element, - * an itemset or non of the above. - */ - virtual nsRepeatState GetRepeatState(); - virtual void SetRepeatState(nsRepeatState aState); - // nsIXFormsContextControl NS_DECL_NSIXFORMSCONTEXTCONTROL @@ -189,14 +169,11 @@ public: nsIXTFElement::NOTIFY_PARENT_CHANGED | nsIXTFElement::NOTIFY_HANDLE_DEFAULT), kElementFlags(nsXFormsUtils::ELEMENT_WITH_MODEL_ATTR), - mHasParent(PR_FALSE), - mHasDoc(PR_FALSE), mPreventLoop(PR_FALSE), mUsesModelBinding(PR_FALSE), mAppearDisabled(PR_FALSE), mOnDeferredBindList(PR_FALSE), - mBindAttrsCount(0), - mRepeatState(eType_Unknown) + mBindAttrsCount(0) {}; protected: @@ -215,12 +192,6 @@ protected: /** This event listener is used to create xforms-hint and xforms-help events. */ nsCOMPtr mEventListener; - /** State that tells whether control has a parent or not */ - PRPackedBool mHasParent; - - /** State that tells whether control has a parent or not */ - PRPackedBool mHasDoc; - /** State to prevent infinite loop when generating and handling xforms-next * and xforms-previous events */ @@ -248,8 +219,6 @@ protected: */ PRInt8 mBindAttrsCount; - nsRepeatState mRepeatState; - /** * List of repeats that the node binding depends on. This happens when using * the index() function in the binding expression. @@ -356,15 +325,6 @@ protected: */ nsresult GetBoundBuiltinType(PRUint16 *aBuiltinType); - /** - * This is called when the parent node for a XForms control changes. - * It checks the ancestors of the element and returns an nsRepeatState - * depending on the element's place in the document. - * - * @param aParent The new parent of the XForms control - */ - nsRepeatState UpdateRepeatState(nsIDOMNode *aParent); - }; #endif diff --git a/mozilla/extensions/xforms/nsXFormsCopyElement.cpp b/mozilla/extensions/xforms/nsXFormsCopyElement.cpp index e389e4a5dcf..841d7c500e8 100644 --- a/mozilla/extensions/xforms/nsXFormsCopyElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsCopyElement.cpp @@ -104,15 +104,14 @@ nsXFormsCopyElement::ParentChanged(nsIDOMElement *aNewParent) if (!nsXFormsUtils::IsXFormsElement(aNewParent, NS_LITERAL_STRING("itemset")) && !nsXFormsUtils::IsXFormsElement(aNewParent, - NS_LITERAL_STRING("contextcontainer"))) { + NS_LITERAL_STRING("item"))) { - // parent of a copy element must always be an itemset. We really can't + // Parent of a copy element must always be an itemset. We really can't // enforce this all that well until we have full schema support but for // now we'll at least warn the author. We are also checking for - // contextcontainer because under Mozilla, the children of an itemset - // element are cloned underneath a contextcontainer which is in turn - // contained in a nsXFormsItemElement. Each such item element is then - // appended as anonymous content of the itemset. + // item because under Mozilla, the children of an itemset + // element are cloned underneath an nsXFormsItemElement. Each such + // item element is then appended as anonymous content of the itemset. nsXFormsUtils::ReportError(NS_LITERAL_STRING("copyError"), mElement); } } @@ -125,14 +124,10 @@ nsXFormsCopyElement::DocumentChanged(nsIDOMDocument* aNewDocument) if (!aNewDocument) return NS_OK; - // tell grandparent (xf:item) that it contains a xf:copy element and + // tell parent (xf:item) that it contains a xf:copy element and // not a xf:value element. - nsCOMPtr contextContainer; - nsresult rv = mElement->GetParentNode(getter_AddRefs(contextContainer)); - NS_ENSURE_TRUE(contextContainer, rv); - nsCOMPtr itemNode; - rv = contextContainer->GetParentNode(getter_AddRefs(itemNode)); + nsresult rv = mElement->GetParentNode(getter_AddRefs(itemNode)); NS_ENSURE_TRUE(itemNode, rv); nsCOMPtr item = do_QueryInterface(itemNode); diff --git a/mozilla/extensions/xforms/nsXFormsItemElement.cpp b/mozilla/extensions/xforms/nsXFormsItemElement.cpp index 6b28d29e0cc..27b1724d1dc 100644 --- a/mozilla/extensions/xforms/nsXFormsItemElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsItemElement.cpp @@ -36,14 +36,13 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsXFormsContextContainer.h" #include "nsIXFormsSelectChild.h" -#include "nsXFormsStubElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsXFormsAtoms.h" #include "nsIDOMNodeList.h" #include "nsIDOMDocument.h" #include "nsIDOMDocumentEvent.h" -#include "nsIDOMEvent.h" #include "nsIPrivateDOMEvent.h" #include "nsString.h" #include "nsXFormsUtils.h" @@ -69,12 +68,12 @@ * select element. */ -class nsXFormsItemElement : public nsXFormsStubElement, +class nsXFormsItemElement : public nsXFormsContextContainer, public nsIXFormsSelectChild, public nsIXFormsItemElement { public: - nsXFormsItemElement() : mElement(nsnull), mDoneAddingChildren(PR_FALSE), + nsXFormsItemElement() : mDoneAddingChildren(PR_FALSE), mIsCopyItem(PR_FALSE) { } @@ -92,14 +91,17 @@ public: NS_IMETHOD BeginAddingChildren(); NS_IMETHOD DoneAddingChildren(); - void Refresh(); + NS_IMETHOD Refresh(); + + // nsIXFormsRepeatItemElement + NS_IMETHOD SetIndexState(PRBool aHasIndex); + NS_IMETHOD GetIndexState(PRBool *aHasIndex); // nsIXFormsSelectChild NS_DECL_NSIXFORMSSELECTCHILD private: - nsIDOMElement* mElement; PRBool mDoneAddingChildren; // If true, indicates that this item contains a xf:copy element (via @@ -108,7 +110,7 @@ private: }; NS_IMPL_ISUPPORTS_INHERITED2(nsXFormsItemElement, - nsXFormsStubElement, + nsXFormsContextContainer, nsIXFormsSelectChild, nsIXFormsItemElement) @@ -292,22 +294,9 @@ nsXFormsItemElement::GetValue(nsAString &aValue) return NS_ERROR_FAILURE; } - nsCOMPtr firstChild, container; - mElement->GetFirstChild(getter_AddRefs(firstChild)); - - // If this element is generated inside an , - // there is a element between this element - // and the actual childnodes. - if (nsXFormsUtils::IsXFormsElement(firstChild, - NS_LITERAL_STRING("contextcontainer"))) { - container = firstChild; - } else { - container = mElement; - } - // Find our value child and get its text content. nsCOMPtr children; - nsresult rv = container->GetChildNodes(getter_AddRefs(children)); + nsresult rv = mElement->GetChildNodes(getter_AddRefs(children)); NS_ENSURE_SUCCESS(rv, rv); PRUint32 childCount; @@ -343,15 +332,9 @@ nsXFormsItemElement::GetCopyNode(nsIDOMNode **aNode) return NS_ERROR_FAILURE; } - // Since this item really contains a copy element, then firstChild MUST be - // a contextcontainer since copy elements can only exist as a child of an - // itemset. - nsCOMPtr container; - mElement->GetFirstChild(getter_AddRefs(container)); - // Find the copy element contained by this item and get the copyNode from it. nsCOMPtr children; - nsresult rv = container->GetChildNodes(getter_AddRefs(children)); + nsresult rv = mElement->GetChildNodes(getter_AddRefs(children)); NS_ENSURE_SUCCESS(rv, rv); PRUint32 childCount; @@ -375,7 +358,7 @@ nsXFormsItemElement::GetCopyNode(nsIDOMNode **aNode) return NS_OK; } -void +NS_IMETHODIMP nsXFormsItemElement::Refresh() { if (mDoneAddingChildren) { @@ -389,11 +372,13 @@ nsXFormsItemElement::Refresh() if (select) { select->Refresh(); } - return; + return NS_OK; } current = parent; } while(current); } + + return NS_OK; } NS_IMETHODIMP nsXFormsItemElement::SetActive(PRBool aActive) @@ -440,21 +425,8 @@ nsXFormsItemElement::GetLabelText(nsAString& aValue) NS_ENSURE_STATE(mElement); aValue.Truncate(0); - nsCOMPtr firstChild, container; - mElement->GetFirstChild(getter_AddRefs(firstChild)); - - // If this element is generated inside an , - // there is a element between this element - // and the actual childnodes. - if (nsXFormsUtils::IsXFormsElement(firstChild, - NS_LITERAL_STRING("contextcontainer"))) { - container = firstChild; - } else { - container = mElement; - } - nsCOMPtr children; - container->GetChildNodes(getter_AddRefs(children)); + mElement->GetChildNodes(getter_AddRefs(children)); NS_ENSURE_STATE(children); PRUint32 childCount; @@ -509,6 +481,24 @@ nsXFormsItemElement::CopyNodeEquals(nsIDOMNode *aNode, PRBool *aIsCopyNode) return rv; } +// nsIXFormsRepeatItemElement +NS_IMETHODIMP +nsXFormsItemElement::SetIndexState(PRBool aHasIndex) +{ + // this function has no real meaning for an item, so don't do anything. + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsItemElement::GetIndexState(PRBool *aHasIndex) +{ + // this function has no real meaning for an item, so always return false + NS_ENSURE_ARG(aHasIndex); + *aHasIndex = PR_FALSE; + return NS_OK; +} + + NS_HIDDEN_(nsresult) NS_NewXFormsItemElement(nsIXTFElement **aResult) { diff --git a/mozilla/extensions/xforms/nsXFormsItemSetElement.cpp b/mozilla/extensions/xforms/nsXFormsItemSetElement.cpp index 847b1e233ee..fd24ae64c16 100644 --- a/mozilla/extensions/xforms/nsXFormsItemSetElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsItemSetElement.cpp @@ -62,6 +62,9 @@ public: NS_IMETHOD OnCreated(nsIXTFElementWrapper *aWrapper); // nsIXTFElement overrides + NS_IMETHOD WillChangeDocument(nsIDOMDocument *aNewDocument); + NS_IMETHOD DocumentChanged(nsIDOMDocument *aNewDocument); + NS_IMETHOD WillChangeParent(nsIDOMElement *aNewParent); NS_IMETHOD ParentChanged(nsIDOMElement *aNewParent); NS_IMETHOD ChildInserted(nsIDOMNode *aChild, PRUint32 aIndex); NS_IMETHOD ChildAppended(nsIDOMNode *aChild); @@ -76,6 +79,21 @@ public: // nsIXFormsSelectChild NS_DECL_NSIXFORMSSELECTCHILD + + /** The standard notification flags set on nsIXTFElement */ + const PRUint32 kItemSetNotificationMask; + + /** Constructor */ + nsXFormsItemSetElement() : + kItemSetNotificationMask(nsIXTFElement::NOTIFY_WILL_CHANGE_DOCUMENT | + nsIXTFElement::NOTIFY_DOCUMENT_CHANGED | + nsIXTFElement::NOTIFY_WILL_CHANGE_PARENT | + nsIXTFElement::NOTIFY_PARENT_CHANGED | + nsIXTFElement::NOTIFY_CHILD_INSERTED | + nsIXTFElement::NOTIFY_CHILD_APPENDED | + nsIXTFElement::NOTIFY_WILL_REMOVE_CHILD | + nsIXTFElement::NOTIFY_BEGIN_ADDING_CHILDREN) + {}; }; NS_IMPL_ISUPPORTS_INHERITED1(nsXFormsItemSetElement, @@ -88,21 +106,41 @@ nsXFormsItemSetElement::OnCreated(nsIXTFElementWrapper *aWrapper) nsresult rv = nsXFormsDelegateStub::OnCreated(aWrapper); NS_ENSURE_SUCCESS(rv, rv); - aWrapper->SetNotificationMask(nsIXTFElement::NOTIFY_PARENT_CHANGED | - nsIXTFElement::NOTIFY_CHILD_INSERTED | - nsIXTFElement::NOTIFY_CHILD_APPENDED | - nsIXTFElement::NOTIFY_WILL_REMOVE_CHILD | - nsIXTFElement::NOTIFY_BEGIN_ADDING_CHILDREN); + aWrapper->SetNotificationMask(kItemSetNotificationMask); + return NS_OK; +} +NS_IMETHODIMP +nsXFormsItemSetElement::WillChangeDocument(nsIDOMDocument *aNewDocument) +{ + SetRepeatState(eType_Unknown); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsItemSetElement::DocumentChanged(nsIDOMDocument *aNewDocument) +{ + nsXFormsStubElement::DocumentChanged(aNewDocument); + + nsCOMPtr parent; + mElement->GetParentNode(getter_AddRefs(parent)); + UpdateRepeatState(parent); + return NS_OK; +} + +NS_IMETHODIMP +nsXFormsItemSetElement::WillChangeParent(nsIDOMElement *aNewParent) +{ + SetRepeatState(eType_Unknown); return NS_OK; } NS_IMETHODIMP nsXFormsItemSetElement::ParentChanged(nsIDOMElement *aNewParent) { - UpdateRepeatState(aNewParent); + nsXFormsStubElement::ParentChanged(aNewParent); - mHasParent = aNewParent != nsnull; + UpdateRepeatState(aNewParent); if (aNewParent) Refresh(); @@ -138,9 +176,10 @@ nsXFormsItemSetElement::BeginAddingChildren() nsCOMPtr wrapper = do_QueryInterface(mElement); NS_ASSERTION(wrapper, "huh? our element must be an xtf wrapper"); - wrapper->SetNotificationMask(nsIXTFElement::NOTIFY_PARENT_CHANGED | - nsIXTFElement::NOTIFY_DONE_ADDING_CHILDREN); - + wrapper->SetNotificationMask( + kItemSetNotificationMask & ~(nsIXTFElement::NOTIFY_CHILD_INSERTED | + nsIXTFElement::NOTIFY_CHILD_APPENDED | + nsIXTFElement::NOTIFY_WILL_REMOVE_CHILD)); return NS_OK; } @@ -151,10 +190,7 @@ nsXFormsItemSetElement::DoneAddingChildren() nsCOMPtr wrapper = do_QueryInterface(mElement); NS_ASSERTION(wrapper, "huh? our element must be an xtf wrapper"); - wrapper->SetNotificationMask(nsIXTFElement::NOTIFY_PARENT_CHANGED | - nsIXTFElement::NOTIFY_CHILD_INSERTED | - nsIXTFElement::NOTIFY_CHILD_APPENDED | - nsIXTFElement::NOTIFY_WILL_REMOVE_CHILD); + wrapper->SetNotificationMask(kItemSetNotificationMask); // Walk our children and get their anonymous content. Refresh(); @@ -312,15 +348,7 @@ nsXFormsItemSetElement::Refresh() anonContent->AppendChild(itemNode, getter_AddRefs(tmpNode)); - // XXX Could we get rid of the ? - rv = domDoc->CreateElementNS(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS), - NS_LITERAL_STRING("contextcontainer"), - getter_AddRefs(contextContainer)); - - NS_ENSURE_SUCCESS(rv, rv); - itemNode->AppendChild(contextContainer, getter_AddRefs(tmpNode)); - - nsCOMPtr ctx(do_QueryInterface(contextContainer)); + nsCOMPtr ctx(do_QueryInterface(itemNode)); if (ctx) { ctx->SetContext(node, i + 1, nodeCount); } @@ -329,12 +357,12 @@ nsXFormsItemSetElement::Refresh() for (PRUint32 j = 0; j < templateNodeCount; ++j) { templateNodes->Item(j, getter_AddRefs(templateNode)); templateNode->CloneNode(PR_TRUE, getter_AddRefs(cloneNode)); - contextContainer->AppendChild(cloneNode, getter_AddRefs(templateNode)); + itemNode->AppendChild(cloneNode, getter_AddRefs(templateNode)); } } - // refresh parent we + // refresh parent so that it has a chance to reflect the changes we just made if (parent) { nsCOMPtr control = do_QueryInterface(parent); if (control) { diff --git a/mozilla/extensions/xforms/nsXFormsMessageElement.cpp b/mozilla/extensions/xforms/nsXFormsMessageElement.cpp index 9b199b37c39..635dabcd880 100644 --- a/mozilla/extensions/xforms/nsXFormsMessageElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsMessageElement.cpp @@ -82,6 +82,7 @@ #include "nsIDOMDocumentEvent.h" #include "nsIChannelEventSink.h" #include "nsIXFormsEphemeralMessageUI.h" +#include "nsIContent.h" #define MESSAGE_WINDOW_PROPERTIES \ "centerscreen,chrome,dependent,dialog" @@ -271,6 +272,14 @@ nsXFormsMessageElement::OnDestroyed() NS_IMETHODIMP nsXFormsMessageElement::HandleEvent(nsIDOMEvent* aEvent) { + if (GetRepeatState() == eType_Template) { + return NS_OK; + } + + nsCOMPtr target; + aEvent->GetTarget(getter_AddRefs(target)); + nsCOMPtr content(do_QueryInterface(target)); + return nsXFormsUtils::EventHandlingAllowed(aEvent, mElement) ? HandleAction(aEvent, nsnull) : NS_OK; } diff --git a/mozilla/extensions/xforms/nsXFormsStubElement.cpp b/mozilla/extensions/xforms/nsXFormsStubElement.cpp index c9a5491886b..91480b22165 100644 --- a/mozilla/extensions/xforms/nsXFormsStubElement.cpp +++ b/mozilla/extensions/xforms/nsXFormsStubElement.cpp @@ -81,6 +81,7 @@ nsXFormsStubElement::WillChangeDocument(nsIDOMDocument *aNewDocument) NS_IMETHODIMP nsXFormsStubElement::DocumentChanged(nsIDOMDocument *aNewDocument) { + mHasDoc = aNewDocument != nsnull; return NS_OK; } @@ -93,6 +94,7 @@ nsXFormsStubElement::WillChangeParent(nsIDOMElement *aNewParent) NS_IMETHODIMP nsXFormsStubElement::ParentChanged(nsIDOMElement *aNewParent) { + mHasParent = aNewParent != nsnull; return NS_OK; } @@ -200,6 +202,76 @@ nsXFormsStubElement::CloneState(nsIDOMElement *aElement) return NS_OK; } +nsRepeatState +nsXFormsStubElement::GetRepeatState() +{ + return mRepeatState; +} + +void +nsXFormsStubElement::SetRepeatState(nsRepeatState aState) +{ + mRepeatState = aState; + return; +} + +nsRepeatState +nsXFormsStubElement::UpdateRepeatState(nsIDOMNode *aParent) +{ + // Walk up the parent chain looking to see if the this control is contained + // in an item. If it is and that item is contained in a itemset, then we + // know that this control was generated as a clone from the itemset's + // template. Similarly, we'll check to see if this control lives in a + // contextcontainer (meaning it was cloned from a repeat's template). + // Otherwise, if neither of these are the case but it lives under a repeat + // or an itemset, then this control must be part of a template. A template + // is the content of a repeat or itemset that gets cloned once for every + // node in the bound nodeset. + // + // If none of this applies, we'll return eType_NotApplicable to show that this + // control isn't bound to a repeating nodeset. + nsRepeatState repeatState = eType_NotApplicable; + + if (!mHasDoc || !mHasParent) { + // If we don't have a document or a parent, none of these tests will work + // correctly so no sense doing them now. If either of these are false the + // repeat state for the object should already be eType_Unknown so just + // return that now. + return eType_Unknown; + } + + nsCOMPtr parent = aParent; + PRBool childIsItem = PR_FALSE; + while (parent) { + if (nsXFormsUtils::IsXFormsElement(parent, + NS_LITERAL_STRING("contextcontainer"))) { + repeatState = eType_GeneratedContent; + break; + } + if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("repeat"))) { + repeatState = eType_Template; + break; + } + if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("itemset"))) { + if (childIsItem) { + repeatState = eType_GeneratedContent; + break; + } + repeatState = eType_Template; + break; + } + + if (nsXFormsUtils::IsXFormsElement(parent, NS_LITERAL_STRING("item"))) { + childIsItem = PR_TRUE; + } + nsCOMPtr tmp; + parent->GetParentNode(getter_AddRefs(tmp)); + parent = tmp; + } + + SetRepeatState(repeatState); + return repeatState; +} nsresult NS_NewXFormsStubElement(nsIXTFElement **aResult) { diff --git a/mozilla/extensions/xforms/nsXFormsStubElement.h b/mozilla/extensions/xforms/nsXFormsStubElement.h index 5e5d633472e..63a26acbe19 100644 --- a/mozilla/extensions/xforms/nsXFormsStubElement.h +++ b/mozilla/extensions/xforms/nsXFormsStubElement.h @@ -42,6 +42,30 @@ #include "nsIXTFElement.h" #include "nsIXFormsControlBase.h" +/** + * nsRepeatState is used to indicate whether the element is inside a + * \ or \ template. If it is, there is no need + * to refresh the widget bound to the element. + * + * eType_Unknown - repeat state has yet to be determined + * eType_Template - element lives inside the template (an original element + * from the document that is hidden from the user) + * eType_GeneratedContent - A generated clone of an element from the template. + * It is generated as the repeat or itemset processes + * the nodeset that it is bound to. For every node in + * the nodeset, the repeat or itemset will go through + * its template and create a clone for every element + * in the template. A user will see these elements. + * eType_NotApplicable - element lives in the DOM and is not contained + * by a repeat or an itemset + */ +enum nsRepeatState { + eType_Unknown, + eType_Template, + eType_GeneratedContent, + eType_NotApplicable +}; + /** * An implementation of a generic XForms element. */ @@ -53,9 +77,51 @@ protected: // derived class destructor. virtual ~nsXFormsStubElement() {} + /** + * This is processed when an XForms control or XForms action has been inserted + * under a parent node AND has been inserted into a document. + * It checks the ancestors of the element and returns an nsRepeatState + * depending on the element's place in the document. + * + * @param aParent The new parent of the XForms control + */ + nsRepeatState UpdateRepeatState(nsIDOMNode *aParent); + + nsRepeatState mRepeatState; + + /** + * State that tells whether control has a parent or not. This could be + * false even if the control has a parent. Just means that the element + * doesn't need to track whether it has a parent or not (i.e. xf:choices) + */ + PRPackedBool mHasParent; + + /** + * State that tells whether control has a document or not. This could be + * false even if the control has a document. Just means that the element + * doesn't need to track whether it has a document or not (i.e. xf:choices) + */ + PRPackedBool mHasDoc; + public: NS_DECL_ISUPPORTS NS_DECL_NSIXTFELEMENT + + /** Constructor */ + nsXFormsStubElement() : + mRepeatState(eType_Unknown), + mHasParent(PR_FALSE), + mHasDoc(PR_FALSE) + {}; + + /** + * Get/Set the repeat state for the xforms control or action. The repeat + * state indicates whether the control or action lives inside a context + * container, a repeat element, an itemset or none of the above. + */ + virtual nsRepeatState GetRepeatState(); + virtual void SetRepeatState(nsRepeatState aState); + }; /* Factory methods */ diff --git a/mozilla/extensions/xforms/resources/content/select1.xml b/mozilla/extensions/xforms/resources/content/select1.xml index e1ff32b04d0..916a5bdf460 100644 --- a/mozilla/extensions/xforms/resources/content/select1.xml +++ b/mozilla/extensions/xforms/resources/content/select1.xml @@ -1092,14 +1092,12 @@ var elm = aElement; - // per http://www.w3.org/TR/2005/PER-xforms-20051006/index-all.html#evt-select - // we send the event to the itemset if it is a parent. - if (elm.parentNode && elm.parentNode.localName == "itemset") - elm = elm.parentNode; + // per errata for XForms 1.0 second edition, we send the event to the + // item, even if it is contained in an itemset elm.dispatchEvent(ev); return true; - ]]> + ]]> diff --git a/mozilla/extensions/xforms/resources/content/selects.xml b/mozilla/extensions/xforms/resources/content/selects.xml index ee5971eab61..5b6fe883ad6 100644 --- a/mozilla/extensions/xforms/resources/content/selects.xml +++ b/mozilla/extensions/xforms/resources/content/selects.xml @@ -732,14 +732,12 @@ if (aIncremental) { // Fire 'select'/'deselect' only if user changed the select value. - // per http://www.w3.org/TR/xforms/slice4.html#evt-select - // we send the event to the itemset if it is a parent. - var parent = this.ownerDocument.getBindingParent(aItem); - var target = parent && parent.localName == "itemset" ? parent : aItem; + // per errata for XForms 1.0 second edition, we send the event to + // the item even if it is contained inside an itemset var eventName = this.isItemMarkedSelected(aItem) ? "xforms-select" : "xforms-deselect"; - this.dispatchXFormsNotificationEvent(eventName, target); + this.dispatchXFormsNotificationEvent(eventName, aItem); } this.updateInstanceData(aIncremental); @@ -823,10 +821,8 @@ if (aIncremental) { // Fire 'select'/'deselect' only if user changed the select1 value. - // per http://www.w3.org/TR/xforms/slice4.html#evt-select - // we send the event to the itemset if it is a parent. - var parent = this.ownerDocument.getBindingParent(aItem); - var target = parent && parent.localName == "itemset" ? parent : aItem; + // per errata for XForms 1.0 second edition, we send the event + // to the item even if it is contained by an itemset function _unselectItems(aItem, aNewSelectedItem, aTarget) { if (aItem != aNewSelectedItem) { @@ -839,11 +835,11 @@ } return true; } - this.traverseItems(this, _unselectItems, aItem, target); + this.traverseItems(this, _unselectItems, aItem, aItem); var eventName = this.isItemMarkedSelected(aItem) ? "xforms-select" : "xforms-deselect"; - this.dispatchXFormsNotificationEvent(eventName, target); + this.dispatchXFormsNotificationEvent(eventName, aItem); } this.updateInstanceData(aIncremental); diff --git a/mozilla/extensions/xforms/resources/content/selectsnw-xhtml.xml b/mozilla/extensions/xforms/resources/content/selectsnw-xhtml.xml index 066c4d8459d..e8e60b8da46 100644 --- a/mozilla/extensions/xforms/resources/content/selectsnw-xhtml.xml +++ b/mozilla/extensions/xforms/resources/content/selectsnw-xhtml.xml @@ -173,7 +173,7 @@ extends="#nativewidget-select-compact"> + class="xf-value" anonid="control" size="5"/> diff --git a/mozilla/extensions/xforms/resources/content/selectsnw.xml b/mozilla/extensions/xforms/resources/content/selectsnw.xml index 25ec2113531..14b3a9df6bc 100644 --- a/mozilla/extensions/xforms/resources/content/selectsnw.xml +++ b/mozilla/extensions/xforms/resources/content/selectsnw.xml @@ -168,11 +168,6 @@ case "item": this.nativeWidget.setLabelFor(parent, label); break; - case "contextcontainer": - // Parent of xf:contextcontainer element is xf:item element in - // the case of auto-generated content of xf:itemset. - this.nativeWidget.setLabelFor(parent.parentNode, label); - break; } } ]]> @@ -788,9 +783,6 @@ if (child.namespaceURI == this.XFORMS_NS) { if (child.localName == "label") return child; - - if (child.localName == "contextcontainer") - return this.getLabelFor(child); } } return null; @@ -884,15 +876,6 @@ continue; var target = listElm.elm; - var parent = target.parentNode; - while (parent && parent != this.selectControl) { - if (parent.namespaceURI == this.XFORMS_NS && - parent.localName == "itemset") { - target = parent; - break; - } - parent = parent.parentNode; - } // First we should send 'xforms-unselect' events for all // unselected item elements and then 'xforms-select' events. @@ -907,8 +890,9 @@ } for (var index = 0; index < deferredEventTargets.length; ++index) { - this.selectControl.dispatchXFormsNotificationEvent("xforms-select", - target); + this.selectControl.dispatchXFormsNotificationEvent( + "xforms-select", deferredEventTargets[index]); + } } @@ -957,7 +941,7 @@ dump("native elm: " + obj.nativeElm.localName); var label = this.getLabelFor(obj.elm); if (label) - dump(", label: " + label.textContent); + dump(", label: " + label.textValue); dump("\n"); } ]]> diff --git a/mozilla/extensions/xforms/resources/content/xforms.css b/mozilla/extensions/xforms/resources/content/xforms.css index 163cdd99b64..2f460d5db83 100755 --- a/mozilla/extensions/xforms/resources/content/xforms.css +++ b/mozilla/extensions/xforms/resources/content/xforms.css @@ -689,7 +689,7 @@ html|*:root html|span.-moz-select1-container { padding-right: 0px; overflow: hidden; border-width: 2px; - padding-bottom: 0px; + padding-bottom: 1px; padding-top: 1px; }