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


C++ Nullable::Value方法代码示例

本文整理汇总了C++中Nullable::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ Nullable::Value方法的具体用法?C++ Nullable::Value怎么用?C++ Nullable::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nullable的用法示例。


在下文中一共展示了Nullable::Value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
MessageEvent::InitMessageEvent(JSContext* aCx, const nsAString& aType,
                               bool aCanBubble, bool aCancelable,
                               JS::Handle<JS::Value> aData,
                               const nsAString& aOrigin,
                               const nsAString& aLastEventId,
                               const Nullable<WindowProxyOrMessagePort>& aSource,
                               const Sequence<OwningNonNull<MessagePort>>& aPorts)
{
  NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);

  Event::InitEvent(aType, aCanBubble, aCancelable);
  mData = aData;
  mozilla::HoldJSObjects(this);
  mOrigin = aOrigin;
  mLastEventId = aLastEventId;

  mWindowSource = nullptr;
  mPortSource = nullptr;

  if (!aSource.IsNull()) {
    if (aSource.Value().IsWindowProxy()) {
      auto* windowProxy = aSource.Value().GetAsWindowProxy();
      mWindowSource = windowProxy ? windowProxy->GetCurrentInnerWindow() : nullptr;
    } else {
      mPortSource = &aSource.Value().GetAsMessagePort();
    }
  }

  mPorts.Clear();
  mPorts.AppendElements(aPorts);
  MessageEventBinding::ClearCachedPortsValue(this);
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:33,代码来源:MessageEvent.cpp

示例2: IccContact

/* static */ nsresult
IccContact::Create(mozContact& aMozContact, nsIIccContact** aIccContact)
{
  *aIccContact = nullptr;
  ErrorResult er;

  // Id
  nsAutoString id;
  aMozContact.GetId(id, er);
  NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);

  // Names
  Nullable<nsTArray<nsString>> names;
  aMozContact.GetName(names, er);
  NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
  if (names.IsNull()) {
    // Set as Empty nsTarray<nsString> for IccContact constructor.
    names.SetValue();
  }

  // Numbers
  Nullable<nsTArray<ContactTelField>> nullableNumberList;
  aMozContact.GetTel(nullableNumberList, er);
  NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
  nsTArray<nsString> numbers;
  if (!nullableNumberList.IsNull()) {
    const nsTArray<ContactTelField>& numberList = nullableNumberList.Value();
    for (uint32_t i = 0; i < numberList.Length(); i++) {
      if (numberList[i].mValue.WasPassed()) {
        numbers.AppendElement(numberList[i].mValue.Value());
      }
    }
  }

  // Emails
  Nullable<nsTArray<ContactField>> nullableEmailList;
  aMozContact.GetEmail(nullableEmailList, er);
  NS_ENSURE_SUCCESS(er.StealNSResult(), NS_ERROR_FAILURE);
  nsTArray<nsString> emails;
  if (!nullableEmailList.IsNull()) {
    const nsTArray<ContactField>& emailList = nullableEmailList.Value();
    for (uint32_t i = 0; i < emailList.Length(); i++) {
      if (emailList[i].mValue.WasPassed()) {
        emails.AppendElement(emailList[i].mValue.Value());
      }
    }
  }

  nsCOMPtr<nsIIccContact> iccContact = new IccContact(id,
                                                      names.Value(),
                                                      numbers,
                                                      emails);
  iccContact.forget(aIccContact);

  return NS_OK;
}
开发者ID:paulmadore,项目名称:luckyde,代码行数:56,代码来源:IccContact.cpp

示例3: GetCurrentTime

