本文整理汇总了C++中nsTArray::LastElement方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTArray::LastElement方法的具体用法?C++ nsTArray::LastElement怎么用?C++ nsTArray::LastElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTArray
的用法示例。
在下文中一共展示了nsTArray::LastElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serialize
void
nsTreeContentView::SerializeItem(Element* aContent, int32_t aParentIndex,
int32_t* aIndex, nsTArray<UniquePtr<Row>>& aRows)
{
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
nsGkAtoms::_true, eCaseMatters))
return;
aRows.AppendElement(MakeUnique<Row>(aContent, aParentIndex));
Row* row = aRows.LastElement().get();
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container,
nsGkAtoms::_true, eCaseMatters)) {
row->SetContainer(true);
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open,
nsGkAtoms::_true, eCaseMatters)) {
row->SetOpen(true);
nsIContent* child =
nsTreeUtils::GetImmediateChild(aContent, nsGkAtoms::treechildren);
if (child && child->IsXULElement()) {
// Now, recursively serialize our child.
int32_t count = aRows.Length();
int32_t index = 0;
Serialize(child, aParentIndex + *aIndex + 1, &index, aRows);
row->mSubtreeSize += aRows.Length() - count;
}
else
row->SetEmpty(true);
} else if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::empty,
nsGkAtoms::_true, eCaseMatters)) {
row->SetEmpty(true);
}
}
}
示例2: AccumulateSPSTelemetry
void
MP4TrackDemuxer::UpdateSamples(nsTArray<RefPtr<MediaRawData>>& aSamples)
{
for (size_t i = 0; i < aSamples.Length(); i++) {
MediaRawData* sample = aSamples[i];
// Collect telemetry from h264 Annex B SPS.
if (mNeedSPSForTelemetry && mp4_demuxer::AnnexB::HasSPS(sample)) {
RefPtr<MediaByteBuffer> extradata =
mp4_demuxer::AnnexB::ExtractExtraData(sample);
mNeedSPSForTelemetry = AccumulateSPSTelemetry(extradata);
}
if (sample->mCrypto.mValid) {
nsAutoPtr<MediaRawDataWriter> writer(sample->CreateWriter());
writer->mCrypto.mMode = mInfo->mCrypto.mMode;
writer->mCrypto.mIVSize = mInfo->mCrypto.mIVSize;
writer->mCrypto.mKeyId.AppendElements(mInfo->mCrypto.mKeyId);
}
if (mInfo->GetAsVideoInfo()) {
sample->mExtraData = mInfo->GetAsVideoInfo()->mExtraData;
}
}
if (mNextKeyframeTime.isNothing() ||
aSamples.LastElement()->mTime >= mNextKeyframeTime.value().ToMicroseconds()) {
SetNextKeyFrameTime();
}
}
示例3: writer
void
MP4TrackDemuxer::UpdateSamples(nsTArray<nsRefPtr<MediaRawData>>& aSamples)
{
for (size_t i = 0; i < aSamples.Length(); i++) {
MediaRawData* sample = aSamples[i];
if (sample->mCrypto.mValid) {
nsAutoPtr<MediaRawDataWriter> writer(sample->CreateWriter());
writer->mCrypto.mMode = mInfo->mCrypto.mMode;
writer->mCrypto.mIVSize = mInfo->mCrypto.mIVSize;
writer->mCrypto.mKeyId.AppendElements(mInfo->mCrypto.mKeyId);
}
if (mInfo->GetAsVideoInfo()) {
sample->mExtraData = mInfo->GetAsVideoInfo()->mExtraData;
}
}
if (mNextKeyframeTime.isNothing() ||
aSamples.LastElement()->mTime >= mNextKeyframeTime.value().ToMicroseconds()) {
mNextKeyframeTime.reset();
mp4_demuxer::Microseconds frameTime = mIterator->GetNextKeyframeTime();
if (frameTime != -1) {
mNextKeyframeTime.emplace(
media::TimeUnit::FromMicroseconds(frameTime));
}
}
}
示例4: writer
void
MP4TrackDemuxer::UpdateSamples(nsTArray<nsRefPtr<MediaRawData>>& aSamples)
{
for (size_t i = 0; i < aSamples.Length(); i++) {
MediaRawData* sample = aSamples[i];
if (sample->mCrypto.valid) {
nsAutoPtr<MediaRawDataWriter> writer(sample->CreateWriter());
writer->mCrypto.mode = mInfo->mCrypto.mode;
writer->mCrypto.iv_size = mInfo->mCrypto.iv_size;
writer->mCrypto.key.AppendElements(mInfo->mCrypto.key);
}
if (mInfo->GetAsVideoInfo()) {
sample->mExtraData = mInfo->GetAsVideoInfo()->mExtraData;
}
}
if (mNextKeyframeTime.isNothing() ||
aSamples.LastElement()->mTime >= mNextKeyframeTime.value().ToMicroseconds()) {
SetNextKeyFrameTime();
}
}
示例5: MakeAnonymousElement
nsresult
nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsresult rv;
// We create an anonymous tree for our input element that is structured as
// follows:
//
// input
// div - outer wrapper with "display:flex" by default
// input - text input field
// div - spin box wrapping up/down arrow buttons
// div - spin up (up arrow button)
// div - spin down (down arrow button)
//
// If you change this, be careful to change the destruction order in
// nsNumberControlFrame::DestroyFrom.
// Create the anonymous outer wrapper:
rv = MakeAnonymousElement(getter_AddRefs(mOuterWrapper),
aElements,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberWrapper,
mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& outerWrapperCI = aElements.LastElement();
// Create the ::-moz-number-text pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mTextField),
outerWrapperCI.mChildren,
nsGkAtoms::input,
nsCSSPseudoElements::ePseudo_mozNumberText,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("text"), PR_FALSE);
HTMLInputElement* content = HTMLInputElement::FromContent(mContent);
HTMLInputElement* textField = HTMLInputElement::FromContent(mTextField);
// Initialize the text field value:
nsAutoString value;
content->GetValue(value);
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::value, value, false);
// If we're readonly, make sure our anonymous text control is too:
nsAutoString readonly;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly, false);
}
// Propogate our tabindex:
int32_t tabIndex;
content->GetTabIndex(&tabIndex);
textField->SetTabIndex(tabIndex);
// Initialize the text field's placeholder, if ours is set:
nsAutoString placeholder;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder, false);
}
if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) {
// We don't want to focus the frame but the text field.
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mTextField);
NS_ASSERTION(element, "Really, this should be a nsIDOMElement!");
fm->SetFocus(element, 0);
}
// Create the ::-moz-number-spin-box pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
outerWrapperCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinBox,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& spinBoxCI = outerWrapperCI.mChildren.LastElement();
// Create the ::-moz-number-spin-up pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinUp),
spinBoxCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinUp,
spinBoxCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
// Create the ::-moz-number-spin-down pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
spinBoxCI.mChildren,
nsGkAtoms::div,
nsCSSPseudoElements::ePseudo_mozNumberSpinDown,
spinBoxCI.mStyleContext);
return rv;
}
示例6: MakeAnonymousElement
nsresult
nsNumberControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
nsresult rv;
// We create an anonymous tree for our input element that is structured as
// follows:
//
// input
// div - outer wrapper with "display:flex" by default
// input - text input field
// div - spin box wrapping up/down arrow buttons
// div - spin up (up arrow button)
// div - spin down (down arrow button)
//
// If you change this, be careful to change the destruction order in
// nsNumberControlFrame::DestroyFrom.
// Create the anonymous outer wrapper:
rv = MakeAnonymousElement(getter_AddRefs(mOuterWrapper),
aElements,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberWrapper,
mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& outerWrapperCI = aElements.LastElement();
// Create the ::-moz-number-text pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mTextField),
outerWrapperCI.mChildren,
nsGkAtoms::input,
CSSPseudoElementType::mozNumberText,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("text"), PR_FALSE);
HTMLInputElement* content = HTMLInputElement::FromContent(mContent);
HTMLInputElement* textField = HTMLInputElement::FromContent(mTextField);
// Initialize the text field value:
nsAutoString value;
content->GetValue(value);
SetValueOfAnonTextControl(value);
// If we're readonly, make sure our anonymous text control is too:
nsAutoString readonly;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::readonly, readonly, false);
}
// Propogate our tabindex:
int32_t tabIndex;
content->GetTabIndex(&tabIndex);
textField->SetTabIndex(tabIndex);
// Initialize the text field's placeholder, if ours is set:
nsAutoString placeholder;
if (mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder)) {
mTextField->SetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, placeholder, false);
}
if (mContent->AsElement()->State().HasState(NS_EVENT_STATE_FOCUS)) {
// We don't want to focus the frame but the text field.
RefPtr<FocusTextField> focusJob = new FocusTextField(mContent, mTextField);
nsContentUtils::AddScriptRunner(focusJob);
}
if (StyleDisplay()->mAppearance == NS_THEME_TEXTFIELD) {
// The author has elected to hide the spinner by setting this
// -moz-appearance. We will reframe if it changes.
return rv;
}
// Create the ::-moz-number-spin-box pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinBox),
outerWrapperCI.mChildren,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberSpinBox,
outerWrapperCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
ContentInfo& spinBoxCI = outerWrapperCI.mChildren.LastElement();
// Create the ::-moz-number-spin-up pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinUp),
spinBoxCI.mChildren,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberSpinUp,
spinBoxCI.mStyleContext);
NS_ENSURE_SUCCESS(rv, rv);
// Create the ::-moz-number-spin-down pseudo-element:
rv = MakeAnonymousElement(getter_AddRefs(mSpinDown),
spinBoxCI.mChildren,
nsGkAtoms::div,
CSSPseudoElementType::mozNumberSpinDown,
//.........这里部分代码省略.........