2016-11-06 08:54:29 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#include "WorkletGlobalScope.h"
|
|
|
|
#include "mozilla/dom/WorkletGlobalScopeBinding.h"
|
2016-11-06 08:54:52 +00:00
|
|
|
#include "mozilla/dom/Console.h"
|
2016-11-06 08:55:41 +00:00
|
|
|
#include "nsContentUtils.h"
|
2016-11-06 08:54:29 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(WorkletGlobalScope)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WorkletGlobalScope)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
2016-11-06 08:54:52 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mConsole)
|
2016-11-06 08:54:29 +00:00
|
|
|
tmp->UnlinkHostObjectURIs();
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WorkletGlobalScope)
|
2016-11-06 08:54:52 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConsole)
|
2016-11-06 08:54:29 +00:00
|
|
|
tmp->TraverseHostObjectURIs(cb);
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(WorkletGlobalScope)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(WorkletGlobalScope)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(WorkletGlobalScope)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkletGlobalScope)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
2016-11-06 08:54:52 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(WorkletGlobalScope)
|
2016-11-06 08:54:29 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2016-11-06 08:54:52 +00:00
|
|
|
WorkletGlobalScope::WorkletGlobalScope(nsPIDOMWindowInner* aWindow)
|
|
|
|
: mWindow(aWindow)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
WorkletGlobalScope::~WorkletGlobalScope()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-11-06 08:54:29 +00:00
|
|
|
JSObject*
|
|
|
|
WorkletGlobalScope::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
{
|
|
|
|
MOZ_CRASH("We should never get here!");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-11-06 08:54:52 +00:00
|
|
|
Console*
|
|
|
|
WorkletGlobalScope::GetConsole(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
if (!mConsole) {
|
|
|
|
mConsole = Console::Create(mWindow, aRv);
|
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mConsole;
|
|
|
|
}
|
|
|
|
|
2016-11-06 08:55:41 +00:00
|
|
|
void
|
|
|
|
WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const
|
|
|
|
{
|
|
|
|
if (!nsContentUtils::DOMWindowDumpEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aString.WasPassed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ConvertUTF16toUTF8 str(aString.Value());
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", str.get());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
fputs(str.get(), stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2016-11-06 08:54:29 +00:00
|
|
|
} // dom namespace
|
|
|
|
} // mozilla namespace
|