diff --git a/content/base/src/nsSelection.cpp b/content/base/src/nsSelection.cpp index d73140c33829..4f36d8b703ea 100644 --- a/content/base/src/nsSelection.cpp +++ b/content/base/src/nsSelection.cpp @@ -18,6 +18,14 @@ #include "nsSelection.h" #include "nsISelection.h" +NS_LAYOUT nsresult +NS_NewSelection(nsISelection** aInstancePtrResult) +{ + static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID); + nsSelection * sel = new nsSelection(); + return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult); +} + nsresult nsSelection::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { @@ -28,13 +36,14 @@ nsresult nsSelection::QueryInterface(const nsIID& aIID, } if (aIID.Equals(kISelectionIID)) { *aInstancePtrResult = (void*) ((nsISelection*)this); - //AddRef(); + AddRef(); return NS_OK; } return !NS_OK; } nsSelection::nsSelection() { + NS_INIT_REFCNT(); mRange = new nsSelectionRange(); } diff --git a/layout/base/src/nsSelection.cpp b/layout/base/src/nsSelection.cpp index d73140c33829..4f36d8b703ea 100644 --- a/layout/base/src/nsSelection.cpp +++ b/layout/base/src/nsSelection.cpp @@ -18,6 +18,14 @@ #include "nsSelection.h" #include "nsISelection.h" +NS_LAYOUT nsresult +NS_NewSelection(nsISelection** aInstancePtrResult) +{ + static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID); + nsSelection * sel = new nsSelection(); + return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult); +} + nsresult nsSelection::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { @@ -28,13 +36,14 @@ nsresult nsSelection::QueryInterface(const nsIID& aIID, } if (aIID.Equals(kISelectionIID)) { *aInstancePtrResult = (void*) ((nsISelection*)this); - //AddRef(); + AddRef(); return NS_OK; } return !NS_OK; } nsSelection::nsSelection() { + NS_INIT_REFCNT(); mRange = new nsSelectionRange(); } diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index d73140c33829..4f36d8b703ea 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -18,6 +18,14 @@ #include "nsSelection.h" #include "nsISelection.h" +NS_LAYOUT nsresult +NS_NewSelection(nsISelection** aInstancePtrResult) +{ + static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID); + nsSelection * sel = new nsSelection(); + return sel->QueryInterface(kISelectionIID, (void**) aInstancePtrResult); +} + nsresult nsSelection::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { @@ -28,13 +36,14 @@ nsresult nsSelection::QueryInterface(const nsIID& aIID, } if (aIID.Equals(kISelectionIID)) { *aInstancePtrResult = (void*) ((nsISelection*)this); - //AddRef(); + AddRef(); return NS_OK; } return !NS_OK; } nsSelection::nsSelection() { + NS_INIT_REFCNT(); mRange = new nsSelectionRange(); }