Backed out changeset 5d65342d7287 to fix orange

This commit is contained in:
Peter Van der Beken 2008-10-31 11:07:26 -07:00
Родитель bdbf96f3cd
Коммит 1b45b6af24
19 изменённых файлов: 393 добавлений и 487 удалений

Просмотреть файл

@ -351,7 +351,6 @@ nsContentList::~nsContentList()
// QueryInterface implementation for nsContentList
NS_INTERFACE_MAP_BEGIN(nsContentList)
NS_INTERFACE_MAP_ENTRY(nsIHTMLCollection)
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLCollection)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ContentList)
@ -502,20 +501,6 @@ nsContentList::GetNodeAt(PRUint32 aIndex)
return Item(aIndex, PR_TRUE);
}
nsISupports*
nsContentList::GetNodeAt(PRUint32 aIndex, nsresult* aResult)
{
*aResult = NS_OK;
return Item(aIndex, PR_TRUE);
}
nsISupports*
nsContentList::GetNamedItem(const nsAString& aName, nsresult* aResult)
{
*aResult = NS_OK;
return NamedItem(aName, PR_TRUE);
}
void
nsContentList::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
PRInt32 aNameSpaceID, nsIAtom* aAttribute,

Просмотреть файл

@ -47,7 +47,7 @@
#include "nsISupports.h"
#include "nsCOMArray.h"
#include "nsString.h"
#include "nsIHTMLCollection.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMNodeList.h"
#include "nsINodeList.h"
#include "nsStubMutationObserver.h"
@ -181,7 +181,7 @@ protected:
*/
class nsContentList : public nsBaseContentList,
protected nsContentListKey,
public nsIHTMLCollection,
public nsIDOMHTMLCollection,
public nsStubMutationObserver
{
public:
@ -241,10 +241,7 @@ public:
// nsBaseContentList overrides
virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
virtual nsINode* GetNodeAt(PRUint32 aIndex);
// nsIHTMLCollection
virtual nsISupports* GetNodeAt(PRUint32 aIndex, nsresult* aResult);
virtual nsISupports* GetNamedItem(const nsAString& aName, nsresult* aResult);
// nsContentList public methods
NS_HIDDEN_(nsISupports*) GetParentObject();

Просмотреть файл

@ -216,35 +216,21 @@ nsDOMAttributeMap::GetAttribute(nsINodeInfo* aNodeInfo)
return node;
}
nsIDOMNode*
nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName, nsresult *aResult)
{
*aResult = NS_OK;
if (mContent) {
nsCOMPtr<nsINodeInfo> ni =
mContent->GetExistingAttrNameFromQName(aAttrName);
if (ni) {
nsIDOMNode* node = GetAttribute(ni);
if (node) {
return node;
}
*aResult = NS_ERROR_OUT_OF_MEMORY;
}
}
return nsnull;
}
NS_IMETHODIMP
nsDOMAttributeMap::GetNamedItem(const nsAString& aAttrName,
nsIDOMNode** aAttribute)
{
NS_ENSURE_ARG_POINTER(aAttribute);
*aAttribute = nsnull;
nsresult rv;
NS_IF_ADDREF(*aAttribute = GetNamedItem(aAttrName, &rv));
nsresult rv = NS_OK;
if (mContent) {
nsCOMPtr<nsINodeInfo> ni =
mContent->GetExistingAttrNameFromQName(aAttrName);
if (ni) {
rv = GetAttribute(ni, aAttribute);
}
}
return rv;
}

Просмотреть файл

@ -171,7 +171,6 @@ public:
PRUint32 Enumerate(AttrCache::EnumReadFunction aFunc, void *aUserArg) const;
nsIDOMNode* GetItemAt(PRUint32 aIndex, nsresult *rv);
nsIDOMNode* GetNamedItem(const nsAString& aAttrName, nsresult *rv);
static nsDOMAttributeMap* FromSupports(nsISupports* aSupports)
{

Просмотреть файл

@ -42,8 +42,8 @@
// IID for the nsIHTMLCollection interface
#define NS_IHTMLCOLLECTION_IID \
{ 0x5709485b, 0xc057, 0x4ba7, \
{ 0x95, 0xbd, 0x98, 0xb7, 0x94, 0x4f, 0x13, 0xe7 } }
{ 0xb90f2c8c, 0xc564, 0x4464, \
{ 0x97, 0x01, 0x05, 0x14, 0xe4, 0xeb, 0x69, 0x65 } }
/**
* An internal interface that allows QI-less getting of nodes from HTML
@ -55,15 +55,9 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLCOLLECTION_IID)
/**
* Get the node at the index. Returns null if the index is out of bounds.
* Get the node at the index. Returns null if the index is out of bounds
*/
virtual nsISupports* GetNodeAt(PRUint32 aIndex, nsresult* aResult) = 0;
/**
* Get the node for the name. Returns null if no node exists for the name.
*/
virtual nsISupports* GetNamedItem(const nsAString& aName,
nsresult* aResult) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)

Просмотреть файл