void
Animation::UpdateFinishedState(bool aSeekFlag)
{
  Nullable<TimeDuration> currentTime = GetCurrentTime();
  TimeDuration effectEnd = TimeDuration(EffectEnd());

  if (!mStartTime.IsNull() &&
      mPendingState == PendingState::NotPending) {
    if (mPlaybackRate > 0.0 &&
        !currentTime.IsNull() &&
        currentTime.Value() >= effectEnd) {
      if (aSeekFlag) {
        mHoldTime = currentTime;
      } else if (!mPreviousCurrentTime.IsNull()) {
        mHoldTime.SetValue(std::max(mPreviousCurrentTime.Value(), effectEnd));
      } else {
        mHoldTime.SetValue(effectEnd);
      }
    } else if (mPlaybackRate < 0.0 &&
               !currentTime.IsNull() &&
               currentTime.Value().ToMilliseconds() <= 0.0) {
      if (aSeekFlag) {
        mHoldTime = currentTime;
      } else {
        mHoldTime.SetValue(0);
      }
    } else if (mPlaybackRate != 0.0 &&
               !currentTime.IsNull()) {
      if (aSeekFlag && !mHoldTime.IsNull()) {
        mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
                              (mHoldTime.Value().MultDouble(1 / mPlaybackRate)));
      }
      mHoldTime.SetNull();
    }
  }

  bool currentFinishedState = IsFinished();
  if (currentFinishedState && !mIsPreviousStateFinished) {
    if (mFinished) {
      mFinished->MaybeResolve(this);
    }
  } else if (!currentFinishedState && mIsPreviousStateFinished) {
    // Clear finished promise. We'll create a new one lazily.
    mFinished = nullptr;
    if (mEffect->AsTransition()) {
      mEffect->SetIsFinishedTransition(false);
    }
  }
  mIsPreviousStateFinished = currentFinishedState;
  // We must recalculate the current time to take account of any mHoldTime
  // changes the code above made.
  mPreviousCurrentTime = GetCurrentTime();
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:53,代码来源:Animation.cpp

示例4: GetCurrentTime

void
Animation::UpdateFinishedState(SeekFlag aSeekFlag,
                               SyncNotifyFlag aSyncNotifyFlag)
{
  Nullable<TimeDuration> currentTime = GetCurrentTime();
  TimeDuration effectEnd = TimeDuration(EffectEnd());

  if (!mStartTime.IsNull() &&
      mPendingState == PendingState::NotPending) {
    if (mPlaybackRate > 0.0 &&
        !currentTime.IsNull() &&
        currentTime.Value() >= effectEnd) {
      if (aSeekFlag == SeekFlag::DidSeek) {
        mHoldTime = currentTime;
      } else if (!mPreviousCurrentTime.IsNull()) {
        mHoldTime.SetValue(std::max(mPreviousCurrentTime.Value(), effectEnd));
      } else {
        mHoldTime.SetValue(effectEnd);
      }
    } else if (mPlaybackRate < 0.0 &&
               !currentTime.IsNull() &&
               currentTime.Value().ToMilliseconds() <= 0.0) {
      if (aSeekFlag == SeekFlag::DidSeek) {
        mHoldTime = currentTime;
      } else {
        mHoldTime.SetValue(0);
      }
    } else if (mPlaybackRate != 0.0 &&
               !currentTime.IsNull() &&
               mTimeline &&
               !mTimeline->GetCurrentTime().IsNull()) {
      if (aSeekFlag == SeekFlag::DidSeek && !mHoldTime.IsNull()) {
        mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
                             (mHoldTime.Value().MultDouble(1 / mPlaybackRate)));
      }
      mHoldTime.SetNull();
    }
  }

  bool currentFinishedState = PlayState() == AnimationPlayState::Finished;
  if (currentFinishedState && !mFinishedIsResolved) {
    DoFinishNotification(aSyncNotifyFlag);
  } else if (!currentFinishedState && mFinishedIsResolved) {
    ResetFinishedPromise();
    if (mEffect->AsTransition()) {
      mEffect->SetIsFinishedTransition(false);
    }
  }
  // We must recalculate the current time to take account of any mHoldTime
  // changes the code above made.
  mPreviousCurrentTime = GetCurrentTime();
}
开发者ID:rhelmer,项目名称:gecko-dev,代码行数:52,代码来源:Animation.cpp

示例5: mb

