зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 192837. Freezing the rest of the DOM HTML interfaces. r=fabian@imajes.info, sr=peterv@netscape.com
This commit is contained in:
Родитель
19bde11d90
Коммит
0b5cb41238
|
@ -39,25 +39,17 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsHTMLSelectAccessible.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLOptGroupElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsIOptionElement.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
/**
|
||||
|
@ -186,7 +178,7 @@ NS_IMETHODIMP nsHTMLSelectableAccessible::ChangeSelection(PRInt32 aIndex, PRUint
|
|||
if (!htmlSelect)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
htmlSelect->GetOptions(getter_AddRefs(options));
|
||||
if (!options)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -526,14 +518,10 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetAccName(nsAString& aName)
|
|||
mDOMNode->GetFirstChild(getter_AddRefs(child));
|
||||
|
||||
if (child) {
|
||||
nsCOMPtr<nsIDOMText> text(do_QueryInterface(child));
|
||||
nsCOMPtr<nsITextContent> text(do_QueryInterface(child));
|
||||
if (text) {
|
||||
nsCOMPtr<nsIContent> content (do_QueryInterface(child));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAutoString txtValue;
|
||||
rv = AppendFlatStringFromContentNode(content, &txtValue);
|
||||
rv = AppendFlatStringFromContentNode(text, &txtValue);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Temp var (txtValue) needed until CompressWhitespace built for nsAString
|
||||
txtValue.CompressWhitespace();
|
||||
|
@ -740,7 +728,7 @@ nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIDOMNode *aListNod
|
|||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement(do_QueryInterface(aListNode));
|
||||
NS_ASSERTION(selectElement, "No select element where it should be");
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
nsresult rv = selectElement->GetOptions(getter_AddRefs(options));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
|
|
@ -42,10 +42,9 @@
|
|||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsFormControlAccessible.h"
|
||||
|
||||
/**
|
||||
|
@ -94,7 +93,7 @@ protected:
|
|||
PRUint32 mIndex;
|
||||
PRInt32 mSelCount;
|
||||
nsHTMLSelectableAccessible *mParent;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> mOptions;
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> mOptions;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> mOption;
|
||||
|
||||
public:
|
||||
|
|
|
@ -1457,7 +1457,10 @@ nsFormSubmission::ProcessValue(nsIDOMHTMLElement* aSource,
|
|||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult rv = mFormProcessor->ProcessValue(aSource, tmpNameStr, *retval);
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
mFormProcessor->ProcessValue(aSource, tmpNameStr, *retval);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Unable to Notify form process observer");
|
||||
}
|
||||
|
||||
|
|
|
@ -236,12 +236,6 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
|
|||
return CallQueryInterface(sub_doc, aContentDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLObjectElement::SetContentDocument(nsIDOMDocument* aContentDocument)
|
||||
{
|
||||
return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMNSHTMLOptionElement.h"
|
||||
#include "nsIOptionElement.h"
|
||||
#include "nsIDOMHTMLOptGroupElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
|
@ -75,6 +76,7 @@
|
|||
*/
|
||||
class nsHTMLOptionElement : public nsGenericHTMLContainerElement,
|
||||
public nsIDOMHTMLOptionElement,
|
||||
public nsIDOMNSHTMLOptionElement,
|
||||
public nsIJSNativeInitializer,
|
||||
public nsIOptionElement
|
||||
{
|
||||
|
@ -97,6 +99,9 @@ public:
|
|||
// nsIDOMHTMLOptionElement
|
||||
NS_DECL_NSIDOMHTMLOPTIONELEMENT
|
||||
|
||||
// nsIDOMNSHTMLOptionElement
|
||||
NS_IMETHOD SetText(const nsAString & aText);
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(JSContext* aContext, JSObject *aObj,
|
||||
PRUint32 argc, jsval *argv);
|
||||
|
@ -104,7 +109,8 @@ public:
|
|||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
nsHTMLValue& aResult);
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute, PRInt32 aModType,
|
||||
NS_IMETHOD GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
PRInt32 aModType,
|
||||
nsChangeHint& aHint) const;
|
||||
|
||||
// nsIOptionElement
|
||||
|
@ -215,6 +221,7 @@ NS_IMPL_RELEASE_INHERITED(nsHTMLOptionElement, nsGenericElement);
|
|||
NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLOptionElement,
|
||||
nsGenericHTMLContainerElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLOptionElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLOptionElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIOptionElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLOptionElement)
|
||||
|
@ -441,14 +448,12 @@ nsHTMLOptionElement::GetIndex(PRInt32* aIndex)
|
|||
|
||||
if (selectElement) {
|
||||
// Get the options from the select object.
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
selectElement->GetOptions(getter_AddRefs(options));
|
||||
|
||||
if (options) {
|
||||
// Walk the options to find out where we are in the list (ick, O(n))
|
||||
PRUint32 length = 0;
|
||||
|
||||
options->GetLength(&length);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> thisOption;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsGenericDOMHTMLCollection.h"
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsIDOMNSHTMLOptionCollectn.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIBoxObject.h"
|
||||
|
@ -90,7 +91,8 @@ class nsHTMLSelectElement;
|
|||
* The collection of options in the select (what you get back when you do
|
||||
* select.options in DOM)
|
||||
*/
|
||||
class nsHTMLOptionCollection: public nsIDOMNSHTMLOptionCollection,
|
||||
class nsHTMLOptionCollection: public nsIDOMHTMLOptionsCollection,
|
||||
public nsIDOMNSHTMLOptionCollection,
|
||||
public nsGenericDOMHTMLCollection
|
||||
{
|
||||
public:
|
||||
|
@ -99,17 +101,19 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIDOMHTMLOptionsCollection interface
|
||||
NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION
|
||||
|
||||
// nsIDOMNSHTMLOptionCollection interface, can't use the macro
|
||||
// NS_DECL_NSIDOMNSHTMLOPTIONCOLLECTION here since GetLength() is
|
||||
// defined in more than one interface
|
||||
NS_IMETHOD SetLength(PRUint32 aLength);
|
||||
NS_IMETHOD GetSelectedIndex(PRInt32* aSelectedIndex);
|
||||
NS_IMETHOD SetSelectedIndex(PRInt32 aSelectedIndex);
|
||||
NS_IMETHOD SetOption(PRInt32 aIndex, nsIDOMHTMLOptionElement* aOption);
|
||||
NS_IMETHOD Add(nsIDOMHTMLOptionElement* aOption);
|
||||
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_DECL_NSIDOMHTMLCOLLECTION
|
||||
// nsIDOMHTMLCollection interface, all its methods are defined in
|
||||
// nsIDOMHTMLOptionsCollection
|
||||
|
||||
// Helpers for nsHTMLSelectElement
|
||||
/**
|
||||
|
@ -1082,7 +1086,7 @@ nsHTMLSelectElement::Remove(PRInt32 aIndex)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::GetOptions(nsIDOMHTMLCollection** aValue)
|
||||
nsHTMLSelectElement::GetOptions(nsIDOMHTMLOptionsCollection** aValue)
|
||||
{
|
||||
*aValue = mOptions;
|
||||
NS_IF_ADDREF(*aValue);
|
||||
|
@ -2230,10 +2234,11 @@ nsHTMLOptionCollection::DropReference()
|
|||
|
||||
// QueryInterface implementation for nsHTMLOptionCollection
|
||||
NS_INTERFACE_MAP_BEGIN(nsHTMLOptionCollection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLOptionsCollection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLOptionCollection)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLCollection)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNSHTMLOptionCollection)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLOptionCollection)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLOptionsCollection)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
|
|
|
@ -236,12 +236,6 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
|
|||
return CallQueryInterface(sub_doc, aContentDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLObjectElement::SetContentDocument(nsIDOMDocument* aContentDocument)
|
||||
{
|
||||
return NS_ERROR_DOM_INVALID_MODIFICATION_ERR;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLObjectElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAString& aValue,
|
||||
|
|
|
@ -71,6 +71,7 @@ XPIDLSRCS = \
|
|||
nsIDOMHTMLObjectElement.idl \
|
||||
nsIDOMHTMLOptGroupElement.idl \
|
||||
nsIDOMHTMLOptionElement.idl \
|
||||
nsIDOMHTMLOptionsCollection.idl \
|
||||
nsIDOMHTMLParagraphElement.idl \
|
||||
nsIDOMHTMLParamElement.idl \
|
||||
nsIDOMHTMLPreElement.idl \
|
||||
|
@ -97,7 +98,8 @@ XPIDLSRCS = \
|
|||
nsIDOMNSHTMLFrameElement.idl \
|
||||
nsIDOMNSHTMLImageElement.idl \
|
||||
nsIDOMNSHTMLInputElement.idl \
|
||||
nsIDOMNSHTMLOptionCollectn.idl \
|
||||
nsIDOMNSHTMLOptionCollectn.idl \
|
||||
nsIDOMNSHTMLOptionElement.idl \
|
||||
nsIDOMNSHTMLSelectElement.idl \
|
||||
nsIDOMNSHTMLTextAreaElement.idl \
|
||||
nsIDOMNSXBLFormControl.idl \
|
||||
|
|
|
@ -40,6 +40,16 @@
|
|||
|
||||
#include "nsIDOMHTMLElement.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLObjectElement interface is the interface to a [X]HTML
|
||||
* object element.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-HTML/
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(a6cf90ac-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIDOMHTMLObjectElement : nsIDOMHTMLElement
|
||||
{
|
||||
|
@ -62,5 +72,5 @@ interface nsIDOMHTMLObjectElement : nsIDOMHTMLElement
|
|||
attribute long vspace;
|
||||
attribute DOMString width;
|
||||
// Introduced in DOM Level 2:
|
||||
attribute nsIDOMDocument contentDocument;
|
||||
readonly attribute nsIDOMDocument contentDocument;
|
||||
};
|
||||
|
|
|
@ -40,12 +40,24 @@
|
|||
|
||||
#include "nsIDOMHTMLElement.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLOptionElement interface is the interface to a [X]HTML
|
||||
* option element.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-HTML/
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(a6cf9092-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIDOMHTMLOptionElement : nsIDOMHTMLElement
|
||||
{
|
||||
readonly attribute nsIDOMHTMLFormElement form;
|
||||
// Modified in DOM Level 2:
|
||||
attribute boolean defaultSelected;
|
||||
attribute DOMString text;
|
||||
readonly attribute DOMString text;
|
||||
// Modified in DOM Level 2:
|
||||
readonly attribute long index;
|
||||
attribute boolean disabled;
|
||||
attribute DOMString label;
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
* Johnny Stenback <jst@netscape.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMHTMLElement.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLOptionsCollection interface is the interface to a
|
||||
* collection of [X]HTML option elements.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-HTML/
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
// Introduced in DOM Level 2:
|
||||
[scriptable, uuid(bce0213c-f70f-488f-b93f-688acca55d63)]
|
||||
interface nsIDOMHTMLOptionsCollection : nsISupports
|
||||
{
|
||||
attribute unsigned long length;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
nsIDOMNode item(in unsigned long index);
|
||||
nsIDOMNode namedItem(in DOMString name);
|
||||
};
|
|
@ -39,6 +39,17 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMHTMLElement.idl"
|
||||
#include "nsIDOMHTMLOptionsCollection.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLSelectElement interface is the interface to a [X]HTML
|
||||
* select element.
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/DOM-Level-2-HTML/
|
||||
*
|
||||
* @status FROZEN
|
||||
*/
|
||||
|
||||
[scriptable, uuid(a6cf9090-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIDOMHTMLSelectElement : nsIDOMHTMLElement
|
||||
|
@ -46,18 +57,22 @@ interface nsIDOMHTMLSelectElement : nsIDOMHTMLElement
|
|||
readonly attribute DOMString type;
|
||||
attribute long selectedIndex;
|
||||
attribute DOMString value;
|
||||
// Modified in DOM Level 2:
|
||||
attribute unsigned long length;
|
||||
// raises(DOMException) on setting
|
||||
|
||||
readonly attribute nsIDOMHTMLFormElement form;
|
||||
readonly attribute nsIDOMHTMLCollection options;
|
||||
// Modified in DOM Level 2:
|
||||
readonly attribute nsIDOMHTMLOptionsCollection options;
|
||||
attribute boolean disabled;
|
||||
attribute boolean multiple;
|
||||
attribute DOMString name;
|
||||
attribute long size;
|
||||
attribute long tabIndex;
|
||||
void add(in nsIDOMHTMLElement element,
|
||||
in nsIDOMHTMLElement before);
|
||||
in nsIDOMHTMLElement before)
|
||||
raises(DOMException);
|
||||
void remove(in long index);
|
||||
void blur();
|
||||
void focus();
|
||||
};
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ interface nsIDOMHTMLOptionElement;
|
|||
[scriptable, uuid(409bbf14-1dd2-11b2-91de-8d672d406276)]
|
||||
interface nsIDOMNSHTMLOptionCollection : nsISupports
|
||||
{
|
||||
attribute unsigned long length;
|
||||
attribute long selectedIndex;
|
||||
|
||||
[noscript] void setOption(in long index,
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao <vidur@netscape.com> (original author)
|
||||
* Johnny Stenback <jst@netscape.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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMHTMLElement.idl"
|
||||
|
||||
[scriptable, uuid(e2dfc89c-7ae0-4651-8aee-7f5edc2aa626)]
|
||||
interface nsIDOMNSHTMLOptionElement : nsISupports
|
||||
{
|
||||
// Settable version of the text attribute.
|
||||
attribute DOMString text;
|
||||
};
|
|
@ -84,7 +84,7 @@ enum nsDOMClassInfoID {
|
|||
// HTML classes
|
||||
eDOMClassInfo_HTMLDocument_id,
|
||||
eDOMClassInfo_HTMLCollection_id,
|
||||
eDOMClassInfo_HTMLOptionCollection_id,
|
||||
eDOMClassInfo_HTMLOptionsCollection_id,
|
||||
eDOMClassInfo_HTMLFormControlCollection_id,
|
||||
eDOMClassInfo_HTMLGenericCollection_id,
|
||||
|
||||
|
|
|
@ -133,6 +133,8 @@
|
|||
|
||||
// HTMLOptionCollection includes
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMNSHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsIDOMNSHTMLOptionCollectn.h"
|
||||
|
||||
// ContentList includes
|
||||
|
@ -473,8 +475,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
nsIXPCScriptable::WANT_ENUMERATE)
|
||||
NS_DEFINE_CLASSINFO_DATA(HTMLCollection, nsHTMLCollectionSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(HTMLOptionCollection,
|
||||
nsHTMLOptionCollectionSH,
|
||||
NS_DEFINE_CLASSINFO_DATA(HTMLOptionsCollection,
|
||||
nsHTMLOptionsCollectionSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_SETPROPERTY)
|
||||
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(HTMLFormControlCollection, HTMLCollection,
|
||||
|
@ -1462,8 +1464,8 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(HTMLOptionCollection,
|
||||
nsIDOMHTMLCollection)
|
||||
DOM_CLASSINFO_MAP_BEGIN(HTMLOptionsCollection, nsIDOMHTMLOptionsCollection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionsCollection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLOptionCollection)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -1680,6 +1682,7 @@ nsDOMClassInfo::Init()
|
|||
|
||||
DOM_CLASSINFO_MAP_BEGIN(HTMLOptionElement, nsIDOMHTMLOptionElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLOptionElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLOptionElement)
|
||||
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
|
@ -5423,8 +5426,7 @@ nsHTMLSelectElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> s(do_QueryInterface(native));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
s->GetOptions(getter_AddRefs(options));
|
||||
|
||||
if (options) {
|
||||
|
@ -5490,7 +5492,7 @@ nsHTMLSelectElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
nsCOMPtr<nsIDOMHTMLSelectElement> select(do_QueryInterface(native));
|
||||
NS_ENSURE_TRUE(select, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
select->GetOptions(getter_AddRefs(options));
|
||||
|
||||
nsCOMPtr<nsIDOMNSHTMLOptionCollection> oc(do_QueryInterface(options));
|
||||
|
@ -5931,12 +5933,12 @@ nsHTMLPluginObjElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
}
|
||||
|
||||
|
||||
// HTMLOptionCollection helper
|
||||
// HTMLOptionsCollection helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionCollectionSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
jsval *vp, PRBool *_retval)
|
||||
nsHTMLOptionsCollectionSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
jsval *vp, PRBool *_retval)
|
||||
{
|
||||
int32 n = GetArrayIndexFromId(cx, id);
|
||||
|
||||
|
|
|
@ -809,7 +809,8 @@ public:
|
|||
class nsHTMLPluginObjElementSH : public nsHTMLAppletElementSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLPluginObjElementSH(nsDOMClassInfoData* aData) : nsHTMLAppletElementSH(aData)
|
||||
nsHTMLPluginObjElementSH(nsDOMClassInfoData* aData)
|
||||
: nsHTMLAppletElementSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -834,16 +835,17 @@ public:
|
|||
};
|
||||
|
||||
|
||||
// HTMLOptionCollection helper
|
||||
// HTMLOptionsCollection helper
|
||||
|
||||
class nsHTMLOptionCollectionSH : public nsHTMLCollectionSH
|
||||
class nsHTMLOptionsCollectionSH : public nsHTMLCollectionSH
|
||||
{
|
||||
protected:
|
||||
nsHTMLOptionCollectionSH(nsDOMClassInfoData* aData) : nsHTMLCollectionSH(aData)
|
||||
nsHTMLOptionsCollectionSH(nsDOMClassInfoData* aData)
|
||||
: nsHTMLCollectionSH(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsHTMLOptionCollectionSH()
|
||||
virtual ~nsHTMLOptionsCollectionSH()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -853,7 +855,7 @@ public:
|
|||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsHTMLOptionCollectionSH(aData);
|
||||
return new nsHTMLOptionsCollectionSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1873,7 +1873,7 @@ wallet_GetSelectIndex(
|
|||
{
|
||||
PRUint32 length;
|
||||
selectElement->GetLength(&length);
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
selectElement->GetOptions(getter_AddRefs(options));
|
||||
if (options) {
|
||||
PRUint32 numOptions;
|
||||
|
@ -3699,7 +3699,7 @@ wallet_CaptureSelectElement(nsIDOMNode* elementNode, nsIDocument* doc) {
|
|||
PRUint32 length;
|
||||
selectElement->GetLength(&length);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
selectElement->GetOptions(getter_AddRefs(options));
|
||||
|
||||
if (options) {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsIHTMLContent.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsIDOMNSHTMLOptionCollectn.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMNSHTMLSelectElement.h"
|
||||
|
@ -892,13 +892,14 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Lists out all the options
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
if (options) {
|
||||
PRUint32 numOptions;
|
||||
options->GetLength(&numOptions);
|
||||
printf("--- Num of Items %d ---\n", numOptions);
|
||||
for (PRUint32 i=0;i<numOptions;i++) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*options, i));
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(options, i));
|
||||
if (optionElement) {
|
||||
nsAutoString text;
|
||||
rv = optionElement->GetLabel(text);
|
||||
|
@ -1486,7 +1487,8 @@ nsListControlFrame::InitSelectionRange(PRInt32 aClickedIndex)
|
|||
GetSelectedIndex(&selectedIndex);
|
||||
if (selectedIndex >= 0) {
|
||||
// Get the end of the contiguous selection
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ASSERTION(options, "Collection of options is null!");
|
||||
PRUint32 numOptions;
|
||||
options->GetLength(&numOptions);
|
||||
|
@ -1494,7 +1496,7 @@ nsListControlFrame::InitSelectionRange(PRInt32 aClickedIndex)
|
|||
// Push i to one past the last selected index in the group
|
||||
for (i=selectedIndex+1; i < numOptions; i++) {
|
||||
PRBool selected;
|
||||
GetOption(*options, i)->GetSelected(&selected);
|
||||
GetOption(options, i)->GetSelected(&selected);
|
||||
if (!selected) {
|
||||
break;
|
||||
}
|
||||
|
@ -1840,10 +1842,10 @@ nsListControlFrame::GetSelect(nsIContent * aContent)
|
|||
// for a given index (AddRefs)
|
||||
//---------------------------------------------------------
|
||||
nsIContent*
|
||||
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLCollection* aCollection, PRInt32 aIndex)
|
||||
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLOptionsCollection* aCollection, PRInt32 aIndex)
|
||||
{
|
||||
nsIContent * content = nsnull;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*aCollection, aIndex));
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(aCollection, aIndex));
|
||||
|
||||
NS_ASSERTION(optionElement != nsnull, "could not get option element by index!");
|
||||
|
||||
|
@ -1863,7 +1865,8 @@ nsListControlFrame::GetOptionContent(PRInt32 aIndex)
|
|||
|
||||
{
|
||||
nsIContent* content = nsnull;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ASSERTION(options.get() != nsnull, "Collection of options is null!");
|
||||
|
||||
if (options) {
|
||||
|
@ -1876,10 +1879,10 @@ nsListControlFrame::GetOptionContent(PRInt32 aIndex)
|
|||
// This returns the collection for nsIDOMHTMLSelectElement or
|
||||
// the nsIContent object is the select is null (AddRefs)
|
||||
//---------------------------------------------------------
|
||||
nsIDOMHTMLCollection*
|
||||
nsIDOMHTMLOptionsCollection*
|
||||
nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect)
|
||||
{
|
||||
nsIDOMHTMLCollection* options = nsnull;
|
||||
nsIDOMHTMLOptionsCollection* options = nsnull;
|
||||
if (!aSelect) {
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = getter_AddRefs(GetSelect(aContent));
|
||||
if (selectElement) {
|
||||
|
@ -1896,21 +1899,22 @@ nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* a
|
|||
// Returns the nsIDOMHTMLOptionElement for a given index
|
||||
// in the select's collection
|
||||
//---------------------------------------------------------
|
||||
nsIDOMHTMLOptionElement*
|
||||
nsListControlFrame::GetOption(nsIDOMHTMLCollection& aCollection, PRInt32 aIndex)
|
||||
nsIDOMHTMLOptionElement*
|
||||
nsListControlFrame::GetOption(nsIDOMHTMLOptionsCollection* aCollection,
|
||||
PRInt32 aIndex)
|
||||
{
|
||||
nsIDOMNode* node = nsnull;
|
||||
if (NS_SUCCEEDED(aCollection.Item(aIndex, &node))) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
if (NS_SUCCEEDED(aCollection->Item(aIndex, getter_AddRefs(node)))) {
|
||||
NS_ASSERTION(node,
|
||||
"Item was successful, but node from collection was null!");
|
||||
if (node) {
|
||||
nsIDOMHTMLOptionElement* option = nsnull;
|
||||
CallQueryInterface(node, &option);
|
||||
NS_RELEASE(node);
|
||||
|
||||
return option;
|
||||
}
|
||||
} else {
|
||||
NS_ASSERTION(0, "Couldn't get option by index from collection!");
|
||||
NS_ERROR("Couldn't get option by index from collection!");
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -2098,7 +2102,8 @@ nsListControlFrame::GetOptionText(PRInt32 aIndex, nsAString & aStr)
|
|||
{
|
||||
aStr.SetLength(0);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
|
||||
if (options) {
|
||||
PRUint32 numOptions;
|
||||
|
@ -2108,7 +2113,7 @@ nsListControlFrame::GetOptionText(PRInt32 aIndex, nsAString & aStr)
|
|||
rv = NS_OK;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(
|
||||
getter_AddRefs(GetOption(*options, aIndex)));
|
||||
getter_AddRefs(GetOption(options, aIndex)));
|
||||
if (optionElement) {
|
||||
#if 0 // This is for turning off labels Bug 4050
|
||||
nsAutoString text;
|
||||
|
@ -2168,7 +2173,9 @@ NS_IMETHODIMP
|
|||
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
|
||||
{
|
||||
if (mContent != nsnull) {
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
|
||||
if (nsnull == options) {
|
||||
*aNumOptions = 0;
|
||||
} else {
|
||||
|
@ -2297,13 +2304,14 @@ nsListControlFrame::SetOptionsSelectedFromFrame(PRInt32 aStartIndex,
|
|||
PRBool
|
||||
nsListControlFrame::ToggleOptionSelectedFromFrame(PRInt32 aIndex)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options(getter_AddRefs(GetOptions(mContent)));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ASSERTION(options, "No options");
|
||||
if (!options) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option(
|
||||
getter_AddRefs(GetOption(*options, aIndex)));
|
||||
getter_AddRefs(GetOption(options, aIndex)));
|
||||
NS_ASSERTION(option, "No option");
|
||||
if (!option) {
|
||||
return PR_FALSE;
|
||||
|
@ -3380,7 +3388,8 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
keyEvent->GetShiftKey(&isShift);
|
||||
|
||||
// now make sure there are options or we are wasting our time
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ENSURE_TRUE(options, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 numOptions = 0;
|
||||
|
@ -3555,7 +3564,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
PRUint32 i;
|
||||
for (i = 0; i < numOptions; i++) {
|
||||
PRUint32 index = (i + startIndex) % numOptions;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(getter_AddRefs(GetOption(*options, index)));
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(getter_AddRefs(GetOption(options, index)));
|
||||
if (optionElement) {
|
||||
nsAutoString text;
|
||||
if (NS_OK == optionElement->GetText(text)) {
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include "nsIContent.h"
|
||||
|
||||
class nsIDOMHTMLSelectElement;
|
||||
class nsIDOMHTMLCollection;
|
||||
class nsIDOMHTMLOptionsCollection;
|
||||
class nsIDOMHTMLOptionElement;
|
||||
class nsIComboboxControlFrame;
|
||||
class nsIViewManager;
|
||||
|
@ -310,9 +310,9 @@ public:
|
|||
|
||||
// Static Methods
|
||||
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
|
||||
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLCollection& aOptions, PRInt32 aIndex);
|
||||
static nsIContent* GetOptionAsContent(nsIDOMHTMLCollection* aCollection,PRInt32 aIndex);
|
||||
static nsIDOMHTMLOptionsCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLOptionsCollection* aOptions, PRInt32 aIndex);
|
||||
static nsIContent* GetOptionAsContent(nsIDOMHTMLOptionsCollection* aCollection,PRInt32 aIndex);
|
||||
|
||||
static void ComboboxFocusSet();
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "nsIHTMLContent.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsIDOMNSHTMLOptionCollectn.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMNSHTMLSelectElement.h"
|
||||
|
@ -892,13 +892,14 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Lists out all the options
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
if (options) {
|
||||
PRUint32 numOptions;
|
||||
options->GetLength(&numOptions);
|
||||
printf("--- Num of Items %d ---\n", numOptions);
|
||||
for (PRUint32 i=0;i<numOptions;i++) {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*options, i));
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(options, i));
|
||||
if (optionElement) {
|
||||
nsAutoString text;
|
||||
rv = optionElement->GetLabel(text);
|
||||
|
@ -1486,7 +1487,8 @@ nsListControlFrame::InitSelectionRange(PRInt32 aClickedIndex)
|
|||
GetSelectedIndex(&selectedIndex);
|
||||
if (selectedIndex >= 0) {
|
||||
// Get the end of the contiguous selection
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ASSERTION(options, "Collection of options is null!");
|
||||
PRUint32 numOptions;
|
||||
options->GetLength(&numOptions);
|
||||
|
@ -1494,7 +1496,7 @@ nsListControlFrame::InitSelectionRange(PRInt32 aClickedIndex)
|
|||
// Push i to one past the last selected index in the group
|
||||
for (i=selectedIndex+1; i < numOptions; i++) {
|
||||
PRBool selected;
|
||||
GetOption(*options, i)->GetSelected(&selected);
|
||||
GetOption(options, i)->GetSelected(&selected);
|
||||
if (!selected) {
|
||||
break;
|
||||
}
|
||||
|
@ -1840,10 +1842,10 @@ nsListControlFrame::GetSelect(nsIContent * aContent)
|
|||
// for a given index (AddRefs)
|
||||
//---------------------------------------------------------
|
||||
nsIContent*
|
||||
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLCollection* aCollection, PRInt32 aIndex)
|
||||
nsListControlFrame::GetOptionAsContent(nsIDOMHTMLOptionsCollection* aCollection, PRInt32 aIndex)
|
||||
{
|
||||
nsIContent * content = nsnull;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(*aCollection, aIndex));
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = getter_AddRefs(GetOption(aCollection, aIndex));
|
||||
|
||||
NS_ASSERTION(optionElement != nsnull, "could not get option element by index!");
|
||||
|
||||
|
@ -1863,7 +1865,8 @@ nsListControlFrame::GetOptionContent(PRInt32 aIndex)
|
|||
|
||||
{
|
||||
nsIContent* content = nsnull;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ASSERTION(options.get() != nsnull, "Collection of options is null!");
|
||||
|
||||
if (options) {
|
||||
|
@ -1876,10 +1879,10 @@ nsListControlFrame::GetOptionContent(PRInt32 aIndex)
|
|||
// This returns the collection for nsIDOMHTMLSelectElement or
|
||||
// the nsIContent object is the select is null (AddRefs)
|
||||
//---------------------------------------------------------
|
||||
nsIDOMHTMLCollection*
|
||||
nsIDOMHTMLOptionsCollection*
|
||||
nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect)
|
||||
{
|
||||
nsIDOMHTMLCollection* options = nsnull;
|
||||
nsIDOMHTMLOptionsCollection* options = nsnull;
|
||||
if (!aSelect) {
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = getter_AddRefs(GetSelect(aContent));
|
||||
if (selectElement) {
|
||||
|
@ -1896,21 +1899,22 @@ nsListControlFrame::GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* a
|
|||
// Returns the nsIDOMHTMLOptionElement for a given index
|
||||
// in the select's collection
|
||||
//---------------------------------------------------------
|
||||
nsIDOMHTMLOptionElement*
|
||||
nsListControlFrame::GetOption(nsIDOMHTMLCollection& aCollection, PRInt32 aIndex)
|
||||
nsIDOMHTMLOptionElement*
|
||||
nsListControlFrame::GetOption(nsIDOMHTMLOptionsCollection* aCollection,
|
||||
PRInt32 aIndex)
|
||||
{
|
||||
nsIDOMNode* node = nsnull;
|
||||
if (NS_SUCCEEDED(aCollection.Item(aIndex, &node))) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
if (NS_SUCCEEDED(aCollection->Item(aIndex, getter_AddRefs(node)))) {
|
||||
NS_ASSERTION(node,
|
||||
"Item was successful, but node from collection was null!");
|
||||
if (node) {
|
||||
nsIDOMHTMLOptionElement* option = nsnull;
|
||||
CallQueryInterface(node, &option);
|
||||
NS_RELEASE(node);
|
||||
|
||||
return option;
|
||||
}
|
||||
} else {
|
||||
NS_ASSERTION(0, "Couldn't get option by index from collection!");
|
||||
NS_ERROR("Couldn't get option by index from collection!");
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
@ -2098,7 +2102,8 @@ nsListControlFrame::GetOptionText(PRInt32 aIndex, nsAString & aStr)
|
|||
{
|
||||
aStr.SetLength(0);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
|
||||
if (options) {
|
||||
PRUint32 numOptions;
|
||||
|
@ -2108,7 +2113,7 @@ nsListControlFrame::GetOptionText(PRInt32 aIndex, nsAString & aStr)
|
|||
rv = NS_OK;
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(
|
||||
getter_AddRefs(GetOption(*options, aIndex)));
|
||||
getter_AddRefs(GetOption(options, aIndex)));
|
||||
if (optionElement) {
|
||||
#if 0 // This is for turning off labels Bug 4050
|
||||
nsAutoString text;
|
||||
|
@ -2168,7 +2173,9 @@ NS_IMETHODIMP
|
|||
nsListControlFrame::GetNumberOfOptions(PRInt32* aNumOptions)
|
||||
{
|
||||
if (mContent != nsnull) {
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
|
||||
if (nsnull == options) {
|
||||
*aNumOptions = 0;
|
||||
} else {
|
||||
|
@ -2297,13 +2304,14 @@ nsListControlFrame::SetOptionsSelectedFromFrame(PRInt32 aStartIndex,
|
|||
PRBool
|
||||
nsListControlFrame::ToggleOptionSelectedFromFrame(PRInt32 aIndex)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options(getter_AddRefs(GetOptions(mContent)));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ASSERTION(options, "No options");
|
||||
if (!options) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option(
|
||||
getter_AddRefs(GetOption(*options, aIndex)));
|
||||
getter_AddRefs(GetOption(options, aIndex)));
|
||||
NS_ASSERTION(option, "No option");
|
||||
if (!option) {
|
||||
return PR_FALSE;
|
||||
|
@ -3380,7 +3388,8 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
keyEvent->GetShiftKey(&isShift);
|
||||
|
||||
// now make sure there are options or we are wasting our time
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options = getter_AddRefs(GetOptions(mContent));
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options =
|
||||
getter_AddRefs(GetOptions(mContent));
|
||||
NS_ENSURE_TRUE(options, NS_ERROR_FAILURE);
|
||||
|
||||
PRUint32 numOptions = 0;
|
||||
|
@ -3555,7 +3564,7 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
PRUint32 i;
|
||||
for (i = 0; i < numOptions; i++) {
|
||||
PRUint32 index = (i + startIndex) % numOptions;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(getter_AddRefs(GetOption(*options, index)));
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement(getter_AddRefs(GetOption(options, index)));
|
||||
if (optionElement) {
|
||||
nsAutoString text;
|
||||
if (NS_OK == optionElement->GetText(text)) {
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include "nsIContent.h"
|
||||
|
||||
class nsIDOMHTMLSelectElement;
|
||||
class nsIDOMHTMLCollection;
|
||||
class nsIDOMHTMLOptionsCollection;
|
||||
class nsIDOMHTMLOptionElement;
|
||||
class nsIComboboxControlFrame;
|
||||
class nsIViewManager;
|
||||
|
@ -310,9 +310,9 @@ public:
|
|||
|
||||
// Static Methods
|
||||
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
|
||||
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLCollection& aOptions, PRInt32 aIndex);
|
||||
static nsIContent* GetOptionAsContent(nsIDOMHTMLCollection* aCollection,PRInt32 aIndex);
|
||||
static nsIDOMHTMLOptionsCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLOptionsCollection* aOptions, PRInt32 aIndex);
|
||||
static nsIContent* GetOptionAsContent(nsIDOMHTMLOptionsCollection* aCollection,PRInt32 aIndex);
|
||||
|
||||
static void ComboboxFocusSet();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче