diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index eae332606c06..0e312383859c 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -65,6 +65,7 @@ #include "nsIServiceManager.h" #include "nsWhitespaceTokenizer.h" #include "nsAttrName.h" +#include "nsPersistentProperties.h" #include "mozilla/Assertions.h" #include "mozilla/BasicEvents.h" @@ -1019,8 +1020,7 @@ Accessible::Attributes() already_AddRefed Accessible::NativeAttributes() { - nsCOMPtr attributes = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + RefPtr attributes = new nsPersistentProperties(); nsAutoString unused; diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index 1a8cabf9bddf..eec89100822a 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -25,7 +25,7 @@ #include "nsFrameSelection.h" #include "nsILineIterator.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIPersistentProperties2.h" +#include "nsPersistentProperties.h" #include "nsIScrollableFrame.h" #include "nsIServiceManager.h" #include "nsITextControlElement.h" @@ -880,8 +880,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset, return nullptr; } - nsCOMPtr attributes = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + RefPtr attributes = new nsPersistentProperties(); Accessible* accAtOffset = GetChildAtOffset(offset); if (!accAtOffset) { @@ -925,8 +924,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset, already_AddRefed HyperTextAccessible::DefaultTextAttributes() { - nsCOMPtr attributes = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + RefPtr attributes = new nsPersistentProperties(); TextAttrsMgr textAttrsMgr(this); textAttrsMgr.GetAttributes(attributes); diff --git a/accessible/windows/msaa/ApplicationAccessibleWrap.cpp b/accessible/windows/msaa/ApplicationAccessibleWrap.cpp index ec9d511e4646..fbe1072d3dfa 100644 --- a/accessible/windows/msaa/ApplicationAccessibleWrap.cpp +++ b/accessible/windows/msaa/ApplicationAccessibleWrap.cpp @@ -11,7 +11,7 @@ #include "IUnknownImpl.h" #include "nsIGfxInfo.h" -#include "nsIPersistentProperties2.h" +#include "nsPersistentProperties.h" #include "nsServiceManagerUtils.h" #include "mozilla/Services.h" @@ -26,8 +26,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessibleWrap, already_AddRefed ApplicationAccessibleWrap::NativeAttributes() { - nsCOMPtr attributes = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + RefPtr attributes = new nsPersistentProperties(); nsCOMPtr gfxInfo = services::GetGfxInfo(); if (gfxInfo) { diff --git a/accessible/xpcom/xpcAccessible.cpp b/accessible/xpcom/xpcAccessible.cpp index 595c8462000c..6a302615f5c7 100644 --- a/accessible/xpcom/xpcAccessible.cpp +++ b/accessible/xpcom/xpcAccessible.cpp @@ -16,7 +16,7 @@ #include "xpcAccessibleDocument.h" #include "nsIMutableArray.h" -#include "nsIPersistentProperties2.h" +#include "nsPersistentProperties.h" using namespace mozilla::a11y; @@ -416,8 +416,7 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes) AutoTArray attrs; proxy->Attributes(&attrs); - nsCOMPtr props = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + RefPtr props = new nsPersistentProperties(); uint32_t attrCount = attrs.Length(); nsAutoString unused; for (uint32_t i = 0; i < attrCount; i++) { diff --git a/accessible/xul/XULTreeGridAccessible.cpp b/accessible/xul/XULTreeGridAccessible.cpp index a14dfde67029..82b4aee9c3f0 100644 --- a/accessible/xul/XULTreeGridAccessible.cpp +++ b/accessible/xul/XULTreeGridAccessible.cpp @@ -18,7 +18,7 @@ #include "nsIBoxObject.h" #include "nsIMutableArray.h" -#include "nsIPersistentProperties2.h" +#include "nsPersistentProperties.h" #include "nsITreeSelection.h" #include "nsComponentManagerUtils.h" #include "mozilla/dom/Element.h" @@ -646,8 +646,7 @@ XULTreeGridCellAccessible::Selected() already_AddRefed XULTreeGridCellAccessible::NativeAttributes() { - nsCOMPtr attributes = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + RefPtr attributes = new nsPersistentProperties(); // "table-cell-index" attribute TableAccessible* table = Table(); diff --git a/js/xpconnect/idl/xpccomponents.idl b/js/xpconnect/idl/xpccomponents.idl index 6189dd0fbd40..c9cdf0756940 100644 --- a/js/xpconnect/idl/xpccomponents.idl +++ b/js/xpconnect/idl/xpccomponents.idl @@ -17,6 +17,7 @@ interface nsICycleCollectorListener; interface nsIEditorSpellCheck; interface nsIFile; interface nsILoadContext; +interface nsIPersistentProperties; interface nsIURI; interface nsIJSCID; interface nsIJSIID; @@ -731,6 +732,9 @@ interface nsIXPCComponents_Utils : nsISupports /* Create a private loadcontext object. */ nsILoadContext createPrivateLoadContext(); + + /* Create a persistent property object. */ + nsIPersistentProperties createPersistentProperties(); }; /** diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 3ae0b16a977d..789437de14e4 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -44,7 +44,7 @@ #include "GeckoProfiler.h" #include "mozilla/EditorSpellCheck.h" #include "nsCommandLine.h" -#include "nsCommandParams.h" +#include "nsPersistentProperties.h" using namespace mozilla; using namespace JS; @@ -3251,6 +3251,15 @@ nsXPCComponents_Utils::CreatePrivateLoadContext(nsILoadContext** aLoadContext) return NS_OK; } +NS_IMETHODIMP +nsXPCComponents_Utils::CreatePersistentProperties(nsIPersistentProperties** aPersistentProperties) +{ + NS_ENSURE_ARG_POINTER(aPersistentProperties); + nsCOMPtr props = new nsPersistentProperties(); + props.forget(aPersistentProperties); + return NS_OK; +} + /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 9f053651e6a9..a8d284e8f7de 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -44,7 +44,7 @@ #include "nsINode.h" #include "nsIObjectLoadingContent.h" #include "nsIOfflineCacheUpdate.h" -#include "nsIPersistentProperties2.h" +#include "nsPersistentProperties.h" #include "nsIPrivateBrowsingChannel.h" #include "nsIPropertyBag2.h" #include "nsIProtocolProxyService.h" @@ -2029,9 +2029,7 @@ NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult, rv = channel->Open2(getter_AddRefs(in)); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr properties = - do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr properties = new nsPersistentProperties(); rv = properties->Load(in); NS_ENSURE_SUCCESS(rv, rv); diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 034f68de13e7..714761b06402 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -28,7 +28,6 @@ #include "nsCycleCollector.h" #include "nsObserverList.h" #include "nsObserverService.h" -#include "nsPersistentProperties.h" #include "nsScriptableInputStream.h" #include "nsBinaryStream.h" #include "nsStorageStream.h" @@ -256,8 +255,6 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry, nsChromeRegistry::GetSingleton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeProtocolHandler) -#define NS_PERSISTENTPROPERTIES_CID NS_IPERSISTENTPROPERTIES_CID /* sigh */ - static already_AddRefed CreateINIParserFactory(const mozilla::Module& aModule, const mozilla::Module::CIDEntry& aEntry) diff --git a/xpcom/build/XPCOMModule.inc b/xpcom/build/XPCOMModule.inc index 478e3238386b..376d2bcd7e24 100644 --- a/xpcom/build/XPCOMModule.inc +++ b/xpcom/build/XPCOMModule.inc @@ -12,8 +12,6 @@ COMPONENT(SCRIPTABLEBASE64ENCODER, nsScriptableBase64EncoderConstructor) COMPONENT(PIPE, nsPipeConstructor) - COMPONENT(PERSISTENTPROPERTIES, nsPersistentProperties::Create) - COMPONENT(ARRAY, nsArrayBase::XPCOMConstructor) COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor) COMPONENT_M(OBSERVERSERVICE, nsObserverService::Create, Module::ALLOW_IN_GPU_PROCESS) diff --git a/xpcom/ds/moz.build b/xpcom/ds/moz.build index eb4e8777910a..fc185b1432a4 100644 --- a/xpcom/ds/moz.build +++ b/xpcom/ds/moz.build @@ -61,6 +61,7 @@ EXPORTS += [ 'nsInterfaceHashtable.h', 'nsJSThingHashtable.h', 'nsMathUtils.h', + 'nsPersistentProperties.h', 'nsPointerHashKeys.h', 'nsProperties.h', 'nsQuickSort.h', diff --git a/xpcom/ds/nsIPersistentProperties2.idl b/xpcom/ds/nsIPersistentProperties2.idl index 9f6897af954f..d0158d6e5b48 100644 --- a/xpcom/ds/nsIPersistentProperties2.idl +++ b/xpcom/ds/nsIPersistentProperties2.idl @@ -58,13 +58,3 @@ interface nsIPersistentProperties : nsIProperties %} }; - -%{C++ - -#define NS_IPERSISTENTPROPERTIES_CID \ -{ 0x2245e573, 0x9464, 0x11d2, \ - { 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } } - -#define NS_PERSISTENTPROPERTIES_CONTRACTID "@mozilla.org/persistent-properties;1" - -%} diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index 433b00960e48..9e0c612a104d 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -459,17 +459,6 @@ nsPersistentProperties::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) return aMallocSizeOf(this) + n; } -nsresult -nsPersistentProperties::Create(nsISupports* aOuter, REFNSIID aIID, - void** aResult) -{ - if (aOuter) { - return NS_ERROR_NO_AGGREGATION; - } - RefPtr props = new nsPersistentProperties(); - return props->QueryInterface(aIID, aResult); -} - NS_IMPL_ISUPPORTS(nsPersistentProperties, nsIPersistentProperties, nsIProperties) NS_IMETHODIMP diff --git a/xpcom/ds/nsPersistentProperties.h b/xpcom/ds/nsPersistentProperties.h index 5e280d377f47..3c67bdb897b7 100644 --- a/xpcom/ds/nsPersistentProperties.h +++ b/xpcom/ds/nsPersistentProperties.h @@ -25,9 +25,6 @@ public: NS_DECL_NSIPROPERTIES NS_DECL_NSIPERSISTENTPROPERTIES - static MOZ_MUST_USE nsresult - Create(nsISupports* aOuter, REFNSIID aIID, void** aResult); - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override; private: diff --git a/xpcom/tests/unit/test_bug121341.js b/xpcom/tests/unit/test_bug121341.js index 6cd9b797396d..df201eb914d7 100644 --- a/xpcom/tests/unit/test_bug121341.js +++ b/xpcom/tests/unit/test_bug121341.js @@ -9,8 +9,7 @@ function run_test() { }); var inp = channel.open2(); - var properties = Cc["@mozilla.org/persistent-properties;1"]. - createInstance(Ci.nsIPersistentProperties); + var properties = Cu.createPersistentProperties(); properties.load(inp); var value; @@ -56,8 +55,7 @@ function run_test() { }); inp = channel2.open2(); - var properties2 = Cc["@mozilla.org/persistent-properties;1"]. - createInstance(Ci.nsIPersistentProperties); + var properties2 = Cu.createPersistentProperties(); try { properties2.load(inp); do_throw("load() didn't fail");