From 57bd111b189887ff800916e08409d3a7e334f7b2 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 20 Jan 2011 15:23:48 -0500 Subject: [PATCH] Bug 627474 - Part 2: Use nsIXPConnect::WrapNative directly in order to avoid having to link in libgklayout in non-libxul builds; r=bzbarsky a=bustage --HG-- extra : rebase_source : 58c2f6e6bc3a8fd1070732a9b27d780739afc7f7 --- toolkit/components/places/src/PlaceInfo.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/toolkit/components/places/src/PlaceInfo.cpp b/toolkit/components/places/src/PlaceInfo.cpp index df6762570e31..5f4a9b1dd9f0 100644 --- a/toolkit/components/places/src/PlaceInfo.cpp +++ b/toolkit/components/places/src/PlaceInfo.cpp @@ -38,7 +38,8 @@ #include "PlaceInfo.h" #include "VisitInfo.h" #include "nsIURI.h" -#include "nsContentUtils.h" +#include "nsServiceManagerUtils.h" +#include "nsIXPConnect.h" namespace mozilla { namespace places { @@ -112,13 +113,23 @@ PlaceInfo::GetVisits(JSContext* aContext, JSObject* global = JS_GetGlobalForScopeChain(aContext); NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED); + static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID); + nsresult rv; + nsCOMPtr xpc(do_GetService(kXPConnectCID, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + for (VisitsArray::size_type idx = 0; idx < mVisits.Length(); idx++) { - jsval wrappedVisit; - nsresult rv = nsContentUtils::WrapNative(aContext, global, mVisits[idx], - &NS_GET_IID(mozIVisitInfo), - &wrappedVisit); + nsCOMPtr wrapper; + rv = xpc->WrapNative(aContext, global, mVisits[idx], + NS_GET_IID(mozIVisitInfo), + getter_AddRefs(wrapper)); NS_ENSURE_SUCCESS(rv, rv); + JSObject* jsobj; + rv = wrapper->GetJSObject(&jsobj); + NS_ENSURE_SUCCESS(rv, rv); + jsval wrappedVisit = OBJECT_TO_JSVAL(jsobj); + JSBool rc = JS_SetElement(aContext, visits, idx, &wrappedVisit); NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED); }