本文整理汇总了C++中mozilla::ErrorResult类的典型用法代码示例。如果您正苦于以下问题:C++ ErrorResult类的具体用法?C++ ErrorResult怎么用?C++ ErrorResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ErrorResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IIRFilterNode
already_AddRefed<IIRFilterNode>
AudioContext::CreateIIRFilter(const mozilla::dom::binding_detail::AutoSequence<double>& aFeedforward,
const mozilla::dom::binding_detail::AutoSequence<double>& aFeedback,
mozilla::ErrorResult& aRv)
{
if (CheckClosed(aRv)) {
return nullptr;
}
if (aFeedforward.Length() == 0 || aFeedforward.Length() > 20) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
if (aFeedback.Length() == 0 || aFeedback.Length() > 20) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
bool feedforwardAllZeros = true;
for (size_t i = 0; i < aFeedforward.Length(); ++i) {
if (aFeedforward.Elements()[i] != 0.0) {
feedforwardAllZeros = false;
}
}
if (feedforwardAllZeros || aFeedback.Elements()[0] == 0.0) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
RefPtr<IIRFilterNode> filterNode =
new IIRFilterNode(this, aFeedforward, aFeedback);
return filterNode.forget();
}
示例2: NS_NewDOMDocumentType
already_AddRefed<mozilla::dom::DocumentType>
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
nsIAtom *aName,
const nsAString& aPublicId,
const nsAString& aSystemId,
const nsAString& aInternalSubset,
mozilla::ErrorResult& rv)
{
if (!aName) {
rv.Throw(NS_ERROR_INVALID_POINTER);
return nullptr;
}
nsCOMPtr<nsINodeInfo> ni =
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr,
kNameSpaceID_None,
nsIDOMNode::DOCUMENT_TYPE_NODE,
aName);
if (!ni) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
nsRefPtr<mozilla::dom::DocumentType> docType =
new mozilla::dom::DocumentType(ni.forget(), aPublicId, aSystemId, aInternalSubset);
return docType.forget();
}
示例3:
void
nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMWindow* aView,
int32_t aDetail,
bool aCtrlKey,
bool aAltKey,
bool aShiftKey,
bool aMetaKey,
nsDOMTouchList* aTouches,
nsDOMTouchList* aTargetTouches,
nsDOMTouchList* aChangedTouches,
mozilla::ErrorResult& aRv)
{
aRv = nsDOMUIEvent::InitUIEvent(aType,
aCanBubble,
aCancelable,
aView,
aDetail);
if (aRv.Failed()) {
return;
}
static_cast<nsInputEvent*>(mEvent)->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mTouches = aTouches;
mTargetTouches = aTargetTouches;
mChangedTouches = aChangedTouches;
}
示例4:
void
HTMLAnchorElement::GetText(nsAString& aText, mozilla::ErrorResult& aRv)
{
if (NS_WARN_IF(!nsContentUtils::GetNodeTextContent(this, true, aText, fallible))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
}
示例5: ActivateTLS
void
TCPSocket::UpgradeToSecure(mozilla::ErrorResult& aRv)
{
if (mReadyState != TCPReadyState::Open) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
if (mSsl) {
return;
}
mSsl = true;
if (mSocketBridgeChild) {
mSocketBridgeChild->SendStartTLS();
return;
}
if (!mAsyncCopierActive) {
ActivateTLS();
} else {
mWaitingForStartTLS = true;
}
}
示例6: CreateURLRunnable
// static
void
URL::CreateObjectURL(const GlobalObject& aGlobal, JSObject* aBlob,
const mozilla::dom::objectURLOptions& aOptions,
nsString& aResult, mozilla::ErrorResult& aRv)
{
JSContext* cx = aGlobal.GetContext();
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
nsCOMPtr<nsIDOMBlob> blob = file::GetDOMBlobFromJSObject(aBlob);
if (!blob) {
SetDOMStringToNull(aResult);
NS_NAMED_LITERAL_STRING(argStr, "Argument 1 of URL.createObjectURL");
NS_NAMED_LITERAL_STRING(blobStr, "Blob");
aRv.ThrowTypeError(MSG_DOES_NOT_IMPLEMENT_INTERFACE, &argStr, &blobStr);
return;
}
nsRefPtr<CreateURLRunnable> runnable =
new CreateURLRunnable(workerPrivate, blob, aOptions, aResult);
if (!runnable->Dispatch(cx)) {
JS_ReportPendingException(cx);
}
}
示例7: global
void
DOMRequest::Then(JSContext* aCx, AnyCallback* aResolveCallback,
AnyCallback* aRejectCallback,
JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aRv)
{
if (!mPromise) {
mPromise = Promise::Create(DOMEventTargetHelper::GetParentObject(), aRv);
if (aRv.Failed()) {
return;
}
if (mDone) {
// Since we create mPromise lazily, it's possible that the DOMRequest object
// has already fired its success/error event. In that case we should
// manually resolve/reject mPromise here. mPromise will take care of
// calling the callbacks on |promise| as needed.
if (mError) {
mPromise->MaybeRejectBrokenly(mError);
} else {
mPromise->MaybeResolve(mResult);
}
}
}
// Just use the global of the Promise itself as the callee global.
JS::Rooted<JSObject*> global(aCx, mPromise->PromiseObj());
global = js::GetGlobalForObjectCrossCompartment(global);
mPromise->Then(aCx, global, aResolveCallback, aRejectCallback, aRetval, aRv);
}
示例8: ActivateTLS
void
TCPSocket::UpgradeToSecure(mozilla::ErrorResult& aRv)
{
if (mReadyState != TCPReadyState::Open) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
if (mSsl) {
return;
}
mSsl = true;
if (mSocketBridgeChild) {
mSocketBridgeChild->SendStartTLS();
return;
}
uint32_t count = 0;
mMultiplexStream->GetCount(&count);
if (!count) {
ActivateTLS();
} else {
mWaitingForStartTLS = true;
}
}
示例9: GetDataAtInternal
void
DataTransfer::MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
uint32_t aIndex,
JS::MutableHandle<JS::Value> aRetval,
nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsIVariant> data;
aRv = GetDataAtInternal(aFormat, aIndex, &aSubjectPrincipal,
getter_AddRefs(data));
if (aRv.Failed()) {
return;
}
if (!data) {
aRetval.setNull();
return;
}
JS::Rooted<JS::Value> result(aCx);
if (!VariantToJsval(aCx, data, aRetval)) {
aRv = NS_ERROR_FAILURE;
return;
}
}
示例10:
JS::Value
IDBRequest::GetResult(JSContext* aCx, mozilla::ErrorResult& aRv) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mHaveResultOrErrorCode) {
// XXX Need a real error code here.
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
}
return mResultVal;
}
示例11: WakeLock
already_AddRefed<WakeLock>
PowerManagerService::NewWakeLock(const nsAString& aTopic,
nsIDOMWindow* aWindow,
mozilla::ErrorResult& aRv)
{
nsRefPtr<WakeLock> wakelock = new WakeLock();
aRv = wakelock->Init(aTopic, aWindow);
if (aRv.Failed()) {
return nullptr;
}
return wakelock.forget();
}
示例12: win
void
nsHistory::SetScrollRestoration(mozilla::dom::ScrollRestoration aMode,
mozilla::ErrorResult& aRv)
{
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
if (!win || !win->HasActiveDocument() || !win->GetDocShell()) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}
win->GetDocShell()->
SetCurrentScrollRestorationIsManual(
aMode == mozilla::dom::ScrollRestoration::Manual);
}
示例13: globalObj
already_AddRefed<TCPSocket>
LegacyMozTCPSocket::Open(const nsAString& aHost,
uint16_t aPort,
const SocketOptions& aOptions,
mozilla::ErrorResult& aRv)
{
AutoJSAPI api;
if (NS_WARN_IF(!api.Init(mGlobal))) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
GlobalObject globalObj(api.cx(), mGlobal->GetGlobalJSObject());
return TCPSocket::Constructor(globalObj, aHost, aPort, aOptions, aRv);
}
示例14: RemoveRequestPromise
void
Cache::RecvAddAllResponse(RequestId aRequestId,
const mozilla::ErrorResult& aError)
{
nsRefPtr<Promise> promise = RemoveRequestPromise(aRequestId);
if (aError.Failed()) {
// TODO: Remove this const_cast (bug 1152078).
// It is safe for now since this ErrorResult is handed off to us by IPDL
// and is thrown into the trash afterwards.
promise->MaybeReject(const_cast<ErrorResult&>(aError));
return;
}
promise->MaybeResolve(JS::UndefinedHandleValue);
}
示例15: marker
void
DOMParser::Init(nsIPrincipal* aPrincipal, nsIURI* aDocumentURI,
nsIURI* aBaseURI, mozilla::ErrorResult& rv)
{
AttemptedInitMarker marker(&mAttemptedInit);
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!cx) {
rv.Throw(NS_ERROR_UNEXPECTED);
return;
}
nsIScriptContext* scriptContext = GetScriptContextFromJSContext(cx);
nsCOMPtr<nsIPrincipal> principal = aPrincipal;
if (!principal && !aDocumentURI) {
principal = nsContentUtils::SubjectPrincipal();
}
rv = Init(principal, aDocumentURI, aBaseURI,
scriptContext ? scriptContext->GetGlobalObject() : nullptr);
}