// https://w3c.github.io/web-animations/#set-the-animation-playback-rate
void
Animation::SetPlaybackRate(double aPlaybackRate)
{
  if (aPlaybackRate == mPlaybackRate) {
    return;
  }

  AutoMutationBatchForAnimation mb(*this);

  Nullable<TimeDuration> previousTime = GetCurrentTime();
  mPlaybackRate = aPlaybackRate;
  if (!previousTime.IsNull()) {
    SetCurrentTime(previousTime.Value());
  }

  // In the case where GetCurrentTime() returns the same result before and
  // after updating mPlaybackRate, SetCurrentTime will return early since,
  // as far as it can tell, nothing has changed.
  // As a result, we need to perform the following updates here:
  // - update timing (since, if the sign of the playback rate has changed, our
  //   finished state may have changed),
  // - dispatch a change notification for the changed playback rate, and
  // - update the playback rate on animations on layers.
  UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Async);
  if (IsRelevant()) {
    nsNodeUtils::AnimationChanged(this);
  }
  PostUpdate();
}
开发者ID:prashant2018,项目名称:gecko-dev,代码行数:30,代码来源:Animation.cpp

示例6: MaybePostRestyle

void
AnimationPlayer::Play(UpdateFlags aFlags)
{
  // FIXME: When we implement finishing behavior (bug 1074630) we should
  // not return early if mIsPaused is false since we may still need to seek.
  // (However, we will need to pass a flag so that when we start playing due to
  //  a change in animation-play-state we *don't* trigger finishing behavior.)
  if (!mIsPaused) {
    return;
  }
  mIsPaused = false;

  Nullable<TimeDuration> timelineTime = mTimeline->GetCurrentTime();
  if (timelineTime.IsNull()) {
    // FIXME: We should just sit in the pending state in this case.
    // We will introduce the pending state in Bug 927349.
    return;
  }

  // Update start time to an appropriate offset from the current timeline time
  MOZ_ASSERT(!mHoldTime.IsNull(), "Hold time should not be null when paused");
  mStartTime.SetValue(timelineTime.Value() - mHoldTime.Value());
  mHoldTime.SetNull();

  if (aFlags == eUpdateStyle) {
    MaybePostRestyle();
  }
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:28,代码来源:AnimationPlayer.cpp

示例7: GetQuotesHistoryVersion

int CDataFeed::GetQuotesHistoryVersion(const uint32 timeoutInMilliseconds)
{
	Nullable<int> version;

	DWORD status = WaitForSingleObject(m_serverQuotesHistoryEvent, 0);
	version = m_cache.GetServerQuotesHistoryVersion();

	string id;

	if (!version.HasValue())
	{
		id = NextId(cExternalSynchCall);
		m_sender->VSendQuotesHistoryRequest(id);

		status = WaitForSingleObject(m_serverQuotesHistoryEvent, timeoutInMilliseconds);
		version = m_cache.GetServerQuotesHistoryVersion();
	}

	if (version.HasValue())
	{
		return version.Value();
	}

	if (WAIT_OBJECT_0 == status)
	{
		throw runtime_error("Couldn't get server quotes storage version due to logout");
	}
	else
	{
		throw CTimeoutException(id, 0);
	}
}
开发者ID:ifzz,项目名称:FDK,代码行数:32,代码来源:DataFeed.cpp

示例8: WantsUntrusted

void
DOMEventTargetHelper::AddEventListener(const nsAString& aType,
                                       EventListener* aListener,
                                       const AddEventListenerOptionsOrBoolean& aOptions,
                                       const Nullable<bool>& aWantsUntrusted,
                                       ErrorResult& aRv)
{
  bool wantsUntrusted;
  if (aWantsUntrusted.IsNull()) {
    nsresult rv = WantsUntrusted(&wantsUntrusted);
    if (NS_FAILED(rv)) {
      aRv.Throw(rv);
      return;
    }
  } else {
    wantsUntrusted = aWantsUntrusted.Value();
  }

  EventListenerManager* elm = GetOrCreateListenerManager();
  if (!elm) {
    aRv.Throw(NS_ERROR_UNEXPECTED);
    return;
  }

  elm->AddEventListener(aType, aListener, aOptions, wantsUntrusted);
}
开发者ID:NAndreasson,项目名称:cowl-patches,代码行数:26,代码来源:DOMEventTargetHelper.cpp

示例9: GetSelectionDirection

void
HTMLTextAreaElement::SetSelectionEnd(const Nullable<uint32_t>& aSelectionEnd,
                                     ErrorResult& aError)
{
  int32_t selEnd = 0;
  if (!aSelectionEnd.IsNull()) {
    selEnd = aSelectionEnd.Value();
  }

  if (mState.IsSelectionCached()) {
    mState.GetSelectionProperties().SetEnd(selEnd);
    return;
  }

  nsAutoString direction;
  nsresult rv = GetSelectionDirection(direction);
  if (NS_FAILED(rv)) {
    aError.Throw(rv);
    return;
  }
  int32_t start, end;
  rv = GetSelectionRange(&start, &end);
  if (NS_FAILED(rv)) {
    aError.Throw(rv);
    return;
  }
  end = selEnd;
  if (start > end) {
    start = end;
  }
  rv = SetSelectionRange(start, end, direction);
  if (NS_FAILED(rv)) {
    aError.Throw(rv);
  }
}
开发者ID:alphan102,项目名称:gecko-dev,代码行数:35,代码来源:HTMLTextAreaElement.cpp

示例10: GetCurrentTime

void
Animation::SilentlySetPlaybackRate(double aPlaybackRate)
{
  Nullable<TimeDuration> previousTime = GetCurrentTime();
  mPlaybackRate = aPlaybackRate;
  if (!previousTime.IsNull()) {
    SilentlySetCurrentTime(previousTime.Value());
  }
}
开发者ID:prashant2018,项目名称:gecko-dev,代码行数:9,代码来源:Animation.cpp

示例11: if

void
HTMLOptionsCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
                           const Nullable<HTMLElementOrLong>& aBefore,
                           ErrorResult& aError)
{
  nsGenericHTMLElement& element =
    aElement.IsHTMLOptionElement() ?
    static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptionElement()) :
    static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptGroupElement());

  if (aBefore.IsNull()) {
    mSelect->Add(element, (nsGenericHTMLElement*)nullptr, aError);
  } else if (aBefore.Value().IsHTMLElement()) {
    mSelect->Add(element, &aBefore.Value().GetAsHTMLElement(), aError);
  } else {
    mSelect->Add(element, aBefore.Value().GetAsLong(), aError);
  }
}
开发者ID:TelefonicaPushServer,项目名称:mozilla-central,代码行数:18,代码来源:HTMLOptionsCollection.cpp

