当前位置: 首页>>代码示例>>C++>>正文


C++ GlobalObject::Get方法代码示例

本文整理汇总了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();
}
开发者ID:Conjuror,项目名称:mozilla-central,代码行数:31,代码来源:nsDOMParser.cpp

示例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);
}
开发者ID:ShakoHo,项目名称:gecko-dev,代码行数:25,代码来源:URL.cpp

示例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);
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:26,代码来源:URL.cpp

示例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();
}
开发者ID:Conjuror,项目名称:mozilla-central,代码行数:36,代码来源:HTMLImageElement.cpp

示例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);
}
开发者ID:JaminLiu,项目名称:gecko-dev,代码行数:35,代码来源:URL.cpp

示例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);
}
开发者ID:ShakoHo,项目名称:gecko-dev,代码行数:26,代码来源:URL.cpp

示例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();
}
开发者ID:matyapiro31,项目名称:instantbird-1.5,代码行数:29,代码来源:Promise.cpp

示例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();
}
开发者ID:Jaxo,项目名称:releases-mozilla-central,代码行数:20,代码来源:MediaRecorder.cpp

示例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();
}
开发者ID:multi-sim,项目名称:releases-mozilla-central,代码行数:12,代码来源:nsFormData.cpp

示例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);
}
开发者ID:Jaxo,项目名称:releases-mozilla-central,代码行数:12,代码来源:Comment.cpp

示例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);
}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:17,代码来源:CSS.cpp

示例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;
}
开发者ID:MekliCZ,项目名称:positron,代码行数:19,代码来源:CSS.cpp

示例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);
  }
}
开发者ID:JaminLiu,项目名称:gecko-dev,代码行数:20,代码来源:URL.cpp

示例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();
}
开发者ID:andriy-guzenko,项目名称:mozilla-central,代码行数:20,代码来源:ArchiveReader.cpp

示例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);
  }
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:22,代码来源:URLMainThread.cpp


注:本文中的GlobalObject::Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。