本文整理汇总了C++中GlobalObject::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalObject::Get方法的具体用法?C++ GlobalObject::Get怎么用?C++ GlobalObject::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalObject
的用法示例。
在下文中一共展示了GlobalObject::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nsDOMParser
/*static */already_AddRefed<nsDOMParser>
nsDOMParser::Constructor(const GlobalObject& aOwner, ErrorResult& rv)
{
nsCOMPtr<nsIPrincipal> prin;
nsCOMPtr<nsIURI> documentURI;
nsCOMPtr<nsIURI> baseURI;
// No arguments; use the subject principal
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
if (!secMan) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
rv = secMan->GetSubjectPrincipal(getter_AddRefs(prin));
if (rv.Failed()) {
return nullptr;
}
// We're called from JS; there better be a subject principal, really.
if (!prin) {
rv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsRefPtr<nsDOMParser> domParser = new nsDOMParser(aOwner.Get());
rv = domParser->InitInternal(aOwner.Get(), prin, documentURI, baseURI);
if (rv.Failed()) {
return nullptr;
}
return domParser.forget();
}
示例2:
void
URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
const nsACString& aScheme,
const objectURLOptions& aOptions,
nsAString& aResult, ErrorResult& aRv)
{
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
nsAutoCString url;
nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(aScheme, aObject,
principal, url);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
global->RegisterHostObjectURI(url);
CopyASCIItoUTF16(url, aResult);
}
示例3:
/* static */ void
URLMainThread::CreateObjectURL(const GlobalObject& aGlobal,
MediaSource& aSource,
const objectURLOptions& aOptions,
nsAString& aResult, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIPrincipal> principal =
nsContentUtils::ObjectPrincipal(aGlobal.Get());
nsAutoCString url;
aRv = nsHostObjectProtocolHandler::AddDataEntry(&aSource, principal, url);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
nsCOMPtr<nsIRunnable> revocation = NS_NewRunnableFunction(
[url] {
nsHostObjectProtocolHandler::RemoveDataEntry(url);
});
nsContentUtils::RunInStableState(revocation.forget());
CopyASCIItoUTF16(url, aResult);
}
示例4: HTMLImageElement
// static
already_AddRefed<HTMLImageElement>
HTMLImageElement::Image(const GlobalObject& aGlobal,
const Optional<uint32_t>& aWidth,
const Optional<uint32_t>& aHeight, ErrorResult& aError)
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aGlobal.Get());
nsIDocument* doc;
if (!win || !(doc = win->GetExtantDoc())) {
aError.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsINodeInfo> nodeInfo =
doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::img, nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
nsRefPtr<HTMLImageElement> img = new HTMLImageElement(nodeInfo.forget());
if (aWidth.WasPassed()) {
img->SetWidth(aWidth.Value(), aError);
if (aError.Failed()) {
return nullptr;
}
if (aHeight.WasPassed()) {
img->SetHeight(aHeight.Value(), aError);
if (aError.Failed()) {
return nullptr;
}
}
}
return img.forget();
}
示例5:
void
URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
const nsACString& aScheme,
const objectURLOptions& aOptions,
nsString& aResult, ErrorResult& aError)
{
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::GetObjectPrincipal(aGlobal.Get());
nsCString url;
nsresult rv = nsHostObjectProtocolHandler::AddDataEntry(aScheme, aObject,
principal, url);
if (NS_FAILED(rv)) {
aError.Throw(rv);
return;
}
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.GetAsSupports());
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
if (window) {
NS_PRECONDITION(window->IsInnerWindow(), "Should be inner window");
if (!window->GetExtantDoc()) {
aError.Throw(NS_ERROR_INVALID_POINTER);
return;
}
nsIDocument* doc = window->GetExtantDoc();
if (doc) {
doc->RegisterHostObjectUri(url);
}
}
CopyASCIItoUTF16(url, aResult);
}
示例6: AddDataEntry
void
URL::CreateObjectURL(const GlobalObject& aGlobal, MediaSource& aSource,
const objectURLOptions& aOptions,
nsAString& aResult,
ErrorResult& aError)
{
nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
nsCString url;
nsresult rv = nsHostObjectProtocolHandler::
AddDataEntry(NS_LITERAL_CSTRING(MEDIASOURCEURI_SCHEME),
&aSource, principal, url);
if (NS_FAILED(rv)) {
aError.Throw(rv);
return;
}
nsCOMPtr<nsIRunnable> revocation = NS_NewRunnableFunction(
[url] {
nsHostObjectProtocolHandler::RemoveDataEntry(url);
});
nsContentUtils::RunInStableState(revocation.forget());
CopyASCIItoUTF16(url, aResult);
}
示例7: Promise
/* static */ already_AddRefed<Promise>
Promise::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
PromiseInit& aInit, ErrorResult& aRv)
{
MOZ_ASSERT(PrefEnabled());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsRefPtr<Promise> promise = new Promise(window);
aInit.Call(promise, *promise->mResolver, aRv,
CallbackObject::eRethrowExceptions);
aRv.WouldReportJSException();
if (aRv.IsJSException()) {
Optional<JS::Handle<JS::Value> > value(aCx);
aRv.StealJSException(aCx, &value.Value());
Maybe<JSAutoCompartment> ac;
EnterCompartment(ac, aCx, value);
promise->mResolver->Reject(aCx, value);
}
return promise.forget();
}
示例8: MediaRecorder
/* static */ already_AddRefed<MediaRecorder>
MediaRecorder::Constructor(const GlobalObject& aGlobal, JSContext* aCx,
DOMMediaStream& aStream, ErrorResult& aRv)
{
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aGlobal.Get());
if (!sgo) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsPIDOMWindow> ownerWindow = do_QueryInterface(aGlobal.Get());
if (!ownerWindow) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsRefPtr<MediaRecorder> object = new MediaRecorder(aStream);
object->Init(aCx, ownerWindow);
return object.forget();
}
示例9: nsFormData
/* static */ already_AddRefed<nsFormData>
nsFormData::Constructor(const GlobalObject& aGlobal,
const Optional<nsHTMLFormElement*>& aFormElement,
ErrorResult& aRv)
{
nsRefPtr<nsFormData> formData = new nsFormData(aGlobal.Get());
if (aFormElement.WasPassed()) {
MOZ_ASSERT(aFormElement.Value());
aRv = aFormElement.Value()->WalkFormElements(formData);
}
return formData.forget();
}
示例10:
/* static */ already_AddRefed<Comment>
Comment::Constructor(const GlobalObject& aGlobal, const nsAString& aData,
ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window || !window->GetDoc()) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
return window->GetDoc()->CreateComment(aData);
}
示例11: GetParsingInfo
/* static */ bool
CSS::Supports(const GlobalObject& aGlobal,
const nsAString& aCondition,
ErrorResult& aRv)
{
nsCSSParser parser;
SupportsParsingInfo info;
nsresult rv = GetParsingInfo(aGlobal.Get(), info);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return false;
}
return parser.EvaluateSupportsCondition(aCondition, info.mDocURI,
info.mBaseURI, info.mPrincipal);
}
示例12:
static nsresult
GetParsingInfo(const GlobalObject& aGlobal,
SupportsParsingInfo& aInfo)
{
nsGlobalWindow* win = xpc::WindowOrNull(aGlobal.Get());
if (!win) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocument> doc = win->GetDoc();
if (!doc) {
return NS_ERROR_FAILURE;
}
aInfo.mDocURI = nsCOMPtr<nsIURI>(doc->GetDocumentURI());
aInfo.mBaseURI = nsCOMPtr<nsIURI>(doc->GetBaseURI());
aInfo.mPrincipal = win->GetPrincipal();
return NS_OK;
}
示例13: asciiurl
void
URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL)
{
nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(aGlobal.Get());
NS_LossyConvertUTF16toASCII asciiurl(aURL);
nsIPrincipal* urlPrincipal =
nsHostObjectProtocolHandler::GetDataEntryPrincipal(asciiurl);
if (urlPrincipal && principal->Subsumes(urlPrincipal)) {
nsCOMPtr<nsPIDOMWindow> w = do_QueryInterface(aGlobal.GetAsSupports());
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(w.get());
if (window && window->GetExtantDoc()) {
window->GetExtantDoc()->UnregisterHostObjectUri(asciiurl);
}
nsHostObjectProtocolHandler::RemoveDataEntry(asciiurl);
}
}
示例14: ArchiveReader
USING_FILE_NAMESPACE
/* static */ already_AddRefed<ArchiveReader>
ArchiveReader::Constructor(const GlobalObject& aGlobal, nsIDOMBlob* aBlob,
const ArchiveReaderOptions& aOptions,
ErrorResult& aError)
{
MOZ_ASSERT(aBlob);
MOZ_ASSERT(PrefEnabled());
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.Get());
if (!window) {
aError.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsRefPtr<ArchiveReader> reader =
new ArchiveReader(aBlob, window, aOptions.mEncoding);
return reader.forget();
}
示例15: RevokeObjectURL
/* static */
void URLMainThread::RevokeObjectURL(const GlobalObject& aGlobal,
const nsAString& aURL, ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
if (!global) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
NS_LossyConvertUTF16toASCII asciiurl(aURL);
nsIPrincipal* urlPrincipal =
BlobURLProtocolHandler::GetDataEntryPrincipal(asciiurl);
if (urlPrincipal && principal->Subsumes(urlPrincipal)) {
global->UnregisterHostObjectURI(asciiurl);
BlobURLProtocolHandler::RemoveDataEntry(asciiurl);
}
}