示例12: MessagePortList

void
MessageEvent::InitMessageEvent(JSContext* aCx, const nsAString& aType,
                               bool aCanBubble, bool aCancelable,
                               JS::Handle<JS::Value> aData,
                               const nsAString& aOrigin,
                               const nsAString& aLastEventId,
                               const Nullable<WindowProxyOrMessagePort>& aSource,
                               const Nullable<Sequence<OwningNonNull<MessagePort>>>& aPorts,
                               ErrorResult& aRv)
{
  aRv = Event::InitEvent(aType, aCanBubble, aCancelable);
  if (NS_WARN_IF(aRv.Failed())) {
    return;
  }

  mData = aData;
  mozilla::HoldJSObjects(this);
  mOrigin = aOrigin;
  mLastEventId = aLastEventId;

  mWindowSource = nullptr;
  mPortSource = nullptr;

  if (!aSource.IsNull()) {
    if (aSource.Value().IsWindowProxy()) {
      mWindowSource = aSource.Value().GetAsWindowProxy();
    } else {
      mPortSource = &aSource.Value().GetAsMessagePort();
    }
  }

  mPorts = nullptr;

  if (!aPorts.IsNull()) {
    nsTArray<RefPtr<MessagePort>> ports;
    for (uint32_t i = 0, len = aPorts.Value().Length(); i < len; ++i) {
      ports.AppendElement(aPorts.Value()[i]);
    }

    mPorts = new MessagePortList(static_cast<Event*>(this), ports);
  }
}
开发者ID:70599,项目名称:Waterfox,代码行数:42,代码来源:MessageEvent.cpp