@ -375,12 +375,6 @@ public:
return mElements.SafeElementAt(aIndex, nsnull);
}
virtual nsISupports* GetNamedItem(const nsAString& aName, nsresult* aResult)
{
*aResult = NS_OK;
return NamedItemInternal(aName, PR_TRUE);
}
nsresult AddElementToTable(nsIFormControl* aChild,
const nsAString& aName);
@ -389,7 +383,8 @@ public:
nsresult IndexOfControl(nsIFormControl* aControl,
PRInt32* aIndex);
nsISupports* NamedItemInternal(const nsAString& aName, PRBool aFlushContent);
void NamedItemInternal(const nsAString& aName, PRBool aFlushContent,
nsISupports **aResult);
/**
* Create a sorted list of form control elements. This list is sorted
@ -1552,8 +1547,8 @@ already_AddRefed<nsISupports>
nsHTMLFormElement::DoResolveName(const nsAString& aName,
PRBool aFlushContent)
{
nsISupports *result;
NS_IF_ADDREF(result = mControls->NamedItemInternal(aName, aFlushContent));
nsISupports *result = nsnull;
mControls->NamedItemInternal(aName, aFlushContent, &result);
return result;
}
@ -2202,19 +2197,20 @@ NS_IMETHODIMP
nsFormControlList::NamedItem(const nsAString& aName,
nsISupports** aReturn)
{
NS_IF_ADDREF(*aReturn = NamedItemInternal(aName, PR_TRUE));
NamedItemInternal(aName, PR_TRUE, aReturn);
return NS_OK;
}
nsISupports*
void
nsFormControlList::NamedItemInternal(const nsAString& aName,
PRBool aFlushContent)
PRBool aFlushContent,
nsISupports** aReturn)
{
if (aFlushContent) {
FlushPendingNotifications();
}
return mNameLookupTable.GetWeak(aName);
mNameLookupTable.Get(aName, aReturn);
}
nsresult

Просмотреть файл

@ -1959,39 +1959,31 @@ nsHTMLOptionCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
return CallQueryInterface(item, aReturn);
}
nsISupports*
nsHTMLOptionCollection::GetNamedItem(const nsAString& aName, nsresult* aResult)
{
*aResult = NS_OK;
PRInt32 count = mElements.Count();
for (PRInt32 i = 0; i < count; i++) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mElements.ObjectAt(i));
if (content &&
(content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
eCaseMatters) ||
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
eCaseMatters))) {
return content;
}
}
return nsnull;
}
NS_IMETHODIMP
nsHTMLOptionCollection::NamedItem(const nsAString& aName,
nsIDOMNode** aReturn)
{
nsresult rv;
nsISupports* item = GetNamedItem(aName, &rv);
if (!item) {
*aReturn = nsnull;
PRInt32 count = mElements.Count();
nsresult rv = NS_OK;
return rv;
*aReturn = nsnull;
for (PRInt32 i = 0; i < count; i++) {
nsCOMPtr<nsIContent> content = do_QueryInterface(mElements.ObjectAt(i));
if (content) {
if (content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, aName,
eCaseMatters) ||
content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, aName,
eCaseMatters)) {
rv = CallQueryInterface(content, aReturn);
break;
}
}
}
return CallQueryInterface(item, aReturn);
return rv;
}
NS_IMETHODIMP

Просмотреть файл

@ -94,7 +94,6 @@ public:
return mElements.SafeObjectAt(aIndex);
}
virtual nsISupports* GetNamedItem(const nsAString& aName, nsresult* aResult);
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTMLOptionCollection,
nsIHTMLCollection)

Просмотреть файл

@ -118,7 +118,6 @@ public:
NS_DECL_NSIDOMHTMLCOLLECTION
virtual nsISupports* GetNodeAt(PRUint32 aIndex, nsresult* aResult);
virtual nsISupports* GetNamedItem(const nsAString& aName, nsresult* aResult);
NS_IMETHOD ParentDestroyed();
@ -325,42 +324,32 @@ TableRowsCollection::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
return CallQueryInterface(node, aReturn);
}
static nsISupports*
static nsresult
GetNamedItemInRowGroup(nsIDOMHTMLCollection* aRows,
const nsAString& aName, nsresult* aResult)
const nsAString& aName, nsIDOMNode** aNamedItem)
{
nsCOMPtr<nsIHTMLCollection> rows = do_QueryInterface(aRows);
if (rows) {
return rows->GetNamedItem(aName, aResult);
if (aRows) {
return aRows->NamedItem(aName, aNamedItem);
}
*aResult = NS_OK;
return nsnull;
}
nsISupports*
TableRowsCollection::GetNamedItem(const nsAString& aName, nsresult* aResult)
{
nsresult rv = NS_OK;
DO_FOR_EACH_ROWGROUP(
nsISupports* item = GetNamedItemInRowGroup(rows, aName, aResult);
if (NS_FAILED(*aResult) || item) {
return item;
}
);
*aResult = rv;
return nsnull;
*aNamedItem = nsnull;
return NS_OK;
}
NS_IMETHODIMP
TableRowsCollection::NamedItem(const nsAString& aName,
nsIDOMNode** aReturn)
{
nsresult rv;
nsISupports* item = GetNamedItem(aName, &rv);
NS_ENSURE_SUCCESS(rv, rv);
return CallQueryInterface(item, aReturn);
*aReturn = nsnull;
nsresult rv = NS_OK;
DO_FOR_EACH_ROWGROUP(
rv = GetNamedItemInRowGroup(rows, aName, aReturn);
NS_ENSURE_SUCCESS(rv, rv);
if (*aReturn) {
return rv;
}
);
return rv;
}
NS_IMETHODIMP

Просмотреть файл

@ -443,7 +443,12 @@
#include "nsIImageDocument.h"
// Storage includes
#include "nsDOMStorage.h"
#include "nsIDOMStorage.h"
#include "nsPIDOMStorage.h"
#include "nsIDOMStorageList.h"
#include "nsIDOMStorageItem.h"
#include "nsIDOMStorageEvent.h"
#include "nsIDOMToString.h"
// Drag and drop
#include "nsIDOMDataTransfer.h"
@ -669,7 +674,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
ARRAY_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_SETPROPERTY)
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(HTMLFormControlCollection, HTMLCollection,
nsHTMLCollectionSH,
nsFormControlListSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(HTMLGenericCollection, HTMLCollection,
nsHTMLCollectionSH,
@ -7710,9 +7715,9 @@ nsNamedArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
PRBool *_retval)
{
if (JSVAL_IS_STRING(id) && !ObjectIsNativeWrapper(cx, obj)) {
nsresult rv = NS_OK;
nsISupports* item = GetNamedItem(wrapper->Native(), nsDependentJSString(id),
&rv);
nsCOMPtr<nsISupports> item;
nsresult rv = GetNamedItem(wrapper->Native(), nsDependentJSString(id),
getter_AddRefs(item));
NS_ENSURE_SUCCESS(rv, rv);
if (item) {
@ -7743,39 +7748,24 @@ nsNamedNodeMapSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return map->GetItemAt(aIndex, aResult);
}
nsISupports*
nsresult
nsNamedNodeMapSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsDOMAttributeMap* map = nsDOMAttributeMap::FromSupports(aNative);
nsCOMPtr<nsIDOMNamedNodeMap> map(do_QueryInterface(aNative));
NS_ENSURE_TRUE(map, NS_ERROR_UNEXPECTED);
return map->GetNamedItem(aName, aResult);
nsIDOMNode *node = nsnull; // Weak, transfer the ownership over to aResult
nsresult rv = map->GetNamedItem(aName, &node);
*aResult = node;
return rv;
}
// HTMLCollection helper
nsresult
nsHTMLCollectionSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 *length)
{
nsIHTMLCollection* collection =
static_cast<nsIHTMLCollection*>(wrapper->Native());
#ifdef DEBUG
{
nsCOMPtr<nsIHTMLCollection> collection_qi =
do_QueryInterface(wrapper->Native());
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIHTMLCollection pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
}
#endif
return collection->GetLength(length);
}
nsISupports*
nsHTMLCollectionSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsresult *aResult)
@ -7795,24 +7785,20 @@ nsHTMLCollectionSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return collection->GetNodeAt(aIndex, aResult);
}
nsISupports*
nsresult
nsHTMLCollectionSH::GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsIHTMLCollection* collection = static_cast<nsIHTMLCollection*>(aNative);
#ifdef DEBUG
{
nsCOMPtr<nsIHTMLCollection> collection_qi = do_QueryInterface(aNative);
nsCOMPtr<nsIDOMHTMLCollection> collection(do_QueryInterface(aNative));
NS_ENSURE_TRUE(collection, NS_ERROR_UNEXPECTED);
// If this assertion fires the QI implementation for the object in
// question doesn't use the nsIHTMLCollection pointer as the nsISupports
// pointer. That must be fixed, or we'll crash...
NS_ASSERTION(collection_qi == collection, "Uh, fix QI!");
}
#endif
nsIDOMNode *node = nsnull; // Weak, transfer the ownership over to aResult
nsresult rv = collection->NamedItem(aName, &node);
return collection->GetNamedItem(aName, aResult);
*aResult = node;
return rv;
}
@ -7840,34 +7826,42 @@ nsContentListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
return rv;
}
NS_IMETHODIMP
nsContentListSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsval id, jsval *vp,
PRBool *_retval)
{
if (JSVAL_IS_STRING(id) && !ObjectIsNativeWrapper(cx, obj)) {
nsContentList *list = nsContentList::FromSupports(wrapper->Native());
nsINode* node = list->NamedItem(nsDependentJSString(id), PR_TRUE);
if (!node) {
return NS_OK;
}
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
nsresult rv = WrapNative(cx, obj, node, NS_GET_IID(nsISupports), vp,
getter_AddRefs(holder));
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
}
return nsNodeListSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
}
// FormControlList helper
nsresult
nsContentListSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 *length)
nsFormControlListSH::GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsISupports **aResult)
{
nsContentList *list = nsContentList::FromSupports(wrapper->Native());
nsCOMPtr<nsIDOMNSHTMLFormControlList> list(do_QueryInterface(aNative));
NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
return list->GetLength(length);
return list->NamedItem(aName, aResult);
}
nsISupports*
nsContentListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsresult *aResult)
{
nsContentList *list = nsContentList::FromSupports(aNative);
return list->GetNodeAt(aIndex, aResult);
}
nsISupports*
nsContentListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
{
nsContentList *list = nsContentList::FromSupports(aNative);
return list->GetNamedItem(aName, aResult);
}
// Document helper for document.location and document.on*
NS_IMETHODIMP
@ -9901,13 +9895,20 @@ nsPluginSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return plugin->GetItemAt(aIndex, aResult);
}
nsISupports*
nsresult
nsPluginSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsPluginElement* plugin = nsPluginElement::FromSupports(aNative);
nsCOMPtr<nsIDOMPlugin> plugin(do_QueryInterface(aNative));
NS_ENSURE_TRUE(plugin, NS_ERROR_UNEXPECTED);
return plugin->GetNamedItem(aName, aResult);
nsIDOMMimeType *mime_type = nsnull;
nsresult rv = plugin->NamedItem(aName, &mime_type);
*aResult = mime_type;
return rv;
}
@ -9922,13 +9923,20 @@ nsPluginArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return array->GetItemAt(aIndex, aResult);
}
nsISupports*
nsresult
nsPluginArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsPluginArray* array = nsPluginArray::FromSupports(aNative);
nsCOMPtr<nsIDOMPluginArray> array(do_QueryInterface(aNative));
NS_ENSURE_TRUE(array, NS_ERROR_UNEXPECTED);
return array->GetNamedItem(aName, aResult);
nsIDOMPlugin *plugin = nsnull;
nsresult rv = array->NamedItem(aName, &plugin);
*aResult = plugin;
return rv;
}
@ -9943,13 +9951,20 @@ nsMimeTypeArraySH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return array->GetItemAt(aIndex, aResult);
}
nsISupports*
nsresult
nsMimeTypeArraySH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsMimeTypeArray* array = nsMimeTypeArray::FromSupports(aNative);
nsCOMPtr<nsIDOMMimeTypeArray> array(do_QueryInterface(aNative));
NS_ENSURE_TRUE(array, NS_ERROR_UNEXPECTED);
return array->GetNamedItem(aName, aResult);
nsIDOMMimeType *mime_type = nsnull;
nsresult rv = array->NamedItem(aName, &mime_type);
*aResult = mime_type;
return rv;
}
@ -10130,14 +10145,20 @@ nsTreeColumnsSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return columns->GetColumnAt(aIndex);
}
nsISupports*
nsresult
nsTreeColumnsSH::GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsTreeColumns* columns = nsTreeColumns::FromSupports(aNative);
nsCOMPtr<nsITreeColumns> columns(do_QueryInterface(aNative));
NS_ENSURE_TRUE(columns, NS_ERROR_UNEXPECTED);
return columns->GetNamedColumn(aName);
nsITreeColumn* column = nsnull; // Weak, transfer the ownership over to aResult
nsresult rv = columns->GetNamedColumn(aName, &column);
*aResult = column;
return rv;
}
#endif
@ -10203,13 +10224,20 @@ nsStorageSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
nsISupports*
nsresult
nsStorageSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsDOMStorage* storage = nsDOMStorage::FromSupports(aNative);
nsCOMPtr<nsIDOMStorage> storage(do_QueryInterface(aNative));
NS_ENSURE_TRUE(storage, NS_ERROR_UNEXPECTED);
return storage->GetNamedItem(aName, aResult);
// Weak, transfer the ownership over to aResult
nsIDOMStorageItem* item = nsnull;
nsresult rv = storage->GetItem(aName, &item);
*aResult = item;
return rv;
}
NS_IMETHODIMP
@ -10314,13 +10342,20 @@ nsStorageSH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// StorageList scriptable helper
nsISupports*
nsresult
nsStorageListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsresult *aResult)
nsISupports **aResult)
{
nsDOMStorageList* storagelist = static_cast<nsDOMStorageList*>(aNative);
nsCOMPtr<nsIDOMStorageList> storagelist(do_QueryInterface(aNative));
NS_ENSURE_TRUE(storagelist, NS_ERROR_UNEXPECTED);
return storagelist->GetNamedItem(aName, aResult);
// Weak, transfer the ownership over to aResult
nsIDOMStorage* storage = nsnull;
nsresult rv = storagelist->NamedItem(aName, &storage);
*aResult = storage;
return rv;
}

Просмотреть файл

@ -693,9 +693,8 @@ protected:
{
}
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult) = 0;
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult) = 0;
public:
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
@ -724,9 +723,8 @@ protected:
nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -749,15 +747,12 @@ protected:
{
}
virtual nsresult GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 *length);
virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -769,24 +764,18 @@ public:
// ContentList helper
class nsContentListSH : public nsNamedArraySH
class nsContentListSH : public nsNodeListSH
{
protected:
nsContentListSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
nsContentListSH(nsDOMClassInfoData* aData) : nsNodeListSH(aData)
{
}
public:
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
JSObject *globalObj, JSObject **parentObj);
virtual nsresult GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 *length);
virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsresult *aResult);
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
@ -796,6 +785,32 @@ public:
// FomrControlList helper
class nsFormControlListSH : public nsHTMLCollectionSH
{
protected:
nsFormControlListSH(nsDOMClassInfoData* aData) : nsHTMLCollectionSH(aData)
{
}
virtual ~nsFormControlListSH()
{
}
// Override nsNamedArraySH::GetNamedItem() since our NamedItem() can
// return either a nsIDOMNode or a nsIHTMLCollection
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsFormControlListSH(aData);
}
};
// Document helper, for document.location and document.on*
class nsDocumentSH : public nsNodeSH
@ -1080,9 +1095,8 @@ protected:
nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -1109,9 +1123,8 @@ protected:
nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -1138,9 +1151,8 @@ protected:
nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -1385,9 +1397,8 @@ protected:
nsresult *aResult);
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -1427,9 +1438,8 @@ protected:
return nsnull;
}
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
@ -1455,9 +1465,8 @@ protected:
return nsnull;
}
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsresult *aResult);
virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsISupports **aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)

Просмотреть файл

@ -49,10 +49,10 @@
nsMimeTypeArray::nsMimeTypeArray(nsIDOMNavigator* navigator)
: mNavigator(navigator),
mPluginMimeTypeCount(0),
mInited(PR_FALSE)
{
mNavigator = navigator;
mMimeTypeCount = 0;
mMimeTypeArray = nsnull;
}
nsMimeTypeArray::~nsMimeTypeArray()
@ -76,34 +76,25 @@ NS_IMPL_RELEASE(nsMimeTypeArray)
NS_IMETHODIMP
nsMimeTypeArray::GetLength(PRUint32* aLength)
{
if (!mInited) {
if (mMimeTypeArray == nsnull) {
nsresult rv = GetMimeTypes();
if (rv != NS_OK)
return rv;
}
NS_ASSERTION(mPluginMimeTypeCount <= mMimeTypeArray.Count(),
"The number of total mimetypes should be equal to or higher "
"than the number of plugin mimetypes.");
*aLength = mPluginMimeTypeCount;
*aLength = mMimeTypeCount;
return NS_OK;
}
nsIDOMMimeType*
nsMimeTypeArray::GetItemAt(PRUint32 aIndex, nsresult *aResult)
{
if (!mInited) {
if (mMimeTypeArray == nsnull) {
*aResult = GetMimeTypes();
if (*aResult != NS_OK)
return nsnull;
}
NS_ASSERTION(mPluginMimeTypeCount <= mMimeTypeArray.Count(),
"The number of total mimetypes should be equal to or higher "
"than the number of plugin mimetypes.");
if (aIndex >= mPluginMimeTypeCount) {
if (aIndex >= mMimeTypeCount) {
*aResult = NS_ERROR_FAILURE;
return nsnull;
@ -124,30 +115,31 @@ nsMimeTypeArray::Item(PRUint32 aIndex, nsIDOMMimeType** aReturn)
return rv;
}
nsIDOMMimeType*
nsMimeTypeArray::GetNamedItem(const nsAString& aName, nsresult* aResult)
NS_IMETHODIMP
nsMimeTypeArray::NamedItem(const nsAString& aName, nsIDOMMimeType** aReturn)
{
if (!mInited) {
*aResult = GetMimeTypes();
if (*aResult != NS_OK)
return nsnull;
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
if (mMimeTypeArray == nsnull) {
nsresult rv = GetMimeTypes();
if (rv != NS_OK)
return rv;
}
NS_ASSERTION(mPluginMimeTypeCount <= mMimeTypeArray.Count(),
"The number of total mimetypes should be equal to or higher "
"than the number of plugin mimetypes.");
*aResult = NS_OK;
nsAutoString type;
for (PRInt32 i = 0; i < mMimeTypeArray.Count(); i++) {
for (PRUint32 i = 0; i < mMimeTypeCount; i++) {
nsIDOMMimeType *mtype = mMimeTypeArray[i];
mtype->GetType(type);
if (type.Equals(aName)) {
return mtype;
*aReturn = mtype;
NS_ADDREF(*aReturn);
return NS_OK;
}
}
@ -174,43 +166,39 @@ nsMimeTypeArray::GetNamedItem(const nsAString& aName, nsresult* aResult)
mimeInfo->GetDefaultDescription(defaultDescription);
if (defaultDescription.IsEmpty()) {
// no support; just leave
return nsnull;
return NS_OK;
}
}
}
}
// If we got here, we support this type! Say so.
nsCOMPtr<nsIDOMMimeType> helper, entry;
if (!(helper = new nsHelperMimeType(aName)) ||
!(entry = new nsMimeType(nsnull, helper)) ||
!mMimeTypeArray.AppendObject(entry)) {
*aResult = NS_ERROR_OUT_OF_MEMORY;
return nsnull;
nsCOMPtr<nsIDOMMimeType> helper = new nsHelperMimeType(aName);
if (!helper) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsCOMPtr<nsIDOMMimeType> entry = new nsMimeType(nsnull, helper);
if (!entry) {
return NS_ERROR_OUT_OF_MEMORY;
}
return entry;
entry.swap(*aReturn);
}
}
return nsnull;
}
NS_IMETHODIMP
nsMimeTypeArray::NamedItem(const nsAString& aName, nsIDOMMimeType** aReturn)
{
nsresult rv;
NS_IF_ADDREF(*aReturn = GetNamedItem(aName, &rv));
return rv;
return NS_OK;
}
void nsMimeTypeArray::Clear()
{
mMimeTypeArray.Clear();
mPluginMimeTypeCount = 0;
if (mMimeTypeArray != nsnull) {
for (PRUint32 i = 0; i < mMimeTypeCount; i++) {
NS_IF_RELEASE(mMimeTypeArray[i]);
}
delete[] mMimeTypeArray;
mMimeTypeArray = nsnull;
}
mMimeTypeCount = 0;
}
nsresult nsMimeTypeArray::Refresh()
@ -221,7 +209,7 @@ nsresult nsMimeTypeArray::Refresh()
nsresult nsMimeTypeArray::GetMimeTypes()
{
NS_PRECONDITION(!mInited && mPluginMimeTypeCount==0,
NS_PRECONDITION(!mMimeTypeArray && mMimeTypeCount==0,
"already initialized");
nsIDOMPluginArray* pluginArray = nsnull;
@ -229,7 +217,7 @@ nsresult nsMimeTypeArray::GetMimeTypes()
if (rv == NS_OK) {
// count up all possible MimeTypes, and collect them here. Later,
// we'll remove duplicates.
mPluginMimeTypeCount = 0;
mMimeTypeCount = 0;
PRUint32 pluginCount = 0;
rv = pluginArray->GetLength(&pluginCount);
if (rv == NS_OK) {
@ -240,23 +228,22 @@ nsresult nsMimeTypeArray::GetMimeTypes()
plugin) {
PRUint32 mimeTypeCount = 0;
if (plugin->GetLength(&mimeTypeCount) == NS_OK)
mPluginMimeTypeCount += mimeTypeCount;
mMimeTypeCount += mimeTypeCount;
}
}
// now we know how many there are, start gathering them.
if (!mMimeTypeArray.SetCapacity(mPluginMimeTypeCount))
mMimeTypeArray = new nsIDOMMimeType*[mMimeTypeCount];
if (mMimeTypeArray == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
PRUint32 mimeTypeIndex = 0;
PRUint32 k;
for (k = 0; k < pluginCount; k++) {
nsIDOMPlugin* plugin = nsnull;
if (pluginArray->Item(k, &plugin) == NS_OK) {
PRUint32 mimeTypeCount = 0;
if (plugin->GetLength(&mimeTypeCount) == NS_OK) {
nsCOMPtr<nsIDOMMimeType> item;
for (PRUint32 j = 0; j < mimeTypeCount; j++) {
plugin->Item(j, getter_AddRefs(item));
mMimeTypeArray.AppendObject(item);
}
for (PRUint32 j = 0; j < mimeTypeCount; j++)
plugin->Item(j, &mMimeTypeArray[mimeTypeIndex++]);
}
NS_RELEASE(plugin);
}

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsIDOMMimeType.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
class nsIDOMNavigator;
@ -58,7 +57,6 @@ public:
nsresult Refresh();
nsIDOMMimeType* GetItemAt(PRUint32 aIndex, nsresult* aResult);
nsIDOMMimeType* GetNamedItem(const nsAString& aName, nsresult* aResult);
static nsMimeTypeArray* FromSupports(nsISupports* aSupports)
{
@ -83,14 +81,8 @@ private:
protected:
nsIDOMNavigator* mNavigator;
// Number of mimetypes handled by plugins.
PRUint32 mPluginMimeTypeCount;
// mMimeTypeArray contains all mimetypes handled by plugins
// (mPluginMimeTypeCount) and any mimetypes that we handle internally and
// have been looked up before. The number of items in mMimeTypeArray should
// thus always be equal to or higher than mPluginMimeTypeCount.
nsCOMArray<nsIDOMMimeType> mMimeTypeArray;
PRBool mInited;
PRUint32 mMimeTypeCount;
nsIDOMMimeType** mMimeTypeArray;
};
class nsMimeType : public nsIDOMMimeType

Просмотреть файл

@ -132,41 +132,34 @@ nsPluginArray::Item(PRUint32 aIndex, nsIDOMPlugin** aReturn)
return rv;
}
nsIDOMPlugin*
nsPluginArray::GetNamedItem(const nsAString& aName, nsresult* aResult)
NS_IMETHODIMP
nsPluginArray::NamedItem(const nsAString& aName, nsIDOMPlugin** aReturn)
{
*aResult = NS_OK;
NS_PRECONDITION(nsnull != aReturn, "null arg");
*aReturn = nsnull;
if (!AllowPlugins())
return nsnull;
return NS_OK;
if (mPluginArray == nsnull) {
*aResult = GetPlugins();
if (*aResult != NS_OK)
return nsnull;
nsresult rv = GetPlugins();
if (rv != NS_OK)
return rv;
}
for (PRUint32 i = 0; i < mPluginCount; i++) {
nsAutoString pluginName;
nsIDOMPlugin* plugin = mPluginArray[i];
if (plugin->GetName(pluginName) == NS_OK && pluginName.Equals(aName)) {
return plugin;
if (plugin->GetName(pluginName) == NS_OK) {
if (pluginName.Equals(aName)) {
*aReturn = plugin;
NS_IF_ADDREF(plugin);
break;
}
}
}
return nsnull;
}
NS_IMETHODIMP
nsPluginArray::NamedItem(const nsAString& aName, nsIDOMPlugin** aReturn)
{
NS_PRECONDITION(nsnull != aReturn, "null arg");
nsresult rv;
NS_IF_ADDREF(*aReturn = GetNamedItem(aName, &rv));
return rv;
return NS_OK;
}
nsresult
@ -371,35 +364,29 @@ nsPluginElement::Item(PRUint32 aIndex, nsIDOMMimeType** aReturn)
return rv;
}
nsIDOMMimeType*
nsPluginElement::GetNamedItem(const nsAString& aName, nsresult *aResult)
{
if (mMimeTypeArray == nsnull) {
*aResult = GetMimeTypes();
if (*aResult != NS_OK)
return nsnull;
}
*aResult = NS_OK;
for (PRUint32 i = 0; i < mMimeTypeCount; i++) {
nsAutoString type;
nsIDOMMimeType* mimeType = mMimeTypeArray[i];
if (mimeType->GetType(type) == NS_OK && type.Equals(aName)) {
return mimeType;
}
}
return nsnull;
}
NS_IMETHODIMP
nsPluginElement::NamedItem(const nsAString& aName, nsIDOMMimeType** aReturn)
{
nsresult rv;
if (mMimeTypeArray == nsnull) {
nsresult rv = GetMimeTypes();
if (rv != NS_OK)
return rv;
}
NS_IF_ADDREF(*aReturn = GetNamedItem(aName, &rv));
*aReturn = nsnull;
for (PRUint32 i = 0; i < mMimeTypeCount; i++) {
nsAutoString type;
nsIDOMMimeType* mimeType = mMimeTypeArray[i];
if (mimeType->GetType(type) == NS_OK) {
if (type.Equals(aName)) {
*aReturn = mimeType;
NS_ADDREF(mimeType);
break;
}
}
}
return rv;
return NS_OK;
}
nsresult

Просмотреть файл

@ -61,7 +61,6 @@ public:
nsresult GetPluginHost(nsIPluginHost** aPluginHost);
nsIDOMPlugin* GetItemAt(PRUint32 aIndex, nsresult* aResult);
nsIDOMPlugin* GetNamedItem(const nsAString& aName, nsresult* aResult);
static nsPluginArray* FromSupports(nsISupports* aSupports)
{
@ -105,7 +104,6 @@ public:
NS_DECL_NSIDOMPLUGIN
nsIDOMMimeType* GetItemAt(PRUint32 aIndex, nsresult* aResult);
nsIDOMMimeType* GetNamedItem(const nsAString& aName, nsresult* aResult);
static nsPluginElement* FromSupports(nsISupports* aSupports)
{

Просмотреть файл

@ -606,24 +606,24 @@ nsDOMStorage::Key(PRUint32 aIndex, nsAString& aKey)
return NS_OK;
}
nsIDOMStorageItem*
nsDOMStorage::GetNamedItem(const nsAString& aKey, nsresult* aResult)
NS_IMETHODIMP
nsDOMStorage::GetItem(const nsAString& aKey, nsIDOMStorageItem **aItem)
{
if (!CacheStoragePermissions()) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
*aItem = nsnull;
if (!CacheStoragePermissions())
return NS_ERROR_DOM_SECURITY_ERR;
*aResult = NS_OK;
if (aKey.IsEmpty())
return nsnull;
return NS_OK;
nsSessionStorageEntry *entry = mItems.GetEntry(aKey);
nsIDOMStorageItem* item = nsnull;
if (entry) {
if (IsCallerSecure() || !entry->mItem->IsSecure()) {
item = entry->mItem;
if (!IsCallerSecure() && entry->mItem->IsSecure()) {
return NS_OK;
}
NS_ADDREF(*aItem = entry->mItem);
}
else if (UseDB()) {
PRBool secure;
@ -632,33 +632,22 @@ nsDOMStorage::GetNamedItem(const nsAString& aKey, nsresult* aResult)
nsresult rv = GetDBValue(aKey, value, &secure, unused);
// return null if access isn't allowed or the key wasn't found
if (rv == NS_ERROR_DOM_SECURITY_ERR || rv == NS_ERROR_DOM_NOT_FOUND_ERR)
return nsnull;
*aResult = rv;
NS_ENSURE_SUCCESS(rv, nsnull);
return NS_OK;
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsDOMStorageItem> newitem =
new nsDOMStorageItem(this, aKey, value, secure);
if (newitem && (entry = mItems.PutEntry(aKey))) {
item = entry->mItem = newitem;
}
else {
*aResult = NS_ERROR_OUT_OF_MEMORY;
}
if (!newitem)
return NS_ERROR_OUT_OF_MEMORY;
entry = mItems.PutEntry(aKey);
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
entry->mItem = newitem;
NS_ADDREF(*aItem = newitem);
}
return item;
}
NS_IMETHODIMP
nsDOMStorage::GetItem(const nsAString& aKey, nsIDOMStorageItem **aItem)
{
nsresult rv;
NS_ADDREF(*aItem = GetNamedItem(aKey, &rv));
return rv;
return NS_OK;
}
NS_IMETHODIMP
@ -1052,17 +1041,21 @@ NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsDOMStorageList)
NS_IMPL_RELEASE(nsDOMStorageList)
nsIDOMStorage*
nsDOMStorageList::GetNamedItem(const nsAString& aDomain, nsresult* aResult)
nsresult
nsDOMStorageList::NamedItem(const nsAString& aDomain,
nsIDOMStorage** aStorage)
{
*aStorage = nsnull;
nsCAutoString requestedDomain;
nsresult rv;
// Normalize the requested domain
nsCOMPtr<nsIIDNService> idn = do_GetService(NS_IDNSERVICE_CONTRACTID);
if (idn) {
*aResult = idn->ConvertUTF8toACE(NS_ConvertUTF16toUTF8(aDomain),
requestedDomain);
NS_ENSURE_SUCCESS(*aResult, nsnull);
rv = idn->ConvertUTF8toACE(NS_ConvertUTF16toUTF8(aDomain),
requestedDomain);
NS_ENSURE_SUCCESS(rv, rv);
} else {
// Don't have the IDN service, best we can do is URL escape.
NS_EscapeURL(NS_ConvertUTF16toUTF8(aDomain),
@ -1072,51 +1065,42 @@ nsDOMStorageList::GetNamedItem(const nsAString& aDomain, nsresult* aResult)
ToLowerCase(requestedDomain);
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
if (!ssm) {
*aResult = NS_ERROR_FAILURE;
return nsnull;
}
if (!ssm)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrincipal> subjectPrincipal;
*aResult = ssm->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal));
NS_ENSURE_SUCCESS(*aResult, nsnull);
rv = ssm->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> uri;
nsCAutoString currentDomain;
if (subjectPrincipal) {
*aResult = subjectPrincipal->GetDomain(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(*aResult, nsnull);
rv = subjectPrincipal->GetDomain(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
if (!uri) {
*aResult = subjectPrincipal->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(*aResult, nsnull);
rv = subjectPrincipal->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
}
if (uri) {
PRPackedBool sessionOnly;
if (!nsDOMStorage::CanUseStorage(uri, &sessionOnly)) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
if (!nsDOMStorage::CanUseStorage(uri, &sessionOnly))
return NS_ERROR_DOM_SECURITY_ERR;
nsCOMPtr<nsIURI> innerUri = NS_GetInnermostURI(uri);
if (!innerUri) {
*aResult = NS_ERROR_UNEXPECTED;
return nsnull;
}
if (!innerUri)
return NS_ERROR_UNEXPECTED;
uri = innerUri;
nsresult rv = uri->GetAsciiHost(currentDomain);
if (NS_FAILED(rv)) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
rv = uri->GetAsciiHost(currentDomain);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SECURITY_ERR);
}
}
PRBool isSystem;
*aResult = ssm->SubjectPrincipalIsSystem(&isSystem);
NS_ENSURE_SUCCESS(*aResult, nsnull);
rv = ssm->SubjectPrincipalIsSystem(&isSystem);
NS_ENSURE_SUCCESS(rv, rv);
// allow code that has read privileges to get the storage for any domain
if (!isSystem && nsContentUtils::IsCallerTrustedForRead())
@ -1125,20 +1109,10 @@ nsDOMStorageList::GetNamedItem(const nsAString& aDomain, nsresult* aResult)
if (isSystem || !currentDomain.IsEmpty()) {
return GetStorageForDomain(uri, NS_ConvertUTF8toUTF16(requestedDomain),
NS_ConvertUTF8toUTF16(currentDomain),
isSystem, aResult);
isSystem, aStorage);
}
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
NS_IMETHODIMP
nsDOMStorageList::NamedItem(const nsAString& aDomain,
nsIDOMStorage** aStorage)
{
nsresult rv;
NS_IF_ADDREF(*aStorage = GetNamedItem(aDomain, &rv));
return rv;
return NS_ERROR_DOM_SECURITY_ERR;
}
// static
@ -1149,22 +1123,23 @@ nsDOMStorageList::CanAccessDomain(const nsAString& aRequestedDomain,
return aRequestedDomain.Equals(aCurrentDomain);
}
nsIDOMStorage*
nsresult
nsDOMStorageList::GetStorageForDomain(nsIURI* aURI,
const nsAString& aRequestedDomain,
const nsAString& aCurrentDomain,
PRBool aNoCurrentDomainCheck,
nsresult* aResult)
nsIDOMStorage** aStorage)
{
nsStringArray requestedDomainArray;
if ((!aNoCurrentDomainCheck &&
!CanAccessDomain(aRequestedDomain, aCurrentDomain)) ||
!ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
if (!aNoCurrentDomainCheck && !CanAccessDomain(aRequestedDomain,
aCurrentDomain)) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsStringArray requestedDomainArray;
PRBool ok = ConvertDomainToArray(aRequestedDomain, &requestedDomainArray);
if (!ok)
return NS_ERROR_DOM_SECURITY_ERR;
// now rebuild a string for the domain.
nsAutoString usedDomain;
PRInt32 requestedPos = 0;
@ -1175,19 +1150,19 @@ nsDOMStorageList::GetStorageForDomain(nsIURI* aURI,
usedDomain.Append(*requestedDomainArray[requestedPos]);
}
*aResult = NS_OK;
// now have a valid domain, so look it up in the storage table
nsIDOMStorage* storage = mStorages.GetWeak(usedDomain);
if (!storage) {
if (!mStorages.Get(usedDomain, aStorage)) {
nsCOMPtr<nsIDOMStorage> newstorage = new nsDOMStorage(aURI, usedDomain, PR_TRUE);
if (newstorage && mStorages.Put(usedDomain, newstorage))
storage = newstorage;
else
*aResult = NS_ERROR_OUT_OF_MEMORY;
if (!newstorage)
return NS_ERROR_OUT_OF_MEMORY;
if (!mStorages.Put(usedDomain, newstorage))
return NS_ERROR_OUT_OF_MEMORY;
newstorage.swap(*aStorage);
}
return storage;
return NS_OK;
}
// static

Просмотреть файл

@ -167,13 +167,6 @@ public:
// clear all values from the store
void ClearAll();
nsIDOMStorageItem* GetNamedItem(const nsAString& aKey, nsresult* aResult);
static nsDOMStorage* FromSupports(nsISupports* aSupports)
{
return static_cast<nsDOMStorage*>(static_cast<nsIDOMStorage*>(aSupports));
}
protected:
friend class nsDOMStorageManager;
@ -224,8 +217,6 @@ public:
// nsIDOMStorageList
NS_DECL_NSIDOMSTORAGELIST
nsIDOMStorage* GetNamedItem(const nsAString& aDomain, nsresult* aResult);
/**
* Check whether aCurrentDomain has access to aRequestedDomain
*/
@ -245,12 +236,12 @@ protected:
* @param aCurrentDomain domain of current caller
* @param aNoCurrentDomainCheck true to skip domain comparison
*/
nsIDOMStorage*
nsresult
GetStorageForDomain(nsIURI* aURI,
const nsAString& aRequestedDomain,
const nsAString& aCurrentDomain,
PRBool aNoCurrentDomainCheck,
nsresult* aResult);
nsIDOMStorage** aStorage);
/**
* Convert the domain into an array of its component parts.

Просмотреть файл

@ -524,22 +524,17 @@ nsTreeColumns::GetColumnFor(nsIDOMElement* aElement, nsITreeColumn** _retval)
return NS_OK;
}
nsITreeColumn*
nsTreeColumns::GetNamedColumn(const nsAString& aId)
{
EnsureColumns();
for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
if (currCol->GetId().Equals(aId)) {
return currCol;
}
}
return nsnull;
}
NS_IMETHODIMP
nsTreeColumns::GetNamedColumn(const nsAString& aId, nsITreeColumn** _retval)
{
NS_IF_ADDREF(*_retval = GetNamedColumn(aId));
EnsureColumns();
*_retval = nsnull;
for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
if (currCol->GetId().Equals(aId)) {
NS_ADDREF(*_retval = currCol);
break;
}
}
return NS_OK;
}
@ -558,6 +553,7 @@ nsTreeColumns::GetColumnAt(PRInt32 aIndex)
NS_IMETHODIMP
nsTreeColumns::GetColumnAt(PRInt32 aIndex, nsITreeColumn** _retval)
{
EnsureColumns();
NS_IF_ADDREF(*_retval = GetColumnAt(aIndex));
return NS_OK;
}

Просмотреть файл

@ -149,7 +149,6 @@ public:
NS_DECL_NSITREECOLUMNS
nsITreeColumn* GetColumnAt(PRInt32 aIndex);
nsITreeColumn* GetNamedColumn(const nsAString& aId);
static nsTreeColumns* FromSupports(nsISupports* aSupports)
{