2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sw=2 et tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsXBLDocumentInfo.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsXBLPrototypeBinding.h"
|
|
|
|
#include "nsIScriptObjectPrincipal.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2013-08-21 23:30:55 -07:00
|
|
|
#include "nsIDOMDocument.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMScriptObjectFactory.h"
|
|
|
|
#include "jsapi.h"
|
2013-07-29 16:45:26 -07:00
|
|
|
#include "jsfriendapi.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsIChromeRegistry.h"
|
|
|
|
#include "nsIPrincipal.h"
|
2012-10-25 08:01:07 -07:00
|
|
|
#include "nsJSPrincipals.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsContentUtils.h"
|
2013-05-22 09:05:26 -07:00
|
|
|
#include "nsCxPusher.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDOMJSUtils.h"
|
2010-05-14 02:24:41 -07:00
|
|
|
#include "mozilla/Services.h"
|
2010-09-02 23:22:18 -07:00
|
|
|
#include "xpcpublic.h"
|
2011-11-03 13:39:08 -07:00
|
|
|
#include "mozilla/scache/StartupCache.h"
|
|
|
|
#include "mozilla/scache/StartupCacheUtils.h"
|
2012-01-13 04:44:14 -08:00
|
|
|
#include "nsCCUncollectableMarker.h"
|
2012-05-02 21:35:38 -07:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
2013-11-20 08:29:03 -08:00
|
|
|
#include "mozilla/dom/URL.h"
|
2011-11-03 13:39:08 -07:00
|
|
|
|
2012-03-28 06:14:33 -07:00
|
|
|
using namespace mozilla;
|
2013-11-20 08:29:03 -08:00
|
|
|
using namespace mozilla::scache;
|
|
|
|
using namespace mozilla::dom;
|
2011-11-03 13:39:08 -07:00
|
|
|
|
|
|
|
static const char kXBLCachePrefix[] = "xblcache";
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* Implementation file */
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
static PLDHashOperator
|
|
|
|
TraverseProtos(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-02-25 20:32:48 -08:00
|
|
|
nsCycleCollectionTraversalCallback *cb =
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
|
2014-02-25 20:32:48 -08:00
|
|
|
aProto->Traverse(*cb);
|
|
|
|
return PL_DHASH_NEXT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
static PLDHashOperator
|
2014-06-23 19:09:36 -07:00
|
|
|
UnlinkProto(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
2007-09-28 06:45:01 -07:00
|
|
|
{
|
2014-06-23 19:09:36 -07:00
|
|
|
aProto->Unlink();
|
2014-02-25 20:32:48 -08:00
|
|
|
return PL_DHASH_NEXT;
|
2007-09-28 06:45:01 -07:00
|
|
|
}
|
|
|
|
|
2007-10-29 06:45:07 -07:00
|
|
|
struct ProtoTracer
|
|
|
|
{
|
2013-05-27 04:50:49 -07:00
|
|
|
const TraceCallbacks &mCallbacks;
|
2007-10-29 06:45:07 -07:00
|
|
|
void *mClosure;
|
|
|
|
};
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
static PLDHashOperator
|
|
|
|
TraceProtos(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
2007-10-29 06:45:07 -07:00
|
|
|
{
|
|
|
|
ProtoTracer* closure = static_cast<ProtoTracer*>(aClosure);
|
2014-02-25 20:32:48 -08:00
|
|
|
aProto->Trace(closure->mCallbacks, closure->mClosure);
|
|
|
|
return PL_DHASH_NEXT;
|
2007-10-29 06:45:07 -07:00
|
|
|
}
|
|
|
|
|
2013-08-01 18:29:05 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXBLDocumentInfo)
|
|
|
|
|
2010-11-08 07:02:49 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXBLDocumentInfo)
|
2007-09-28 06:45:01 -07:00
|
|
|
if (tmp->mBindingTable) {
|
2014-06-23 19:09:36 -07:00
|
|
|
tmp->mBindingTable->EnumerateRead(UnlinkProto, nullptr);
|
2007-09-28 06:45:01 -07:00
|
|
|
}
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXBLDocumentInfo)
|
2012-01-13 04:44:14 -08:00
|
|
|
if (tmp->mDocument &&
|
|
|
|
nsCCUncollectableMarker::InGeneration(cb, tmp->mDocument->GetMarkedCCGeneration())) {
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
return NS_SUCCESS_INTERRUPTED_TRAVERSE;
|
|
|
|
}
|
2012-11-14 23:32:40 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
|
2007-03-22 10:30:00 -07:00
|
|
|
if (tmp->mBindingTable) {
|
2014-02-25 20:32:48 -08:00
|
|
|
tmp->mBindingTable->EnumerateRead(TraverseProtos, &cb);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-10-29 06:45:07 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
2007-10-29 06:45:07 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsXBLDocumentInfo)
|
|
|
|
if (tmp->mBindingTable) {
|
2013-05-27 04:50:49 -07:00
|
|
|
ProtoTracer closure = { aCallbacks, aClosure };
|
2014-02-25 20:32:48 -08:00
|
|
|
tmp->mBindingTable->EnumerateRead(TraceProtos, &closure);
|
2007-10-29 06:45:07 -07:00
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-11 03:04:28 -08:00
|
|
|
static void
|
2012-05-03 12:28:10 -07:00
|
|
|
UnmarkXBLJSObject(void* aP, const char* aName, void* aClosure)
|
2012-02-11 03:04:28 -08:00
|
|
|
{
|
2013-09-08 20:28:48 -07:00
|
|
|
JS::ExposeObjectToActiveJS(static_cast<JSObject*>(aP));
|
2012-02-11 03:04:28 -08:00
|
|
|
}
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
static PLDHashOperator
|
|
|
|
UnmarkProtos(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
2012-02-11 03:04:28 -08:00
|
|
|
{
|
2014-02-25 20:32:48 -08:00
|
|
|
aProto->Trace(TraceCallbackFunc(UnmarkXBLJSObject), nullptr);
|
|
|
|
return PL_DHASH_NEXT;
|
2012-02-11 03:04:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsXBLDocumentInfo::MarkInCCGeneration(uint32_t aGeneration)
|
2012-02-11 03:04:28 -08:00
|
|
|
{
|
|
|
|
if (mDocument) {
|
|
|
|
mDocument->MarkUncollectableForCCGeneration(aGeneration);
|
|
|
|
}
|
2012-03-18 07:17:05 -07:00
|
|
|
// Unmark any JS we hold
|
2012-02-11 03:04:28 -08:00
|
|
|
if (mBindingTable) {
|
2014-02-25 20:32:48 -08:00
|
|
|
mBindingTable->EnumerateRead(UnmarkProtos, nullptr);
|
2012-02-11 03:04:28 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-25 09:35:27 -07:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXBLDocumentInfo)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2013-08-09 09:25:14 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-03-06 03:11:31 -08:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXBLDocumentInfo)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXBLDocumentInfo)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsXBLDocumentInfo::nsXBLDocumentInfo(nsIDocument* aDocument)
|
|
|
|
: mDocument(aDocument),
|
2011-10-17 07:59:28 -07:00
|
|
|
mScriptAccess(true),
|
|
|
|
mIsChrome(false),
|
2012-07-30 07:20:58 -07:00
|
|
|
mFirstBinding(nullptr)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsIURI* uri = aDocument->GetDocumentURI();
|
|
|
|
if (IsChromeURI(uri)) {
|
|
|
|
// Cache whether or not this chrome XBL can execute scripts.
|
2010-05-14 02:24:41 -07:00
|
|
|
nsCOMPtr<nsIXULChromeRegistry> reg =
|
|
|
|
mozilla::services::GetXULChromeRegistryService();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (reg) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool allow = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
reg->AllowScriptsForPackage(uri, &allow);
|
|
|
|
mScriptAccess = allow;
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
mIsChrome = true;
|
2013-12-13 08:54:04 -08:00
|
|
|
} else {
|
|
|
|
// If this binding isn't running with system principal, then it's running
|
|
|
|
// from a remote-XUL whitelisted domain. This is already a not-really-
|
|
|
|
// supported configuration (among other things, we don't use XBL scopes in
|
|
|
|
// that configuration for compatibility reasons). But we should still at
|
|
|
|
// least make an effort to prevent binding code from running if content
|
|
|
|
// script is disabled or if the source domain is blacklisted (since the
|
|
|
|
// source domain for remote XBL must always be the same as the source domain
|
|
|
|
// of the bound content).
|
|
|
|
//
|
|
|
|
// If we just ask the binding document if script is enabled, it will
|
|
|
|
// discover that it has no inner window, and return false. So instead, we
|
|
|
|
// short-circuit the normal compartment-managed script-disabling machinery,
|
|
|
|
// and query the policy for the URI directly.
|
|
|
|
bool allow;
|
|
|
|
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
|
|
|
nsresult rv = ssm->PolicyAllowsScript(uri, &allow);
|
|
|
|
mScriptAccess = NS_SUCCEEDED(rv) && allow;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsXBLDocumentInfo::~nsXBLDocumentInfo()
|
|
|
|
{
|
2014-02-25 20:32:48 -08:00
|
|
|
mozilla::DropJSObjects(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-14 18:55:54 -07:00
|
|
|
nsXBLPrototypeBinding*
|
|
|
|
nsXBLDocumentInfo::GetPrototypeBinding(const nsACString& aRef)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!mBindingTable)
|
2013-04-02 18:14:24 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (aRef.IsEmpty()) {
|
|
|
|
// Return our first binding
|
2010-07-14 18:55:54 -07:00
|
|
|
return mFirstBinding;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
return mBindingTable->Get(aRef);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-14 18:55:54 -07:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLDocumentInfo::SetPrototypeBinding(const nsACString& aRef, nsXBLPrototypeBinding* aBinding)
|
|
|
|
{
|
2007-10-29 06:45:07 -07:00
|
|
|
if (!mBindingTable) {
|
2014-02-25 20:32:48 -08:00
|
|
|
mBindingTable = new nsClassHashtable<nsCStringHashKey, nsXBLPrototypeBinding>();
|
2013-08-16 13:10:17 -07:00
|
|
|
mozilla::HoldJSObjects(this);
|
2007-10-29 06:45:07 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
NS_ENSURE_STATE(!mBindingTable->Get(aRef));
|
|
|
|
mBindingTable->Put(aRef, aBinding);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-03 13:39:08 -07:00
|
|
|
void
|
|
|
|
nsXBLDocumentInfo::RemovePrototypeBinding(const nsACString& aRef)
|
|
|
|
{
|
|
|
|
if (mBindingTable) {
|
2014-02-25 20:32:48 -08:00
|
|
|
nsAutoPtr<nsXBLPrototypeBinding> bindingToRemove;
|
|
|
|
mBindingTable->RemoveAndForget(aRef, bindingToRemove);
|
|
|
|
|
|
|
|
// We do not want to destroy the binding, so just forget it.
|
|
|
|
bindingToRemove.forget();
|
2011-11-03 13:39:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Callback to enumerate over the bindings from this document and write them
|
|
|
|
// out to the cache.
|
2014-02-25 20:32:48 -08:00
|
|
|
static PLDHashOperator
|
|
|
|
WriteBinding(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
2011-11-03 13:39:08 -07:00
|
|
|
{
|
2014-02-25 20:32:48 -08:00
|
|
|
aProto->Write((nsIObjectOutputStream*)aClosure);
|
2011-11-03 13:39:08 -07:00
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
return PL_DHASH_NEXT;
|
2011-11-03 13:39:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
|
|
|
nsXBLDocumentInfo::ReadPrototypeBindings(nsIURI* aURI, nsXBLDocumentInfo** aDocInfo)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aDocInfo = nullptr;
|
2011-11-03 13:39:08 -07:00
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString spec(kXBLCachePrefix);
|
2011-11-03 13:39:08 -07:00
|
|
|
nsresult rv = PathifyURI(aURI, spec);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
StartupCache* startupCache = StartupCache::GetSingleton();
|
|
|
|
NS_ENSURE_TRUE(startupCache, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsAutoArrayPtr<char> buf;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t len;
|
2011-11-03 13:39:08 -07:00
|
|
|
rv = startupCache->GetBuffer(spec.get(), getter_Transfers(buf), &len);
|
|
|
|
// GetBuffer will fail if the binding is not in the cache.
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObjectInputStream> stream;
|
|
|
|
rv = NewObjectInputStreamFromBuffer(buf, len, getter_AddRefs(stream));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
buf.forget();
|
|
|
|
|
|
|
|
// The file compatibility.ini stores the build id. This is checked in
|
|
|
|
// nsAppRunner.cpp and will delete the cache if a different build is
|
|
|
|
// present. However, we check that the version matches here to be safe.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t version;
|
2011-11-03 13:39:08 -07:00
|
|
|
rv = stream->Read32(&version);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (version != XBLBinding_Serialize_Version) {
|
|
|
|
// The version that exists is different than expected, likely created with a
|
|
|
|
// different build, so invalidate the cache.
|
|
|
|
startupCache->InvalidateCache();
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
nsContentUtils::GetSecurityManager()->
|
|
|
|
GetSystemPrincipal(getter_AddRefs(principal));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocument> domdoc;
|
2012-07-30 07:20:58 -07:00
|
|
|
rv = NS_NewXBLDocument(getter_AddRefs(domdoc), aURI, nullptr, principal);
|
2011-11-03 13:39:08 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
|
2012-03-22 13:46:03 -07:00
|
|
|
NS_ASSERTION(doc, "Must have a document!");
|
|
|
|
nsRefPtr<nsXBLDocumentInfo> docInfo = new nsXBLDocumentInfo(doc);
|
2011-11-03 13:39:08 -07:00
|
|
|
|
|
|
|
while (1) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t flags;
|
2011-11-03 13:39:08 -07:00
|
|
|
nsresult rv = stream->Read8(&flags);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (flags == XBLBinding_Serialize_NoMoreBindings)
|
|
|
|
break;
|
|
|
|
|
2014-02-27 10:04:10 -08:00
|
|
|
rv = nsXBLPrototypeBinding::ReadNewBinding(stream, docInfo, doc, flags);
|
2011-11-03 13:39:08 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
docInfo.swap(*aDocInfo);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXBLDocumentInfo::WritePrototypeBindings()
|
|
|
|
{
|
|
|
|
// Only write out bindings with the system principal
|
|
|
|
if (!nsContentUtils::IsSystemPrincipal(mDocument->NodePrincipal()))
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString spec(kXBLCachePrefix);
|
2011-11-03 13:39:08 -07:00
|
|
|
nsresult rv = PathifyURI(DocumentURI(), spec);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
StartupCache* startupCache = StartupCache::GetSingleton();
|
|
|
|
NS_ENSURE_TRUE(startupCache, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObjectOutputStream> stream;
|
|
|
|
nsCOMPtr<nsIStorageStream> storageStream;
|
|
|
|
rv = NewObjectOutputWrappedStorageStream(getter_AddRefs(stream),
|
|
|
|
getter_AddRefs(storageStream),
|
|
|
|
true);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = stream->Write32(XBLBinding_Serialize_Version);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
if (mBindingTable) {
|
|
|
|
mBindingTable->EnumerateRead(WriteBinding, stream);
|
|
|
|
}
|
2011-11-03 13:39:08 -07:00
|
|
|
|
|
|
|
// write a end marker at the end
|
|
|
|
rv = stream->Write8(XBLBinding_Serialize_NoMoreBindings);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
stream->Close();
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t len;
|
2011-11-03 13:39:08 -07:00
|
|
|
nsAutoArrayPtr<char> buf;
|
|
|
|
rv = NewBufferFromStorageStream(storageStream, getter_Transfers(buf), &len);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return startupCache->PutBuffer(spec.get(), buf, len);
|
|
|
|
}
|
|
|
|
|
2010-07-14 18:55:54 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLDocumentInfo::SetFirstPrototypeBinding(nsXBLPrototypeBinding* aBinding)
|
|
|
|
{
|
|
|
|
mFirstBinding = aBinding;
|
|
|
|
}
|
|
|
|
|
2014-02-25 20:32:48 -08:00
|
|
|
static PLDHashOperator
|
|
|
|
FlushScopedSkinSheets(const nsACString &aKey, nsXBLPrototypeBinding *aProto, void* aClosure)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-02-25 20:32:48 -08:00
|
|
|
aProto->FlushSkinSheets();
|
|
|
|
return PL_DHASH_NEXT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-07-14 18:55:54 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLDocumentInfo::FlushSkinStylesheets()
|
|
|
|
{
|
2014-02-25 20:32:48 -08:00
|
|
|
if (mBindingTable) {
|
|
|
|
mBindingTable->EnumerateRead(FlushScopedSkinSheets, nullptr);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-08-09 09:25:12 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
AssertInCompilationScope()
|
|
|
|
{
|
|
|
|
AutoJSContext cx;
|
2014-04-20 11:48:14 -07:00
|
|
|
// Note - Inverting the order of these operands is a rooting hazard.
|
|
|
|
MOZ_ASSERT(xpc::GetCompilationScope() == JS::CurrentGlobalOrNull(cx));
|
2013-08-09 09:25:12 -07:00
|
|
|
}
|
|
|
|
#endif
|