mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 15:55:16 +00:00
[XForms] label's accessors getValue method should return explicit content too. Bug 327239, patch by surkov, r=olli+allan
This commit is contained in:
parent
6e68d2a1e8
commit
f08f7e8b66
@ -139,7 +139,6 @@ XPIDLSRCS = \
|
||||
nsIDelegateInternal.idl \
|
||||
nsIXFormsUIWidget.idl \
|
||||
nsIXFormsItemElement.idl \
|
||||
nsIXFormsLabelElement.idl \
|
||||
nsIXFormsItemSetUIElement.idl \
|
||||
nsIXFormsRepeatUIElement.idl \
|
||||
nsIXFormsAccessors.idl \
|
||||
|
@ -1,52 +0,0 @@
|
||||
/* -*- 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
|
||||
* Olli Pettay.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Olli Pettay <Olli.Pettay@helsinki.fi> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 implemented by the label element.
|
||||
*/
|
||||
[uuid(f357747b-a1a2-4044-bd25-cb5d5b4fde3a)]
|
||||
interface nsIXFormsLabelElement : nsISupports
|
||||
{
|
||||
/**
|
||||
* The text value of the \<label\> element.
|
||||
*/
|
||||
readonly attribute AString textValue;
|
||||
};
|
@ -52,11 +52,12 @@
|
||||
#include "nsIModelElementPrivate.h"
|
||||
#include "nsIXFormsItemElement.h"
|
||||
#include "nsIXFormsControl.h"
|
||||
#include "nsIXFormsLabelElement.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsXFormsModelElement.h"
|
||||
#include "nsIXFormsCopyElement.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIXFormsDelegate.h"
|
||||
#include "nsIXFormsAccessors.h"
|
||||
|
||||
/**
|
||||
* nsXFormsItemElement implements the XForms \<item\> element.
|
||||
@ -436,11 +437,14 @@ nsXFormsItemElement::GetLabelText(nsAString& aValue)
|
||||
for (PRUint32 i = 0; i < childCount; ++i) {
|
||||
children->Item(i, getter_AddRefs(child));
|
||||
if (nsXFormsUtils::IsXFormsElement(child, NS_LITERAL_STRING("label"))) {
|
||||
nsCOMPtr<nsIXFormsLabelElement> label(do_QueryInterface(child));
|
||||
if (label) {
|
||||
label->GetTextValue(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIXFormsDelegate> label(do_QueryInterface(child));
|
||||
NS_ENSURE_STATE(label);
|
||||
|
||||
nsCOMPtr<nsIXFormsAccessors> accessors;
|
||||
label->GetXFormsAccessors(getter_AddRefs(accessors));
|
||||
NS_ENSURE_STATE(accessors);
|
||||
|
||||
return accessors->GetValue(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,23 +56,21 @@
|
||||
#include "nsIXFormsUIWidget.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIXFormsLabelElement.h"
|
||||
#include "nsIXFormsItemElement.h"
|
||||
|
||||
class nsXFormsLabelElement : public nsXFormsDelegateStub,
|
||||
public nsIStreamListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIXFormsLabelElement
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIXFORMSLABELELEMENT
|
||||
|
||||
// nsIXFormsDelegate
|
||||
NS_IMETHOD GetValue(nsAString& aValue);
|
||||
NS_IMETHOD WidgetAttached();
|
||||
|
||||
// nsIXFormsControl
|
||||
NS_IMETHOD IsEventTarget(PRBool *aOK);
|
||||
@ -88,6 +86,8 @@ public:
|
||||
NS_IMETHOD AttributeSet(nsIAtom *aName, const nsAString &aSrc);
|
||||
NS_IMETHOD AttributeRemoved(nsIAtom *aName);
|
||||
|
||||
nsXFormsLabelElement() : mWidgetLoaded(PR_FALSE) {};
|
||||
|
||||
#ifdef DEBUG_smaug
|
||||
virtual const char* Name() { return "label"; }
|
||||
#endif
|
||||
@ -96,14 +96,14 @@ private:
|
||||
|
||||
nsCString mSrcAttrText;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
PRBool mWidgetLoaded;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED4(nsXFormsLabelElement,
|
||||
NS_IMPL_ISUPPORTS_INHERITED3(nsXFormsLabelElement,
|
||||
nsXFormsDelegateStub,
|
||||
nsIRequestObserver,
|
||||
nsIStreamListener,
|
||||
nsIInterfaceRequestor,
|
||||
nsIXFormsLabelElement)
|
||||
nsIInterfaceRequestor)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsLabelElement::OnCreated(nsIXTFBindableElementWrapper *aWrapper)
|
||||
@ -199,6 +199,28 @@ nsXFormsLabelElement::GetValue(nsAString& aValue)
|
||||
// handle linking ('src') attribute
|
||||
aValue = NS_ConvertUTF8toUTF16(mSrcAttrText);
|
||||
}
|
||||
if (aValue.IsVoid()) {
|
||||
NS_ENSURE_STATE(mElement);
|
||||
|
||||
nsCOMPtr<nsIDOM3Node> inner(do_QueryInterface(mElement));
|
||||
if (inner) {
|
||||
inner->GetTextContent(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsLabelElement::WidgetAttached()
|
||||
{
|
||||
mWidgetLoaded = PR_TRUE;
|
||||
|
||||
// We shouldn't report to model that label is ready to work
|
||||
// if label is loading external resource. We will report
|
||||
// about it later when external resource will be loaded.
|
||||
if (!mChannel)
|
||||
nsXFormsDelegateStub::WidgetAttached();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -398,25 +420,8 @@ nsXFormsLabelElement::OnStopRequest(nsIRequest *aRequest,
|
||||
mSrcAttrText.Truncate();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXFormsUIWidget> widget = do_QueryInterface(mElement);
|
||||
if (widget)
|
||||
widget->Refresh();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsLabelElement::GetTextValue(nsAString& aValue)
|
||||
{
|
||||
NS_ENSURE_STATE(mElement);
|
||||
GetValue(aValue);
|
||||
|
||||
if (aValue.IsVoid()) {
|
||||
nsCOMPtr<nsIDOM3Node> inner(do_QueryInterface(mElement));
|
||||
if (inner) {
|
||||
inner->GetTextContent(aValue);
|
||||
}
|
||||
}
|
||||
if (mWidgetLoaded)
|
||||
nsXFormsDelegateStub::WidgetAttached();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user