示例13: Request

NS_IMETHODIMP
QuotaManagerService::ClearStoragesForPrincipal(nsIPrincipal* aPrincipal,
                                               const nsACString& aPersistenceType,
                                               bool aClearAll,
                                               nsIQuotaRequest** _retval)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aPrincipal);

  nsCString suffix;
  aPrincipal->OriginAttributesRef().CreateSuffix(suffix);

  if (NS_WARN_IF(aClearAll && !suffix.IsEmpty())) {
    // The originAttributes should be default originAttributes when the
    // aClearAll flag is set.
    return NS_ERROR_INVALID_ARG;
  }

  RefPtr<Request> request = new Request(aPrincipal);

  ClearOriginParams params;

  nsresult rv = CheckedPrincipalToPrincipalInfo(aPrincipal,
                                                params.principalInfo());
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return rv;
  }

  Nullable<PersistenceType> persistenceType;
  rv = NullablePersistenceTypeFromText(aPersistenceType, &persistenceType);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return NS_ERROR_INVALID_ARG;
  }

  if (persistenceType.IsNull()) {
    params.persistenceTypeIsExplicit() = false;
  } else {
    params.persistenceType() = persistenceType.Value();
    params.persistenceTypeIsExplicit() = true;
  }

  params.clearAll() = aClearAll;

  nsAutoPtr<PendingRequestInfo> info(new RequestInfo(request, params));

  rv = InitiateRequest(info);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return rv;
  }

  request.forget(_retval);
  return NS_OK;
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:53,代码来源:QuotaManagerService.cpp

示例14: SetCurrentTime

void
Animation::SetCurrentTimeAsDouble(const Nullable<double>& aCurrentTime,
                                        ErrorResult& aRv)
{
  if (aCurrentTime.IsNull()) {
    if (!GetCurrentTime().IsNull()) {
      aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
    }
    return;
  }

  return SetCurrentTime(TimeDuration::FromMilliseconds(aCurrentTime.Value()));
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:13,代码来源:Animation.cpp

示例15: ErrorInvalidValue

void
WebGLContext::BufferData(GLenum target,
                         const Nullable<ArrayBuffer> &maybeData,
                         GLenum usage)
{
    if (IsContextLost())
        return;

    if (maybeData.IsNull()) {
        // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386
        return ErrorInvalidValue("bufferData: null object passed");
    }

    WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferData");

    if (!bufferSlot) {
        return;
    }

    const ArrayBuffer& data = maybeData.Value();
    data.ComputeLengthAndData();

    // Careful: data.Length() could conceivably be any uint32_t, but GLsizeiptr
    // is like intptr_t.
    if (!CheckedInt<GLsizeiptr>(data.Length()).isValid())
        return ErrorOutOfMemory("bufferData: bad size");

    if (!ValidateBufferUsageEnum(usage, "bufferData: usage"))
        return;

    WebGLBuffer* boundBuffer = bufferSlot->get();

    if (!boundBuffer)
        return ErrorInvalidOperation("bufferData: no buffer bound!");

    MakeContextCurrent();
    InvalidateBufferFetching();

    GLenum error = CheckedBufferData(target, data.Length(), data.Data(), usage);

    if (error) {
        GenerateWarning("bufferData generated error %s", ErrorName(error));
        return;
    }

    boundBuffer->SetByteLength(data.Length());
    if (!boundBuffer->ElementArrayCacheBufferData(data.Data(), data.Length())) {
        return ErrorOutOfMemory("bufferData: out of memory");
    }
}
开发者ID:afabbro,项目名称:gecko-dev,代码行数:50,代码来源:WebGLContextBuffers.cpp


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